metaforce/Runtime/World/CPhysicsActor.hpp

143 lines
3.6 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"
2016-04-22 20:22:45 +00:00
#include "Collision/CCollisionPrimitive.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_;
zeus::CAxisAngle xc_;
zeus::CVector3f x18_;
zeus::CAxisAngle x24_;
float x30_;
SMoverData(float a) : x30_(a) {}
};
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;
float xf0_inertialTensor;
float xf4_inertialTensorRecip;
zeus::CAABox x1a4_baseBoundingBox;
2016-04-27 00:26:02 +00:00
std::unique_ptr<CCollisionPrimitive> x1c0_collisionPrimitive;
2016-04-22 20:22:45 +00:00
zeus::CVector3f x1e8_primitiveOffset;
float x23c_stepUpHeight;
float x240_stepDownHeight;
float x244_restitutionCoefModifier;
float x248_collisionAccuracyModifier;
public:
2016-04-19 00:17:49 +00:00
CPhysicsActor(TUniqueId, bool, const std::string&, const CEntityInfo&,
2016-04-22 20:22:45 +00:00
const zeus::CTransform&, CModelData&&, const CMaterialList&,
2016-04-19 00:17:49 +00:00
const zeus::CAABox&, const SMoverData&, const CActorParameters&,
float, float);
2016-04-23 10:51:53 +00:00
void AddToRenderer(const zeus::CFrustum &, CStateManager &){}
void Render(CStateManager& mgr) { CActor::Render(mgr); }
float GetCollisionAccuracyModifier()
2016-04-22 20:22:45 +00:00
{ return x248_collisionAccuracyModifier; }
void SetCollisionAccuracyModifier(float modifier)
2016-04-22 20:22:45 +00:00
{ x248_collisionAccuracyModifier = modifier; }
float GetCoefficientOfRestitutionModifier()
2016-04-22 20:22:45 +00:00
{ return x244_restitutionCoefModifier; }
void SetCoefficientOfRestitutionModifier(float modifier)
2016-04-22 20:22:45 +00:00
{ x244_restitutionCoefModifier = modifier;}
void DrawCollisionPrimitive()
{ }
void Render(const CStateManager&)
{}
2016-03-04 23:04:53 +00:00
zeus::CVector3f GetAimPosition(const CStateManager&, float val)
{
if (val <= 0.0)
return GetBoundingBox().center();
2016-03-04 23:04:53 +00:00
//zeus::CVector3f delta = PredictMotion(val);
return zeus::CVector3f();
}
2016-03-04 23:04:53 +00:00
zeus::CVector3f GetOrbitPosition(const CStateManager&)
{ return GetBoundingBox().center(); }
float GetStepUpHeight()
2016-04-22 20:22:45 +00:00
{ return x23c_stepUpHeight; }
float GetStepDownHeight()
2016-04-22 20:22:45 +00:00
{ return x240_stepDownHeight; }
2016-03-04 23:04:53 +00:00
void SetPrimitiveOffset(const zeus::CVector2f& offset)
2016-04-22 20:22:45 +00:00
{ x1e8_primitiveOffset = offset; }
2016-03-04 23:04:53 +00:00
zeus::CVector3f GetPrimitiveOffset()
2016-04-22 20:22:45 +00:00
{ return x1e8_primitiveOffset; }
float GetWeight()
2016-04-22 20:22:45 +00:00
{ return 24.525002f * xe8_mass; }
void MoveCollisionPrimitive(const zeus::CVector3f& offset)
{
x1e8_primitiveOffset = offset;
}
2016-03-04 23:04:53 +00:00
void SetBoundingBox(const zeus::CAABox& box)
2016-04-22 20:22:45 +00:00
{
x1a4_baseBoundingBox = box;
MoveCollisionPrimitive(zeus::CVector3f::skZero);
}
2016-03-04 23:04:53 +00:00
zeus::CAABox GetMotionVolume()
{ return zeus::CAABox::skInvertedBox; }
2016-04-22 20:22:45 +00:00
zeus::CAABox GetBoundingBox();
2016-03-04 23:04:53 +00:00
const zeus::CAABox& GetBaseBoundingBox() const
2016-04-22 20:22:45 +00:00
{ return x1a4_baseBoundingBox; }
void CollidedWith(const TUniqueId&, const CCollisionInfoList&, CStateManager&)
{}
2016-03-04 23:04:53 +00:00
zeus::CTransform GetPrimitiveTransform()
{
2016-03-04 23:04:53 +00:00
return zeus::CTransform();
}
2016-04-27 00:26:02 +00:00
const CCollisionPrimitive* GetCollisionPrimitive() const
{ return x1c0_collisionPrimitive.get(); }
2015-11-02 18:50:24 +00:00
void SetInertiaTensorScalar(float tensor)
{
if (tensor <= 0.0f)
tensor = 1.0f;
2016-04-22 20:22:45 +00:00
xf0_inertialTensor = tensor;
xf4_inertialTensorRecip = 1.0f / tensor;
}
void SetMass(float mass)
{
2016-04-22 20:22:45 +00:00
xe8_mass = mass;
float tensor = 1.0f;
if (mass > 0.0f)
tensor = 1.0f / mass;
2016-04-22 20:22:45 +00:00
xec_massRecip = tensor;
2015-11-02 18:50:24 +00:00
SetInertiaTensorScalar(mass * tensor);
}
2015-08-22 01:58:41 +00:00
};
}
2016-04-13 06:07:23 +00:00
#endif // __URDE_CPHYSICSACTOR_HPP__