Direction not normalized in isect_ray_aabb_v3_simple()? #55964

Closed
opened 2018-07-13 15:08:34 +02:00 by CodeManX · 5 comments
Member

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?

**Blender Version** 2.79 **Short description of error** In [rna_Object_ray_cast() ](https://developer.blender.org/diffusion/B/browse/master/source/blender/makesrna/intern/rna_object_api.c;f6367ecfb65502a1ec40c5e382800b2ac214a499$320), 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?
Author
Member

Added subscriber: @CodeManX

Added subscriber: @CodeManX

Added subscriber: @mont29

Added subscriber: @mont29
Bastien Montagne self-assigned this 2018-07-25 17:41:30 +02:00

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.

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.

This issue was referenced by blender/blender@29d1db9ed6

This issue was referenced by blender/blender@29d1db9ed6253f68c5452be1f0125ed364d4a954

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#55964
No description provided.