Documentations
PhysicsAPI mostly documented. Namespace MomentOFInertia and ICustomBody still not documented
This commit is contained in:
parent
3ef5a46779
commit
6ac4254b9d
Binary file not shown.
Binary file not shown.
|
@ -24,7 +24,7 @@
|
|||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
|
@ -66,22 +66,22 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)..\External\Bin\DLL\</OutDir>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)..\External\Bin\DLL\</OutDir>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(SolutionDir)..\External\Bin\DLL\</OutDir>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(SolutionDir)..\External\Bin\DLL\</OutDir>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -93,7 +93,7 @@ unsigned int API_Impl::AddObject( ::Utility::DynamicMemory::UniquePointer<ICusto
|
|||
return 0;
|
||||
}
|
||||
|
||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( unsigned int objRef )
|
||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> API_Impl::ExtractObject( unsigned int objRef )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
return NULL;
|
||||
|
@ -104,6 +104,12 @@ void API_Impl::DestroyObject( unsigned int 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 )
|
||||
{
|
||||
//! @todo TODO: implement stub
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "OysterCollision3D.h"
|
||||
#include "OysterMath.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
|
@ -20,10 +19,9 @@ namespace Oyster
|
|||
|
||||
namespace Constant
|
||||
{
|
||||
const float gravity_constant = (const float)6.67284e-11; // The _big_G_! ( N(m/kg)^2 ) Used in real gravityforcefields.
|
||||
const float gravity_constant = (const float)6.67284e-11; //!< The _big_G_! ( N(m/kg)^2 ) Used in real gravityforcefields.
|
||||
}
|
||||
|
||||
|
||||
class MomentOfInertia
|
||||
{
|
||||
public:
|
||||
|
@ -38,43 +36,172 @@ namespace Oyster
|
|||
static ::Oyster::Math::Float4x4 & CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length );
|
||||
};
|
||||
|
||||
|
||||
class API
|
||||
{
|
||||
public:
|
||||
typedef void (*EventAction_Collision)( unsigned int, unsigned int );
|
||||
typedef void (*EventAction_Destruction)( unsigned int, ::Utility::DynamicMemory::UniquePointer<ICustomBody> );
|
||||
|
||||
/** Gets the Physics instance. */
|
||||
static API & Instance();
|
||||
|
||||
virtual void SetDeltaTime( float deltaTime ) = 0;
|
||||
/********************************************************
|
||||
* Sets the time length of each physics update frame.
|
||||
********************************************************/
|
||||
virtual void SetDeltaTime( float seconds ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* Sets the Gravityconstant in the physics that will be
|
||||
* used in ForceField calculations.
|
||||
* @param g: Default is the real world Constant::gravity_constant [N(m/kg)^2]
|
||||
********************************************************/
|
||||
virtual void SetGravityConstant( float g ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* Sets the function that will be called by the engine
|
||||
* whenever a subscribed collision occurs.
|
||||
********************************************************/
|
||||
virtual void SetAction( EventAction_Collision functionPointer ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* Sets the function that will be called by the engine
|
||||
* whenever an object is being destroyed for some reason.
|
||||
* - Because DestroyObject(...) were called.
|
||||
* - Out of memory forced engine to destroy an object.
|
||||
********************************************************/
|
||||
virtual void SetAction( EventAction_Destruction functionPointer ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* Triggers the engine to run next update frame.
|
||||
* All accumulated forces and changes will be consumed.
|
||||
* EventAction functions might be called.
|
||||
********************************************************/
|
||||
virtual void Update() = 0;
|
||||
|
||||
/********************************************************
|
||||
* An object in limbo state will be ignored during the physics frame Update.
|
||||
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
|
||||
* @return true if object is in limbo state.
|
||||
********************************************************/
|
||||
virtual bool IsInLimbo( unsigned int 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()
|
||||
********************************************************/
|
||||
virtual void MoveToLimbo( unsigned int 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()
|
||||
********************************************************/
|
||||
virtual void ReleaseFromLimbo( unsigned int 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;
|
||||
|
||||
/********************************************************
|
||||
* Fetches and removes an object from the engine.
|
||||
* Will not call the provided EventAction_Destruction method.
|
||||
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
|
||||
* @return A pointer along with the responsibility to delete. NULL if faulty objRef.
|
||||
********************************************************/
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( unsigned int 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()
|
||||
********************************************************/
|
||||
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;
|
||||
|
||||
/********************************************************
|
||||
* Apply force on an object.
|
||||
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
|
||||
* @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;
|
||||
|
||||
/********************************************************
|
||||
* Apply force on an object.
|
||||
* @param objRefA: Provided by API::AddObject(...) & ICustomBody::GetReference()
|
||||
* @param objRefB: Provided by API::AddObject(...) & ICustomBody::GetReference()
|
||||
* @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;
|
||||
|
||||
/********************************************************
|
||||
* 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 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;
|
||||
|
||||
/********************************************************
|
||||
* 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 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;
|
||||
|
||||
/********************************************************
|
||||
* 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 m: [kg]
|
||||
********************************************************/
|
||||
virtual void SetMass_KeepVelocity( unsigned int 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 m: [kg]
|
||||
********************************************************/
|
||||
virtual void SetMass_KeepMomentum( unsigned int objRef, ::Oyster::Math::Float m ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* Instantly moves an object.
|
||||
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
|
||||
* @param worldPos: Relative to the world origo. (Not relative to object) [m]
|
||||
********************************************************/
|
||||
virtual void SetCenter( unsigned int objRef, const ::Oyster::Math::Float3 &worldPos ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* Instantly redirects object.
|
||||
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
|
||||
* @param rotation: New rotation.
|
||||
********************************************************/
|
||||
virtual void SetRotation( unsigned int objRef, const ::Oyster::Math::Float4x4 &rotation ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* Instantly moves and redirects object.
|
||||
* @param objRef: Provided by API::AddObject(...) & ICustomBody::GetReference()
|
||||
* @param orientation: New orientation.
|
||||
********************************************************/
|
||||
virtual void SetOrientation( unsigned int objRef, const ::Oyster::Math::Float4x4 &orientation ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* Creates a new dynamically allocated object that can be used as a component for more complex ICustomBodies.
|
||||
* @return A pointer along with the responsibility to delete.
|
||||
********************************************************/
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> CreateSimpleRigidBody() const = 0;
|
||||
|
||||
protected:
|
||||
|
@ -112,7 +239,7 @@ 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!
|
||||
// Utility Collection of Miscellanious Handy Functions
|
||||
// © Dan Andersson 2013
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!
|
||||
|
||||
#ifndef UTILITIES_H
|
||||
#define UTILITIES_H
|
||||
|
@ -16,50 +16,50 @@ namespace Utility
|
|||
{
|
||||
namespace DynamicMemory
|
||||
{
|
||||
/// If dynamicInstance is not NULL, then delete
|
||||
//! If dynamicInstance is not NULL, then delete
|
||||
template<typename Type> void SafeDeleteInstance( Type *dynamicInstance );
|
||||
|
||||
/// If dynamicArray is not NULL, then delete []
|
||||
//! If dynamicArray is not NULL, then delete []
|
||||
template<typename Type> void SafeDeleteArray( Type dynamicArray[] );
|
||||
|
||||
template<typename Type>
|
||||
struct UniquePointer
|
||||
{ /// Wrapper to safely transfer dynamic ownership/responsibility
|
||||
//! Wrapper to safely transfer dynamic ownership/responsibility
|
||||
template<typename Type> struct UniquePointer
|
||||
{
|
||||
public:
|
||||
/// Assigns assignedInstance ownership to this UniquePonter, old owned instance will be deleted.
|
||||
/// If NULL is assigned is equavalent with clearing all responsibilities from this UniquePointer.
|
||||
//! Assigns assignedInstance ownership to this UniquePonter, old owned instance will be deleted.
|
||||
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniquePointer.
|
||||
UniquePointer( Type *assignedInstance = NULL );
|
||||
|
||||
/// Will auto delete assigned dynamic instance.
|
||||
//! Will auto delete assigned dynamic instance.
|
||||
~UniquePointer();
|
||||
|
||||
/// Assigns assignedInstance ownership to this UniquePonter, old owned instance will be deleted.
|
||||
/// If NULL is assigned is equavalent with clearing all responsibilities from this UniquePointer.
|
||||
//! Assigns assignedInstance ownership to this UniquePonter, old owned instance will be deleted.
|
||||
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniquePointer.
|
||||
UniquePointer<Type> & operator = ( Type *assignedInstance );
|
||||
|
||||
/// Transfers assignedInstance ownership from donor to this UniquePonter, old owned instance will be deleted.
|
||||
/// If donor had nothing, is equavalent with clearing all responsibilities from this UniquePointer.
|
||||
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned instance will be deleted.
|
||||
//! If donor had nothing, is equavalent with clearing all responsibilities from this UniquePointer.
|
||||
UniquePointer<Type> & operator = ( const UniquePointer<Type> &donor );
|
||||
|
||||
/// Access the assigned dynamic instance. Will crash if nothing there
|
||||
//! Access the assigned dynamic instance. Will crash if nothing there
|
||||
operator Type* ();
|
||||
|
||||
/// Access the assigned dynamic instance. Will crash if nothing there
|
||||
//! Access the assigned dynamic instance. Will crash if nothing there
|
||||
operator const Type* () const;
|
||||
|
||||
/// Access members of the assigned dynamic instance. Will crash if nothing there
|
||||
//! Access members of the assigned dynamic instance. Will crash if nothing there
|
||||
Type * operator -> ();
|
||||
|
||||
/// Access members of the assigned dynamic instance. Will crash if nothing there
|
||||
//! Access members of the assigned dynamic instance. Will crash if nothing there
|
||||
const Type * operator -> () const;
|
||||
|
||||
/// If true, this UniquePointer have a current ownership/responsibility of a dynamic instance.
|
||||
//! If true, this UniquePointer have a current ownership/responsibility of a dynamic instance.
|
||||
operator bool () const;
|
||||
|
||||
/// This UniquePointer drops all claims of ownership/responsibility and returns the dynamic instance. Now it is your responsibility to delete.
|
||||
//! This UniquePointer drops all claims of ownership/responsibility and returns the dynamic instance. Now it is your responsibility to delete.
|
||||
Type* Release();
|
||||
|
||||
/// (inline) If true, this UniquePointer have a current ownership/responsibility of a dynamic instance.
|
||||
//! (inline) If true, this UniquePointer have a current ownership/responsibility of a dynamic instance.
|
||||
bool HaveOwnership() const;
|
||||
|
||||
private:
|
||||
|
@ -68,38 +68,38 @@ namespace Utility
|
|||
|
||||
template<typename Type>
|
||||
struct UniqueArray
|
||||
{ /// Wrapper to safely transfer dynamic ownership/responsibility
|
||||
{ //! Wrapper to safely transfer dynamic ownership/responsibility
|
||||
public:
|
||||
/// Assigns assignedInstance ownership to this UniquePonter, old owned array will be deleted.
|
||||
/// If NULL is assigned is equavalent with clearing all responsibilities from this UniqueArray.
|
||||
//! Assigns assignedInstance ownership to this UniquePonter, old owned array will be deleted.
|
||||
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniqueArray.
|
||||
UniqueArray( Type assignedArray[] = NULL );
|
||||
|
||||
/// Will auto delete assigned dynamic array.
|
||||
//! Will auto delete assigned dynamic array.
|
||||
~UniqueArray();
|
||||
|
||||
/// Assigns assignedInstance ownership to this UniquePonter, old owned array will be deleted.
|
||||
/// If NULL is assigned is equavalent with clearing all responsibilities from this UniqueArray.
|
||||
//! Assigns assignedInstance ownership to this UniquePonter, old owned array will be deleted.
|
||||
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniqueArray.
|
||||
UniqueArray<Type> & operator = ( Type assignedArray[] );
|
||||
|
||||
/// Transfers assignedInstance ownership from donor to this UniquePonter, old owned array will be deleted.
|
||||
/// If donor had nothing, is equavalent with clearing all responsibilities from this UniqueArray.
|
||||
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned array will be deleted.
|
||||
//! If donor had nothing, is equavalent with clearing all responsibilities from this UniqueArray.
|
||||
UniqueArray<Type> & operator = ( const UniqueArray<Type> &donor );
|
||||
|
||||
/// Accesses the instance at index i of this UniqeArray's owned dynamic array.
|
||||
/// Will crash if out-of-bound or there is no assigned array.
|
||||
//! Accesses the instance at index i of this UniqeArray's owned dynamic array.
|
||||
//! Will crash if out-of-bound or there is no assigned array.
|
||||
template<typename Index> Type & operator [] ( Index i );
|
||||
|
||||
/// Accesses the instance at index i of this UniqeArray's owned dynamic array.
|
||||
/// Will crash if out-of-bound or there is no assigned array.
|
||||
//! Accesses the instance at index i of this UniqeArray's owned dynamic array.
|
||||
//! Will crash if out-of-bound or there is no assigned array.
|
||||
template<typename Index> const Type & operator [] ( Index i ) const;
|
||||
|
||||
/// If true, this UniqueArray have a current ownership/responsibility of a dynamic instance.
|
||||
//! If true, this UniqueArray have a current ownership/responsibility of a dynamic instance.
|
||||
operator bool () const;
|
||||
|
||||
/// This UniqueArray drops all claims of ownership/responsibility and returns the dynamic array. Now it is your responsibility to delete.
|
||||
//! This UniqueArray drops all claims of ownership/responsibility and returns the dynamic array. Now it is your responsibility to delete.
|
||||
Type* Release();
|
||||
|
||||
/// (inline) If true, this UniqueArray have a current ownership/responsibility of a dynamic array.
|
||||
//! (inline) If true, this UniqueArray have a current ownership/responsibility of a dynamic array.
|
||||
bool HaveOwnership() const;
|
||||
|
||||
private:
|
||||
|
@ -193,7 +193,7 @@ namespace Utility
|
|||
inline ValueType Degree( const ValueType &radian )
|
||||
{ return radian * (180.0f / 3.1415926535897932384626433832795f); }
|
||||
|
||||
// SPECIALIZATIONS //////////////////////////////////////////
|
||||
// SPECIALIZATIONS //!//!//!//!//!//!//!//!//!//!//!//!//!//!
|
||||
|
||||
template<> inline char Average<char>( const char &valueA, const char &valueB )
|
||||
{ return (valueA + valueB) >> 1; }
|
||||
|
|
Loading…
Reference in New Issue