Page MenuHome

Direction not normalized in isect_ray_aabb_v3_simple()?
Closed, ResolvedPublic

Description

Blender Version
2.79

Short description of error
In rna_Object_ray_cast(), which implements the code for Object.ray_cast(origin, direction, distance) in the bpy API, the direction vector is normalized before the call to BLI_bvhtree_ray_cast().

However, the more efficient bounding box test that is run before that calls isect_ray_aabb_v3_simple() with the original direction vector and it is not normalized in that function: https://developer.blender.org/diffusion/B/browse/master/source/blender/blenlib/intern/math_geom.c;f6367ecfb65502a1ec40c5e382800b2ac214a499$2479

Does it simply not matter whether a unit vector is passed or not, or could this be a bug?

Event Timeline

codemanx created this task.Jul 13 2018, 3:08 PM
Bastien Montagne (mont29) lowered the priority of this task from 90 to 50.

Checking code of said isect_ray_aabb_v3_simple makes it obvious it does not care whether direction is normalized or not, for its 'match or not match' main result.

However, it does affect the distance return parameters - which are used in said RNA function, so I guess indeed direction vector should be normalized here.

And there is also a risk of division by zero in isect_ray_aabb_v3_simple, will fix as well.