[Bf-blender-cvs] [921c829] master: Code cleanup: redundant normalize in bmbvh ray cast

Campbell Barton noreply at git.blender.org
Wed Mar 12 08:32:22 CET 2014


Commit: 921c829bcf51c6cf55456f4983a3647569592ba4
Author: Campbell Barton
Date:   Wed Mar 12 15:50:18 2014 +1100
https://developer.blender.org/rB921c829bcf51c6cf55456f4983a3647569592ba4

Code cleanup: redundant normalize in bmbvh ray cast

===================================================================

M	source/blender/blenkernel/intern/editmesh_bvh.c
M	source/blender/blenlib/intern/BLI_kdopbvh.c

===================================================================

diff --git a/source/blender/blenkernel/intern/editmesh_bvh.c b/source/blender/blenkernel/intern/editmesh_bvh.c
index 018a919..943469e 100644
--- a/source/blender/blenkernel/intern/editmesh_bvh.c
+++ b/source/blender/blenkernel/intern/editmesh_bvh.c
@@ -217,11 +217,8 @@ static void bmbvh_ray_cast_cb(void *userdata, int index, const BVHTreeRay *ray,
 
 		copy_v3_v3(hit->no, ltri[0]->f->no);
 
-		copy_v3_v3(hit->co, ray->direction);
-		normalize_v3(hit->co);
-		mul_v3_fl(hit->co, dist);
-		add_v3_v3(hit->co, ray->origin);
-		
+		madd_v3_v3v3fl(hit->co, ray->origin, ray->direction, dist);
+
 		copy_v2_v2(bmcb_data->uv, uv);
 	}
 }
@@ -310,10 +307,7 @@ static void bmbvh_find_face_segment_cb(void *userdata, int index, const BVHTreeR
 
 		copy_v3_v3(hit->no, ltri[0]->f->no);
 
-		copy_v3_v3(hit->co, ray->direction);
-		normalize_v3(hit->co);
-		mul_v3_fl(hit->co, dist);
-		add_v3_v3(hit->co, ray->origin);
+		madd_v3_v3v3fl(hit->co, ray->origin, ray->direction, dist);
 
 		copy_v2_v2(bmcb_data->uv, uv);
 	}
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 5d97c1c..41c5707 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -1440,7 +1440,7 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node)
 	}
 	else {
 		/* pick loop direction to dive into the tree (based on ray direction and split axis) */
-		if (data->ray_dot_axis[(int)node->main_axis] > 0.0f) {
+		if (data->ray_dot_axis[node->main_axis] > 0.0f) {
 			for (i = 0; i != node->totnode; i++) {
 				dfs_raycast(data, node->children[i]);
 			}
@@ -1541,16 +1541,12 @@ float BLI_bvhtree_bb_raycast(const float bv[6], const float light_start[3], cons
 	data.hit.dist = FLT_MAX;
 	
 	/* get light direction */
-	data.ray.direction[0] = light_end[0] - light_start[0];
-	data.ray.direction[1] = light_end[1] - light_start[1];
-	data.ray.direction[2] = light_end[2] - light_start[2];
+	sub_v3_v3v3(data.ray.direction, light_end, light_start);
 	
 	data.ray.radius = 0.0;
 	
-	data.ray.origin[0] = light_start[0];
-	data.ray.origin[1] = light_start[1];
-	data.ray.origin[2] = light_start[2];
-	
+	copy_v3_v3(data.ray.origin, light_start);
+
 	normalize_v3(data.ray.direction);
 	copy_v3_v3(data.ray_dot_axis, data.ray.direction);




More information about the Bf-blender-cvs mailing list