RayCast seems to sometimes hit mesh in Blender 2.69 I would like to check if my camera has line-of-sight of an Empty, and I need to use Blender 2.69 although I only have 2.78 on my own system. I'm using ray_cast to determine line of sight, and it appears to work in 2.78 but not 2.69! Here's my process.

For Blender 2.78 I open up my .ply file and import the mesh, and then load in both where I'll put my camera (camera_location) and where I'll put the empty (empty_location). I don't actually create any objects just yet. Then, I use the following code to detect line-of-sight.

direction = empty_location - Vector(camera_location)
(ray_hit, location, normal, index, obj, matrix) = scene.ray_cast( camera_location, direction )


And it will hit the mesh and return the expected values. 

Now in Blender 2.69, I use a the same process, but invoke ray_cast differently because it is parametrized differently:

(ray_hit, obj, matrix, location, normal) = scene.ray_cast( camera_location, empty_location )


And sometimes it returns the expected values. Other times it seems to miss the mesh altogether and just returns ray_hit=False, location=&lt;Vector (0.0000, 0.0000, 0.0000)&gt;

Does anyone know why this could be and ideally, a solution?
I suspect that the problem is that the cast ray stops at end. In some cases, precision errors might cause the ray to stop before actually hitting the mesh. In my case, making the ray go twice as far solved the problem. Use

direction = empty_location - Vector(camera_location)
(ray_hit, obj, matrix, location, normal) = scene.ray_cast( camera_location, empty_location + direction )


for Blender 2.69