Changed API.

Replaced unsigned int references with ICustomBody pointers and replaced
documentation as needed.
This commit is contained in:
Robin Engman 2013-11-25 10:54:27 +01:00
parent 6ac4254b9d
commit c3e3f9e461
6 changed files with 60 additions and 92 deletions

View File

@ -28,11 +28,6 @@ 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 );

View File

@ -71,86 +71,78 @@ void API_Impl::Update()
/** @todo TODO: Fix this function.*/
}
bool API_Impl::IsInLimbo( unsigned int objRef )
bool API_Impl::IsInLimbo( const ICustomBody* objRef )
{
//! @todo TODO: implement stub
return true;
}
void API_Impl::MoveToLimbo( unsigned int objRef )
void API_Impl::MoveToLimbo( const ICustomBody* objRef )
{
/** @todo TODO: Fix this function.*/
}
void API_Impl::ReleaseFromLimbo( unsigned int objRef )
void API_Impl::ReleaseFromLimbo( const ICustomBody* objRef )
{
/** @todo TODO: Fix this function.*/
}
unsigned int API_Impl::AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle )
void API_Impl::AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle )
{
/** @todo TODO: Fix this function.*/
return 0;
}
::Utility::DynamicMemory::UniquePointer<ICustomBody> API_Impl::ExtractObject( unsigned int objRef )
::Utility::DynamicMemory::UniquePointer<ICustomBody> API_Impl::ExtractObject( const ICustomBody* objRef )
{
//! @todo TODO: implement stub
return NULL;
}
void API_Impl::DestroyObject( unsigned int objRef )
void API_Impl::DestroyObject( const ICustomBody* objRef )
{
/** @todo TODO: Fix this function.*/
}
const ICustomBody & API_Impl::Peek( unsigned int objRef ) const
{
//! @todo TODO: implement stub
return Error::nobody;
}
void API_Impl::ApplyForceAt( unsigned int objRef, const Float3 &worldPos, const Float3 &worldF )
void API_Impl::ApplyForceAt( const ICustomBody* 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 )
void API_Impl::ApplyCollisionResponse( const ICustomBody* objRefA, const ICustomBody* objRefB, Float &deltaWhen, Float3 &worldPointOfContact )
{
//! @todo TODO: implement stub
}
void API_Impl::SetMomentOfInertiaTensor_KeepVelocity( unsigned int objRef, const Float4x4 &localI )
void API_Impl::SetMomentOfInertiaTensor_KeepVelocity( const ICustomBody* objRef, const Float4x4 &localI )
{
//! @todo TODO: implement stub
}
void API_Impl::SetMomentOfInertiaTensor_KeepMomentum( unsigned int objRef, const Float4x4 &localI )
void API_Impl::SetMomentOfInertiaTensor_KeepMomentum( const ICustomBody* objRef, const Float4x4 &localI )
{
//! @todo TODO: implement stub
}
void API_Impl::SetMass_KeepVelocity( unsigned int objRef, Float m )
void API_Impl::SetMass_KeepVelocity( const ICustomBody* objRef, Float m )
{
//! @todo TODO: implement stub
}
void API_Impl::SetMass_KeepMomentum( unsigned int objRef, Float m )
void API_Impl::SetMass_KeepMomentum( const ICustomBody* objRef, Float m )
{
//! @todo TODO: implement stub
}
void API_Impl::SetCenter( unsigned int objRef, const Float3 &worldPos )
void API_Impl::SetCenter( const ICustomBody* objRef, const Float3 &worldPos )
{
//! @todo TODO: implement stub
}
void API_Impl::SetRotation( unsigned int objRef, const Float4x4 &rotation )
void API_Impl::SetRotation( const ICustomBody* objRef, const Float4x4 &rotation )
{
//! @todo TODO: implement stub
}
void API_Impl::SetOrientation( unsigned int objRef, const Float4x4 &orientation )
void API_Impl::SetOrientation( const ICustomBody* objRef, const Float4x4 &orientation )
{
//! @todo TODO: implement stub
}

