Page MenuHome

ray_cast face index with n_gons
Closed, ResolvedPublic

Description

--- Operating System, Graphics card ---
Windows 7 64.

--- Blender version with error, and version that worked ---
Current build 58838
I have experienced this for a while (5 months?) but just worked around it until I thought it might be proactive to mention it

--- Short description of error ---
When using the object.ray_cast() method, if the object has ngons, and the ray intersects the n_gon, the ray_cast
function returns the face_index of the TRIANGULATED n_gon, resulting in face indices that do not exist in in the mesh.
This is troublesome for me, because I'm developing some tools which raycast the users interaction onto the object.
My workaround is to create a temporary object and triangulate it.

--- Steps for others to reproduce the error (preferably based on attached .blend file) ---
Open blender default scene
Add a cylinder primitive with ngon caps

in the python console type the following:

from mathutils import Vector
C.object.ray_cast(Vector((0,0,0)),Vector((0,0,2)))

>>>(Vector((0.0, 0.0, 0.9999999403953552)), Vector((0.0, 0.0, 0.9999999403953552)), 45)

Notice it returns 45 as the face index but there are only 34 faces in the cylinder primitive.

Event Timeline

Campbell Barton (campbellbarton) changed the task status from Unknown Status to Resolved.Aug 6 2013, 4:16 AM