Cloth: Bugfix for wrong number of bending springs, could result in visual artifacts
authorDaniel Genrich <daniel.genrich@gmx.net>
Wed, 20 Feb 2008 15:54:34 +0000 (15:54 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Wed, 20 Feb 2008 15:54:34 +0000 (15:54 +0000)
source/blender/blenkernel/intern/cloth.c

index 802e14b683f8d39f1030465bb422ab59f65c2e04..ec128bc3a0295ca71ac37703b4e4f1c2a077fdd7 100644 (file)
@@ -1210,7 +1210,6 @@ int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
        EdgeHash *edgehash = NULL;
        LinkNode *search = NULL, *search2 = NULL;
        float temp[3];
-       LinkNode *node = NULL, *node2 = NULL;
        
        // error handling
        if ( numedges==0 )
@@ -1251,11 +1250,7 @@ int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
                        spring->stiffness = (cloth->verts[spring->kl].struct_stiff + cloth->verts[spring->ij].struct_stiff) / 2.0;
                        struct_springs++;
                        
-                       if(!i)
-                               node2 = BLI_linklist_append_fast ( &cloth->springs, spring );
-                       else
-                               node2 = BLI_linklist_append_fast ( &node->next, spring );
-                       node = node2;
+                       BLI_linklist_prepend ( &cloth->springs, spring );
                }
        }
        
@@ -1282,8 +1277,7 @@ int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
                BLI_linklist_append ( &edgelist[spring->kl], spring );
                shear_springs++;
 
-               node2 = BLI_linklist_append_fast ( &node->next, spring );
-               node = node2;
+               BLI_linklist_prepend ( &cloth->springs, spring );
 
                if ( mface[i].v4 )
                {
@@ -1300,8 +1294,7 @@ int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
                        BLI_linklist_append ( &edgelist[spring->kl], spring );
                        shear_springs++;
 
-                       node2 = BLI_linklist_append_fast ( &node->next, spring );
-                       node = node2;
+                       BLI_linklist_prepend ( &cloth->springs, spring );
                }
        }
        
@@ -1336,8 +1329,7 @@ int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
                                BLI_edgehash_insert ( edgehash, spring->ij, index2, NULL );
                                bend_springs++;
 
-                               node2 = BLI_linklist_append_fast ( &node->next, spring );
-                               node = node2;
+                               BLI_linklist_prepend ( &cloth->springs, spring );
                        }
                        search = search->next;
                }