From 026b427deb906d291306d8cb4c183f21510033ee Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 29 Nov 2013 09:21:44 +0100 Subject: [PATCH] Implemented a temporary collision test update Will only call the subscribed CollisioEventAction whenevera collision is detected. --- Bin/DLL/GamePhysics_x86D.exp | Bin 4647 -> 0 bytes .../Implementation/PhysicsAPI_Impl.cpp | 37 +++++++++++++++++- .../Implementation/SimpleRigidBody.cpp | 5 +++ .../Implementation/SimpleRigidBody.h | 1 + .../Implementation/SphericalRigidBody.cpp | 5 +++ .../Implementation/SphericalRigidBody.h | 2 +- Code/GamePhysics/PhysicsAPI.h | 5 +++ 7 files changed, 52 insertions(+), 3 deletions(-) delete mode 100644 Bin/DLL/GamePhysics_x86D.exp diff --git a/Bin/DLL/GamePhysics_x86D.exp b/Bin/DLL/GamePhysics_x86D.exp deleted file mode 100644 index 0cea5aa656b285c7e0ab517de7be488640d073f4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4647 zcmeHKOK%%h6h3LvI*&dQ-tU?cXi_R;CvKcVDvuwKM%YQ3P*b51VdA+-MmQd8WPfQo(0^ytXZtxAttK zY_HX4XYw(^W{JY8AZvmIe6%B9T9N+w&1C#DqTjj*6A^4Epjj_sJ+SySIT zIMqSHGG(IOs)|^Z`)gQ^%Z;dHyBs*OOhz79>+vPS67DmlXl{$Dv$U~L6_#UY?GC(6 zrL|PMRn24-oaMDt*fL~H&JvmsZZXGMCfiZgjGqREkQ$s0z)> zR5r!Br721ggDwNB&*M2JJl}*T`w3vbWKkfuw+M{`(a6BKA3iKu1;~vpLT7=GNLG`` zS{&?Ax#s`}B})PyldKLLl57_ExMc4Ehb5Z>@+u|`F3_LDb0T`9+6W|HSmVr-8_9<{wve$s8B>Mu$-8e#5fX_(wHSj*kR3M*` z2z>**U$VD=&r0?!@BztmAp1gut^*&GYzuf=vYWt%BpU$!iSG+I#Rcl)!jyYa&6g6% zR7#yUoal13g_ep22o)P@%$x$XufpmbjLn(9#aP0DPaZL`OO7P zN)J zpOU0Y=$oyX&(ZfjWrl{)CR<}tB7t1TOKHYF)7gnSD6nePC)rGp!^t6ehVl= zyfkmPwdMkf9Z;?Xlpg}hsGCmac4;-B{1Q-3H=Wo!8&~gAZelOQ&RX9o_IIntersects(*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. ********************************************************/