fast closest mesh intersect check

827 views
Skip to first unread message

Mathew Schwartz

unread,
Jun 18, 2012, 1:05:23 PM6/18/12
to python_in...@googlegroups.com
To abstract the situation, i have some large plane say at y=0 (up axis is y), ontop of the plane i have some objects, from y=2 to y=3.  from any location on the y=5 plane, i want to find out if there is an object below it or if it is a clear path to the plane at y=0. 

So i am using the openmaya.intersect(), and it works well to get the location of the intersection.  Now, i really want to be getting the closest mesh that intersects with my ray, and if that is the 0 plane then i know theres no obstruction.  From what I understand of all the intersect methods, i need to be giving a mesh and then checking if that mesh intersects.  What i want is to just find out the closest mesh that gets hit by the ray. 

I have this code that works, but its super slow when I have alot of objects in my scene and i need to test multiple locations.  Any idea how to speed it up?


thanks,

mat

http://pastebin.com/ZKPCGP7r   

Chad Vernon

unread,
Jun 18, 2012, 1:09:11 PM6/18/12
to python_in...@googlegroups.com
You could sort the meshes in a spatial partitioning data structure and then test the bounding boxes for intersections first, then do the mesh intersections.  The individual meshes themselves could also be organized in their own spatial data structure to do ray/triangle intersections.


Reply all
Reply to author
Forward
0 new messages