[Bf-blender-cvs] [0badb6c804c] master: Cleanup: rename dist -> depth

Campbell Barton noreply at git.blender.org
Thu Oct 5 12:29:23 CEST 2017


Commit: 0badb6c804c24d5d5f5b78e8711fcb76b7f5ee6b
Author: Campbell Barton
Date:   Thu Oct 5 21:06:04 2017 +1100
Branches: master
https://developer.blender.org/rB0badb6c804c24d5d5f5b78e8711fcb76b7f5ee6b

Cleanup: rename dist -> depth

Prepare to add code that stores distance to the ray, avoid confusion.

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

M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/blenkernel/intern/pbvh_intern.h
M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index cc84be6e2c1..08959e79740 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -101,12 +101,12 @@ void BKE_pbvh_raycast(
 bool BKE_pbvh_node_raycast(
         PBVH *bvh, PBVHNode *node, float (*origco)[3], bool use_origco,
         const float ray_start[3], const float ray_normal[3],
-        float *dist);
+        float *depth);
 
 bool BKE_pbvh_bmesh_node_raycast_detail(
         PBVHNode *node,
         const float ray_start[3], const float ray_normal[3],
-        float *dist, float *r_detail);
+        float *depth, float *r_detail);
 
 /* for orthographic cameras, project the far away ray segment points to the root node so
  * we can have better precision. */
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 4b154d3301c..bc93aa5678a 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1537,14 +1537,16 @@ void BKE_pbvh_raycast(
 bool ray_face_intersection_quad(
         const float ray_start[3], const float ray_normal[3],
         const float t0[3], const float t1[3], const float t2[3], const float t3[3],
-        float *dist)
+        float *depth)
 {
-	float dist_test;
+	float depth_test;
 
-	if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist_test, NULL, 0.1f) && (dist_test < *dist)) ||
-	    (isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist_test, NULL, 0.1f) && (dist_test < *dist)))
+	if ((isect_ray_tri_epsilon_v3(
+	         ray_start, ray_normal, t0, t1, t2, &depth_test, NULL, 0.1f) && (depth_test < *depth)) ||
+	    (isect_ray_tri_epsilon_v3(
+	         ray_start, ray_normal, t0, t2, t3, &depth_test, NULL, 0.1f) && (depth_test < *depth)))
 	{
-		*dist = dist_test;
+		*depth = depth_test;
 		return true;
 	}
 	else {
@@ -1555,12 +1557,14 @@ bool ray_face_intersection_quad(
 bool ray_face_intersection_tri(
         const float ray_start[3], const float ray_normal[3],
         const float t0[3], const float t1[3], const float t2[3],
-        float *dist)
+        float *depth)
 {
-	float dist_test;
+	float depth_test;
 
-	if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist_test, NULL, 0.1f) && (dist_test < *dist))) {
-		*dist = dist_test;
+	if ((isect_ray_tri_epsilon_v3(
+	         ray_start, ray_normal, t0, t1, t2, &depth_test, NULL, 0.1f) && (depth_test < *depth)))
+	{
+		*depth = depth_test;
 		return true;
 	}
 	else {
@@ -1572,7 +1576,7 @@ static bool pbvh_faces_node_raycast(
         PBVH *bvh, const PBVHNode *node,
         float (*origco)[3],
         const float ray_start[3], const float ray_normal[3],
-        float *dist)
+        float *depth)
 {
 	const MVert *vert = bvh->verts;
 	const MLoop *mloop = bvh->mloop;
@@ -1594,7 +1598,7 @@ static bool pbvh_faces_node_raycast(
 			        origco[face_verts[0]],
 			        origco[face_verts[1]],
 			        origco[face_verts[2]],
-			        dist);
+			        depth);
 		}
 		else {
 			/* intersect with current coordinates */
@@ -1603,7 +1607,7 @@ static bool pbvh_faces_node_raycast(
 			        vert[mloop[lt->tri[0]].v].co,
 			        vert[mloop[lt->tri[1]].v].co,
 			        vert[mloop[lt->tri[2]].v].co,
-			        dist);
+			        depth);
 		}
 	}
 
@@ -1614,7 +1618,7 @@ static bool pbvh_grids_node_raycast(
         PBVH *bvh, PBVHNode *node,
         float (*origco)[3],
         const float ray_start[3], const float ray_normal[3],
-        float *dist)
+        float *depth)
 {
 	const int totgrid = node->totprim;
 	const int gridsize = bvh->gridkey.grid_size;
@@ -1644,7 +1648,7 @@ static bool pbvh_grids_node_raycast(
 					        origco[y * gridsize + x + 1],
 					        origco[(y + 1) * gridsize + x + 1],
 					        origco[(y + 1) * gridsize + x],
-					        dist);
+					        depth);
 				}
 				else {
 					hit |= ray_face_intersection_quad(
@@ -1653,7 +1657,7 @@ static bool pbvh_grids_node_raycast(
 					        CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y),
 					        CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y + 1),
 					        CCG_grid_elem_co(&bvh->gridkey, grid, x, y + 1),
-					        dist);
+					        depth);
 				}
 			}
 		}
