diff --git a/Code/GamePhysics/GamePhysics.vcxproj b/Code/GamePhysics/GamePhysics.vcxproj
index 06e64fd1..1abcc6f8 100644
--- a/Code/GamePhysics/GamePhysics.vcxproj
+++ b/Code/GamePhysics/GamePhysics.vcxproj
@@ -166,6 +166,8 @@
+
+
diff --git a/Code/GamePhysics/GamePhysics.vcxproj.filters b/Code/GamePhysics/GamePhysics.vcxproj.filters
index 15221691..aa3cbd73 100644
--- a/Code/GamePhysics/GamePhysics.vcxproj.filters
+++ b/Code/GamePhysics/GamePhysics.vcxproj.filters
@@ -42,6 +42,12 @@
Header Files\Include
+
+ Header Files\Include
+
+
+ Header Files\Include
+
diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp
index 46b3369c..d01d95f7 100644
--- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp
+++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp
@@ -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;
diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp
index 364d7454..ce31456e 100644
--- a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp
+++ b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp
@@ -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 )
diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h
index 84a3d639..6c43a754 100644
--- a/Code/GamePhysics/PhysicsAPI.h
+++ b/Code/GamePhysics/PhysicsAPI.h
@@ -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
\ No newline at end of file
diff --git a/Code/GamePhysics/PhysicsFormula-Impl.h b/Code/GamePhysics/PhysicsFormula-Impl.h
new file mode 100644
index 00000000..2c97de24
--- /dev/null
+++ b/Code/GamePhysics/PhysicsFormula-Impl.h
@@ -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
\ No newline at end of file
diff --git a/Code/GamePhysics/PhysicsFormula.h b/Code/GamePhysics/PhysicsFormula.h
new file mode 100644
index 00000000..c015e571
--- /dev/null
+++ b/Code/GamePhysics/PhysicsFormula.h
@@ -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
\ No newline at end of file