diff --git a/Code/GamePhysics/GamePhysics.vcxproj.filters b/Code/GamePhysics/GamePhysics.vcxproj.filters
index 8c1b9f8b..07661556 100644
--- a/Code/GamePhysics/GamePhysics.vcxproj.filters
+++ b/Code/GamePhysics/GamePhysics.vcxproj.filters
@@ -30,7 +30,7 @@
- Header Files\Implementation
+ Source Files
\ No newline at end of file
diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h
index 5711b277..d9ae0a59 100644
--- a/Code/GamePhysics/PhysicsAPI.h
+++ b/Code/GamePhysics/PhysicsAPI.h
@@ -1,6 +1,7 @@
#ifndef PHYSICS_API_H
#define PHYSICS_API_H
+#include "OysterCollision3D.h"
#include "OysterMath.h"
#include "Utilities.h"
@@ -12,6 +13,12 @@ namespace Oyster
class IRigidBody;
class IParticle;
+ enum UpdateState
+ {
+ resting,
+ altered
+ };
+
namespace Constant
{
const float gravity_constant = (const float)6.67284e-11; // The _big_G_! ( N(m/kg)^2 ) Used in real gravityforcefields.
@@ -32,17 +39,28 @@ namespace Oyster
virtual void Update() = 0;
- virtual void MoveToLimbo( unsigned int objRef );
- virtual void ReleaseFromLimbo( unsigned int objRef );
+ virtual bool IsInLimbo( unsigned int objRef ) = 0;
+ virtual void MoveToLimbo( unsigned int objRef ) = 0;
+ virtual void ReleaseFromLimbo( unsigned int objRef ) = 0;
- virtual unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer handle );
- virtual void DestroyObject( unsigned int objRef );
+ virtual unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer handle ) = 0;
+ virtual ::Utility::DynamicMemory::UniquePointer ExtractObject( unsigned int objRef ) = 0;
+ virtual void DestroyObject( unsigned int objRef ) = 0;
};
class IRigidBody
{
public:
+ virtual ~IRigidBody() {};
+ virtual UpdateState Update( ::Oyster::Math::Float timeStepLength ) = 0;
+
+ virtual bool IsSubscribingCollisions() const = 0;
+ virtual bool IsIntersecting( const IRigidBody &object, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) = 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;
};
class IParticle
diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h
index 4c954cd6..ba427bb6 100644
--- a/Code/OysterMath/LinearMath.h
+++ b/Code/OysterMath/LinearMath.h
@@ -386,6 +386,23 @@ namespace LinearAlgebra3D
return targetMem;
}
+ template
+ inline ::LinearAlgebra::Matrix4x4 OrientationMatrix_LookAtDirection( const ::LinearAlgebra::Vector3 &normalizedDirection, const ::LinearAlgebra::Vector3 &normalizedUpVector, const ::LinearAlgebra::Vector3 &worldPos )
+ { // Righthanded system! Forward is considered to be along negative z axis. Up is considered along positive y axis.
+ ::LinearAlgebra::Vector3 right = normalizedDirection.Cross( normalizedUpVector ).GetNormalized();
+ return ::LinearAlgebra::Matrix4x4( ::LinearAlgebra::Vector4( right, 0.0f ),
+ ::LinearAlgebra::Vector4( right.Cross( normalizedDirection ), 0.0f ),
+ ::LinearAlgebra::Vector4( -normalizedDirection, 0.0f ),
+ ::LinearAlgebra::Vector4( worldPos, 1.0f ) );
+ }
+
+ template
+ inline ::LinearAlgebra::Matrix4x4 OrientationMatrix_LookAtPos( const ::LinearAlgebra::Vector3 &worldLookAt, const ::LinearAlgebra::Vector3 &normalizedUpVector, const ::LinearAlgebra::Vector3 &worldPos )
+ { // Righthanded system! Forward is considered to be along negative z axis. Up is considered along positive y axis.
+ ::LinearAlgebra::Vector3 direction = ( worldLookAt - worldPos ).GetNormalized();
+ return OrientationMatrix_LookAtDirection( direction, normalizedUpVector, worldPos );
+ }
+
template
inline ::LinearAlgebra::Matrix4x4 & InverseOrientationMatrix( const ::LinearAlgebra::Matrix4x4 &orientationMatrix, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() )
{
@@ -458,7 +475,7 @@ namespace LinearAlgebra3D
template
inline ::LinearAlgebra::Vector3 NormalProjection( const ::LinearAlgebra::Vector3 &vector, const ::LinearAlgebra::Vector3 &normalizedAxis )
- { return axis * ( vector.Dot(axis) ); }
+ { return normalizedAxis * ( vector.Dot(normalizedAxis) ); }
}
#include "Utilities.h"
diff --git a/Code/OysterMath/OysterMath.cpp b/Code/OysterMath/OysterMath.cpp
index ab318e92..35df5975 100644
--- a/Code/OysterMath/OysterMath.cpp
+++ b/Code/OysterMath/OysterMath.cpp
@@ -131,6 +131,16 @@ namespace Oyster { namespace Math3D
return ::LinearAlgebra3D::OrientationMatrix( sumDeltaAngularAxis, sumTranslation, centerOfMass, targetMem );
}
+ Float4x4 & OrientationMatrix_LookAtDirection( const Float3 &normalizedDirection, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem )
+ {
+ return targetMem = ::LinearAlgebra3D::OrientationMatrix_LookAtDirection( normalizedDirection, normalizedUpVector, worldPos );
+ }
+
+ Float4x4 & OrientationMatrix_LookAtPos( const Float3 &worldLookAt, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem )
+ {
+ return targetMem = ::LinearAlgebra3D::OrientationMatrix_LookAtPos( worldLookAt, normalizedUpVector, worldPos );
+ }
+
Float4x4 & InverseOrientationMatrix( const Float4x4 &orientationMatrix, Float4x4 &targetMem )
{
return ::LinearAlgebra3D::InverseOrientationMatrix( orientationMatrix, targetMem );
diff --git a/Code/OysterMath/OysterMath.h b/Code/OysterMath/OysterMath.h
index 4a1eeefe..125fd29d 100644
--- a/Code/OysterMath/OysterMath.h
+++ b/Code/OysterMath/OysterMath.h
@@ -207,6 +207,12 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized
*******************************************************************/
Float4x4 & OrientationMatrix( const Float3 &sumDeltaAngularAxis, const Float3 &sumTranslation, const Float3 ¢erOfMass, Float4x4 &targetMem = Float4x4() );
+ //! @todo TODO: Add documentation and not tested
+ Float4x4 & OrientationMatrix_LookAtDirection( const Float3 &normalizedDirection, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem = Float4x4() );
+
+ //! @todo TODO: Add documentation and not tested
+ Float4x4 & OrientationMatrix_LookAtPos( const Float3 &worldLookAt, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem = Float4x4() );
+
/// If orientationMatrix is assumed to be by all definitions a rigid orientation matrix aka rigid body matrix. Then this is a much faster inverse method.
Float4x4 & InverseOrientationMatrix( const Float4x4 &orientationMatrix, Float4x4 &targetMem = Float4x4() );
diff --git a/Code/OysterPhysics3D/RigidBody.cpp b/Code/OysterPhysics3D/RigidBody.cpp
index fb663cf4..214a1aee 100644
--- a/Code/OysterPhysics3D/RigidBody.cpp
+++ b/Code/OysterPhysics3D/RigidBody.cpp
@@ -70,7 +70,7 @@ void RigidBody::Update_LeapFrog( Float deltaTime )
this->box.center += deltaPos;
}
- // update movements and clear impulseForceSum and impulseTorqueSum
+ // update momentums and clear impulseForceSum and impulseTorqueSum
this->linearMomentum += linearImpulse;
this->impulseForceSum = Float3::null;
this->angularMomentum += angularImpulse;