Merge branch 'blender2.7'
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 27 Dec 2018 10:43:06 +0000 (11:43 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 27 Dec 2018 10:43:06 +0000 (11:43 +0100)
1  2 
source/blender/blenkernel/intern/cloth.c

index 75e1884f9a3b2c1fc0e0dd5cbdcef7c20fab92b6,5396a1905b95b6f1c52974cf1cb613701bc6581f..30b5d92bdb7ca8386b0ca075e72b4f48cbfabee8
@@@ -1341,23 -1280,18 +1341,28 @@@ static int cloth_build_springs ( ClothM
        cloth->springs = NULL;
        cloth->edgeset = NULL;
  
 -      edgelist = MEM_callocN(sizeof(*edgelist) * mvert_num, "cloth_edgelist_alloc" );
 +      if (clmd->sim_parms->bending_model == CLOTH_BENDING_ANGULAR) {
 +              spring_ref = MEM_callocN(sizeof(*spring_ref) * numedges, "temp bend spring reference");
  
 -      if (!edgelist)
 -              return 0;
 +              if (!spring_ref) {
 +                      return 0;
 +              }
 +      }
 +      else {
 +              edgelist = MEM_callocN(sizeof(*edgelist) * mvert_num, "cloth_edgelist_alloc" );
 +
 +              if (!edgelist) {
 +                      return 0;
 +              }
 +      }
  
 -      for (i = 0; i < mvert_num; i++) {
+       clmd->sim_parms->avg_spring_len = 0.0f;
 -      // structural springs
 -      for ( i = 0; i < numedges; i++ ) {
++      for (int i = 0; i < mvert_num; i++) {
+               cloth->verts[i].avg_spring_len = 0.0f;
+       }
 +      /* Structural springs. */
 +      for (int i = 0; i < numedges; i++) {
                spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
  
                if ( spring ) {