This commit is contained in:
Dander7BD 2013-12-16 08:58:15 +01:00
parent c740bd5935
commit c854b1af58
7 changed files with 83 additions and 41 deletions

View File

@ -166,6 +166,8 @@
<ClInclude Include="Implementation\SimpleRigidBody.h" />
<ClInclude Include="Implementation\SphericalRigidBody.h" />
<ClInclude Include="PhysicsAPI.h" />
<ClInclude Include="PhysicsFormula-Impl.h" />
<ClInclude Include="PhysicsFormula.h" />
<ClInclude Include="PhysicsStructs-Impl.h" />
<ClInclude Include="PhysicsStructs.h" />
</ItemGroup>

View File

@ -42,6 +42,12 @@
<ClInclude Include="PhysicsStructs-Impl.h">
<Filter>Header Files\Include</Filter>
</ClInclude>
<ClInclude Include="PhysicsFormula.h">
<Filter>Header Files\Include</Filter>
</ClInclude>
<ClInclude Include="PhysicsFormula-Impl.h">
<Filter>Header Files\Include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp">

View File

@ -4,7 +4,6 @@
#include "SphericalRigidBody.h"
using namespace ::Oyster::Physics;
using namespace ::Oyster::Physics3D;
using namespace ::Oyster::Math;
using namespace ::Oyster::Collision3D;
using namespace ::Utility::DynamicMemory;
@ -27,31 +26,6 @@ namespace
}
}
Float4x4 & MomentOfInertia::CreateSphereMatrix( const Float mass, const Float radius, ::Oyster::Math::Float4x4 &targetMem )
{
return targetMem = Formula::MomentOfInertia::Sphere(mass, radius);
}
Float4x4 & MomentOfInertia::CreateHollowSphereMatrix( const Float mass, const Float radius, ::Oyster::Math::Float4x4 &targetMem )
{
return targetMem = Formula::MomentOfInertia::HollowSphere(mass, radius);
}
Float4x4 & MomentOfInertia::CreateCuboidMatrix( const Float mass, const Float height, const Float width, const Float depth, ::Oyster::Math::Float4x4 &targetMem )
{
return targetMem = Formula::MomentOfInertia::Cuboid(mass, height, width, depth);
}
Float4x4 & MomentOfInertia::CreateCylinderMatrix( const Float mass, const Float height, const Float radius, ::Oyster::Math::Float4x4 &targetMem )
{
return targetMem = Formula::MomentOfInertia::Cylinder(mass, height, radius);
}
Float4x4 & MomentOfInertia::CreateRodMatrix( const Float mass, const Float length, ::Oyster::Math::Float4x4 &targetMem )
{
return targetMem = Formula::MomentOfInertia::RodCenter(mass, length);
}
API & API::Instance()
{
return API_instance;

View File

@ -21,7 +21,7 @@ SphericalRigidBody::SphericalRigidBody( const API::SphericalBodyDescription &des
{
this->rigid = RigidBody( Box( desc.rotation, desc.centerPosition, Float3(2.0f * desc.radius) ),
desc.mass,
MomentOfInertia::CreateSphereMatrix( desc.mass, desc.radius ) );
Formula::MomentOfInertia::CreateSphereMatrix( desc.mass, desc.radius ) );
this->gravityNormal = Float3::null;
if( desc.subscription )

View File

@ -35,20 +35,6 @@ namespace Oyster
const float gravity_constant = (const float)6.67284e-11; //!< The _big_G_! ( N(m/kg)^2 ) Used in real gravityforcefields.
}
class PHYSICS_DLL_USAGE MomentOfInertia
{
public:
static ::Oyster::Math::Float4x4 & CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
static ::Oyster::Math::Float4x4 & CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
static ::Oyster::Math::Float4x4 & CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
static ::Oyster::Math::Float4x4 & CreateCylinderMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
static ::Oyster::Math::Float4x4 & CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
};
class PHYSICS_DLL_USAGE API
{
public:
@ -436,5 +422,6 @@ namespace Oyster
}
#include "PhysicsStructs.h"
#include "PhysicsFormula.h"
#endif

View File

@ -0,0 +1,46 @@
#ifndef PHYSICS_FORMULA_IMPL_H
#define PHYSICS_FORMULA_IMPL_H
#include "PhysicsFormula.h"
#include "OysterPhysics3D.h"
namespace Oyster { namespace Physics { namespace Formula
{
namespace MomentOfInertia
{
inline ::Oyster::Math::Float4x4 CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius )
{
return ::Oyster::Physics3D::Formula::MomentOfInertia::Sphere(mass, radius);
}
inline ::Oyster::Math::Float4x4 CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius )
{
return ::Oyster::Physics3D::Formula::MomentOfInertia::HollowSphere(mass, radius);
}
inline ::Oyster::Math::Float4x4 CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth )
{
return ::Oyster::Physics3D::Formula::MomentOfInertia::Cuboid(mass, height, width, depth);
}
inline ::Oyster::Math::Float4x4 CreateCylinderMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius )
{
return ::Oyster::Physics3D::Formula::MomentOfInertia::Cylinder(mass, height, radius);
}
inline ::Oyster::Math::Float4x4 CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length )
{
return ::Oyster::Physics3D::Formula::MomentOfInertia::RodCenter(mass, length);
}
}
namespace CollisionResponse
{
inline ::Oyster::Math::Float Impulse( ::Oyster::Math::Float e, ::Oyster::Math::Float mA, ::Oyster::Math::Float gA, ::Oyster::Math::Float mB, ::Oyster::Math::Float gB )
{
return (e+1) * (mB*gA - mA*gB) / (mA + mB);
}
}
} } }
#endif

View File

@ -0,0 +1,27 @@
#ifndef PHYSICS_FORMULA_H
#define PHYSICS_FORMULA_H
#include "OysterMath.h"
namespace Oyster { namespace Physics { namespace Formula
{
namespace MomentOfInertia
{
::Oyster::Math::Float4x4 CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius );
::Oyster::Math::Float4x4 CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius );
::Oyster::Math::Float4x4 CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth );
::Oyster::Math::Float4x4 CreateCylinderMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius );
::Oyster::Math::Float4x4 CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length );
}
namespace CollisionResponse
{
::Oyster::Math::Float Impulse( ::Oyster::Math::Float coeffOfRestitution,
::Oyster::Math::Float massA, ::Oyster::Math::Float momentumA,
::Oyster::Math::Float massB, ::Oyster::Math::Float momentumB );
}
} } }
#include "PhysicsFormula-Impl.h"
#endif