Fix for broken hair sim in old files.
authorLukas Tönne <lukas.toenne@gmail.com>
Tue, 26 Aug 2014 13:30:59 +0000 (15:30 +0200)
committerLukas Tönne <lukas.toenne@gmail.com>
Tue, 26 Aug 2014 13:57:25 +0000 (15:57 +0200)
Files older than rB37e1285 have broken hair sim due to the (hacky)
velocity "damping" factor, which is not initialized to 1.

source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/intern/particle_system.c
source/blender/blenloader/intern/versioning_270.c

index e2d4f7c5a22300b92d60899cd4ccea9acf0bd1b3..46a0c36a5f22cfcaf16f2ab079613709b60c0cb7 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         271
-#define BLENDER_SUBVERSION      5
+#define BLENDER_SUBVERSION      6
 /* 262 was the last editmesh release but it has compatibility code for bmesh data */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   5
index e32b46f4b73c11735de2d0a5b23873fca1b8686f..09e20c026917c59df590335171833f31d9f31c16 100644 (file)
@@ -4012,6 +4012,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
        if (!psys->clmd) {
                psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth);
                psys->clmd->sim_parms->goalspring = 0.0f;
+               psys->clmd->sim_parms->vel_damping = 1.0f;
                psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL|CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS;
                psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
        }
index 2e4d38eebcc98a3d492e76b41d826af96139ae12..6f8919c3693ed884b61ef2b1cf32ed648e6a258c 100644 (file)
@@ -35,6 +35,7 @@
 #define DNA_DEPRECATED_ALLOW
 
 #include "DNA_brush_types.h"
+#include "DNA_cloth_types.h"
 #include "DNA_constraint_types.h"
 #include "DNA_sdna_types.h"
 #include "DNA_space_types.h"
@@ -42,6 +43,7 @@
 #include "DNA_object_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_modifier_types.h"
+#include "DNA_particle_types.h"
 #include "DNA_linestyle_types.h"
 #include "DNA_actuator_types.h"
 
@@ -356,4 +358,19 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
                        scene->r.preview_start_resolution = 64;
                }
        }
+
+       if (!MAIN_VERSION_ATLEAST(main, 271, 6)) {
+               Object *ob;
+               for (ob = main->object.first; ob; ob = ob->id.next) {
+                       ModifierData *md;
+
+                       for (md = ob->modifiers.first; md; md = md->next) {
+                               if (md->type == eModifierType_ParticleSystem) {
+                                       ParticleSystemModifierData *pmd = (ParticleSystemModifierData*) md;
+                                       if (pmd->psys && pmd->psys->clmd)
+                                               pmd->psys->clmd->sim_parms->vel_damping = 1.0f;
+                               }
+                       }
+               }
+       }
 }