[Bf-blender-cvs] [5cc7036aa39] master: Factorize some common modifiers depsgraph relation update code.

Bastien Montagne noreply at git.blender.org
Sat Apr 11 17:17:05 CEST 2020


Commit: 5cc7036aa39506f3af3608ad450f1fdf6b2f3347
Author: Bastien Montagne
Date:   Fri Apr 10 22:00:21 2020 +0200
Branches: master
https://developer.blender.org/rB5cc7036aa39506f3af3608ad450f1fdf6b2f3347

Factorize some common modifiers depsgraph relation update code.

Add a utility to deal with common 'object or posebone transform' case.

===================================================================

M	source/blender/modifiers/intern/MOD_displace.c
M	source/blender/modifiers/intern/MOD_util.c
M	source/blender/modifiers/intern/MOD_util.h
M	source/blender/modifiers/intern/MOD_uvwarp.c
M	source/blender/modifiers/intern/MOD_warp.c
M	source/blender/modifiers/intern/MOD_wave.c
M	source/blender/modifiers/intern/MOD_weightvgedit.c
M	source/blender/modifiers/intern/MOD_weightvgmix.c
M	source/blender/modifiers/intern/MOD_weightvgproximity.c

===================================================================

diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index a03167c082f..b074e398ab6 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -135,14 +135,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
 {
   DisplaceModifierData *dmd = (DisplaceModifierData *)md;
   if (dmd->map_object != NULL && dmd->texmapping == MOD_DISP_MAP_OBJECT) {
-    if (dmd->map_bone[0] && dmd->map_object->type == OB_ARMATURE) {
-      DEG_add_object_relation(
-          ctx->node, dmd->map_object, DEG_OB_COMP_EVAL_POSE, "Displace Modifier");
-    }
-    else {
-      DEG_add_object_relation(
-          ctx->node, dmd->map_object, DEG_OB_COMP_TRANSFORM, "Displace Modifier");
-    }
+    MOD_depsgraph_update_object_bone_relation(
+        ctx->node, dmd->map_object, dmd->map_bone, "Displace Modifier");
     DEG_add_modifier_to_transform_relation(ctx->node, "Displace Modifier");
   }
   if (dmd->texmapping == MOD_DISP_MAP_GLOBAL ||
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 912b4a871a6..f6b7c829c13 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -262,6 +262,22 @@ void MOD_get_vgroup(
   }
 }
 
+void MOD_depsgraph_update_object_bone_relation(struct DepsNodeHandle *node,
+                                               Object *object,
+                                               const char *bonename,
+                                               const char *description)
+{
+  if (object == NULL) {
+    return;
+  }
+  if (bonename[0] != '\0' && object->type == OB_ARMATURE) {
+    DEG_add_object_relation(node, object, DEG_OB_COMP_EVAL_POSE, description);
+  }
+  else {
+    DEG_add_object_relation(node, object, DEG_OB_COMP_TRANSFORM, description);
+  }
+}
+
 /* only called by BKE_modifier.h/modifier.c */
 void modifier_type_init(ModifierTypeInfo *types[])
 {
diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h
index e1991de3bb8..38e2083082d 100644
--- a/source/blender/modifiers/intern/MOD_util.h
+++ b/source/blender/modifiers/intern/MOD_util.h
@@ -56,4 +56,8 @@ void MOD_get_vgroup(struct Object *ob,
                     struct MDeformVert **dvert,
                     int *defgrp_index);
 
+void MOD_depsgraph_update_object_bone_relation(struct DepsNodeHandle *node,
+                                               struct Object *object,
+                                               const char *bonename,
+                                               const char *description);
 #endif /* __MOD_UTIL_H__ */
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index 46298c0e00d..6545159bdde 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -233,26 +233,14 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk,
   walk(userData, ob, &umd->object_src, IDWALK_CB_NOP);
 }
 
-static void uv_warp_deps_object_bone_new(struct DepsNodeHandle *node,
-                                         Object *object,
-                                         const char *bonename)
-{
-  if (object != NULL) {
-    if (object->type == OB_ARMATURE && bonename[0]) {
-      DEG_add_object_relation(node, object, DEG_OB_COMP_EVAL_POSE, "UVWarp Modifier");
-    }
-    else {
-      DEG_add_object_relation(node, object, DEG_OB_COMP_TRANSFORM, "UVWarp Modifier");
-    }
-  }
-}
-
 static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
 {
   UVWarpModifierData *umd = (UVWarpModifierData *)md;
 
-  uv_warp_deps_object_bone_new(ctx->node, umd->object_src, umd->bone_src);
-  uv_warp_deps_object_bone_new(ctx->node, umd->object_dst, umd->bone_dst);
+  MOD_depsgraph_update_object_bone_relation(
+      ctx->node, umd->object_src, umd->bone_src, "UVWarp Modifier");
+  MOD_depsgraph_update_object_bone_relation(
+      ctx->node, umd->object_dst, umd->bone_dst, "UVWarp Modifier");
 
   DEG_add_modifier_to_transform_relation(ctx->node, "UVWarp Modifier");
 }
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 732644411b0..d5826342e07 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -152,31 +152,22 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void
   walk(userData, ob, md, "texture");
 }
 
