Mostly add CPhysicsActor::GetRotateToORAngularMomentumWR

Former-commit-id: fe02b80545
This commit is contained in:
Henrique Gemignani Passos Lima 2022-11-04 12:50:34 +02:00
parent 7f947e6442
commit c109339372
4 changed files with 14 additions and 4 deletions

View File

@ -71,6 +71,9 @@ public:
float GetX() const { return x; } float GetX() const { return x; }
float GetY() const { return y; } float GetY() const { return y; }
float GetZ() const { return z; } float GetZ() const { return z; }
const CVector3f& GetImaginary() const {
// TODO: hack! has a Vector3f field?
return *reinterpret_cast<const CVector3f*>(&x); }
private: private:
float w; float w;

View File

@ -141,7 +141,7 @@ public:
void MoveToWR(const CVector3f&, float); void MoveToWR(const CVector3f&, float);
void MoveToInOneFrameWR(const CVector3f&, float); void MoveToInOneFrameWR(const CVector3f&, float);
CVector3f GetMoveToORImpulseWR(const CVector3f& impulse, float d) const; CVector3f GetMoveToORImpulseWR(const CVector3f& impulse, float d) const;
CAxisAngle GetRotateToORAngularMomentumWR(const CQuaternion& q, float d) const; CVector3f GetRotateToORAngularMomentumWR(const CQuaternion& q, float d) const;
void RotateToWR(const CQuaternion&, float); void RotateToWR(const CQuaternion&, float);
void MoveToOR(const CVector3f&, float); void MoveToOR(const CVector3f&, float);

View File

@ -76,6 +76,7 @@ double atan2(double y, double x);
_MATH_INLINE float sinf(float x) { return (float)sin((double)x); } _MATH_INLINE float sinf(float x) { return (float)sin((double)x); }
_MATH_INLINE float cosf(float x) { return (float)cos((double)x); } _MATH_INLINE float cosf(float x) { return (float)cos((double)x); }
float tanf(float x); float tanf(float x);
double acos(double x);
float acosf(float x); float acosf(float x);
double ldexp(double x, int exp); double ldexp(double x, int exp);

View File

@ -229,7 +229,13 @@ CVector3f CPhysicsActor::GetMoveToORImpulseWR(const CVector3f& trans, float d) c
return (GetMass() * impulse) * (1.f / d); return (GetMass() * impulse) * (1.f / d);
} }
CAxisAngle CPhysicsActor::GetRotateToORAngularMomentumWR(const CQuaternion& q, float d) const { CVector3f CPhysicsActor::GetRotateToORAngularMomentumWR(const CQuaternion& q, float d) const {
// TODO if (q.GetW() > 0.99999976f) {
return CAxisAngle(); return CVector3f::Zero();
} else {
const CVector3f rotated = GetTransform().Rotate(q.GetImaginary());
float ac = acos(q.GetW());
return rotated.AsNormalized() * ((ac * 2.0f) * (1.0f / d)) * xf0_inertiaTensor;
}
} }