Space.RayCast

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
jstroh
Posts: 37
Joined: Fri May 02, 2008 9:33 am

Space.RayCast

Post by jstroh »

I'm getting ready to implement decals and it would be super extra awesome if there was a version of this function that returned the triangle hit in a statictrianglegroup and maybe n iterations of the triangles around it. Possible? Purdy please? Purdy purdy please?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Space.RayCast

Post by Norbo »

Static triangle groups/terrains don't actually have triangles until something is near them for optimization purposes, so a raycast can only test against the geometry that could be present (though this would be fairly easy to circumvent with a group-specific ray check that just returns the positions of the vertices). Additionally, the only connectivity information stored by the static triangle group is through its index buffer, which doesn't lend itself to easily/quickly searching outward from a hit triangle.

I'll do some more investigating, but with the way things are set up, I suspect the final result may be, at best, a bit slow. It also will not be integrated directly with space.rayCast, but instead a special method for the static triangle group.
jstroh
Posts: 37
Joined: Fri May 02, 2008 9:33 am

Re: Space.RayCast

Post by jstroh »

Ok thanks much. I should just do my own raycast against my triangles. I already have a connectivity graph for navigation mesh generation.

Any advice on how to structure a triangle soup for fast ray/triangle?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Space.RayCast

Post by Norbo »

One good way would be to create a bounding volume hierarchy, like what is used internally in the static triangle group. From there, it only takes O(log(n)) ray-AABB tests to get down to the exact triangle. I've previously gone over some of the implementation details in a post in an earlier thread (http://www.bepu-games.com/forums/viewto ... &sk=t&sd=a).
Post Reply