ApplyEffect is now easier to handle for the user

Only needs a function with a pointer to an ICustomBody now.
This commit is contained in:
Robin Engman 2014-01-22 12:36:12 +01:00
parent 5c85580ffd
commit 0cae6261e9
5 changed files with 10 additions and 6 deletions

View File

@ -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) );
}
}
}

View File

@ -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
{

View File

@ -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);
}

View File

@ -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 );

View File

@ -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.