From 3d26cf112b2d1b71f908123cf72caa495e8e3f74 Mon Sep 17 00:00:00 2001 From: Germano Date: Fri, 4 May 2018 07:39:07 -0300 Subject: 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. --- source/blender/blenkernel/BKE_shrinkwrap.h | 2 +- source/blender/blenkernel/intern/constraint.c | 8 ++++---- source/blender/blenkernel/intern/shrinkwrap.c | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel') 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); } -- cgit v1.2.3 From b886cdf81d94edb62cac73578fa8ab9ede623452 Mon Sep 17 00:00:00 2001 From: Germano Date: Fri, 4 May 2018 07:43:08 -0300 Subject: Mesh Remap: Change the sphere_radius parameter instead of creating a bvhtree with epsilon equal to the value of ray_radius. This is the desirable behavior. It also removes one more use of `bvhtree_from_mesh_looptri`. --- source/blender/blenkernel/intern/mesh_remap.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c index 8dc812463db..84994e80784 100644 --- a/source/blender/blenkernel/intern/mesh_remap.c +++ b/source/blender/blenkernel/intern/mesh_remap.c @@ -543,15 +543,13 @@ void BKE_mesh_remap_calc_verts_from_dm( float *weights = MEM_mallocN(sizeof(*weights) * tmp_buff_size, __func__); dm_src->getVertCos(dm_src, vcos_src); - if (mode & MREMAP_USE_NORPROJ) { - bvhtree_from_mesh_looptri( - &treedata, dm_src, ray_radius, 2, 6); - } - else { - bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2); - } + + bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2); if (mode == MREMAP_MODE_VERT_POLYINTERP_VNORPROJ) { + if (mode & MREMAP_USE_NORPROJ) { + treedata.sphere_radius = ray_radius; + } for (i = 0; i < numverts_dst; i++) { copy_v3_v3(tmp_co, verts_dst[i].co); normal_short_to_float_v3(tmp_no, verts_dst[i].no); -- cgit v1.2.3