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"
|
2016-08-31 00:33:59 +00:00
|
|
|
#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
|
|
|
|
{
|
2016-08-31 00:33:59 +00:00
|
|
|
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_;
|
2016-08-31 00:33:59 +00:00
|
|
|
float x30_mass;
|
2016-04-19 00:17:49 +00:00
|
|
|
|
2016-08-31 00:33:59 +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;
|
2016-09-02 15:26:29 +00:00
|
|
|
zeus::CAxisAngle x28_angularMomentum;
|
2016-12-19 18:27:58 +00:00
|
|
|
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)
|
2017-06-18 01:58:13 +00:00
|
|
|
{}
|
|
|
|
CMotionState(const zeus::CVector3f& origin, const zeus::CNUQuaternion& orientation)
|
|
|
|
: x0_translation(origin), xc_orientation(orientation)
|
|
|
|
{}
|
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-12-19 18:27:58 +00:00
|
|
|
|
2016-09-01 09:31:18 +00:00
|
|
|
public:
|
2017-06-12 04:23:34 +00:00
|
|
|
CPhysicsState(const zeus::CVector3f& translation, const zeus::CQuaternion& orient,
|
|
|
|
const zeus::CVector3f& v2, const zeus::CAxisAngle& a1, const zeus::CVector3f& v3,
|
|
|
|
const zeus::CVector3f& v4, const zeus::CVector3f& v5, const zeus::CAxisAngle& a2,
|
|
|
|
const zeus::CAxisAngle& a3)
|
|
|
|
: x0_translation(translation)
|
|
|
|
, xc_orientation(orient)
|
|
|
|
, x1c_constantForce(v2)
|
|
|
|
, x28_angularMomentum(a1)
|
|
|
|
, x34_momentum(v3)
|
|
|
|
, x40_force(v4)
|
|
|
|
, x4c_impulse(v5)
|
|
|
|
, x58_torque(a2)
|
|
|
|
, x64_angularImpulse(a3)
|
|
|
|
{}
|
2016-09-01 09:31:18 +00:00
|
|
|
|
2017-06-12 04:23:34 +00:00
|
|
|
void SetTranslation(const zeus::CVector3f& tr) { x0_translation = tr; }
|
|
|
|
void SetOrientation(const zeus::CQuaternion& orient) { xc_orientation = orient; }
|
|
|
|
const zeus::CQuaternion& GetOrientation() const { return xc_orientation; }
|
|
|
|
const zeus::CVector3f& GetTranslation() const { return x0_translation; }
|
|
|
|
const zeus::CVector3f& GetConstantForceWR() const { return x1c_constantForce; }
|
|
|
|
const zeus::CAxisAngle& GetAngularMomentumWR() const { return x28_angularMomentum; }
|
|
|
|
const zeus::CVector3f& GetMomentumWR() const { return x34_momentum; }
|
|
|
|
const zeus::CVector3f& GetForceWR() const { return x40_force; }
|
|
|
|
const zeus::CVector3f& GetImpulseWR() const { return x4c_impulse; }
|
|
|
|
const zeus::CAxisAngle& GetTorque() const { return x58_torque; }
|
|
|
|
const zeus::CAxisAngle& GetAngularImpulseWR() const { return x64_angularImpulse; }
|
2016-09-01 09:31:18 +00:00
|
|
|
};
|
|
|
|
|
2015-08-22 01:58:41 +00:00
|
|
|
class CPhysicsActor : public CActor
|
|
|
|
{
|
2017-06-19 07:00:50 +00:00
|
|
|
friend class CGroundMovement;
|
2015-11-02 18:45:39 +00:00
|
|
|
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;
|
2016-12-19 18:27:58 +00:00
|
|
|
union {
|
2016-09-01 09:31:18 +00:00
|
|
|
struct
|
|
|
|
{
|
2017-06-18 01:58:13 +00:00
|
|
|
bool xf8_24_movable : 1;
|
|
|
|
bool xf8_25_angularEnabled : 1;
|
2016-09-01 09:31:18 +00:00
|
|
|
};
|
|
|
|
u8 _dummy = 0;
|
|
|
|
};
|
2017-06-18 01:58:13 +00:00
|
|
|
bool xf9_standardCollider = false;
|
2016-09-01 09:31:18 +00:00
|
|
|
zeus::CVector3f xfc_constantForce;
|
|
|
|
zeus::CAxisAngle x108_angularMomentum;
|
2016-08-31 00:33:59 +00:00
|
|
|
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;
|
2017-09-07 03:55:31 +00:00
|
|
|
zeus::CVector3f x18c_moveImpulse;
|
|
|
|
zeus::CAxisAngle x198_moveAngularImpulse;
|
2016-04-22 20:22:45 +00:00
|
|
|
zeus::CAABox x1a4_baseBoundingBox;
|
2016-08-31 00:33:59 +00:00
|
|
|
CCollidableAABox x1c0_collisionPrimitive;
|
2016-04-22 20:22:45 +00:00
|
|
|
zeus::CVector3f x1e8_primitiveOffset;
|
2017-06-18 01:58:13 +00:00
|
|
|
CMotionState x1f4_lastNonCollidingState;
|
2017-06-19 07:00:50 +00:00
|
|
|
std::experimental::optional<zeus::CVector3f> x228_lastFloorPlaneNormal;
|
2017-06-18 01:58:13 +00:00
|
|
|
float x238_maximumCollisionVelocity = 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;
|
2017-06-18 01:58:13 +00:00
|
|
|
u32 x24c_numTicksStuck;
|
|
|
|
u32 x250_numTicksPartialUpdate;
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2015-11-02 18:45:39 +00:00
|
|
|
public:
|
2017-11-13 06:19:18 +00:00
|
|
|
CPhysicsActor(TUniqueId, bool, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
|
2016-12-19 18:27:58 +00:00
|
|
|
const CMaterialList&, const zeus::CAABox&, const SMoverData&, const CActorParameters&, float, float);
|
2015-11-02 18:45:39 +00:00
|
|
|
|
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;
|
2017-06-18 01:58:13 +00:00
|
|
|
virtual void CollidedWith(TUniqueId, const CCollisionInfoList&, CStateManager&);
|
2016-09-01 04:10:08 +00:00
|
|
|
virtual float GetStepUpHeight() const;
|
|
|
|
virtual float GetStepDownHeight() const;
|
|
|
|
virtual float GetWeight() const;
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2017-03-26 05:53:04 +00:00
|
|
|
float GetMass() const { return xe8_mass; }
|
2016-08-31 00:33:59 +00:00
|
|
|
void SetPrimitiveOffset(const zeus::CVector2f& offset);
|
|
|
|
zeus::CVector3f GetPrimitiveOffset();
|
|
|
|
void MoveCollisionPrimitive(const zeus::CVector3f& offset);
|
|
|
|
void SetBoundingBox(const zeus::CAABox& box);
|
2017-06-19 07:00:50 +00:00
|
|
|
zeus::CAABox GetMotionVolume(float dt) const;
|
2016-09-01 04:10:08 +00:00
|
|
|
zeus::CVector3f CalculateNewVelocityWR_UsingImpulses() const;
|
2016-09-01 09:31:18 +00:00
|
|
|
zeus::CAABox GetBoundingBox() const;
|
2016-08-31 00:33:59 +00:00
|
|
|
const zeus::CAABox& GetBaseBoundingBox() const;
|
2016-09-01 04:10:08 +00:00
|
|
|
void AddMotionState(const CMotionState& mst);
|
|
|
|
CMotionState GetMotionState() const;
|
2017-06-18 01:58:13 +00:00
|
|
|
const CMotionState& GetLastNonCollidingState() const { return x1f4_lastNonCollidingState; }
|
|
|
|
void SetLastNonCollidingState(const CMotionState& mst) { x1f4_lastNonCollidingState = mst; }
|
2016-09-01 09:31:18 +00:00
|
|
|
void SetMotionState(const CMotionState& mst);
|
2017-06-18 01:58:13 +00:00
|
|
|
float GetMaximumCollisionVelocity() const { return x238_maximumCollisionVelocity; }
|
|
|
|
void SetMaximumCollisionVelocity(float v) { x238_maximumCollisionVelocity = v; }
|
2016-08-31 00:33:59 +00:00
|
|
|
void SetInertiaTensorScalar(float tensor);
|
|
|
|
void SetMass(float mass);
|
2016-09-01 04:10:08 +00:00
|
|
|
void SetAngularVelocityOR(const zeus::CAxisAngle& angVel);
|
|
|
|
zeus::CAxisAngle GetAngularVelocityOR() const;
|
2017-06-19 07:00:50 +00:00
|
|
|
const zeus::CAxisAngle& GetAngularVelocityWR() const { return x144_angularVelocity; }
|
2016-09-01 04:10:08 +00:00
|
|
|
void SetAngularVelocityWR(const zeus::CAxisAngle& angVel);
|
2017-09-17 03:13:03 +00:00
|
|
|
const zeus::CVector3f& GetForceOR() const { return x15c_force; }
|
2016-09-01 04:10:08 +00:00
|
|
|
void SetVelocityWR(const zeus::CVector3f& vel);
|
|
|
|
void SetVelocityOR(const zeus::CVector3f& vel);
|
2017-06-19 07:00:50 +00:00
|
|
|
void SetMomentumWR(const zeus::CVector3f& m) { x150_momentum = m; }
|
2017-07-14 05:14:19 +00:00
|
|
|
const zeus::CVector3f& GetConstantForce() { return xfc_constantForce; }
|
2017-07-10 04:55:51 +00:00
|
|
|
void SetConstantForce(const zeus::CVector3f& f) { xfc_constantForce = f; }
|
|
|
|
void SetAngularMomentum(const zeus::CAxisAngle& m) { x108_angularMomentum = m; }
|
2017-06-19 07:00:50 +00:00
|
|
|
const zeus::CVector3f& GetMomentum() const { return x150_momentum; }
|
2017-06-18 01:58:13 +00:00
|
|
|
const zeus::CVector3f& GetVelocity() const { return x138_velocity; }
|
2017-09-30 03:45:57 +00:00
|
|
|
const zeus::CAxisAngle& GetAngularImpulse() const { return x180_angularImpulse; }
|
|
|
|
void SetAngularImpulse(const zeus::CAxisAngle& i) { x180_angularImpulse = i; }
|
2016-09-01 04:10:08 +00:00
|
|
|
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);
|
2016-12-19 18:27:58 +00:00
|
|
|
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;
|
2017-06-18 01:58:13 +00:00
|
|
|
bool IsMovable() const { return xf8_24_movable; }
|
|
|
|
void SetMovable(bool m) { xf8_24_movable = m; }
|
|
|
|
bool IsAngularEnabled() const { return xf8_25_angularEnabled; }
|
|
|
|
void SetAngularEnabled(bool e) { xf8_25_angularEnabled = e; }
|
|
|
|
float GetCollisionAccuracyModifier() const { return x248_collisionAccuracyModifier; }
|
|
|
|
void SetCollisionAccuracyModifier(float m) { x248_collisionAccuracyModifier = m; }
|
|
|
|
float GetCoefficientOfRestitutionModifier() const { return x244_restitutionCoefModifier; }
|
|
|
|
void SetCoefficientOfRestitutionModifier(float m) { x244_restitutionCoefModifier = m; }
|
|
|
|
bool IsUseStandardCollider() const { return xf9_standardCollider; }
|
|
|
|
u32 GetNumTicksPartialUpdate() const { return x250_numTicksPartialUpdate; }
|
|
|
|
void SetNumTicksPartialUpdate(u32 t) { x250_numTicksPartialUpdate = t; }
|
|
|
|
u32 GetNumTicksStuck() const { return x24c_numTicksStuck; }
|
|
|
|
void SetNumTicksStuck(u32 t) { x24c_numTicksStuck = t; }
|
2017-06-19 07:00:50 +00:00
|
|
|
const std::experimental::optional<zeus::CVector3f>& GetLastFloorPlaneNormal() const { return x228_lastFloorPlaneNormal; }
|
|
|
|
void SetLastFloorPlaneNormal(const std::experimental::optional<zeus::CVector3f>& n) { x228_lastFloorPlaneNormal = n; }
|
2016-09-01 09:31:18 +00:00
|
|
|
|
|
|
|
CMotionState PredictMotion_Internal(float) const;
|
|
|
|
CMotionState PredictMotion(float dt) const;
|
|
|
|
CMotionState PredictLinearMotion(float dt) const;
|
|
|
|
CMotionState PredictAngularMotion(float dt) const;
|
2016-12-19 18:27:58 +00:00
|
|
|
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__
|