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.
This commit is contained in:
Germano 2018-05-04 07:39:07 -03:00
parent 82d59c6588
commit 3d26cf112b
3 changed files with 12 additions and 12 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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);
}