[Bf-blender-cvs] [3d26cf112b2] master: Constraint: Shrink Warp: Replace `bvhtree_from_mesh_looptri` with` bvhtree_from_mesh_get`.

Germano noreply at git.blender.org
Fri May 4 12:39:17 CEST 2018


Commit: 3d26cf112b2d1b71f908123cf72caa495e8e3f74
Author: Germano
Date:   Fri May 4 07:39:07 2018 -0300
Branches: master
https://developer.blender.org/rB3d26cf112b2d1b71f908123cf72caa495e8e3f74

Constraint: Shrink Warp: Replace `bvhtree_from_mesh_looptri` with` bvhtree_from_mesh_get`.

The value of epsilon was never used to create this bvhtree because whenever we activate this constraint, a bvhtree with parameter epsilon 0.0 was created and cached.

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

M	source/blender/blenkernel/BKE_shrinkwrap.h
M	source/blender/blenkernel/intern/constraint.c
M	source/blender/blenkernel/intern/shrinkwrap.c

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

diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index d2ab4f3164c..31b4b5cecc5 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -90,7 +90,7 @@ void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Object
  * (where each tree was built on its own coords space)
  */
 bool BKE_shrinkwrap_project_normal(
-        char options, const float vert[3], const float dir[3],
+        char options, const float vert[3], const float dir[3], const float ray_radius,
         const struct SpaceTransform *transf, BVHTree *tree, BVHTreeRayHit *hit,
         BVHTree_RayCastCallback callback, void *userdata);
 
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 4689de825b2..88b2ca20563 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -3562,15 +3562,15 @@ static void shrinkwrap_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra
 						break;
 					}
 
-					bvhtree_from_mesh_looptri(&treeData, target, scon->dist, 4, 6);
+					bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI, 4);
 					if (treeData.tree == NULL) {
 						fail = true;
 						break;
 					}
 
-					
-					if (BKE_shrinkwrap_project_normal(0, co, no, &transform, treeData.tree, &hit,
-					                                  treeData.raycast_callback, &treeData) == false)
+					treeData.sphere_radius = scon->dist;
+					if (BKE_shrinkwrap_project_normal(0, co, no, treeData.sphere_radius, &transform, treeData.tree,
+					                                  &hit, treeData.raycast_callback, &treeData) == false)
 					{
 						fail = true;
 						break;
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index ced836181a5..bf22b106cf8 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -191,8 +191,8 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
  *	MOD_SHRINKWRAP_CULL_TARGET_BACKFACE (back faces hits are ignored)
  */
 bool BKE_shrinkwrap_project_normal(
-        char options, const float vert[3],
-        const float dir[3], const SpaceTransform *transf,
+        char options, const float vert[3], const float dir[3],
+        const float ray_radius, const SpaceTransform *transf,
         BVHTree *tree, BVHTreeRayHit *hit,
         BVHTree_RayCastCallback callback, void *userdata)
 {
@@ -229,7 +229,7 @@ bool BKE_shrinkwrap_project_normal(
 
 	hit_tmp.index = -1;
 
-	BLI_bvhtree_ray_cast(tree, co, no, 0.0f, &hit_tmp, callback, userdata);
+	BLI_bvhtree_ray_cast(tree, co, no, ray_radius, &hit_tmp, callback, userdata);
 
 	if (hit_tmp.index != -1) {
 		/* invert the normal first so face culling works on rotated objects */
@@ -322,13 +322,13 @@ static void shrinkwrap_calc_normal_projection_cb_ex(
 	if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) {
 		if (aux_tree) {
 			BKE_shrinkwrap_project_normal(
-			        0, tmp_co, tmp_no,
+			        0, tmp_co, tmp_no, 0.0,
 			        local2aux, aux_tree, hit,
 			        aux_callback, auxData);
 		}
 
 		BKE_shrinkwrap_project_normal(
-		        calc->smd->shrinkOpts, tmp_co, tmp_no,
+		        calc->smd->shrinkOpts, tmp_co, tmp_no, 0.0,
 		        &calc->local2target, targ_tree, hit,
 		        targ_callback, treeData);
 	}
@@ -340,13 +340,13 @@ static void shrinkwrap_calc_normal_projection_cb_ex(
 
 		if (aux_tree) {
 			BKE_shrinkwrap_project_normal(
-			        0, tmp_co, inv_no,
+			        0, tmp_co, inv_no, 0.0,
 			        local2aux, aux_tree, hit,
 			        aux_callback, auxData);
 		}
 
 		BKE_shrinkwrap_project_normal(
-		        calc->smd->shrinkOpts, tmp_co, inv_no,
+		        calc->smd->shrinkOpts, tmp_co, inv_no, 0.0,
 		        &calc->local2target, targ_tree, hit,
 		        targ_callback, treeData);
 	}



More information about the Bf-blender-cvs mailing list