mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 21:07:42 +00:00
Formatting, and more script object implementations
This commit is contained in:
@@ -7,16 +7,16 @@ CPhysicsActor::CPhysicsActor(TUniqueId uid, bool active, const std::string& name
|
||||
const zeus::CTransform& xf, CModelData&& mData, const CMaterialList& matList,
|
||||
const zeus::CAABox& box, const SMoverData& moverData, const CActorParameters& actorParms,
|
||||
float stepUp, float stepDown)
|
||||
: CActor(uid, active, name, info, xf, std::move(mData), matList, actorParms, kInvalidUniqueId)
|
||||
, xe8_mass(moverData.x30_mass)
|
||||
, xec_massRecip(moverData.x30_mass <= 0.f ? 1.f : 1.f / moverData.x30_mass)
|
||||
, xf8_24_(true)
|
||||
, x150_momentum(moverData.x18_)
|
||||
, x1c0_collisionPrimitive(box, matList)
|
||||
, x1f4_translation(xf.origin)
|
||||
, x200_orientation(xf.buildMatrix3f())
|
||||
, x23c_stepUpHeight(stepUp)
|
||||
, x240_stepDownHeight(stepDown)
|
||||
: CActor(uid, active, name, info, xf, std::move(mData), matList, actorParms, kInvalidUniqueId)
|
||||
, xe8_mass(moverData.x30_mass)
|
||||
, xec_massRecip(moverData.x30_mass <= 0.f ? 1.f : 1.f / moverData.x30_mass)
|
||||
, xf8_24_(true)
|
||||
, x150_momentum(moverData.x18_)
|
||||
, x1c0_collisionPrimitive(box, matList)
|
||||
, x1f4_translation(xf.origin)
|
||||
, x200_orientation(xf.buildMatrix3f())
|
||||
, x23c_stepUpHeight(stepUp)
|
||||
, x240_stepDownHeight(stepDown)
|
||||
{
|
||||
SetMass(moverData.x30_mass);
|
||||
MoveCollisionPrimitive(zeus::CVector3f::skZero);
|
||||
@@ -25,15 +25,9 @@ CPhysicsActor::CPhysicsActor(TUniqueId uid, bool active, const std::string& name
|
||||
ComputeDerivedQuantities();
|
||||
}
|
||||
|
||||
void CPhysicsActor::Render(const CStateManager &mgr) const
|
||||
{
|
||||
CActor::Render(mgr);
|
||||
}
|
||||
void CPhysicsActor::Render(const CStateManager& mgr) const { CActor::Render(mgr); }
|
||||
|
||||
zeus::CVector3f CPhysicsActor::GetOrbitPosition(const CStateManager &) const
|
||||
{
|
||||
return GetBoundingBox().center();
|
||||
}
|
||||
zeus::CVector3f CPhysicsActor::GetOrbitPosition(const CStateManager&) const { return GetBoundingBox().center(); }
|
||||
|
||||
zeus::CVector3f CPhysicsActor::GetAimPosition(const CStateManager&, float dt) const
|
||||
{
|
||||
@@ -43,61 +37,32 @@ zeus::CVector3f CPhysicsActor::GetAimPosition(const CStateManager&, float dt) co
|
||||
return GetBoundingBox().center() + trans;
|
||||
}
|
||||
|
||||
void CPhysicsActor::CollidedWith(const TUniqueId &, const CCollisionInfoList &, CStateManager &)
|
||||
{
|
||||
}
|
||||
void CPhysicsActor::CollidedWith(const TUniqueId&, const CCollisionInfoList&, CStateManager&) {}
|
||||
|
||||
const CCollisionPrimitive& CPhysicsActor::GetCollisionPrimitive() const
|
||||
{
|
||||
return x1c0_collisionPrimitive;
|
||||
}
|
||||
const CCollisionPrimitive& CPhysicsActor::GetCollisionPrimitive() const { return x1c0_collisionPrimitive; }
|
||||
|
||||
zeus::CTransform CPhysicsActor::GetPrimitiveTransform() const
|
||||
{
|
||||
return zeus::CTransform::Translate(x34_transform.origin + x1e8_primitiveOffset);
|
||||
}
|
||||
|
||||
float CPhysicsActor::GetStepUpHeight() const
|
||||
{
|
||||
return x23c_stepUpHeight;
|
||||
}
|
||||
float CPhysicsActor::GetStepUpHeight() const { return x23c_stepUpHeight; }
|
||||
|
||||
float CPhysicsActor::GetStepDownHeight() const
|
||||
{
|
||||
return x240_stepDownHeight;
|
||||
}
|
||||
float CPhysicsActor::GetStepDownHeight() const { return x240_stepDownHeight; }
|
||||
|
||||
float CPhysicsActor::GetWeight() const
|
||||
{
|
||||
return 24.525002f * xe8_mass;
|
||||
}
|
||||
float CPhysicsActor::GetWeight() const { return 24.525002f * xe8_mass; }
|
||||
|
||||
void CPhysicsActor::sub_8011A4C(float f)
|
||||
{
|
||||
x238_ = f;
|
||||
}
|
||||
void CPhysicsActor::sub_8011A4C(float f) { x238_ = f; }
|
||||
|
||||
float CPhysicsActor::sub_8011A4B8() const
|
||||
{
|
||||
return x238_;
|
||||
}
|
||||
float CPhysicsActor::sub_8011A4B8() const { return x238_; }
|
||||
|
||||
void CPhysicsActor::SetPrimitiveOffset(const zeus::CVector2f &offset)
|
||||
{
|
||||
x1e8_primitiveOffset = offset;
|
||||
}
|
||||
void CPhysicsActor::SetPrimitiveOffset(const zeus::CVector2f& offset) { x1e8_primitiveOffset = offset; }
|
||||
|
||||
zeus::CVector3f CPhysicsActor::GetPrimitiveOffset()
|
||||
{
|
||||
return x1e8_primitiveOffset;
|
||||
}
|
||||
zeus::CVector3f CPhysicsActor::GetPrimitiveOffset() { return x1e8_primitiveOffset; }
|
||||
|
||||
void CPhysicsActor::MoveCollisionPrimitive(const zeus::CVector3f &offset)
|
||||
{
|
||||
x1e8_primitiveOffset = offset;
|
||||
}
|
||||
void CPhysicsActor::MoveCollisionPrimitive(const zeus::CVector3f& offset) { x1e8_primitiveOffset = offset; }
|
||||
|
||||
void CPhysicsActor::SetBoundingBox(const zeus::CAABox &box)
|
||||
void CPhysicsActor::SetBoundingBox(const zeus::CAABox& box)
|
||||
{
|
||||
x1a4_baseBoundingBox = box;
|
||||
MoveCollisionPrimitive(zeus::CVector3f::skZero);
|
||||
@@ -129,14 +94,11 @@ zeus::CVector3f CPhysicsActor::CalculateNewVelocityWR_UsingImpulses() const
|
||||
|
||||
zeus::CAABox CPhysicsActor::GetBoundingBox() const
|
||||
{
|
||||
return { x1a4_baseBoundingBox.min + x1e8_primitiveOffset + x34_transform.origin,
|
||||
x1a4_baseBoundingBox.max + x1e8_primitiveOffset + x34_transform.origin };
|
||||
return {x1a4_baseBoundingBox.min + x1e8_primitiveOffset + x34_transform.origin,
|
||||
x1a4_baseBoundingBox.max + x1e8_primitiveOffset + x34_transform.origin};
|
||||
}
|
||||
|
||||
const zeus::CAABox& CPhysicsActor::GetBaseBoundingBox() const
|
||||
{
|
||||
return x1a4_baseBoundingBox;
|
||||
}
|
||||
const zeus::CAABox& CPhysicsActor::GetBaseBoundingBox() const { return x1a4_baseBoundingBox; }
|
||||
|
||||
void CPhysicsActor::AddMotionState(const CMotionState& mst)
|
||||
{
|
||||
@@ -160,7 +122,7 @@ CMotionState CPhysicsActor::GetMotionState() const
|
||||
return {x34_transform.origin, {x34_transform.buildMatrix3f()}, xfc_constantForce, x108_angularMomentum};
|
||||
}
|
||||
|
||||
void CPhysicsActor::SetMotionState(const CMotionState &mst)
|
||||
void CPhysicsActor::SetMotionState(const CMotionState& mst)
|
||||
{
|
||||
x34_transform = zeus::CTransform::Translate(x34_transform.origin) * zeus::CMatrix3f(mst.xc_orientation);
|
||||
|
||||
@@ -210,31 +172,22 @@ void CPhysicsActor::SetAngularVelocityWR(const zeus::CAxisAngle& angVel)
|
||||
x108_angularMomentum = xf0_inertiaTensor * x144_angularVelocity;
|
||||
}
|
||||
|
||||
void CPhysicsActor::SetVelocityWR(const zeus::CVector3f &vel)
|
||||
void CPhysicsActor::SetVelocityWR(const zeus::CVector3f& vel)
|
||||
{
|
||||
x138_velocity = vel;
|
||||
xfc_constantForce = xe8_mass * x138_velocity;
|
||||
}
|
||||
|
||||
void CPhysicsActor::SetVelocityOR(const zeus::CVector3f& vel)
|
||||
{
|
||||
SetVelocityWR(x34_transform.rotate(vel));
|
||||
}
|
||||
void CPhysicsActor::SetVelocityOR(const zeus::CVector3f& vel) { SetVelocityWR(x34_transform.rotate(vel)); }
|
||||
|
||||
zeus::CVector3f CPhysicsActor::GetTotalForcesWR() const
|
||||
{
|
||||
return x15c_force + x150_momentum;
|
||||
}
|
||||
zeus::CVector3f CPhysicsActor::GetTotalForcesWR() const { return x15c_force + x150_momentum; }
|
||||
|
||||
void CPhysicsActor::RotateInOneFrameOR(const zeus::CQuaternion &q, float d)
|
||||
void CPhysicsActor::RotateInOneFrameOR(const zeus::CQuaternion& q, float d)
|
||||
{
|
||||
x198_ += GetRotateToORAngularMomentumWR(q, d);
|
||||
}
|
||||
|
||||
void CPhysicsActor::MoveInOneFrameOR(const zeus::CVector3f &trans, float d)
|
||||
{
|
||||
x18c_ += GetMoveToORImpulseWR(trans, d);
|
||||
}
|
||||
void CPhysicsActor::MoveInOneFrameOR(const zeus::CVector3f& trans, float d) { x18c_ += GetMoveToORImpulseWR(trans, d); }
|
||||
|
||||
void CPhysicsActor::RotateToOR(const zeus::CQuaternion& q, float d)
|
||||
{
|
||||
@@ -250,7 +203,7 @@ void CPhysicsActor::MoveToOR(const zeus::CVector3f& trans, float d)
|
||||
|
||||
void CPhysicsActor::sub_8011B098(const zeus::CVector3f& trans, float d)
|
||||
{
|
||||
x18c_ += xe8_mass * (trans - x34_transform.origin) * (1.f / d);
|
||||
x18c_ += xe8_mass * (trans - x34_transform.origin) * (1.f / d);
|
||||
}
|
||||
|
||||
void CPhysicsActor::MoveToWR(const zeus::CVector3f& trans, float d)
|
||||
@@ -263,11 +216,11 @@ zeus::CAxisAngle CPhysicsActor::GetRotateToORAngularMomentumWR(const zeus::CQuat
|
||||
{
|
||||
if (q.w > 0.99999976)
|
||||
return zeus::CAxisAngle::skZero;
|
||||
return (xf0_inertiaTensor * (((2.f * std::acos(q.w)) * (1.f / d)) *
|
||||
x34_transform.rotate({q.x, q.y, q.z}).normalized()));
|
||||
return (xf0_inertiaTensor *
|
||||
(((2.f * std::acos(q.w)) * (1.f / d)) * x34_transform.rotate({q.x, q.y, q.z}).normalized()));
|
||||
}
|
||||
|
||||
zeus::CVector3f CPhysicsActor::GetMoveToORImpulseWR(const zeus::CVector3f &trans, float d) const
|
||||
zeus::CVector3f CPhysicsActor::GetMoveToORImpulseWR(const zeus::CVector3f& trans, float d) const
|
||||
{
|
||||
return (xe8_mass * x34_transform.rotate(trans)) * (1.f / d);
|
||||
}
|
||||
@@ -302,19 +255,19 @@ void CPhysicsActor::ComputeDerivedQuantities()
|
||||
bool CPhysicsActor::WillMove(const CStateManager&)
|
||||
{
|
||||
if (!zeus::close_enough(zeus::CVector3f::skZero, x138_velocity) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x168_impulse) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x174_torque) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x18c_) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x144_angularVelocity) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x180_angularImpulse) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x198_) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, GetTotalForcesWR()))
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x168_impulse) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x174_torque) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x18c_) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x144_angularVelocity) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x180_angularImpulse) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, x198_) ||
|
||||
!zeus::close_enough(zeus::CVector3f::skZero, GetTotalForcesWR()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPhysicsActor::SetPhysicsState(const CPhysicsState &state)
|
||||
void CPhysicsActor::SetPhysicsState(const CPhysicsState& state)
|
||||
{
|
||||
SetTranslation(state.GetTranslation());
|
||||
x34_transform = zeus::CTransform::Translate(x34_transform.origin) * zeus::CMatrix3f(state.GetOrientation());
|
||||
@@ -323,7 +276,8 @@ void CPhysicsActor::SetPhysicsState(const CPhysicsState &state)
|
||||
xe4_29_ = true;
|
||||
|
||||
xfc_constantForce = state.GetConstantForceWR();
|
||||
x108_angularMomentum = state.GetAngularMomentumWR();;
|
||||
x108_angularMomentum = state.GetAngularMomentumWR();
|
||||
;
|
||||
x150_momentum = state.GetMomentumWR();
|
||||
x15c_force = state.GetForceWR();
|
||||
x168_impulse = state.GetImpulseWR();
|
||||
@@ -334,8 +288,11 @@ void CPhysicsActor::SetPhysicsState(const CPhysicsState &state)
|
||||
|
||||
CPhysicsState CPhysicsActor::GetPhysicsState() const
|
||||
{
|
||||
return {x34_transform.origin, {x34_transform.buildMatrix3f()}, xfc_constantForce, x108_angularMomentum,
|
||||
x150_momentum, x15c_force, x168_impulse, x174_torque, x180_angularImpulse};
|
||||
return {x34_transform.origin, {x34_transform.buildMatrix3f()},
|
||||
xfc_constantForce, x108_angularMomentum,
|
||||
x150_momentum, x15c_force,
|
||||
x168_impulse, x174_torque,
|
||||
x180_angularImpulse};
|
||||
}
|
||||
|
||||
CMotionState CPhysicsActor::PredictMotion_Internal(float dt) const
|
||||
@@ -358,19 +315,16 @@ CMotionState CPhysicsActor::PredictMotion(float dt) const
|
||||
CMotionState CPhysicsActor::PredictLinearMotion(float dt) const
|
||||
{
|
||||
zeus::CVector3f velocity = CalculateNewVelocityWR_UsingImpulses();
|
||||
return {velocity * dt, zeus::CNUQuaternion::skNoRotation,
|
||||
((x15c_force + x150_momentum) * dt) + x168_impulse,
|
||||
zeus::CAxisAngle::skZero};
|
||||
return {velocity * dt, zeus::CNUQuaternion::skNoRotation, ((x15c_force + x150_momentum) * dt) + x168_impulse,
|
||||
zeus::CAxisAngle::skZero};
|
||||
}
|
||||
|
||||
CMotionState CPhysicsActor::PredictAngularMotion(float dt) const
|
||||
{
|
||||
const zeus::CVector3f v1 = xf4_inertiaTensorRecip * (x180_angularImpulse + x198_);
|
||||
zeus::CNUQuaternion q = 0.5f * zeus::CNUQuaternion({0.f, x144_angularVelocity + v1});
|
||||
return {zeus::CVector3f::skZero,
|
||||
q * zeus::CNUQuaternion(x34_transform.buildMatrix3f()) * dt,
|
||||
zeus::CVector3f::skZero,
|
||||
(x174_torque * dt) + x180_angularImpulse};
|
||||
return {zeus::CVector3f::skZero, q * zeus::CNUQuaternion(x34_transform.buildMatrix3f()) * dt,
|
||||
zeus::CVector3f::skZero, (x174_torque * dt) + x180_angularImpulse};
|
||||
}
|
||||
|
||||
void CPhysicsActor::ApplyForceOR(const zeus::CVector3f& force, const zeus::CAxisAngle& torque)
|
||||
@@ -379,28 +333,25 @@ void CPhysicsActor::ApplyForceOR(const zeus::CVector3f& force, const zeus::CAxis
|
||||
x174_torque += x34_transform.rotate(torque);
|
||||
}
|
||||
|
||||
void CPhysicsActor::ApplyForceWR(const zeus::CVector3f &force, const zeus::CAxisAngle& torque)
|
||||
void CPhysicsActor::ApplyForceWR(const zeus::CVector3f& force, const zeus::CAxisAngle& torque)
|
||||
{
|
||||
x15c_force += force;
|
||||
x174_torque += torque;
|
||||
}
|
||||
|
||||
void CPhysicsActor::ApplyImpulseOR(const zeus::CVector3f &impulse, const zeus::CAxisAngle &angle)
|
||||
void CPhysicsActor::ApplyImpulseOR(const zeus::CVector3f& impulse, const zeus::CAxisAngle& angle)
|
||||
{
|
||||
x168_impulse += x34_transform.rotate(impulse);
|
||||
x180_angularImpulse += x34_transform.rotate(angle);
|
||||
}
|
||||
|
||||
void CPhysicsActor::ApplyImpulseWR(const zeus::CVector3f &impulse, const zeus::CAxisAngle& angleImp)
|
||||
void CPhysicsActor::ApplyImpulseWR(const zeus::CVector3f& impulse, const zeus::CAxisAngle& angleImp)
|
||||
{
|
||||
x168_impulse += impulse;
|
||||
x180_angularImpulse += angleImp;
|
||||
}
|
||||
|
||||
void CPhysicsActor::ApplyTorqueWR(const zeus::CVector3f& torque)
|
||||
{
|
||||
x174_torque += torque;
|
||||
}
|
||||
void CPhysicsActor::ApplyTorqueWR(const zeus::CVector3f& torque) { x174_torque += torque; }
|
||||
|
||||
void CPhysicsActor::UseCollisionImpulses()
|
||||
{
|
||||
@@ -413,74 +364,40 @@ void CPhysicsActor::UseCollisionImpulses()
|
||||
}
|
||||
|
||||
CPhysicsState::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)
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
void CPhysicsState::SetTranslation(const zeus::CVector3f& tr)
|
||||
{
|
||||
x0_translation = tr;
|
||||
}
|
||||
void CPhysicsState::SetTranslation(const zeus::CVector3f& tr) { x0_translation = tr; }
|
||||
|
||||
void CPhysicsState::SetOrientation(const zeus::CQuaternion& orient)
|
||||
{
|
||||
xc_orientation = orient;
|
||||
}
|
||||
void CPhysicsState::SetOrientation(const zeus::CQuaternion& orient) { xc_orientation = orient; }
|
||||
|
||||
const zeus::CQuaternion& CPhysicsState::GetOrientation() const
|
||||
{
|
||||
return xc_orientation;
|
||||
}
|
||||
const zeus::CQuaternion& CPhysicsState::GetOrientation() const { return xc_orientation; }
|
||||
|
||||
const zeus::CVector3f& CPhysicsState::GetTranslation() const
|
||||
{
|
||||
return x0_translation;
|
||||
}
|
||||
const zeus::CVector3f& CPhysicsState::GetTranslation() const { return x0_translation; }
|
||||
|
||||
const zeus::CVector3f& CPhysicsState::GetConstantForceWR() const
|
||||
{
|
||||
return x1c_constantForce;
|
||||
}
|
||||
const zeus::CVector3f& CPhysicsState::GetConstantForceWR() const { return x1c_constantForce; }
|
||||
|
||||
const zeus::CAxisAngle& CPhysicsState::GetAngularMomentumWR() const
|
||||
{
|
||||
return x28_angularMomentum;
|
||||
}
|
||||
const zeus::CAxisAngle& CPhysicsState::GetAngularMomentumWR() const { return x28_angularMomentum; }
|
||||
|
||||
const zeus::CVector3f& CPhysicsState::GetMomentumWR() const
|
||||
{
|
||||
return x34_momentum;
|
||||
}
|
||||
const zeus::CVector3f& CPhysicsState::GetMomentumWR() const { return x34_momentum; }
|
||||
|
||||
const zeus::CVector3f& CPhysicsState::GetForceWR() const
|
||||
{
|
||||
return x40_force;
|
||||
}
|
||||
const zeus::CVector3f& CPhysicsState::GetForceWR() const { return x40_force; }
|
||||
|
||||
const zeus::CVector3f& CPhysicsState::GetImpulseWR() const
|
||||
{
|
||||
return x4c_impulse;
|
||||
}
|
||||
const zeus::CVector3f& CPhysicsState::GetImpulseWR() const { return x4c_impulse; }
|
||||
|
||||
const zeus::CAxisAngle& CPhysicsState::GetTorque() const
|
||||
{
|
||||
return x58_torque;
|
||||
}
|
||||
|
||||
const zeus::CAxisAngle& CPhysicsState::GetAngularImpulseWR() const
|
||||
{
|
||||
return x64_angularImpulse;
|
||||
}
|
||||
const zeus::CAxisAngle& CPhysicsState::GetTorque() const { return x58_torque; }
|
||||
|
||||
const zeus::CAxisAngle& CPhysicsState::GetAngularImpulseWR() const { return x64_angularImpulse; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user