diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-08-21 10:05:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-08-21 10:09:18 +0300 |
commit | c727fc59abe2b7e525bdc6594bbd7ec3285936e0 (patch) | |
tree | dfcadf23e28c2464655f4c06a5f94621721fe0c2 /source/blender/blenlib/intern/BLI_kdopbvh.c | |
parent | a98b02ff941edb1d92892f520641433582754f0d (diff) |
BVH-raycast: ensure input direction is unit-length
This was already the case for most users of ray-cast.
Doing this avoids 2x normalize calls per ray-cast in many places.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_kdopbvh.c')
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdopbvh.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index d6d0443893e..1b9b6e38208 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -1650,6 +1650,8 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], f BVHRayCastData data; BVHNode *root = tree->nodes[tree->totleaf]; + BLI_ASSERT_UNIT_V3(dir); + data.tree = tree; data.callback = callback; @@ -1659,8 +1661,6 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], f copy_v3_v3(data.ray.direction, dir); data.ray.radius = radius; - normalize_v3(data.ray.direction); - bvhtree_ray_cast_data_precalc(&data); if (hit) @@ -1713,6 +1713,8 @@ int BLI_bvhtree_ray_cast_all(BVHTree *tree, const float co[3], const float dir[3 BVHRayCastData data; BVHNode *root = tree->nodes[tree->totleaf]; + BLI_ASSERT_UNIT_V3(dir); + data.tree = tree; data.callback = callback; @@ -1722,8 +1724,6 @@ int BLI_bvhtree_ray_cast_all(BVHTree *tree, const float co[3], const float dir[3 copy_v3_v3(data.ray.direction, dir); data.ray.radius = radius; - normalize_v3(data.ray.direction); - bvhtree_ray_cast_data_precalc(&data); data.hit.index = -1; |