diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2018-10-03 19:09:43 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2018-10-17 17:55:34 +0300 |
commit | e5b18390fa591c8b37b9ef9884611b2888bab188 (patch) | |
tree | 78c9feebbe3d266f6c2960d9b6259743d51f60ed /source/blender/depsgraph/intern/builder | |
parent | d31ea3b89aa8d583a6d089f96dff46c0759f8c8a (diff) |
Shrinkwrap: implement the use of smooth normals in constraint & modifier.
- Use smooth normals to displace in Above Surface mode.
- Add an option to align an axis to the normal in the constraint.
I've seen people request the alignment feature, and it seems useful.
For the actual aligning I use the damped track logic.
In order to conveniently keep mesh data needed for normal
computation together, a new data structure is introduced.
Reviewers: mont29
Differential Revision: https://developer.blender.org/D3762
Diffstat (limited to 'source/blender/depsgraph/intern/builder')
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_relations.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 56c2f32b387..c40df4cb74e 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -91,6 +91,7 @@ extern "C" { #include "BKE_particle.h" #include "BKE_rigidbody.h" #include "BKE_shader_fx.h" +#include "BKE_shrinkwrap.h" #include "BKE_sound.h" #include "BKE_tracking.h" #include "BKE_world.h" @@ -986,9 +987,20 @@ void DepsgraphRelationBuilder::build_constraints(ID *id, } } else if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) { + bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data; + /* Constraints which requires the target object surface. */ ComponentKey target_key(&ct->tar->id, DEG_NODE_TYPE_GEOMETRY); add_relation(target_key, constraint_op_key, cti->name); + + /* Add dependency on normal layers if necessary. */ + if (ct->tar->type == OB_MESH && scon->shrinkType != MOD_SHRINKWRAP_NEAREST_VERTEX) { + bool track = (scon->flag & CON_SHRINKWRAP_TRACK_NORMAL) != 0; + if (track || BKE_shrinkwrap_needs_normals(scon->shrinkType, scon->shrinkMode)) { + add_customdata_mask(target_key, CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL); + } + } + /* NOTE: obdata eval now doesn't necessarily depend on the * object's transform. */ |