Commit: 02281951d0fbda1231401cd38d7a8164b2213680 Author: Alexander Gavrilov Date: Thu Dec 15 23:37:14 2022 +0200 Branches: temp-angavrilov https://developer.blender.org/rB02281951d0fbda1231401cd38d7a8164b2213680
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 c95c3a1a934..f5514fcc632 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 7 +#define BLENDER_FILE_SUBVERSION 8 /* 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 8 /** 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 73efe8fbcaa..368268e4cb7 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -3845,6 +3845,38 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_ATLEAST(bmain, 305, 8)) { + 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 if (ELEM(md->type, eModifierType_Lattice, eModifierType_MeshDeform)) { + /* These modifiers will also allow a following Multi Modifier to work. */ + after_armature = (md->mode & (eModifierMode_Realtime | eModifierMode_Render)) != 0; + } + else { + after_armature = false; + } + } + } + } + /** * Versioning code until next subversion bump goes here. * _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs