Page 1 of 1
Query whether a co-ordinate is occupied in Space
Posted: Wed Dec 21, 2011 11:20 am
by al9191
In the space object I can access the entities and then loop through them and get all the points contained within them, and then try and work out if a certain co-ordinate is taken. (I need to do this in order to do path-finding.)
However, is there a way using the BEPU API to test a space with a co-ordinate to see if it is occupied by something?
Re: Query whether a co-ordinate is occupied in Space
Posted: Wed Dec 21, 2011 9:02 pm
by Norbo
The Space.BroadPhase.QueryAccelerator supports volume queries which could be used. A tiny BoundingBox could be checked against every other object in the space, returning all AABB overlaps.
Since the query accelerator only considers bounding boxes, additional tests would be necessary if you wanted to test the point's position against the geometry of the shapes themselves. One option would be something like the CharacterController's QueryManager, which performs pairwise tests for contacts with an overlapped set of objects. The query object could be a small sphere representing the point. This leverages the NarrowPhase and NarrowPhaseHelper, so the complexity of different entity types or static meshes is abstracted away.
Re: Query whether a co-ordinate is occupied in Space
Posted: Thu Dec 22, 2011 12:39 am
by al9191
How do you use the QueryAccelerator to query a position?
Is there any demos/samples that do anything like this?
Also, what is the CharacterController and it's QueryManager and can't find them in the API or the Sample demos?
Re: Query whether a co-ordinate is occupied in Space
Posted: Thu Dec 22, 2011 12:58 am
by Norbo
How do you use the QueryAccelerator to query a position?
Is there any demos/samples that do anything like this?
There is no demo that does exactly this, but using the QueryAccelerator is quite simple. Just use the Space.BroadPhase.QueryAccelerator.GetOverlaps method. There is no overload that accepts only a point, so instead create a small BoundingSphere or BoundingBox that represents the point.
The result of calling that method will be a list of BroadPhaseEntry objects. StaticMesh, InstancedMesh, Terrain, and all the Entity.CollisionInformation objects are BroadPhaseEntries.
Also, what is the CharacterController and it's QueryManager and can't find them in the API or the Sample demos?
The CharacterController and its QueryManager can be found in the BEPUphysicsDemos in the main source download. It is in the BEPUphysicsDemos project in the folder Alternate Movement/Character. The CharacterController is used in the demos for FPS-like control. You can run around, jump, step up and down, crouch, and so on. The QueryManager is used by the CharacterController to do shape queries for crouching or stepping, among other things.
Re: Query whether a co-ordinate is occupied in Space
Posted: Thu Dec 22, 2011 1:16 am
by al9191
Norbo wrote:
There is no demo that does exactly this, but using the QueryAccelerator is quite simple. Just use the Space.BroadPhase.QueryAccelerator.GetOverlaps method. There is no overload that accepts only a point, so instead create a small BoundingSphere or BoundingBox that represents the point.
Ok thanks for the help this is exactly what I need. The QueryAccelerator only seems to have a method called GetEntries and it takes a bounding shape argument and an IList argument but returns nothing. I have tried passing in an IList but it is abstract class so can't instansiate one to pass in. Am I doing it right?
Code: Select all
IList<BroadPhaseEntry> list;
BoundingSphere sphere = new BoundingSphere(point, accuracy);
space.BroadPhase.QueryAccelerator.GetEntries(sphere, list);
Re: Query whether a co-ordinate is occupied in Space
Posted: Thu Dec 22, 2011 1:24 am
by Norbo
The QueryAccelerator only seems to have a method called GetEntries
Woops, sorry- yes, it's GetEntries, not GetOverlaps
it takes a bounding shape argument and an IList argument but returns nothing. I have tried passing in an IList but it is abstract class so can't instansiate one to pass in. Am I doing it right?
The GetEntries method will dump the entries it finds overlapping the given bounding volume into the IList<BroadPhaseEntry> you provide. Any type which implements IList<BroadPhaseEntry> will work. So
List<BroadPhaseEntry> could be used.
Re: Query whether a co-ordinate is occupied in Space
Posted: Thu Dec 22, 2011 1:26 am
by al9191
Ok I am using the right method then! Thanks very much.
I will carry on with this approach for now.

.
Thanks.