[Bf-blender-cvs] [fd632846417] temp-angavrilov: Fix T103074: flipped vertex group meaning in Multi-Modifier Armature.

Alexander Gavrilov noreply at git.blender.org
Thu Dec 29 16:09:28 CET 2022


Commit: fd6328464172453fa76280c305249ef986348014
Author: Alexander Gavrilov
Date:   Thu Dec 15 23:37:14 2022 +0200
Branches: temp-angavrilov
https://developer.blender.org/rBfd6328464172453fa76280c305249ef986348014

Fix T103074: flipped vertex group meaning in Multi-Modifier Armature.

For some reason the Armature modifier in the Multi-Modifier mode
interpreted the vertex group in a way essentially opposite to the
regular mode. Moreover, this depended not on the Multi-Modifier
checkbox, but on whether the mode was actually active.

This fixes the flip and adds versioning code to patch old files.
One difficulty is that whether the Multi-Modifier flag is valid
can be different between the viewport and render. The versioning
code assumes any modifier enabled in either to be active.

This change is not forward compatible, so min version is also bumped.

Differential Revision: https://developer.blender.org/D16787

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

M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/intern/armature_deform.c
M	source/blender/blenloader/intern/versioning_300.cc

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

diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 2ddda93c93b..915b28e5f9b 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -25,13 +25,13 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 6
+#define BLENDER_FILE_SUBVERSION 7
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the file
  * was written with too new a version. */
 #define BLENDER_FILE_MIN_VERSION 305
-#define BLENDER_FILE_MIN_SUBVERSION 4
+#define BLENDER_FILE_MIN_SUBVERSION 7
 
 /** User readable version string. */
 const char *BKE_blender_version_string(void);
diff --git a/source/blender/blenkernel/intern/armature_deform.c b/source/blender/blenkernel/intern/armature_deform.c
index 64a3937c191..973fdbd0c57 100644
--- a/source/blender/blenkernel/intern/armature_deform.c
+++ b/source/blender/blenkernel/intern/armature_deform.c
@@ -270,7 +270,7 @@ static void armature_vert_task_with_dvert(const ArmatureUserdata *data,
   float *vec = NULL, (*smat)[3] = NULL;
   float contrib = 0.0f;
   float armature_weight = 1.0f; /* default to 1 if no overall def group */
-  float prevco_weight = 1.0f;   /* weight for optional cached vertexcos */
+  float prevco_weight = 0.0f;   /* weight for optional cached vertexcos */
 
   if (use_quaternion) {
     memset(&sumdq, 0, sizeof(DualQuat));
@@ -295,7 +295,9 @@ static void armature_vert_task_with_dvert(const ArmatureUserdata *data,
 
     /* hackish: the blending factor can be used for blending with vert_coords_prev too */
     if (vert_coords_prev) {
-      prevco_weight = armature_weight;
+      /* This weight specifies the contribution from the coordinates at the start of this
+       * modifier evaluation, while armature_weight is normally the opposite of that. */
+      prevco_weight = 1.0f - armature_weight;
       armature_weight = 1.0f;
     }
   }
diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc
index b1e207375f6..645971ee09d 100644
--- a/source/blender/blenloader/intern/versioning_300.cc
+++ b/source/blender/blenloader/intern/versioning_300.cc
@@ -3836,6 +3836,35 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
       }
     }
   }
+
+  if (!MAIN_VERSION_ATLEAST(bmain, 305, 7)) {
+    LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
+      bool after_armature = false;
+      LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
+        if (md->type == eModifierType_Armature) {
+          ArmatureModifierData *amd = (ArmatureModifierData *)md;
+          if (amd->multi) {
+            /* Toggle the invert vertex group flag on operational Multi Modifier entries. */
+            if (after_armature && amd->defgrp_name[0]) {
+              amd->deformflag ^= ARM_DEF_INVERT_VGROUP;
+            }
+          }
+          else {
+            /* Disabled multi modifiers don't reset propagation, but non-multi ones do. */
+            after_armature = false;
+          }
+          /* Multi Modifier is only valid and operational after an active Armature modifier. */
+          if (md->mode & (eModifierMode_Realtime | eModifierMode_Render)) {
+            after_armature = true;
+          }
+        }
+        else {
+          after_armature = false;
+        }
+      }
+    }
+  }
+
   /**
    * Versioning code until next subversion bump goes here.
    *



More information about the Bf-blender-cvs mailing list