Page 1 of 1

Space.RayCast

Posted: Fri May 30, 2008 5:35 pm
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?

Re: Space.RayCast

Posted: Fri May 30, 2008 8:05 pm
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.

Re: Space.RayCast

Posted: Fri May 30, 2008 9:05 pm
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?

Re: Space.RayCast

Posted: Fri May 30, 2008 9:56 pm
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).