diff --git a/Bin/DLL/GamePhysics_x86D.exp b/Bin/DLL/GamePhysics_x86D.exp deleted file mode 100644 index 0cea5aa6..00000000 Binary files a/Bin/DLL/GamePhysics_x86D.exp and /dev/null differ diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index ed8f8eed..3d3080da 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -11,6 +11,22 @@ using namespace ::Utility::DynamicMemory; API_Impl API_instance; +namespace +{ + void OnPossibleCollision( Octree& worldScene, unsigned int protoTempRef, unsigned int deuterTempRef ) + { /** @todo TODO: OnPossibleCollision is a temporary solution .*/ + auto proto = worldScene.GetCustomBody( protoTempRef ); + auto deuter = worldScene.GetCustomBody( deuterTempRef ); + + float deltaWhen; + Float3 worldWhere; + if( deuter->Intersects(*deuter, 1.0f, deltaWhen, worldWhere) ) + { + proto->CallSubscription( proto, deuter ); + } + } +} + Float4x4 & MomentOfInertia::CreateSphereMatrix( const Float mass, const Float radius) { return Formula::MomentOfInertia::Sphere(mass, radius); @@ -80,8 +96,25 @@ void API_Impl::SetSubscription( API::EventAction_Destruction functionPointer ) } void API_Impl::Update() -{ - /** @todo TODO: Fix this function.*/ +{ /** @todo TODO: Update is a temporary solution .*/ + ::std::vector updateList; + auto proto = this->worldScene.Sample( Universe(), updateList ).begin(); + for( ; proto != updateList.end(); ++proto ) + { + this->worldScene.Visit( *proto, OnPossibleCollision ); + } + + proto = updateList.begin(); + for( ; proto != updateList.end(); ++proto ) + { + switch( (*proto)->Update(this->updateFrameLength) ) + { + case UpdateState_altered: + this->worldScene.SetAsAltered( this->worldScene.GetTemporaryReferenceOf(*proto) ); + case UpdateState_resting: default: + break; + } + } } bool API_Impl::IsInLimbo( const ICustomBody* objRef ) diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp index 40a1b7ee..70bc6938 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp @@ -42,6 +42,11 @@ UniquePointer SimpleRigidBody::Clone() const return new SimpleRigidBody( *this ); } +void SimpleRigidBody::CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ) +{ + this->collisionAction( proto, deuter ); +} + bool SimpleRigidBody::IsAffectedByGravity() const { return !this->ignoreGravity; diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.h b/Code/GamePhysics/Implementation/SimpleRigidBody.h index c76f6a51..a674a20d 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.h +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.h @@ -15,6 +15,7 @@ namespace Oyster { namespace Physics ::Utility::DynamicMemory::UniquePointer Clone() const; + void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ); bool IsAffectedByGravity() const; bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const; bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const; diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp index 292a2dd2..c741a68a 100644 --- a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp @@ -44,6 +44,11 @@ UniquePointer SphericalRigidBody::Clone() const return new SphericalRigidBody( *this ); } +void SphericalRigidBody::CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ) +{ + this->collisionAction( proto, deuter ); +} + bool SphericalRigidBody::IsAffectedByGravity() const { return !this->ignoreGravity; diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.h b/Code/GamePhysics/Implementation/SphericalRigidBody.h index 61f5d604..37263e91 100644 --- a/Code/GamePhysics/Implementation/SphericalRigidBody.h +++ b/Code/GamePhysics/Implementation/SphericalRigidBody.h @@ -16,7 +16,7 @@ namespace Oyster { namespace Physics ::Utility::DynamicMemory::UniquePointer Clone() const; - bool IsSubscribingCollisions() const; + void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ); bool IsAffectedByGravity() const; bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const; bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const; diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h index 5d44b695..29014214 100644 --- a/Code/GamePhysics/PhysicsAPI.h +++ b/Code/GamePhysics/PhysicsAPI.h @@ -246,6 +246,11 @@ namespace Oyster ********************************************************/ virtual ::Utility::DynamicMemory::UniquePointer Clone() const = 0; + /******************************************************** + * @todo TODO: need doc + ********************************************************/ + virtual void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ) = 0; + /******************************************************** * @return true if Engine should apply gravity on this object. ********************************************************/