Page 1 of 1

Getting entity from a broadphase entry.

Posted: Wed Feb 15, 2012 6:07 pm
by samcruise
Hi,

I'm a bit new to all this so apologies in advance!

I'm using BroadPhase.QueryAccelerator.GetEntries() to get a list of broad phase entries within a bounding volume.

How can I get the entity with which the volume overlaps from the broad phase entry?

Cheers

Re: Getting entity from a broadphase entry.

Posted: Wed Feb 15, 2012 8:12 pm
by samcruise
Ah don't worry - I set the tag of the collision information object. Perfect

Re: Getting entity from a broadphase entry.

Posted: Wed Feb 15, 2012 9:57 pm
by Norbo
Ah don't worry - I set the tag of the collision information object. Perfect
That is indeed one way to do it. Sticking some game logic object in the tag is useful to bind everything together too.

Another way is to check to see if the BroadPhaseEntry is an EntityCollidable. The organization goes like this:
-A BroadPhaseEntry lives in the BroadPhase and collision detection pipeline.
-The Collidable class inherits from BroadPhaseEntry. Collidables are capable of generating contacts between each other. Examples of concrete objects which inherit Collidable include Terrain, StaticMesh, and InstancedMesh.
-The EntityCollidable class also inherits from Collidable. Entities use EntityCollidables as collision proxies in the collision detection pipeline. An entity's EntityCollidable is stored in the entity.CollisionInformation property. An EntityCollidable has an Entity property which references the Entity which owns it.

So, the tagless method would be:
-Attempt a cast from a BroadPhaseEntry to EntityCollidable.
-If it succeeds, check the Entity property of the EntityCollidable object.