From 0cae6261e9d2fa0a7f9bad46f6dc024b6076c79d Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Wed, 22 Jan 2014 12:36:12 +0100 Subject: [PATCH] ApplyEffect is now easier to handle for the user Only needs a function with a pointer to an ICustomBody now. --- Code/GamePhysics/Implementation/Octree.cpp | 2 +- Code/GamePhysics/Implementation/Octree.h | 2 +- Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp | 2 +- Code/GamePhysics/Implementation/PhysicsAPI_Impl.h | 2 +- Code/GamePhysics/PhysicsAPI.h | 8 ++++++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Code/GamePhysics/Implementation/Octree.cpp b/Code/GamePhysics/Implementation/Octree.cpp index 60f05298..3faff29e 100644 --- a/Code/GamePhysics/Implementation/Octree.cpp +++ b/Code/GamePhysics/Implementation/Octree.cpp @@ -134,7 +134,7 @@ void Octree::Visit(const Oyster::Collision3D::ICollideable& collideable, Visitor { if(collideable.Intersects(this->leafData[i].container)) { - hitAction(*this, i); + hitAction( this->GetCustomBody(i) ); } } } diff --git a/Code/GamePhysics/Implementation/Octree.h b/Code/GamePhysics/Implementation/Octree.h index 6c6606a9..7b350795 100644 --- a/Code/GamePhysics/Implementation/Octree.h +++ b/Code/GamePhysics/Implementation/Octree.h @@ -18,7 +18,7 @@ namespace Oyster static const unsigned int invalid_ref; typedef void(*VisitorAction)(Octree&, unsigned int, unsigned int); - typedef void(*VisitorActionCollideable)(Octree&, unsigned int); + typedef void(*VisitorActionCollideable)(ICustomBody*); struct Data { diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 2899eae6..5b88baf5 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -268,7 +268,7 @@ void API_Impl::RemoveGravity( const API::Gravity &g ) } } -void API_Impl::ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(Octree&, unsigned int) ) +void API_Impl::ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(ICustomBody*) ) { this->worldScene.Visit(collideable, hitAction); } diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h index ad2c91a4..c50668de 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h @@ -35,7 +35,7 @@ namespace Oyster void AddGravity( const API::Gravity &g ); void RemoveGravity( const API::Gravity &g ); - void ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(Octree&, unsigned int) ); + void ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(ICustomBody*) ); //void ApplyForceAt( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF ); diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h index 4e1844f5..98daac0d 100644 --- a/Code/GamePhysics/PhysicsAPI.h +++ b/Code/GamePhysics/PhysicsAPI.h @@ -16,7 +16,6 @@ namespace Oyster { class API; class ICustomBody; - class Octree; namespace Struct { @@ -137,7 +136,12 @@ namespace Oyster ********************************************************/ virtual void RemoveGravity( const API::Gravity &g ) = 0; - virtual void ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(Octree&, unsigned int) ) = 0; + /******************************************************** + * Applies an effect to objects that collide with the set volume. + * @param collideable: An ICollideable that defines the volume of the effect. + * @param hitAction: A function that contains the effect. + ********************************************************/ + virtual void ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(ICustomBody*) ) = 0; ///******************************************************** // * Apply force on an object.