Temporary fix for loading crash of .blends with cached frames. Also fixed some goal...
authorDaniel Genrich <daniel.genrich@gmx.net>
Tue, 18 Sep 2007 07:16:57 +0000 (07:16 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Tue, 18 Sep 2007 07:16:57 +0000 (07:16 +0000)
source/blender/blenkernel/intern/cloth.c
source/blender/blenkernel/intern/implicit.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c

index 47925e352eb1fc4cfa3c2298a408761dee861624..14370b59d68f54d07da227ca81f875c30845b5d9 100644 (file)
@@ -913,13 +913,10 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, DerivedMesh *dm, short v
        verts = clothObj->verts;
 
        for (i = 0; i < numverts; i++, verts++)
-       {                               
-               /* so this will definily be below SOFTGOALSNAP */
-               verts->goal= 0.0f; 
-               
+       {                                       
                // LATER ON, support also mass painting here
                if(clmd->sim_parms.flags & CSIMSETT_FLAG_GOAL) 
-               {                       
+               {                                               
                        dvert = dm->getVertData(dm, i, CD_MDEFORMVERT);
                        if(dvert)       
                        {               
@@ -1211,7 +1208,12 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
                                Mat4MulVecfl(ob->obmat, verts->x);
 
                                verts->mass = clmd->sim_parms.mass;
-                               verts->goal= clmd->sim_parms.defgoal;
+                               
+                               if(clmd->sim_parms.flags & CSIMSETT_FLAG_GOAL) 
+                                       verts->goal= clmd->sim_parms.defgoal;
+                               else
+                                       verts->goal= 0.0f;
+                               
                                verts->flags = 0;
                                VECCOPY(verts->xold, verts->x);
                                VECCOPY(verts->xconst, verts->x);
index 18044db6049916c50fbeb63b03ab549e0723b187..aa28f0a20869f9766d84327a40f793c7be079d0f 100644 (file)
@@ -570,7 +570,7 @@ DO_INLINE void mul_bfmatrix_S(fmatrix3x3 *matrix, float scalar)
 /* STATUS: verified */
 DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, float (*fLongVector)[3])
 {
-       int i = 0,j=0;
+       unsigned int i = 0,j=0;
        zero_lfvector(to, from[0].vcount);
        /* process diagonal elements */ 
        for(i = 0; i < from[0].vcount; i++)
index 4f1e9a5644c15f135cb06e2897375e33ca376eec..546247f8e35f571a83368ca91527b0454c575653 100644 (file)
@@ -4873,6 +4873,7 @@ static void clothModifier_deformVerts(
        DerivedMesh *dm = NULL;
 
        // if possible use/create DerivedMesh
+       
        if(derivedData) dm = CDDM_copy(derivedData);
        else if(ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob);
        
index 19f74096e540ddb8459e98bbfef83e5f4a23b061..3fbfef12f1f8f2d0558a7624e63743e41e28b6b8 100644 (file)
@@ -2878,11 +2878,13 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
                   ClothModifierData    *clmd = (ClothModifierData*) md;
 
                   clmd->clothObject = NULL;
-                       /*
-                  if (clmd->sim_parms.flags & CSIMSETT_FLAG_BAKED) {
-                         clmd->baked_data = newdataadr (fd, clmd->baked_data);
+                  clmd->sim_parms.cache = NULL;
+               
+                  if (clmd->sim_parms.cache) {
+                          // TODO 
+                         // clmd->cache = newdataadr (fd, clmd->cache);
                          printf ("direct_link_modifiers: read cloth baked_data.\n");
-                  }*/
+                  }
                } 
                else if (md->type==eModifierType_Hook) {
                        HookModifierData *hmd = (HookModifierData*) md;
index 4203824ae65af7d63650964e43d52e5e40227257..0a0c49c5ef8e0c4e4aed6d79a4c2d4dda60785a8 100644 (file)
@@ -813,6 +813,23 @@ static void write_constraint_channels(WriteData *wd, ListBase *chanbase)
 
 }
 
+/*
+// TODO: finish this
+static void write_cloth_cache(WriteData *wd, LinkNode *ln)
+{
+       
+       while(ln) {
+               writestruct(wd, DATA, "cloth_cache", 1, ln);            
+               writestruct(wd, DATA, "cloth_cache_frame", 1, ln->link);
+               writestruct(wd, DATA, "cloth_cache_frame_verts", 1, ln->link);
+               writestruct(wd, DATA, "cloth_cache_frame_springs", 1, ln->link);
+               }
+
+               ln = ln->next;
+       }
+}
+*/
+               
 static void write_modifiers(WriteData *wd, ListBase *modbase)
 {
        ModifierData *md;
@@ -832,16 +849,20 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
        else if (md->type==eModifierType_Cloth) {
                   int                                  n;
                   ClothModifierData    *clmd = (ClothModifierData *) md;
-               /*
-                  if ((clmd->sim_parms.flags & CSIMSETT_FLAG_BAKED) && clmd->baked_data) {
+
+                  if (clmd->sim_parms.cache) {
                          // Compute the number of vertices we're saving.
-                          
+                          // TODO
+                          // write_cloth_cache();
+                         /*
+                          // old code
                          n = (clmd->sim_parms.bake_end_frame - clmd->sim_parms.bake_start_frame + 1) *
                                 clmd->sim_parms.bake_num_verts;
                          writedata (wd, DATA, n *  sizeof (clmd->baked_data [0]), clmd->baked_data);
                          printf ("write_modifiers: wrote %d elements of size %d for cloth baked data.\n",
                                          n, sizeof (clmd->baked_data [0]));
-                  }*/
+                          */
+                  }
                }
        }
 }