Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-04-24 16:24:53 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-04-29 20:52:11 +0300
commit047081841113da73d7a13886218f5a56cfc62de6 (patch)
tree1d1ff84acc96c4a88689a5c802a96b292fbc8487 /source/blender/modifiers/intern/MOD_armature.c
parent413ffd4606f52fe76a0a61f05582c086d37c3744 (diff)
Fix T59848: precisely represent the dependencies of Armature modifier.
When the modifier uses vertex groups, the set of the bones it actually needs is precisely defined by the set of the group names. If envelopes are enabled, this refinement is not available, because any bone can potentially be used. This can be used in the dependency graph construction to allow objects deformed by a part of the armature to be used in constraints on other bones, e.g. for placing cartoon-style face elements on top of the body mesh via Shrinkwrap constraints. Since the list of vertex group names is now used as an input by the dependency graph, adding/removing/renaming groups should now be triggering a graph rebuild. Differential Revision: https://developer.blender.org/D4715
Diffstat (limited to 'source/blender/modifiers/intern/MOD_armature.c')
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index 6a01b01c0d9..31a1f5207c6 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -24,11 +24,13 @@
#include <string.h>
#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
+#include "BKE_action.h"
#include "BKE_editmesh.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -91,7 +93,26 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
ArmatureModifierData *amd = (ArmatureModifierData *)md;
if (amd->object != NULL) {
- DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_EVAL_POSE, "Armature Modifier");
+ /* If not using envelopes, create relations to individual bones for more rigging flexibility. */
+ if ((amd->deformflag & ARM_DEF_ENVELOPE) == 0 && (amd->object->pose != NULL) &&
+ ELEM(ctx->object->type, OB_MESH, OB_LATTICE, OB_GPENCIL)) {
+ /* If neither vertex groups nor envelopes are used, the modifier has no bone dependencies. */
+ if ((amd->deformflag & ARM_DEF_VGROUP) != 0) {
+ /* Enumerate groups that match existing bones. */
+ LISTBASE_FOREACH (bDeformGroup *, dg, &ctx->object->defbase) {
+ if (BKE_pose_channel_find_name(amd->object->pose, dg->name) != NULL) {
+ /* Can't check BONE_NO_DEFORM because it can be animated. */
+ DEG_add_bone_relation(
+ ctx->node, amd->object, dg->name, DEG_OB_COMP_BONE, "Armature Modifier");
+ }
+ }
+ }
+ }
+ /* Otherwise require the whole pose to be complete. */
+ else {
+ DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_EVAL_POSE, "Armature Modifier");
+ }
+
DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_TRANSFORM, "Armature Modifier");
}
DEG_add_modifier_to_transform_relation(ctx->node, "Armature Modifier");