Page 1 of 1

Grouping entities for raycasting

Posted: Sat Dec 18, 2010 7:43 pm
by seabert
Hi Norbo / everyone!

In my project I would like to do some ray casting against entities. The problem is I don't want to check every entity in the space. (Only terrain/debris/etc. )
What is the best practice to handle this? Ideally I'd love to add entities to a group and add that group to the space or something.


Thanks in advance!

Re: Grouping entities for raycasting

Posted: Sat Dec 18, 2010 8:18 pm
by Norbo
Right now, there's not a great option other than maybe trying to create a separate broadphase. That will probably have difficulties of its own in the current version. Filtering using the multi-hit raycast method versions are probably the simplest/best bet.

In v0.15.0, in addition to the raycasting overhaul, there are a few new data structures. All of the collision objects implement an interface which allow them to be used with them. You could add the objects that you're interested in raycasting against to one of these BoundingBoxTrees and query them speedily. The BoundingBoxTree is designed to be used with objects which generally don't move significantly relative to each other, though.

Later (probably v0.16.0), there will also be a specialized dynamic bounding hierarchy similar to the current broadphase that can be used separately for raycasting acceleration. This structure will likely also be used to accelerate raycasts on future broadphases whose structure doesn't immediately offer raycast acceleration.

Re: Grouping entities for raycasting

Posted: Sat Dec 18, 2010 8:24 pm
by seabert
All right cheers Norbo for the fast reply.
I will use your method until the new version arrives.

Keep up the awesome work :o