From 67f6823f7393469bc3847f21fd2887ff380141d4 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Wed, 18 Apr 2012 20:45:52 +0200 Subject: [PATCH 1/2] More 'const', so that Rotate(vector) can be called on a const hsQuat&. --- Sources/Plasma/CoreLib/hsQuat.cpp | 4 ++-- Sources/Plasma/CoreLib/hsQuat.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Plasma/CoreLib/hsQuat.cpp b/Sources/Plasma/CoreLib/hsQuat.cpp index da9c1667..4b8556b9 100644 --- a/Sources/Plasma/CoreLib/hsQuat.cpp +++ b/Sources/Plasma/CoreLib/hsQuat.cpp @@ -65,14 +65,14 @@ hsQuat::hsQuat(float rad, const hsVector3* axis) fZ = axis->fZ*s; } -hsQuat hsQuat::Inverse() +hsQuat hsQuat::Inverse() const { hsQuat q2 = Conjugate(); float msInv = 1.0f/q2.MagnitudeSquared(); return (q2 * msInv); } -hsPoint3 hsQuat::Rotate(const hsScalarTriple* v) +hsPoint3 hsQuat::Rotate(const hsScalarTriple* v) const { hsQuat qInv = Inverse(); hsQuat qVec(v->fX, v->fY, v->fZ, 0); diff --git a/Sources/Plasma/CoreLib/hsQuat.h b/Sources/Plasma/CoreLib/hsQuat.h index a61f484e..3153c194 100644 --- a/Sources/Plasma/CoreLib/hsQuat.h +++ b/Sources/Plasma/CoreLib/hsQuat.h @@ -71,7 +71,7 @@ public: { fX = X; fY = Y; fZ = Z; fW = W; } void GetAngleAxis(float *rad, hsVector3 *axis) const; void SetAngleAxis(const float rad, const hsVector3 &axis); - hsPoint3 Rotate(const hsScalarTriple* v); + hsPoint3 Rotate(const hsScalarTriple* v) const; // Access operators float& operator[](int i) { return (&fX)[i]; } @@ -94,7 +94,7 @@ public: float MagnitudeSquared(); hsQuat Conjugate() const { return hsQuat(-fX,-fY,-fZ,fW); } - hsQuat Inverse(); + hsQuat Inverse() const; // Binary operators hsQuat operator-(const hsQuat&) const; hsQuat operator+(const hsQuat&) const; From 3d0f01ff03ca5034644e375f6a1962315ef7b337 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Wed, 18 Apr 2012 20:51:14 +0200 Subject: [PATCH 2/2] Convert the impact velocity to avatar-local coordinates, because that's what {Running|Ground}Impact::PreCondition() expects. Fixes landing animations depending on what direction relative to the age you jump rather than whether you land forward or straight down. --- Sources/Plasma/PubUtilLib/plAvatar/plAvCallbackAction.cpp | 2 ++ Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.h | 1 + 2 files changed, 3 insertions(+) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvCallbackAction.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvCallbackAction.cpp index 235c3450..f784ace5 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvCallbackAction.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvCallbackAction.cpp @@ -137,6 +137,8 @@ void plWalkingController::RecalcVelocity(double timeNow, double timePrev, hsBool // always (0,0,0) outside of the controller update proc fImpactTime = fWalkingStrategy->GetAirTime(); fImpactVelocity = fController->GetAchievedLinearVelocity(); + // convert orientation from subworld to avatar-local coordinates + fImpactVelocity = (hsVector3)fController->GetLocalRotation().Rotate(&fImpactVelocity); fClearImpact = false; } else diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.h b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.h index 00f6ce31..44ba1ba8 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.h @@ -147,6 +147,7 @@ public: virtual void CheckAndHandleAnyStateChanges(); virtual void UpdateSubstepNonPhysical(); virtual const hsPoint3& GetLocalPosition()=0; + const hsQuat& GetLocalRotation() { return fLocalRotation; } virtual void MoveActorToSim(); virtual void OverrideAchievedVelocity(hsVector3 newAchievedVel)