2013-11-21 17:22:13 +01:00
|
|
|
#ifndef OYSTER_PHYSICS_SIMPLE_RIGIDBODY_H
|
|
|
|
#define OYSTER_PHYSICS_SIMPLE_RIGIDBODY_H
|
|
|
|
|
|
|
|
#include "..\PhysicsAPI.h"
|
2013-11-25 16:35:56 +01:00
|
|
|
#include "RigidBody.h"
|
2013-12-19 10:53:55 +01:00
|
|
|
#include "Octree.h"
|
2013-11-21 17:22:13 +01:00
|
|
|
|
|
|
|
namespace Oyster { namespace Physics
|
|
|
|
{
|
|
|
|
class SimpleRigidBody : public ICustomBody
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SimpleRigidBody();
|
2013-11-28 11:58:46 +01:00
|
|
|
SimpleRigidBody( const API::SimpleBodyDescription &desc );
|
2013-11-21 17:22:13 +01:00
|
|
|
virtual ~SimpleRigidBody();
|
|
|
|
|
|
|
|
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
|
|
|
|
|
2013-12-06 09:46:30 +01:00
|
|
|
State GetState() const;
|
|
|
|
State & GetState( State &targetMem ) const;
|
|
|
|
void SetState( const State &state );
|
2013-12-20 12:13:12 +01:00
|
|
|
//::Oyster::Math::Float3 GetRigidLinearVelocity() const;
|
2013-12-06 09:46:30 +01:00
|
|
|
|
2014-01-29 11:22:04 +01:00
|
|
|
SubscriptMessage CallSubscription_BeforeCollisionResponse( const ICustomBody *deuter );
|
|
|
|
void CallSubscription_AfterCollisionResponse( const ICustomBody *deuter, ::Oyster::Math::Float kineticEnergyLoss );
|
2014-01-17 16:07:25 +01:00
|
|
|
void CallSubscription_Move();
|
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
bool IsAffectedByGravity() const;
|
2013-11-21 17:22:13 +01:00
|
|
|
bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const;
|
2013-12-18 08:57:27 +01:00
|
|
|
bool Intersects( const ::Oyster::Collision3D::ICollideable &shape, ::Oyster::Math::Float4 &worldPointOfContact ) const;
|
|
|
|
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float4 &worldPointOfContact ) const;
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2014-02-03 15:48:42 +01:00
|
|
|
void SetTimeOfContact( ::Oyster::Math::Float4 &worldPointOfContact );
|
|
|
|
|
2013-11-21 17:22:13 +01:00
|
|
|
::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const;
|
2013-12-18 08:57:27 +01:00
|
|
|
::Oyster::Math::Float4 & GetNormalAt( const ::Oyster::Math::Float4 &worldPos, ::Oyster::Math::Float4 &targetMem = ::Oyster::Math::Float4() ) const;
|
2013-11-26 13:27:34 +01:00
|
|
|
::Oyster::Math::Float3 & GetGravityNormal( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
|
2014-01-20 13:44:12 +01:00
|
|
|
void * GetCustomTag() const;
|
2013-12-18 14:16:13 +01:00
|
|
|
//::Oyster::Math::Float3 & GetCenter( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
|
|
|
|
//::Oyster::Math::Float4x4 & GetRotation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
|
|
|
//::Oyster::Math::Float4x4 & GetOrientation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
|
|
|
//::Oyster::Math::Float4x4 & GetView( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
2013-11-21 17:22:13 +01:00
|
|
|
|
|
|
|
UpdateState Update( ::Oyster::Math::Float timeStepLength );
|
2013-12-20 11:30:11 +01:00
|
|
|
void Predict( ::Oyster::Math::Float4 &outDeltaPos, ::Oyster::Math::Float4 &outDeltaAxis, const ::Oyster::Math::Float4 &actingLinearImpulse, const ::Oyster::Math::Float4 &actingAngularImpulse, ::Oyster::Math::Float deltaTime );
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2013-12-19 10:53:55 +01:00
|
|
|
void SetScene( void *scene );
|
2014-01-17 16:07:25 +01:00
|
|
|
|
2014-01-29 11:22:04 +01:00
|
|
|
void SetSubscription( EventAction_BeforeCollisionResponse functionPointer );
|
|
|
|
void SetSubscription( EventAction_AfterCollisionResponse functionPointer );
|
2014-01-17 16:07:25 +01:00
|
|
|
void SetSubscription( EventAction_Move functionPointer );
|
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
void SetGravity( bool ignore);
|
|
|
|
void SetGravityNormal( const ::Oyster::Math::Float3 &normalizedVector );
|
2014-01-20 13:44:12 +01:00
|
|
|
void SetCustomTag( void *ref );
|
2013-12-18 14:16:13 +01:00
|
|
|
//void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI );
|
|
|
|
//void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI );
|
|
|
|
//void SetMass_KeepVelocity( ::Oyster::Math::Float m );
|
|
|
|
//void SetMass_KeepMomentum( ::Oyster::Math::Float m );
|
|
|
|
//void SetCenter( const ::Oyster::Math::Float3 &worldPos );
|
|
|
|
//void SetRotation( const ::Oyster::Math::Float4x4 &rotation );
|
|
|
|
//void SetOrientation( const ::Oyster::Math::Float4x4 &orientation );
|
|
|
|
//void SetSize( const ::Oyster::Math::Float3 &size );
|
|
|
|
//void SetMomentum( const ::Oyster::Math::Float3 &worldG );
|
2013-11-21 17:22:13 +01:00
|
|
|
|
|
|
|
private:
|
2013-11-28 11:58:46 +01:00
|
|
|
::Oyster::Physics3D::RigidBody rigid;
|
2013-12-20 11:15:43 +01:00
|
|
|
::Oyster::Math::Float4 deltaPos, deltaAxis;
|
2013-11-26 13:27:34 +01:00
|
|
|
::Oyster::Math::Float3 gravityNormal;
|
2014-02-03 15:48:42 +01:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct { ::Oyster::Math::Float3 center, axis, reach; } previousSpatial;
|
|
|
|
::Oyster::Math::Float timeOfContact;
|
|
|
|
} collisionRebound;
|
|
|
|
|
2014-01-29 11:22:04 +01:00
|
|
|
EventAction_BeforeCollisionResponse onCollision;
|
|
|
|
EventAction_AfterCollisionResponse onCollisionResponse;
|
2014-01-17 16:07:25 +01:00
|
|
|
EventAction_Move onMovement;
|
2014-02-03 15:48:42 +01:00
|
|
|
|
2013-12-19 10:53:55 +01:00
|
|
|
Octree *scene;
|
2014-01-20 13:44:12 +01:00
|
|
|
void *customTag;
|
2013-12-20 11:15:43 +01:00
|
|
|
bool ignoreGravity, isForwarded;
|
2013-11-21 17:22:13 +01:00
|
|
|
};
|
|
|
|
} }
|
|
|
|
|
|
|
|
#endif
|