Commit: d5e022941609b3f824ae0a244e966ba320455343
Author: ishbosamiya
Date:   Thu Jun 20 11:36:44 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rBd5e022941609b3f824ae0a244e966ba320455343

Cloth: adding vertices into Cloth is faster now

Instead of increasing the size of cloth->verts by one each time, it is much 
faster and better to do so before itself, number of vertices that will be added 
is already known.

===================================================================

M       source/blender/blenkernel/intern/cloth.c

===================================================================

diff --git a/source/blender/blenkernel/intern/cloth.c 
b/source/blender/blenkernel/intern/cloth.c
index 9d8d0406384..fff43461bb7 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -1090,22 +1090,25 @@ static bool 
cloth_remeshing_split_edges(ClothModifierData *clmd, LinkNodePair *s
   if (num_bad_edges == 0) {
     return false;
   }
+  Cloth *cloth = clmd->clothObject;
+  cloth->verts = MEM_reallocN(cloth->verts,
+                              (cloth->mvert_num + num_bad_edges) * 
sizeof(ClothVertex));
   BMEdge *e;
   for (int i = 0; i < num_bad_edges; i++) {
     e = bad_edges[i];
     BMEdge old_edge = *e;
     BMVert *new_vert = cloth_remeshing_split_edge_keep_triangles(bm, e, e->v1, 
0.5);
     BM_elem_flag_enable(new_vert, BM_ELEM_SELECT);
-    Cloth *cloth = clmd->clothObject;
-    cloth->verts = MEM_reallocN(cloth->verts, (cloth->mvert_num + 1) * 
sizeof(ClothVertex));
     BLI_assert(cloth->verts != NULL);
     ClothVertex *v1, *v2;
     v1 = cloth_remeshing_find_cloth_vertex(old_edge.v1, cloth->verts, 
cloth->mvert_num);
     v2 = cloth_remeshing_find_cloth_vertex(old_edge.v2, cloth->verts, 
cloth->mvert_num);
+#if 0
     printf("v: %f %f %f\n", old_edge.v1->co[0], old_edge.v1->co[1], 
old_edge.v1->co[2]);
     cloth_remeshing_print_all_verts(cloth->verts, cloth->mvert_num);
     printf("v: %f %f %f\n", old_edge.v2->co[0], old_edge.v2->co[1], 
old_edge.v2->co[2]);
     cloth_remeshing_print_all_verts(cloth->verts, cloth->mvert_num);
+#endif
     BLI_assert(v1 != NULL);
     BLI_assert(v2 != NULL);
     cloth->mvert_num += 1;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to