object.ray_cast() is not behaving as I would expect in Blender 2.77. I understand that it expects object local coordinates, but this problem happens when the object is not translated, rotated, or scaled.
If I edit the shape of the cube mesh without moving the cube, the results of
ray_cast() seem plain wrong.
Steps to reproduce
- Create a cube at 0,0,0
- Move a vertex of the cube from 1,1,1 to 5,5,5
- Create an empty called "src" at 2,2,2
- Create an empty called "dst" at 2,2,6
Run this python
cb = bpy.data.objects['Cube'] src = bpy.data.objects['src'] dst = bpy.data.objects['dst'] hit, loc, norm, face = cb.ray_cast(src.location, dst.location) bpy.ops.object.empty_add(location = loc)
This is the result on my system. The new Empty created at the interesection point is selected:
The source and the destination are both at x = 2 and y = 2. The cube has a surface at x = 2 and y = 2. So why on earth is the intersection point at x = 2.22222, y = 2.22222?