Fix T59587: Hair dynamics works different when opened in 2.8
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 7 Feb 2019 10:46:17 +0000 (11:46 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 7 Feb 2019 10:48:42 +0000 (11:48 +0100)
Is a missing do-verisoning code in e3d31b8dfbd.

Unfortunately, at this point it is rather tricky to tell old and new
hair dynamics modifiers apart. Probably easier to accept possible
breackage of the files which were created in 2.7 and saved during
2.8 which had incomplete do-version code.

source/blender/blenloader/intern/versioning_280.c

index 136891ee96e390139b0b8673932f11d2f23d751f..1510b339c98ddeae6407c01d302a73ceb270d4ff 100644 (file)
@@ -1981,9 +1981,16 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
                if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "short", "bending_model")) {
                        for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
                                for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+                                       ClothModifierData *clmd = NULL;
                                        if (md->type == eModifierType_Cloth) {
-                                               ClothModifierData *clmd = (ClothModifierData *)md;
-
+                                               clmd = (ClothModifierData *)md;
+                                       }
+                                       else if (md->type == eModifierType_ParticleSystem) {
+                                               ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
+                                               ParticleSystem *psys = psmd->psys;
+                                               clmd = psys->clmd;
+                                       }
+                                       if (clmd != NULL) {
                                                clmd->sim_parms->bending_model = CLOTH_BENDING_LINEAR;
                                                clmd->sim_parms->tension = clmd->sim_parms->structural;
                                                clmd->sim_parms->compression = clmd->sim_parms->structural;