-static void warp_deps_object_bone_new(struct DepsNodeHandle *node,
-                                      Object *object,
-                                      const char *bonename)
-{
-  if (bonename[0] && object->type == OB_ARMATURE) {
-    DEG_add_object_relation(node, object, DEG_OB_COMP_EVAL_POSE, "Warp Modifier");
-  }
-  else {
-    DEG_add_object_relation(node, object, DEG_OB_COMP_TRANSFORM, "Warp Modifier");
-  }
-}
-
 static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
 {
   WarpModifierData *wmd = (WarpModifierData *)md;
 
   if (wmd->object_from != NULL && wmd->object_to != NULL) {
-    warp_deps_object_bone_new(ctx->node, wmd->object_from, wmd->bone_from);
-    warp_deps_object_bone_new(ctx->node, wmd->object_to, wmd->bone_to);
+    MOD_depsgraph_update_object_bone_relation(
+        ctx->node, wmd->object_from, wmd->bone_from, "Warp Modifier");
+    MOD_depsgraph_update_object_bone_relation(
+        ctx->node, wmd->object_to, wmd->bone_to, "Warp Modifier");
 
     DEG_add_modifier_to_transform_relation(ctx->node, "Warp Modifier");
   }
 
   if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != NULL) {
-    warp_deps_object_bone_new(ctx->node, wmd->map_object, wmd->map_bone);
+    MOD_depsgraph_update_object_bone_relation(
+        ctx->node, wmd->map_object, wmd->map_bone, "Warp Modifier");
 
     DEG_add_modifier_to_transform_relation(ctx->node, "Warp Modifier map");
   }
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 024d70bcfda..02950870e8e 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -98,22 +98,16 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void
 static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
 {
   WaveModifierData *wmd = (WaveModifierData *)md;
+
   if (wmd->objectcenter != NULL) {
     DEG_add_object_relation(ctx->node, wmd->objectcenter, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
   }
-  if (wmd->map_object != NULL) {
-    if (wmd->map_bone[0] && wmd->map_object->type == OB_ARMATURE) {
-      DEG_add_object_relation(
-          ctx->node, wmd->map_object, DEG_OB_COMP_EVAL_POSE, "Wave Modifier");
-    }
-    else {
-      DEG_add_object_relation(
-          ctx->node, wmd->map_object, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
-    }
-  }
+  MOD_depsgraph_update_object_bone_relation(
+      ctx->node, wmd->map_object, wmd->map_bone, "Wave Modifier");
   if (wmd->objectcenter != NULL || wmd->map_object != NULL) {
     DEG_add_modifier_to_transform_relation(ctx->node, "Wave Modifier");
   }
+
   if (wmd->texture != NULL) {
     DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Wave Modifier");
   }
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index e304ca31e86..c80a5f63903 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -45,6 +45,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "MOD_modifiertypes.h"
+#include "MOD_util.h"
 #include "MOD_weightvg_util.h"
 
 /**************************************
@@ -135,14 +136,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
 {
   WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
   if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
-    if (wmd->mask_tex_map_bone[0] && wmd->mask_tex_map_obj->type == OB_ARMATURE) {
-      DEG_add_object_relation(
-          ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_EVAL_POSE, "WeightVGEdit Modifier");
-    }
-    else {
-      DEG_add_object_relation(
-          ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGEdit Modifier");
-    }
+    MOD_depsgraph_update_object_bone_relation(
+        ctx->node, wmd->mask_tex_map_obj, wmd->mask_tex_map_bone, "WeightVGEdit Modifier");
     DEG_add_modifier_to_transform_relation(ctx->node, "WeightVGEdit Modifier");
   }
   else if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) {
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index b109d0af5aa..e764b354ba5 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -43,6 +43,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "MOD_modifiertypes.h"
+#include "MOD_util.h"
 #include "MOD_weightvg_util.h"
 
 /**
@@ -181,14 +182,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
 {
   WeightVGMixModifierData *wmd = (WeightVGMixModifierData *)md;
   if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
-    if (wmd->mask_tex_map_bone[0] && wmd->mask_tex_map_obj->type == OB_ARMATURE) {
-      DEG_add_object_relation(
-          ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_EVAL_POSE, "WeightVGMix Modifier");
-    }
-    else {
-      DEG_add_object_relation(
-          ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGMix Modifier");
-    }
+    MOD_depsgraph_update_object_bone_relation(
+        ctx->node, wmd->mask_tex_map_obj, wmd->mask_tex_map_bone, "WeightVGMix Modifier");
     DEG_add_object_relation(
         ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_GEOMETRY, "WeightVGMix Modifier");
 
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list