View File

@ -20,26 +20,24 @@ namespace Oyster
void Update();
bool IsInLimbo( unsigned int objRef );
void MoveToLimbo( unsigned int objRef );
void ReleaseFromLimbo( unsigned int objRef );
bool IsInLimbo( const ICustomBody* objRef );
void MoveToLimbo( const ICustomBody* objRef );
void ReleaseFromLimbo( const ICustomBody* objRef );
unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle );
::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( unsigned int objRef );
void DestroyObject( unsigned int objRef );
void AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle );
::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( const ICustomBody* objRef );
void DestroyObject( const ICustomBody* objRef );
const ICustomBody & Peek( unsigned int objRef ) const;
void ApplyForceAt( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF );
void ApplyCollisionResponse( const ICustomBody* objRefA, const ICustomBody* objRefB, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact );
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 );
void SetMomentOfInertiaTensor_KeepVelocity( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &localI );
void SetMomentOfInertiaTensor_KeepMomentum( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &localI );
void SetMass_KeepVelocity( const ICustomBody* objRef, ::Oyster::Math::Float m );
void SetMass_KeepMomentum( const ICustomBody* objRef, ::Oyster::Math::Float m );
void SetCenter( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos );
void SetRotation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &rotation );
void SetOrientation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &orientation );
::Utility::DynamicMemory::UniquePointer<ICustomBody> CreateSimpleRigidBody() const;
};

View File

@ -38,12 +38,6 @@ bool SimpleRigidBody::Intersects( const ICollideable &shape ) const
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

View File

