Getting all entitys inside a bounding frustrum

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Danthekilla
Posts: 136
Joined: Sun Jan 17, 2010 11:35 am

Getting all entitys inside a bounding frustrum

Post by Danthekilla »

Hey Norbo, (and others)


I am using some code like this

Code: Select all

PhysicsManager.GET.PhysicsSpace.BroadPhase.QueryAccelerator.GetEntries(boundingFrustum, overlaps);
But this only gets me the bounding boxes that overlap and not the actual overlaps.

So I need to cull this list of overlaps down to the actual accurate non broadphase overlaps but I cannot find any methods for making this kind of query.

Currently I have added a naïve approximation where I test against a set of spheres that approximate the volume of the bounding frustrum.

But I would really like a more accurate and less hacky method.

Any ideas?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Getting all entitys inside a bounding frustrum

Post by Norbo »

One approach would be to represent the frustum as a ConvexHullShape, and then use the NarrowPhaseHelpers.GetPairHandler to grab a pair to test. The character's QueryManager.QueryContacts function does this.

That said, it's not going to be ideal. An enormous convex hull tested against relatively small objects will tend to encounter some numerical imprecision due to GJK/MPR, and it's not going to be terribly fast.

There are often ways around this depending on the final goal. For example, if the goal is merely-reasonably-tight frustum culling, it's often sufficient to test a limited number of separating axes. For objects that are small relative to the frustum, it may be sufficient to just use the offset from the center of the object to the closest point on the frustum. You can then compute the interval of the frustum and object along that axis using the extreme point functions. If the intervals do not overlap, then you know the frustum is not intersected. This kind of approach can result in false positives, but many applications don't care. (I do a similar kind of approximate axis testing for GPU-side object culling and light->froxel allocation.)
Danthekilla
Posts: 136
Joined: Sun Jan 17, 2010 11:35 am

Re: Getting all entitys inside a bounding frustrum

Post by Danthekilla »

I probably should have mentioned that I am not using it for anything graphical.

I am actually using it to represent a hit area when the player attacks with a melee weapon.

So the frustum is only about 1.9 meters long in general and has a fov of 45 degrees. The idea was to find intersections within that area for figuring out what creatures have been hit.

I will probably end up using a ConvexHullShape to represent it then, I was just wondering if there was a built in method.
Post Reply