@@ -1668,7 +1672,7 @@ static bool pbvh_grids_node_raycast(
 bool BKE_pbvh_node_raycast(
         PBVH *bvh, PBVHNode *node, float (*origco)[3], bool use_origco,
         const float ray_start[3], const float ray_normal[3],
-        float *dist)
+        float *depth)
 {
 	bool hit = false;
 
@@ -1679,16 +1683,16 @@ bool BKE_pbvh_node_raycast(
 		case PBVH_FACES:
 			hit |= pbvh_faces_node_raycast(
 			        bvh, node, origco,
-			        ray_start, ray_normal, dist);
+			        ray_start, ray_normal, depth);
 			break;
 		case PBVH_GRIDS:
 			hit |= pbvh_grids_node_raycast(
 			        bvh, node, origco,
-			        ray_start, ray_normal, dist);
+			        ray_start, ray_normal, depth);
 			break;
 		case PBVH_BMESH:
 			hit = pbvh_bmesh_node_raycast(
-			        node, ray_start, ray_normal, dist, use_origco);
+			        node, ray_start, ray_normal, depth, use_origco);
 			break;
 	}
 
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index c5e49883dc6..529dfae05e2 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1466,7 +1466,7 @@ static bool pbvh_bmesh_collapse_short_edges(
 
 bool pbvh_bmesh_node_raycast(
         PBVHNode *node, const float ray_start[3],
-        const float ray_normal[3], float *dist,
+        const float ray_normal[3], float *depth,
         bool use_original)
 {
 	bool hit = false;
@@ -1479,7 +1479,7 @@ bool pbvh_bmesh_node_raycast(
 			        node->bm_orco[t[0]],
 			        node->bm_orco[t[1]],
 			        node->bm_orco[t[2]],
-			        dist);
+			        depth);
 		}
 	}
 	else {
@@ -1498,7 +1498,7 @@ bool pbvh_bmesh_node_raycast(
 				        v_tri[0]->co,
 				        v_tri[1]->co,
 				        v_tri[2]->co,
-				        dist);
+				        depth);
 			}
 		}
 	}
@@ -1509,7 +1509,7 @@ bool pbvh_bmesh_node_raycast(
 bool BKE_pbvh_bmesh_node_raycast_detail(
         PBVHNode *node,
         const float ray_start[3], const float ray_normal[3],
-        float *dist, float *r_detail)
+        float *depth, float *r_detail)
 {
 	if (node->flag & PBVH_FullyHidden)
 		return 0;
@@ -1531,7 +1531,7 @@ bool BKE_pbvh_bmesh_node_raycast_detail(
 			        v_tri[0]->co,
 			        v_tri[1]->co,
 			        v_tri[2]->co,
-			        dist);
+			        depth);
 
 			if (hit_local) {
 				f_hit = f;
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h
index 01057318568..7d75930b3c6 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -185,11 +185,11 @@ void pbvh_grow_nodes(PBVH *bvh, int totnode);
 bool ray_face_intersection_quad(
         const float ray_start[3], const float ray_normal[3],
         const float *t0, const float *t1, const float *t2, const float *t3,
-        float *r_dist);
+        float *depth);
 bool ray_face_intersection_tri(
         const float ray_start[3], const float ray_normal[3],
         const float *t0, const float *t1, const float *t2,
-        float *r_dist);
+        float *depth);
 void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag);
 
 /* pbvh_bmesh.c */
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 3035f4b7979..1bff1f460ea 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1538,14 +1538,14 @@ typedef struct {
 	SculptSession *ss;
 	const float *ray_start, *ray_normal;
 	bool hit;
-	float dist;
+	float depth;
 	bool original;
 } SculptRaycastData;
 
 typedef struct {
 	const float *ray_start, *ray_normal;
 	bool hit;
-	float dist;
+	float depth;
 	float detail;
 } SculptDetailRaycastData;
 
@@ -4322,10 +4322,10 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin)
 		}
 
 		if (BKE_pbvh_node_raycast(srd->ss->pbvh, node, origco, use_origco,
-		                          srd->ray_start, srd->ray_normal, &srd->dist))
+		                          srd->ray_start, srd->ray_normal, &srd->depth))
 		{
 			srd->hit = 1;
-			*tmin = srd->dist;
+			*tmin = srd->depth;
 		}
 	}
 }
@@ -4335,10 +4335,10 @@ static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin)
 	if (BKE_pbvh_node_get_tmin(node) < *tmin) {
 		SculptDetailRaycastData *srd = data_v;
 		if (BKE_pbvh_bmesh_node_raycast_detail(node, srd->ray_start, srd->ray_normal,
-		                                       &srd->dist, &srd->detail))
+		                                       &srd->depth, &srd->detail))
 		{
 			srd->hit = 1;
-			*tmin = srd->dist;
+			*tmin = srd->depth;
 		}
 	}
 }
@@ -4385,8 +4385,7 @@ bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
 	Object *ob;
 	SculptSession *ss;
 	StrokeCache *cache;
-	float ray_start[3], ray_end[3], ray_normal[3], dist;
-	SculptRaycastData srd;
+	float ray_start[3], ray_end[3], ray_normal[3], depth;
 	bool original;
 	ViewContext vc;
 
@@ -4400,28 +4399,35 @@ bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
 
 	sculpt_stroke_modifiers_check(C, ob);
 
-	dist = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original);
-
-	srd.original = original;
-	srd.ss = ob->sculpt;
-	srd.hit = 0;
-	srd.ray_start = ray_start;
-	srd.ray_normal = ray_normal;
-	srd.dist = dist;
+	depth = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original);
 
-	BKE_pbvh_raycast(ss->pbvh, sculpt_raycast_cb, &srd,
-			 ray_start, ray_normal, srd.original);
-
-	copy_v3_v3(out, ray_normal);
-	mul_v3_fl(out, srd.dist);
-	add_v3_v3(out, ray_start);
+	bool hit = false;
+	{
+		SculptRaycastData srd = {
+			.original = original,
+			.ss = ob->sculpt,
+			.hit = 0,
+			.ray_start = ray_start,
+			.ray_normal = ray_normal,
+			.depth = depth,
+		};
+		BKE_pbvh_raycast(
+		        ss->pbvh, scu

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list