@ -17,7 +17,6 @@ namespace Oyster { namespace Physics
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;

View File

@ -80,123 +80,115 @@ namespace Oyster
/********************************************************
* An object in limbo state will be ignored during the physics frame Update.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
* @return true if object is in limbo state.
********************************************************/
virtual bool IsInLimbo( unsigned int objRef ) = 0;
virtual bool IsInLimbo( const ICustomBody* objRef ) = 0;
/********************************************************
* An object in limbo state will be ignored during the physics frame Update.
* This will put an object in Limbo state.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
********************************************************/
virtual void MoveToLimbo( unsigned int objRef ) = 0;
virtual void MoveToLimbo( const ICustomBody* objRef ) = 0;
/********************************************************
* An object in limbo state will be ignored during the physics frame Update.
* This will clear the accumulated force/torque and remove the Limbo state.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
********************************************************/
virtual void ReleaseFromLimbo( unsigned int objRef ) = 0;
virtual void ReleaseFromLimbo( const ICustomBody* objRef ) = 0;
/********************************************************
* Introduces a new object into the engine.
* @param handle: A pointer along with the responsibility to delete.
* @return an objectReference needed in most methods. Error::not_a_reference if faulty handle.
********************************************************/
virtual unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle ) = 0;
virtual void AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle ) = 0;
/********************************************************
* Fetches and removes an object from the engine.
* Will not call the provided EventAction_Destruction method.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
* @return A pointer along with the responsibility to delete. NULL if faulty objRef.
********************************************************/
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( unsigned int objRef ) = 0;
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( const ICustomBody* objRef ) = 0;
/********************************************************
* Removes an object from the engine.
* Will call the provided EventAction_Destruction method. Not if objRef is faulty.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
********************************************************/
virtual void DestroyObject( unsigned int objRef ) = 0;
/********************************************************
* Peeks at object at objRef.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @return the instance ofthe found object. Error::nobody if faulty objRef
********************************************************/
virtual const ICustomBody & Peek( unsigned int objRef ) const = 0;
virtual void DestroyObject( const ICustomBody* objRef ) = 0;
/********************************************************
* Apply force on an object.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
* @param worldPos: Relative to the world origo. (Not relative to object) [m]
* @param worldF: Vector with the direction and magnitude of the force. [N]
********************************************************/
virtual void ApplyForceAt( unsigned int objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF ) = 0;
virtual void ApplyForceAt( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF ) = 0;
/********************************************************
* Apply force on an object.
* @param objRefA: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRefB: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRefA: A pointer to the ICustomBody representing a physical object.
* @param objRefB: A pointer to the ICustomBody representing a physical object.
* @param deltaWhen: The elapsed simulation time since last update frame. [s]
* @param worldPointOfContact: Point of Collision, relative to the world origo. (Not relative to the objects) [m]
********************************************************/
virtual void ApplyCollisionResponse( unsigned int objRefA, unsigned int objRefB, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) = 0;
virtual void ApplyCollisionResponse( const ICustomBody* objRefA, const ICustomBody* objRefB, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) = 0;
/********************************************************
* Sets the MomentOfInertia tensor matrix of an object without changing it's angular velocity.
* Noticeable effect: The angular momentum will change. Changing the amount of kinetic energy.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
* @param localI: The tensor matrix relative to the axises of the object. @see MomentOfInertia namespace.
********************************************************/
virtual void SetMomentOfInertiaTensor_KeepVelocity( unsigned int objRef, const ::Oyster::Math::Float4x4 &localI ) = 0;
virtual void SetMomentOfInertiaTensor_KeepVelocity( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &localI ) = 0;
/********************************************************
* Sets the MomentOfInertia tensor matrix of an object without changing it's angular momentum.
* Noticeable effect: The angular velocity will change. Can be used to create slow effects.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
* @param localI: The tensor matrix relative to the axises of the object. @see MomentOfInertia namespace.
********************************************************/
virtual void SetMomentOfInertiaTensor_KeepMomentum( unsigned int objRef, const ::Oyster::Math::Float4x4 &localI ) = 0;
virtual void SetMomentOfInertiaTensor_KeepMomentum( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &localI ) = 0;
/********************************************************
* Sets the mass of an object without changing it's linear velocity.
* Noticeable effect: The linear momentum will change. Changing the amount of kinetic energy.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
* @param m: [kg]
********************************************************/
virtual void SetMass_KeepVelocity( unsigned int objRef, ::Oyster::Math::Float m ) = 0;
virtual void SetMass_KeepVelocity( const ICustomBody* objRef, ::Oyster::Math::Float m ) = 0;
/********************************************************
* Sets the mass of an object without changing it's linear velocity.
* Noticeable effect: The linear velocity will change. Can be used to create slow effects.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
* @param m: [kg]
********************************************************/
virtual void SetMass_KeepMomentum( unsigned int objRef, ::Oyster::Math::Float m ) = 0;
virtual void SetMass_KeepMomentum( const ICustomBody* objRef, ::Oyster::Math::Float m ) = 0;
/********************************************************
* Instantly moves an object.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
* @param worldPos: Relative to the world origo. (Not relative to object) [m]
********************************************************/
virtual void SetCenter( unsigned int objRef, const ::Oyster::Math::Float3 &worldPos ) = 0;
virtual void SetCenter( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos ) = 0;
/********************************************************
* Instantly redirects object.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
* @param rotation: New rotation.
********************************************************/
virtual void SetRotation( unsigned int objRef, const ::Oyster::Math::Float4x4 &rotation ) = 0;
virtual void SetRotation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &rotation ) = 0;
/********************************************************
* Instantly moves and redirects object.
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
* @param objRef: A pointer to the ICustomBody representing a physical object.
* @param orientation: New orientation.
********************************************************/
virtual void SetOrientation( unsigned int objRef, const ::Oyster::Math::Float4x4 &orientation ) = 0;
virtual void SetOrientation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &orientation ) = 0;
/********************************************************
* Creates a new dynamically allocated object that can be used as a component for more complex ICustomBodies.
@ -219,7 +211,6 @@ namespace Oyster
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;
@ -240,7 +231,6 @@ namespace Oyster
namespace Error
{ //! The content in here is used as API return errorvalues.
const unsigned int not_a_reference = ::Utility::Value::numeric_limits<unsigned int>::max();
class NullBody : public ICustomBody
{