diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2018-07-08 13:47:26 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2018-10-01 15:47:03 +0300 |
commit | e38a0b3748683a35601c256053f716ad8b57002f (patch) | |
tree | 940e008c1259316cf58921538b96b208fce84da0 /source/blender/blenkernel | |
parent | be0e58d980d963c60869c412ada86641baaa2e48 (diff) |
Shrinkwrap Constraint: implement projection features from the modifier.
Allow raycasting in two directions and culling front or back faces.
Also implement a new Invert Cull option in both constraint and
modifier that can be used to aim for faces aligned with the project
axis direction when raycasting both ways.
Reviewers: mont29
Differential Revision: https://developer.blender.org/D3737
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/shrinkwrap.c | 10 |
2 files changed, 26 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index b1a7c98dc9c..575f534c7ca 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3533,8 +3533,24 @@ static void shrinkwrap_get_tarmat(struct Depsgraph *depsgraph, bConstraint *con, break; } - if (BKE_shrinkwrap_project_normal(0, co, no, 0.0f, &transform, treeData.tree, - &hit, treeData.raycast_callback, &treeData) == false) + char cull_mode = scon->flag & CON_SHRINKWRAP_PROJECT_CULL_MASK; + + BKE_shrinkwrap_project_normal(cull_mode, co, no, 0.0f, &transform, treeData.tree, + &hit, treeData.raycast_callback, &treeData); + + if (scon->flag & CON_SHRINKWRAP_PROJECT_OPPOSITE) { + float inv_no[3]; + negate_v3_v3(inv_no, no); + + if ((scon->flag & CON_SHRINKWRAP_PROJECT_INVERT_CULL) && (cull_mode != 0)) { + cull_mode ^= CON_SHRINKWRAP_PROJECT_CULL_MASK; + } + + BKE_shrinkwrap_project_normal(cull_mode, co, inv_no, 0.0f, &transform, treeData.tree, + &hit, treeData.raycast_callback, &treeData); + } + + if (hit.index < 0) { fail = true; break; diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 21b21d6ddd8..5408c07adf1 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -240,7 +240,7 @@ bool BKE_shrinkwrap_project_normal( BLI_space_transform_invert_normal(transf, hit_tmp.no); } - if (options & (MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE | MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) { + if (options & MOD_SHRINKWRAP_CULL_TARGET_MASK) { /* apply backface */ const float dot = dot_v3v3(dir, hit_tmp.no); if (((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) || @@ -341,6 +341,12 @@ static void shrinkwrap_calc_normal_projection_cb_ex( float inv_no[3]; negate_v3_v3(inv_no, tmp_no); + char options = calc->smd->shrinkOpts; + + if ((options & MOD_SHRINKWRAP_INVERT_CULL_TARGET) && (options & MOD_SHRINKWRAP_CULL_TARGET_MASK)) { + options ^= MOD_SHRINKWRAP_CULL_TARGET_MASK; + } + if (aux_tree) { BKE_shrinkwrap_project_normal( 0, tmp_co, inv_no, 0.0, @@ -349,7 +355,7 @@ static void shrinkwrap_calc_normal_projection_cb_ex( } BKE_shrinkwrap_project_normal( - calc->smd->shrinkOpts, tmp_co, inv_no, 0.0, + options, tmp_co, inv_no, 0.0, &calc->local2target, targ_tree, hit, targ_callback, treeData); } |