metaforce/Runtime/World/CPhysicsActor.hpp

177 lines
6.5 KiB
C++
Raw Normal View History

2016-04-13 06:07:23 +00:00
#ifndef __URDE_CPHYSICSACTOR_HPP__
#define __URDE_CPHYSICSACTOR_HPP__
2015-08-22 01:58:41 +00:00
#include "CActor.hpp"
#include "Collision/CCollidableAABox.hpp"
2015-08-22 01:58:41 +00:00
2016-03-04 23:04:53 +00:00
namespace urde
2015-08-22 01:58:41 +00:00
{
2016-04-22 20:22:45 +00:00
class CCollisionInfoList;
2016-04-19 00:17:49 +00:00
struct SMoverData;
2015-08-22 01:58:41 +00:00
2016-04-19 00:17:49 +00:00
struct SMoverData
{
zeus::CVector3f x0_velocity;
zeus::CAxisAngle xc_angularVelocity;
2017-03-01 03:42:06 +00:00
zeus::CVector3f x18_momentum;
2016-04-19 00:17:49 +00:00
zeus::CAxisAngle x24_;
float x30_mass;
2016-04-19 00:17:49 +00:00
SMoverData(float mass) : x30_mass(mass) {}
};
struct CMotionState
{
2016-09-01 09:31:18 +00:00
zeus::CVector3f x0_translation;
zeus::CNUQuaternion xc_orientation;
zeus::CVector3f x1c_velocity;
zeus::CAxisAngle x28_angularMomentum;
CMotionState(const zeus::CVector3f& origin, const zeus::CNUQuaternion& orientation, const zeus::CVector3f& velocity,
const zeus::CAxisAngle& angle)
: x0_translation(origin), xc_orientation(orientation), x1c_velocity(velocity), x28_angularMomentum(angle)
{
}
2016-04-19 00:17:49 +00:00
};
2016-09-01 09:31:18 +00:00
class CPhysicsState
{
zeus::CVector3f x0_translation;
zeus::CQuaternion xc_orientation;
zeus::CVector3f x1c_constantForce;
zeus::CAxisAngle x28_angularMomentum;
zeus::CVector3f x34_momentum;
zeus::CVector3f x40_force;
zeus::CVector3f x4c_impulse;
zeus::CAxisAngle x58_torque;
zeus::CAxisAngle x64_angularImpulse;
2016-09-01 09:31:18 +00:00
public:
CPhysicsState(const zeus::CVector3f&, const zeus::CQuaternion&, const zeus::CVector3f&, const zeus::CAxisAngle&,
const zeus::CVector3f&, const zeus::CVector3f&, const zeus::CVector3f&, const zeus::CAxisAngle&,
const zeus::CAxisAngle&);
2016-09-01 09:31:18 +00:00
void SetOrientation(const zeus::CQuaternion&);
const zeus::CQuaternion& GetOrientation() const;
void SetTranslation(const zeus::CVector3f&);
const zeus::CVector3f& GetTranslation() const;
const zeus::CVector3f& GetConstantForceWR() const;
const zeus::CAxisAngle& GetAngularMomentumWR() const;
const zeus::CVector3f& GetMomentumWR() const;
const zeus::CVector3f& GetForceWR() const;
const zeus::CVector3f& GetImpulseWR() const;
const zeus::CAxisAngle& GetTorque() const;
const zeus::CAxisAngle& GetAngularImpulseWR() const;
};
2015-08-22 01:58:41 +00:00
class CPhysicsActor : public CActor
{
protected:
2016-04-22 20:22:45 +00:00
float xe8_mass;
float xec_massRecip;
2016-09-01 04:10:08 +00:00
float xf0_inertiaTensor;
float xf4_inertiaTensorRecip;
union {
2016-09-01 09:31:18 +00:00
struct
{
bool xf8_24_ : 1;
bool xf8_25_ : 1;
};
u8 _dummy = 0;
};
bool xf9_ = false;
zeus::CVector3f xfc_constantForce;
zeus::CAxisAngle x108_angularMomentum;
zeus::CMatrix3f x114_;
2016-09-01 04:10:08 +00:00
zeus::CVector3f x138_velocity;
zeus::CAxisAngle x144_angularVelocity;
2016-09-01 09:31:18 +00:00
zeus::CVector3f x150_momentum;
zeus::CVector3f x15c_force;
zeus::CVector3f x168_impulse;
zeus::CAxisAngle x174_torque;
zeus::CAxisAngle x180_angularImpulse;
zeus::CVector3f x18c_;
zeus::CAxisAngle x198_;
2016-04-22 20:22:45 +00:00
zeus::CAABox x1a4_baseBoundingBox;
CCollidableAABox x1c0_collisionPrimitive;
2016-04-22 20:22:45 +00:00
zeus::CVector3f x1e8_primitiveOffset;
2016-09-01 19:39:13 +00:00
zeus::CVector3f x1f4_translation;
zeus::CNUQuaternion x200_orientation;
2016-09-01 09:31:18 +00:00
zeus::CAxisAngle x210_;
zeus::CAxisAngle x21c_;
bool x234_ = false;
float x238_ = 1000000.0f;
2016-04-22 20:22:45 +00:00
float x23c_stepUpHeight;
float x240_stepDownHeight;
2016-09-01 19:39:13 +00:00
float x244_restitutionCoefModifier = 0.f;
float x248_collisionAccuracyModifier = 1.f;
u32 x24c_;
u32 x250_;
public:
CPhysicsActor(TUniqueId, bool, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CMaterialList&, const zeus::CAABox&, const SMoverData&, const CActorParameters&, float, float);
2016-09-01 09:31:18 +00:00
void Render(const CStateManager& mgr) const;
zeus::CVector3f GetOrbitPosition(const CStateManager&) const;
zeus::CVector3f GetAimPosition(const CStateManager&, float val) const;
2017-03-03 22:13:23 +00:00
virtual const CCollisionPrimitive* GetCollisionPrimitive() const;
2016-09-01 04:10:08 +00:00
virtual zeus::CTransform GetPrimitiveTransform() const;
virtual void CollidedWith(const TUniqueId&, const CCollisionInfoList&, CStateManager&);
2016-09-01 04:10:08 +00:00
virtual float GetStepUpHeight() const;
virtual float GetStepDownHeight() const;
virtual float GetWeight() const;
void sub_8011A4C(float f);
float sub_8011A4B8() const;
void SetPrimitiveOffset(const zeus::CVector2f& offset);
zeus::CVector3f GetPrimitiveOffset();
void MoveCollisionPrimitive(const zeus::CVector3f& offset);
void SetBoundingBox(const zeus::CAABox& box);
2016-09-01 04:10:08 +00:00
zeus::CAABox GetMotionVolume(float f31) const;
zeus::CVector3f CalculateNewVelocityWR_UsingImpulses() const;
2016-09-01 09:31:18 +00:00
zeus::CAABox GetBoundingBox() const;
const zeus::CAABox& GetBaseBoundingBox() const;
2016-09-01 04:10:08 +00:00
void AddMotionState(const CMotionState& mst);
CMotionState GetMotionState() const;
2016-09-01 09:31:18 +00:00
void SetMotionState(const CMotionState& mst);
void SetInertiaTensorScalar(float tensor);
2017-03-03 22:13:23 +00:00
void SetCoefficientOfRestitutionModifier(float);
void SetMass(float mass);
2016-09-01 04:10:08 +00:00
void SetAngularVelocityOR(const zeus::CAxisAngle& angVel);
zeus::CAxisAngle GetAngularVelocityOR() const;
void SetAngularVelocityWR(const zeus::CAxisAngle& angVel);
void SetVelocityWR(const zeus::CVector3f& vel);
void SetVelocityOR(const zeus::CVector3f& vel);
zeus::CVector3f GetTotalForcesWR() const;
void RotateInOneFrameOR(const zeus::CQuaternion& q, float d);
2016-09-01 09:31:18 +00:00
void MoveInOneFrameOR(const zeus::CVector3f& trans, float d);
void RotateToOR(const zeus::CQuaternion& q, float d);
void MoveToOR(const zeus::CVector3f& trans, float d);
void sub_8011B098(const zeus::CVector3f& v1, float d);
2016-09-01 09:31:18 +00:00
void MoveToWR(const zeus::CVector3f& trans, float d);
zeus::CAxisAngle GetRotateToORAngularMomentumWR(const zeus::CQuaternion& q, float d) const;
zeus::CVector3f GetMoveToORImpulseWR(const zeus::CVector3f& trans, float d) const;
2016-09-01 04:10:08 +00:00
void ClearImpulses();
void ClearForcesAndTorques();
void Stop();
void ComputeDerivedQuantities();
bool WillMove(const CStateManager&);
2016-09-01 09:31:18 +00:00
void SetPhysicsState(const CPhysicsState& state);
CPhysicsState GetPhysicsState() const;
CMotionState PredictMotion_Internal(float) const;
CMotionState PredictMotion(float dt) const;
CMotionState PredictLinearMotion(float dt) const;
CMotionState PredictAngularMotion(float dt) const;
void ApplyForceOR(const zeus::CVector3f& force, const zeus::CAxisAngle& angle);
2016-09-01 09:31:18 +00:00
void ApplyForceWR(const zeus::CVector3f& force, const zeus::CAxisAngle& angle);
void ApplyImpulseOR(const zeus::CVector3f& impulse, const zeus::CAxisAngle& angle);
void ApplyImpulseWR(const zeus::CVector3f& impulse, const zeus::CAxisAngle& angle);
void ApplyTorqueWR(const zeus::CVector3f& torque);
void UseCollisionImpulses();
2015-08-22 01:58:41 +00:00
};
}
2016-04-13 06:07:23 +00:00
#endif // __URDE_CPHYSICSACTOR_HPP__