IRigidBody done
Renamed to ICustomBody * Added bunch of other stuff
This commit is contained in:
parent
dc9f4597e2
commit
9749749748
|
@ -146,10 +146,13 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Implementation\PhysicsAPI_Impl.h" />
|
||||
<ClInclude Include="Implementation\SimpleRigidBody.h" />
|
||||
<ClInclude Include="PhysicsAPI.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Implementation\NullBody.cpp" />
|
||||
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp" />
|
||||
<ClCompile Include="Implementation\SimpleRigidBody.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -27,10 +27,19 @@
|
|||
<ClInclude Include="Implementation\PhysicsAPI_Impl.h">
|
||||
<Filter>Header Files\Implementation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Implementation\SimpleRigidBody.h">
|
||||
<Filter>Header Files\Implementation</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Implementation\SimpleRigidBody.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Implementation\NullBody.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,83 @@
|
|||
#include "..\PhysicsAPI.h"
|
||||
|
||||
using namespace ::Oyster::Physics;
|
||||
using namespace ::Oyster::Physics::Error;
|
||||
using namespace ::Oyster::Math;
|
||||
using namespace ::Oyster::Collision3D;
|
||||
using namespace ::Utility::DynamicMemory;
|
||||
|
||||
NullBody::~NullBody() {}
|
||||
|
||||
UniquePointer<ICustomBody> NullBody::Clone() const
|
||||
{
|
||||
return new NullBody( *this );
|
||||
}
|
||||
|
||||
bool NullBody::IsSubscribingCollisions() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NullBody::Intersects( const ICustomBody &object, Float &deltaWhen, Float3 &worldPointOfContact ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NullBody::Intersects( const ICollideable &shape ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int NullBody::GetReference() const
|
||||
{
|
||||
return not_a_reference;
|
||||
}
|
||||
|
||||
Sphere & NullBody::GetBoundingSphere( Sphere &targetMem ) const
|
||||
{
|
||||
return targetMem = Sphere( Float3::null, 0.0f );
|
||||
}
|
||||
|
||||
Float3 & NullBody::GetNormalAt( const Float3 &worldPos, Float3 &targetMem ) const
|
||||
{
|
||||
return targetMem = Float3::standard_unit_z;
|
||||
}
|
||||
|
||||
Float3 & NullBody::GetCenter( Float3 &targetMem ) const
|
||||
{
|
||||
return targetMem = Float3::null;
|
||||
}
|
||||
|
||||
Float4x4 & NullBody::GetRotation( Float4x4 &targetMem ) const
|
||||
{
|
||||
return targetMem = Float4x4::identity;
|
||||
}
|
||||
|
||||
Float4x4 & NullBody::GetOrientation( Float4x4 &targetMem ) const
|
||||
{
|
||||
return targetMem = Float4x4::identity;
|
||||
}
|
||||
|
||||
Float4x4 & NullBody::GetView( Float4x4 &targetMem ) const
|
||||
{
|
||||
return targetMem = Float4x4::identity;
|
||||
}
|
||||
|
||||
UpdateState NullBody::Update( Float timeStepLength )
|
||||
{
|
||||
return resting;
|
||||
}
|
||||
|
||||
void NullBody::SetMomentOfInertiaTensor_KeepVelocity( const Float4x4 &localI ) {}
|
||||
|
||||
void NullBody::SetMomentOfInertiaTensor_KeepMomentum( const Float4x4 &localI ) {}
|
||||
|
||||
void NullBody::SetMass_KeepVelocity( Float m ) {}
|
||||
|
||||
void NullBody::SetMass_KeepMomentum( Float m ) {}
|
||||
|
||||
void NullBody::SetCenter( const Float3 &worldPos ) {}
|
||||
|
||||
void NullBody::SetRotation( const Float4x4 &rotation ) {}
|
||||
|
||||
void NullBody::SetOrientation( const Float4x4 &orientation ) {}
|
|
@ -1,7 +1,10 @@
|
|||
#include "PhysicsAPI_Impl.h"
|
||||
#include "SimpleRigidBody.h"
|
||||
|
||||
using namespace Oyster;
|
||||
using namespace Physics;
|
||||
using namespace ::Oyster::Physics;
|
||||
using namespace ::Oyster::Math;
|
||||
using namespace ::Oyster::Collision3D;
|
||||
using namespace ::Utility::DynamicMemory;
|
||||
|
||||
API_Impl instance;
|
||||
|
||||
|
@ -42,6 +45,12 @@ void API_Impl::Update()
|
|||
/** @todo TODO: Fix this function.*/
|
||||
}
|
||||
|
||||
bool API_Impl::IsInLimbo( unsigned int objRef )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return true;
|
||||
}
|
||||
|
||||
void API_Impl::MoveToLimbo( unsigned int objRef )
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
|
@ -51,13 +60,70 @@ void API_Impl::ReleaseFromLimbo( unsigned int objRef )
|
|||
/** @todo TODO: Fix this function.*/
|
||||
}
|
||||
|
||||
unsigned int API_Impl::AddObject( ::Utility::DynamicMemory::UniquePointer<IRigidBody> handle )
|
||||
unsigned int API_Impl::AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle )
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( unsigned int objRef )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void API_Impl::DestroyObject( unsigned int objRef )
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
}
|
||||
|
||||
void API_Impl::ApplyForceAt( unsigned int objRef, const Float3 &worldPos, const Float3 &worldF )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void API_Impl::ApplyCollisionResponse( unsigned int objRefA, unsigned int objRefB, Float &deltaWhen, Float3 &worldPointOfContact )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void API_Impl::SetMomentOfInertiaTensor_KeepVelocity( unsigned int objRef, const Float4x4 &localI )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void API_Impl::SetMomentOfInertiaTensor_KeepMomentum( unsigned int objRef, const Float4x4 &localI )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void API_Impl::SetMass_KeepVelocity( unsigned int objRef, Float m )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void API_Impl::SetMass_KeepMomentum( unsigned int objRef, Float m )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void API_Impl::SetCenter( unsigned int objRef, const Float3 &worldPos )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void API_Impl::SetRotation( unsigned int objRef, const Float4x4 &rotation )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void API_Impl::SetOrientation( unsigned int objRef, const Float4x4 &orientation )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
UniquePointer<ICustomBody> API_Impl::CreateSimpleRigidBody() const
|
||||
{
|
||||
return new SimpleRigidBody();
|
||||
}
|
|
@ -20,11 +20,28 @@ namespace Oyster
|
|||
|
||||
void Update();
|
||||
|
||||
bool IsInLimbo( unsigned int objRef );
|
||||
void MoveToLimbo( unsigned int objRef );
|
||||
void ReleaseFromLimbo( unsigned int objRef );
|
||||
|
||||
unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer<IRigidBody> handle );
|
||||
unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle );
|
||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( unsigned int objRef );
|
||||
void DestroyObject( unsigned int objRef );
|
||||
|
||||
const ICustomBody & Peek( unsigned int objRef ) const;
|
||||
|
||||
void ApplyForceAt( unsigned int objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF );
|
||||
void ApplyCollisionResponse( unsigned int objRefA, unsigned int objRefB, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact );
|
||||
|
||||
void SetMomentOfInertiaTensor_KeepVelocity( unsigned int objRef, const ::Oyster::Math::Float4x4 &localI );
|
||||
void SetMomentOfInertiaTensor_KeepMomentum( unsigned int objRef, const ::Oyster::Math::Float4x4 &localI );
|
||||
void SetMass_KeepVelocity( unsigned int objRef, ::Oyster::Math::Float m );
|
||||
void SetMass_KeepMomentum( unsigned int objRef, ::Oyster::Math::Float m );
|
||||
void SetCenter( unsigned int objRef, const ::Oyster::Math::Float3 &worldPos );
|
||||
void SetRotation( unsigned int objRef, const ::Oyster::Math::Float4x4 &rotation );
|
||||
void SetOrientation( unsigned int objRef, const ::Oyster::Math::Float4x4 &orientation );
|
||||
|
||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> CreateSimpleRigidBody() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
#include "SimpleRigidBody.h"
|
||||
|
||||
using namespace ::Oyster::Physics;
|
||||
using namespace ::Oyster::Math;
|
||||
using namespace ::Oyster::Collision3D;
|
||||
using namespace ::Utility::DynamicMemory;
|
||||
|
||||
SimpleRigidBody::SimpleRigidBody()
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
SimpleRigidBody::~SimpleRigidBody()
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
UniquePointer<ICustomBody> SimpleRigidBody::Clone() const
|
||||
{
|
||||
return new SimpleRigidBody( *this );
|
||||
}
|
||||
|
||||
bool SimpleRigidBody::IsSubscribingCollisions() const
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SimpleRigidBody::Intersects( const ICustomBody &object, Float &deltaWhen, Float3 &worldPointOfContact ) const
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SimpleRigidBody::Intersects( const ICollideable &shape ) const
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int SimpleRigidBody::GetReference() const
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return Error::not_a_reference;
|
||||
}
|
||||
|
||||
Sphere & SimpleRigidBody::GetBoundingSphere( Sphere &targetMem ) const
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return targetMem = Sphere( Float3::null, 0.0f );
|
||||
}
|
||||
|
||||
Float3 & SimpleRigidBody::GetNormalAt( const Float3 &worldPos, Float3 &targetMem ) const
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return targetMem = Float3::standard_unit_z;
|
||||
}
|
||||
|
||||
Float3 & SimpleRigidBody::GetCenter( Float3 &targetMem ) const
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return targetMem = Float3::null;
|
||||
}
|
||||
|
||||
Float4x4 & SimpleRigidBody::GetRotation( Float4x4 &targetMem ) const
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return targetMem = Float4x4::identity;
|
||||
}
|
||||
|
||||
Float4x4 & SimpleRigidBody::GetOrientation( Float4x4 &targetMem ) const
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return targetMem = Float4x4::identity;
|
||||
}
|
||||
|
||||
Float4x4 & SimpleRigidBody::GetView( Float4x4 &targetMem ) const
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return targetMem = Float4x4::identity;
|
||||
}
|
||||
|
||||
UpdateState SimpleRigidBody::Update( Float timeStepLength )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return resting;
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetMomentOfInertiaTensor_KeepVelocity( const Float4x4 &localI )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetMomentOfInertiaTensor_KeepMomentum( const Float4x4 &localI )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetMass_KeepVelocity( Float m )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetMass_KeepMomentum( Float m )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetCenter( const Float3 &worldPos )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetRotation( const Float4x4 &rotation )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetOrientation( const Float4x4 &orientation )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef OYSTER_PHYSICS_SIMPLE_RIGIDBODY_H
|
||||
#define OYSTER_PHYSICS_SIMPLE_RIGIDBODY_H
|
||||
|
||||
#include "..\PhysicsAPI.h"
|
||||
|
||||
namespace Oyster { namespace Physics
|
||||
{
|
||||
class SimpleRigidBody : public ICustomBody
|
||||
{
|
||||
public:
|
||||
SimpleRigidBody();
|
||||
virtual ~SimpleRigidBody();
|
||||
|
||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
|
||||
|
||||
bool IsSubscribingCollisions() const;
|
||||
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
|
||||
bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const;
|
||||
|
||||
unsigned int GetReference() const;
|
||||
::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const;
|
||||
::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
|
||||
::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;
|
||||
|
||||
UpdateState Update( ::Oyster::Math::Float timeStepLength );
|
||||
|
||||
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 );
|
||||
|
||||
private:
|
||||
};
|
||||
} }
|
||||
|
||||
#endif
|
|
@ -1,36 +0,0 @@
|
|||
#ifndef PHYSICS_API_H
|
||||
#define PHYSICS_API_H
|
||||
|
||||
#include "OysterMath.h"
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Physics
|
||||
{
|
||||
class API;
|
||||
class IRigidBody;
|
||||
class IParticle;
|
||||
|
||||
class API
|
||||
{
|
||||
public:
|
||||
static API & Instance();
|
||||
};
|
||||
|
||||
class IRigidBody
|
||||
{
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
class IParticle
|
||||
{
|
||||
public:
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
namespace Collision
|
||||
{}
|
||||
}
|
||||
#endif
|
|
@ -10,8 +10,7 @@ namespace Oyster
|
|||
namespace Physics
|
||||
{
|
||||
class API;
|
||||
class IRigidBody;
|
||||
class IParticle;
|
||||
class ICustomBody;
|
||||
|
||||
enum UpdateState
|
||||
{
|
||||
|
@ -28,7 +27,7 @@ namespace Oyster
|
|||
{
|
||||
public:
|
||||
typedef void (*EventAction_Collision)( unsigned int, unsigned int );
|
||||
typedef void (*EventAction_Destruction)( unsigned int, ::Utility::DynamicMemory::UniquePointer<IRigidBody> );
|
||||
typedef void (*EventAction_Destruction)( unsigned int, ::Utility::DynamicMemory::UniquePointer<ICustomBody> );
|
||||
|
||||
static API & Instance();
|
||||
|
||||
|
@ -43,34 +42,94 @@ namespace Oyster
|
|||
virtual void MoveToLimbo( unsigned int objRef ) = 0;
|
||||
virtual void ReleaseFromLimbo( unsigned int objRef ) = 0;
|
||||
|
||||
virtual unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer<IRigidBody> handle ) = 0;
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<IRigidBody> ExtractObject( unsigned int objRef ) = 0;
|
||||
virtual unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle ) = 0;
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( unsigned int objRef ) = 0;
|
||||
virtual void DestroyObject( unsigned int objRef ) = 0;
|
||||
|
||||
virtual const ICustomBody & Peek( unsigned int objRef ) const = 0;
|
||||
|
||||
virtual void ApplyForceAt( unsigned int objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF ) = 0;
|
||||
virtual void ApplyCollisionResponse( unsigned int objRefA, unsigned int objRefB, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) = 0;
|
||||
|
||||
virtual void SetMomentOfInertiaTensor_KeepVelocity( unsigned int objRef, const ::Oyster::Math::Float4x4 &localI ) = 0;
|
||||
virtual void SetMomentOfInertiaTensor_KeepMomentum( unsigned int objRef, const ::Oyster::Math::Float4x4 &localI ) = 0;
|
||||
virtual void SetMass_KeepVelocity( unsigned int objRef, ::Oyster::Math::Float m ) = 0;
|
||||
virtual void SetMass_KeepMomentum( unsigned int objRef, ::Oyster::Math::Float m ) = 0;
|
||||
virtual void SetCenter( unsigned int objRef, const ::Oyster::Math::Float3 &worldPos ) = 0;
|
||||
virtual void SetRotation( unsigned int objRef, const ::Oyster::Math::Float4x4 &rotation ) = 0;
|
||||
virtual void SetOrientation( unsigned int objRef, const ::Oyster::Math::Float4x4 &orientation ) = 0;
|
||||
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> CreateSimpleRigidBody() const = 0;
|
||||
|
||||
protected:
|
||||
virtual ~API() {}
|
||||
};
|
||||
|
||||
class IRigidBody
|
||||
class ICustomBody
|
||||
{
|
||||
public:
|
||||
virtual ~IRigidBody() {};
|
||||
virtual ~ICustomBody() {};
|
||||
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const = 0;
|
||||
|
||||
virtual bool IsSubscribingCollisions() const = 0;
|
||||
virtual bool Intersects( const ICustomBody &object, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const = 0;
|
||||
virtual bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const = 0;
|
||||
|
||||
virtual unsigned int GetReference() const = 0;
|
||||
virtual ::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const = 0;
|
||||
virtual ::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
|
||||
virtual ::Oyster::Math::Float3 & GetCenter( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
|
||||
virtual ::Oyster::Math::Float4x4 & GetRotation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0;
|
||||
virtual ::Oyster::Math::Float4x4 & GetOrientation( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0;
|
||||
virtual ::Oyster::Math::Float4x4 & GetView( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const = 0;
|
||||
|
||||
virtual UpdateState Update( ::Oyster::Math::Float timeStepLength ) = 0;
|
||||
|
||||
virtual bool IsSubscribingCollisions() const = 0;
|
||||
virtual bool IsIntersecting( const IRigidBody &object, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) = 0;
|
||||
|
||||
virtual unsigned int GetReference() const = 0;
|
||||
virtual ::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const = 0;
|
||||
virtual ::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
|
||||
virtual void SetMomentOfInertiaTensor_KeepVelocity( const ::Oyster::Math::Float4x4 &localI ) = 0;
|
||||
virtual void SetMomentOfInertiaTensor_KeepMomentum( const ::Oyster::Math::Float4x4 &localI ) = 0;
|
||||
virtual void SetMass_KeepVelocity( ::Oyster::Math::Float m ) = 0;
|
||||
virtual void SetMass_KeepMomentum( ::Oyster::Math::Float m ) = 0;
|
||||
virtual void SetCenter( const ::Oyster::Math::Float3 &worldPos ) = 0;
|
||||
virtual void SetRotation( const ::Oyster::Math::Float4x4 &rotation ) = 0;
|
||||
virtual void SetOrientation( const ::Oyster::Math::Float4x4 &orientation ) = 0;
|
||||
};
|
||||
|
||||
class IParticle
|
||||
namespace Error
|
||||
{
|
||||
public:
|
||||
const unsigned int not_a_reference = ::Utility::Value::numeric_limits<unsigned int>::max();
|
||||
|
||||
};
|
||||
class NullBody : public ICustomBody
|
||||
{
|
||||
public:
|
||||
virtual ~NullBody();
|
||||
|
||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
|
||||
|
||||
bool IsSubscribingCollisions() const;
|
||||
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
|
||||
bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const;
|
||||
|
||||
unsigned int GetReference() const;
|
||||
::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const;
|
||||
::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
|
||||
::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;
|
||||
|
||||
UpdateState Update( ::Oyster::Math::Float timeStepLength );
|
||||
|
||||
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 );
|
||||
|
||||
} const nobody;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Collision
|
||||
{}
|
||||
}
|
||||
#endif
|
|
@ -225,7 +225,7 @@ Float3 RigidBody::GetLinearVelocity() const
|
|||
}
|
||||
|
||||
void RigidBody::GetMomentumAt( const Float3 &worldPos, const Float3 &surfaceNormal, Float3 &normalMomentum, Float3 &tangentialMomentum ) const
|
||||
{
|
||||
{ // by Dan Andersson
|
||||
Float3 worldOffset = worldPos - this->box.center;
|
||||
Float3 momentum = Formula::TangentialLinearMomentum( this->angularMomentum, worldOffset );
|
||||
momentum += this->linearMomentum;
|
||||
|
@ -234,7 +234,18 @@ void RigidBody::GetMomentumAt( const Float3 &worldPos, const Float3 &surfaceNorm
|
|||
tangentialMomentum = momentum - normalMomentum;
|
||||
}
|
||||
|
||||
void RigidBody::SetMomentOfInertia( const Float4x4 &localI )
|
||||
void RigidBody::SetMomentOfInertia_KeepVelocity( const ::Oyster::Math::Float4x4 &localI )
|
||||
{ // by Dan Andersson
|
||||
if( localI.GetDeterminant() != 0.0f ) // insanitycheck! momentOfInertiaTensor must be invertable
|
||||
{
|
||||
Float3 w = Formula::AngularVelocity( (this->box.rotation * this->momentOfInertiaTensor).GetInverse(),
|
||||
this->angularMomentum );
|
||||
this->momentOfInertiaTensor = localI;
|
||||
this->angularMomentum = Formula::AngularMomentum( this->box.rotation*localI, w );
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBody::SetMomentOfInertia_KeepMomentum( const Float4x4 &localI )
|
||||
{ // by Dan Andersson
|
||||
if( localI.GetDeterminant() != 0.0f ) // insanitycheck! momentOfInertiaTensor must be invertable
|
||||
{
|
||||
|
@ -246,9 +257,9 @@ void RigidBody::SetMass_KeepVelocity( const Float &m )
|
|||
{ // by Dan Andersson
|
||||
if( m != 0.0f ) // insanitycheck! mass must be invertable
|
||||
{
|
||||
Float3 velocity = Formula::LinearVelocity( this->mass, this->linearMomentum );
|
||||
Float3 v = Formula::LinearVelocity( this->mass, this->linearMomentum );
|
||||
this->mass = m;
|
||||
this->linearMomentum = Formula::LinearMomentum( this->mass, velocity );
|
||||
this->linearMomentum = Formula::LinearMomentum( this->mass, v );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,8 @@ namespace Oyster { namespace Physics3D
|
|||
|
||||
// SET METHODS ////////////////////////////////
|
||||
|
||||
void SetMomentOfInertia( const ::Oyster::Math::Float4x4 &localI );
|
||||
void SetMomentOfInertia_KeepVelocity( const ::Oyster::Math::Float4x4 &localI );
|
||||
void SetMomentOfInertia_KeepMomentum( const ::Oyster::Math::Float4x4 &localI );
|
||||
void SetMass_KeepVelocity( const ::Oyster::Math::Float &m );
|
||||
void SetMass_KeepMomentum( const ::Oyster::Math::Float &m );
|
||||
|
||||
|
|
Loading…
Reference in New Issue