I've been trying to use blender for "line of sight" type tests. For this, I want to use the ray_cast function (the raycasting function not in the blender game engine). No matter what I try I can't get the code to work at all.
(assume I have 2 objects, a and b)
When I attempt to ray_cast from a to b, I can only get the correct answer if it is the first time I've used that function since opening blender, and if at least one of either the start or end locations is on the origin. Subsequent ray_casts done after moving one object do not change the result (as in, I get the same result as the first time) even after manually updating the scene. If I try to cast without either the start or end point being on the origin, then the returns null (Vector<0,0,0>, Vector<0,0,0>, -1)
I've noticed that similar things happen with other render functions, such as Object.closest_point_on_mesh, etc... can anyone help me? below is the code I use for rayCasting.
#
import bpy
def main():
a = bpy.data.objects['a']
b = bpy.data.objects['b']
x = a.ray_cast(a.location,b.location)
print(x[0])
main()
#