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?
Query whether a co-ordinate is occupied in Space
Re: Query whether a co-ordinate is occupied in Space
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.
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
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?
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
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.How do you use the QueryAccelerator to query a position?
Is there any demos/samples that do anything like this?
The result of calling that method will be a list of BroadPhaseEntry objects. StaticMesh, InstancedMesh, Terrain, and all the Entity.CollisionInformation objects are BroadPhaseEntries.
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.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
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?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.
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
Woops, sorry- yes, it's GetEntries, not GetOverlapsThe QueryAccelerator only seems to have a method called GetEntries

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.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?
Re: Query whether a co-ordinate is occupied in Space
Ok I am using the right method then! Thanks very much.
I will carry on with this approach for now.
.
Thanks.
I will carry on with this approach for now.

Thanks.