Physics branch disaster Patch
critical changes in Sprint1 branch caused major problems for the physics patch. Files had to be backed up, Physics branch destroyed along with it's log data. So that a new Physics branch could be made from the new Sprint1. This patch is those copied files put back into the new physics branch. .. logdata and 3hours lost (1h/person)
This commit is contained in:
parent
c9e6bbf899
commit
b8d0a106b3
|
@ -145,7 +145,11 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Include\GamePhysics.h" />
|
||||
<ClInclude Include="Implementation\PhysicsAPI_Impl.h" />
|
||||
<ClInclude Include="PhysicsAPI.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -16,16 +16,21 @@
|
|||
<Filter Include="Header Files\Implementation">
|
||||
<UniqueIdentifier>{f2cb55b8-47a0-45c7-8dce-5b93f945a57b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Implementation">
|
||||
<UniqueIdentifier>{cac9a78f-f09b-4850-b1aa-ea87e8368678}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Include">
|
||||
<UniqueIdentifier>{792daa4b-b2f7-4664-9529-71a929365274}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Include\GamePhysics.h">
|
||||
<ClInclude Include="PhysicsAPI.h">
|
||||
<Filter>Header Files\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Implementation\PhysicsAPI_Impl.h">
|
||||
<Filter>Header Files\Implementation</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp">
|
||||
<Filter>Header Files\Implementation</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,63 @@
|
|||
#include "PhysicsAPI_Impl.h"
|
||||
|
||||
using namespace Oyster;
|
||||
using namespace Physics;
|
||||
|
||||
API_Impl instance;
|
||||
|
||||
API & Instance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
API_Impl::API_Impl()
|
||||
{
|
||||
/** @todo TODO: Fix this constructor.*/
|
||||
}
|
||||
|
||||
API_Impl::~API_Impl()
|
||||
{
|
||||
/** @todo TODO: Fix this destructor.*/
|
||||
}
|
||||
|
||||
void API_Impl::SetDeltaTime( float deltaTime )
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
}
|
||||
void API_Impl::SetGravityConstant( float g )
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
}
|
||||
void API_Impl::SetAction( EventAction_Collision functionPointer )
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
}
|
||||
void API_Impl::SetAction( EventAction_Destruction functionPointer )
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
}
|
||||
|
||||
void API_Impl::Update()
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
}
|
||||
|
||||
void API_Impl::MoveToLimbo( unsigned int objRef )
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
}
|
||||
void API_Impl::ReleaseFromLimbo( unsigned int objRef )
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
}
|
||||
|
||||
unsigned int API_Impl::AddObject( ::Utility::DynamicMemory::UniquePointer<IRigidBody> handle )
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
void API_Impl::DestroyObject( unsigned int objRef )
|
||||
{
|
||||
/** @todo TODO: Fix this function.*/
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef PHYSICS_API_IMPL_H
|
||||
#define PHYSICS_API_IMPL_H
|
||||
|
||||
#include "../PhysicsAPI.h"
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Physics
|
||||
{
|
||||
class API_Impl : public API
|
||||
{
|
||||
public:
|
||||
API_Impl();
|
||||
virtual ~API_Impl();
|
||||
|
||||
void SetDeltaTime( float deltaTime );
|
||||
void SetGravityConstant( float g );
|
||||
void SetAction( EventAction_Collision functionPointer );
|
||||
void SetAction( EventAction_Destruction functionPointer );
|
||||
|
||||
void Update();
|
||||
|
||||
void MoveToLimbo( unsigned int objRef );
|
||||
void ReleaseFromLimbo( unsigned int objRef );
|
||||
|
||||
unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer<IRigidBody> handle );
|
||||
void DestroyObject( unsigned int objRef );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,58 @@
|
|||
#ifndef PHYSICS_API_H
|
||||
#define PHYSICS_API_H
|
||||
|
||||
#include "OysterMath.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Physics
|
||||
{
|
||||
class API;
|
||||
class IRigidBody;
|
||||
class IParticle;
|
||||
|
||||
namespace Constant
|
||||
{
|
||||
const float gravity_constant = (const float)6.67284e-11; // The _big_G_! ( N(m/kg)^2 ) Used in real gravityforcefields.
|
||||
}
|
||||
|
||||
class API
|
||||
{
|
||||
public:
|
||||
typedef void (*EventAction_Collision)( unsigned int, unsigned int );
|
||||
typedef void (*EventAction_Destruction)( unsigned int, ::Utility::DynamicMemory::UniquePointer<IRigidBody> );
|
||||
|
||||
static API & Instance();
|
||||
|
||||
virtual void SetDeltaTime( float deltaTime ) = 0;
|
||||
virtual void SetGravityConstant( float g ) = 0;
|
||||
virtual void SetAction( EventAction_Collision functionPointer ) = 0;
|
||||
virtual void SetAction( EventAction_Destruction functionPointer ) = 0;
|
||||
|
||||
virtual void Update() = 0;
|
||||
|
||||
virtual void MoveToLimbo( unsigned int objRef );
|
||||
virtual void ReleaseFromLimbo( unsigned int objRef );
|
||||
|
||||
virtual unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer<IRigidBody> handle );
|
||||
virtual void DestroyObject( unsigned int objRef );
|
||||
};
|
||||
|
||||
class IRigidBody
|
||||
{
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
class IParticle
|
||||
{
|
||||
public:
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
namespace Collision
|
||||
{}
|
||||
}
|
||||
#endif
|
|
@ -218,10 +218,14 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized
|
|||
inline Float4x4 & ViewProjectionMatrix( const Float4x4 &view, const Float4x4 &projection, Float4x4 &targetMem = Float4x4() )
|
||||
{ return targetMem = projection * view; }
|
||||
|
||||
/// Helper inline function that sets and then returns targetMem = transformer * transformee
|
||||
inline Float4x4 & TransformMatrix( const Float4x4 &transformer, const Float4x4 &transformee, Float4x4 &targetMem = Float4x4() )
|
||||
/** Helper inline function that sets and then returns targetMem = transformer * transformee */
|
||||
inline Float4x4 & TransformMatrix( const Float4x4 &transformer, const Float4x4 &transformee, Float4x4 &targetMem )
|
||||
{ return targetMem = transformer * transformee; }
|
||||
|
||||
/** Helper inline function that sets and then returns transformer * transformee */
|
||||
inline Float4x4 TransformMatrix( const Float4x4 &transformer, const Float4x4 &transformee )
|
||||
{ return transformer * transformee; }
|
||||
|
||||
/// Helper inline function that sets and then returns targetMem = transformer * transformee
|
||||
inline Float4 & TransformVector( const Float4x4 &transformer, const Float4 &transformee, Float4 &targetMem = Float4() )
|
||||
{ return targetMem = transformer * transformee; }
|
||||
|
|
|
@ -39,6 +39,9 @@ RigidBody & RigidBody::operator = ( const RigidBody &body )
|
|||
void RigidBody::Update_LeapFrog( Float deltaTime )
|
||||
{ // by Dan Andersson: Euler leap frog update when Runga Kutta is not needed
|
||||
|
||||
// Important! The member data is all world data except the Inertia tensor. Thus a new InertiaTensor needs to be created to be compatible with the rest of the world data.
|
||||
Float4x4 wMomentOfInertiaTensor = TransformMatrix( this->box.orientation, this->momentOfInertiaTensor );
|
||||
|
||||
// updating the linear
|
||||
// dv = dt * a = dt * F / m
|
||||
// ds = dt * avg_v
|
||||
|
@ -49,7 +52,7 @@ void RigidBody::Update_LeapFrog( Float deltaTime )
|
|||
// updating the angular
|
||||
// dw = dt * a = dt * ( I^-1 * T )
|
||||
// rotation = dt * avg_w
|
||||
Float4x4 inversedMomentOfInertiaTensor = this->momentOfInertiaTensor.GetInverse();
|
||||
Float4x4 inversedMomentOfInertiaTensor = wMomentOfInertiaTensor.GetInverse();
|
||||
Float3 deltaAngularVelocity = Formula::AngularImpulseAcceleration( inversedMomentOfInertiaTensor, this->impulseTorqueSum ); // I^-1 * T
|
||||
deltaAngularVelocity *= deltaTime;
|
||||
Float3 rotationAxis = ::Utility::Value::AverageWithDelta( Formula::AngularVelocity(inversedMomentOfInertiaTensor,this->angularMomentum), deltaAngularVelocity );
|
||||
|
@ -73,7 +76,7 @@ void RigidBody::Update_LeapFrog( Float deltaTime )
|
|||
// update movements and clear impulses
|
||||
this->linearMomentum += Formula::LinearMomentum( this->mass, deltaLinearVelocity );
|
||||
this->impulseForceSum = Float3::null;
|
||||
this->angularMomentum += Formula::AngularMomentum( this->momentOfInertiaTensor, deltaAngularVelocity );
|
||||
this->angularMomentum += Formula::AngularMomentum( wMomentOfInertiaTensor, deltaAngularVelocity );
|
||||
this->impulseTorqueSum = Float3::null;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,25 +14,23 @@ namespace Oyster { namespace Physics3D
|
|||
struct RigidBody
|
||||
{ /// A struct of a simple rigid body.
|
||||
public:
|
||||
::Oyster::Collision3D::Box box; /// Contains data representing physical presence.
|
||||
::Oyster::Math::Float3 angularMomentum, /// The angular momentum H (Nm*s) around an parallell axis.
|
||||
linearMomentum, /// The linear momentum G (kg*m/s).
|
||||
impulseTorqueSum, /// The impulse torque T (Nm) that will be consumed each update.
|
||||
impulseForceSum; /// The impulse force F (N) that will be consumed each update.
|
||||
::Oyster::Collision3D::Box box; /** Contains data representing physical presence. (worldValue) */
|
||||
::Oyster::Math::Float3 angularMomentum, /** The angular momentum H (Nm*s) around an parallell axis. (worldValue) */
|
||||
linearMomentum, /** The linear momentum G (kg*m/s). (worldValue) */
|
||||
impulseTorqueSum, /** The impulse torque T (Nm) that will be consumed each update. (worldValue) */
|
||||
impulseForceSum; /** The impulse force F (N) that will be consumed each update. (worldValue) */
|
||||
|
||||
RigidBody( const ::Oyster::Collision3D::Box &box = ::Oyster::Collision3D::Box(), ::Oyster::Math::Float mass = 1.0f );
|
||||
|
||||
RigidBody & operator = ( const RigidBody &body );
|
||||
|
||||
void Update_LeapFrog( ::Oyster::Math::Float deltaTime );
|
||||
void ApplyImpulseForce( const ::Oyster::Math::Float3 &f );
|
||||
void ApplyImpulseForceAt_Local( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
|
||||
void ApplyImpulseForceAt_World( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos ); /// ApplyImpulseForce_LocalPos is preferred
|
||||
void ApplyLinearImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
||||
void ApplyLinearImpulseAccelerationAt_Local( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos );
|
||||
void ApplyLinearImpulseAccelerationAt_World( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos ); /// ApplyLinearImpulseAcceleration_LocalPos is preferred
|
||||
void ApplyImpulseTorque( const ::Oyster::Math::Float3 &t );
|
||||
void ApplyAngularImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
||||
void ApplyImpulseForce( const ::Oyster::Math::Float3 &worldF );
|
||||
void ApplyImpulseForceAt( const ::Oyster::Math::Float3 &worldF, const ::Oyster::Math::Float3 &worldPos );
|
||||
void ApplyLinearImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||
void ApplyLinearImpulseAccelerationAt( const ::Oyster::Math::Float3 &worldA, const ::Oyster::Math::Float3 &worldPos );
|
||||
void ApplyImpulseTorque( const ::Oyster::Math::Float3 &worldT );
|
||||
void ApplyAngularImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||
|
||||
// ACCESS METHODS /////////////////////////////
|
||||
|
||||
|
@ -68,56 +66,44 @@ namespace Oyster { namespace Physics3D
|
|||
::Oyster::Math::Float3 GetLinearImpulseAcceleration() const;
|
||||
::Oyster::Math::Float3 GetLinearVelocity() const;
|
||||
|
||||
::Oyster::Math::Float3 GetTangentialImpulseForceAt_Local( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetTangentialImpulseForceAt_World( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetTangentialLinearMomentumAt_Local( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetTangentialLinearMomentumAt_World( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetTangentialImpulseAccelerationAt_Local( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetTangentialImpulseAccelerationAt_World( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetTangentialLinearVelocityAt_Local( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetTangentialLinearVelocityAt_World( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetTangentialImpulseForceAt( const ::Oyster::Math::Float3 &worldPos ) const;
|
||||
::Oyster::Math::Float3 GetTangentialLinearMomentumAt( const ::Oyster::Math::Float3 &worldPos ) const;
|
||||
::Oyster::Math::Float3 GetTangentialImpulseAccelerationAt( const ::Oyster::Math::Float3 &worldPos ) const;
|
||||
::Oyster::Math::Float3 GetTangentialLinearVelocityAt( const ::Oyster::Math::Float3 &worldPos ) const;
|
||||
|
||||
::Oyster::Math::Float3 GetImpulseForceAt_Local( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetImpulseForceAt_World( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetLinearMomentumAt_Local( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetLinearMomentumAt_World( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetImpulseAccelerationAt_Local( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetImpulseAccelerationAt_World( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetLinearVelocityAt_Local( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetLinearVelocityAt_World( const ::Oyster::Math::Float3 &pos ) const;
|
||||
::Oyster::Math::Float3 GetImpulseForceAt( const ::Oyster::Math::Float3 &worldPos ) const;
|
||||
::Oyster::Math::Float3 GetLinearMomentumAt( const ::Oyster::Math::Float3 &worldPos ) const;
|
||||
::Oyster::Math::Float3 GetImpulseAccelerationAt( const ::Oyster::Math::Float3 &worldPos ) const;
|
||||
::Oyster::Math::Float3 GetLinearVelocityAt( const ::Oyster::Math::Float3 &worldPos ) const;
|
||||
|
||||
// SET METHODS ////////////////////////////////
|
||||
|
||||
void SetMomentOfInertia( const ::Oyster::Math::Float4x4 &i );
|
||||
void SetMomentOfInertia( const ::Oyster::Math::Float4x4 &localI );
|
||||
void SetMass_KeepVelocity( const ::Oyster::Math::Float &m );
|
||||
void SetMass_KeepMomentum( const ::Oyster::Math::Float &m );
|
||||
|
||||
void SetOrientation( const ::Oyster::Math::Float4x4 &o );
|
||||
void SetSize( const ::Oyster::Math::Float3 &widthHeight );
|
||||
void SetCenter( const ::Oyster::Math::Float3 &p );
|
||||
void SetCenter( const ::Oyster::Math::Float3 &worldPos );
|
||||
|
||||
void SetImpulseTorque( const ::Oyster::Math::Float3 &t );
|
||||
void SetAngularMomentum( const ::Oyster::Math::Float3 &h );
|
||||
void SetAngularImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
||||
void SetAngularVelocity( const ::Oyster::Math::Float3 &w );
|
||||
void SetImpulseTorque( const ::Oyster::Math::Float3 &worldT );
|
||||
void SetAngularMomentum( const ::Oyster::Math::Float3 &worldH );
|
||||
void SetAngularImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||
void SetAngularVelocity( const ::Oyster::Math::Float3 &worldW );
|
||||
|
||||
void SetImpulseForce( const ::Oyster::Math::Float3 &f );
|
||||
void SetLinearMomentum( const ::Oyster::Math::Float3 &g );
|
||||
void SetLinearImpulseAcceleration( const ::Oyster::Math::Float3 &a );
|
||||
void SetLinearVelocity( const ::Oyster::Math::Float3 &v );
|
||||
void SetImpulseForce( const ::Oyster::Math::Float3 &worldF );
|
||||
void SetLinearMomentum( const ::Oyster::Math::Float3 &worldG );
|
||||
void SetLinearImpulseAcceleration( const ::Oyster::Math::Float3 &worldA );
|
||||
void SetLinearVelocity( const ::Oyster::Math::Float3 &worldV );
|
||||
|
||||
void SetImpulseForceAt_Local( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
|
||||
void SetImpulseForceAt_World( const ::Oyster::Math::Float3 &f, const ::Oyster::Math::Float3 &pos );
|
||||
void SetLinearMomentumAt_Local( const ::Oyster::Math::Float3 &g, const ::Oyster::Math::Float3 &pos );
|
||||
void SetLinearMomentumAt_World( const ::Oyster::Math::Float3 &g, const ::Oyster::Math::Float3 &pos );
|
||||
void SetImpulseAccelerationAt_Local( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos );
|
||||
void SetImpulseAccelerationAt_World( const ::Oyster::Math::Float3 &a, const ::Oyster::Math::Float3 &pos );
|
||||
void SetLinearVelocityAt_Local( const ::Oyster::Math::Float3 &v, const ::Oyster::Math::Float3 &pos );
|
||||
void SetLinearVelocityAt_World( const ::Oyster::Math::Float3 &v, const ::Oyster::Math::Float3 &pos );
|
||||
void SetImpulseForceAt( const ::Oyster::Math::Float3 &worldF, const ::Oyster::Math::Float3 &worldPos );
|
||||
void SetLinearMomentumAt( const ::Oyster::Math::Float3 &worldG, const ::Oyster::Math::Float3 &worldPos );
|
||||
void SetImpulseAccelerationAt( const ::Oyster::Math::Float3 &worldA, const ::Oyster::Math::Float3 &worldPos );
|
||||
void SetLinearVelocityAt( const ::Oyster::Math::Float3 &worldV, const ::Oyster::Math::Float3 &worldPos );
|
||||
|
||||
private:
|
||||
::Oyster::Math::Float mass; /// m (kg)
|
||||
::Oyster::Math::Float4x4 momentOfInertiaTensor; /// I (Nm*s) Tensor matrix ( only need to be 3x3 matrix, but is 4x4 for future hardware acceleration )
|
||||
::Oyster::Math::Float mass; /** m (kg) */
|
||||
::Oyster::Math::Float4x4 momentOfInertiaTensor; /** I (Nm*s) Tensor matrix ( only need to be 3x3 matrix, but is 4x4 for future hardware acceleration ) (localValue) */
|
||||
};
|
||||
|
||||
// INLINE IMPLEMENTATIONS ///////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue