diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2020-07-06 20:44:30 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2020-07-06 20:44:30 +0300 |
commit | 12817083ec615f9d3e3f0261d5d4247b81bfbbf8 (patch) | |
tree | c9fc06e39d36453bb702ceb5cee93e1e05a21629 /source/blender/blenkernel/intern/cloth.c | |
parent | a856de700b4274ebc1735aa349f7425c7c23cbfc (diff) |
Cleanup: Use the BLI_edgehash API in the sewing simulation of cloths
Also remove the code in the ghash that is no longer used.
This change simplifies the existing code.
Differential Revision: https://developer.blender.org/D8219
Diffstat (limited to 'source/blender/blenkernel/intern/cloth.c')
-rw-r--r-- | source/blender/blenkernel/intern/cloth.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 6b25095a87a..7c8c1cf6653 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -30,7 +30,6 @@ #include "DNA_scene_types.h" #include "BLI_edgehash.h" -#include "BLI_ghash.h" #include "BLI_linklist.h" #include "BLI_math.h" #include "BLI_rand.h" @@ -587,7 +586,7 @@ void cloth_free_modifier(ClothModifierData *clmd) } if (cloth->sew_edge_graph) { - BLI_ghash_free(cloth->sew_edge_graph, MEM_freeN, NULL); + BLI_edgeset_free(cloth->sew_edge_graph); cloth->sew_edge_graph = NULL; } @@ -669,7 +668,7 @@ void cloth_free_modifier_extern(ClothModifierData *clmd) } if (cloth->sew_edge_graph) { - BLI_ghash_free(cloth->sew_edge_graph, MEM_freeN, NULL); + BLI_edgeset_free(cloth->sew_edge_graph); cloth->sew_edge_graph = NULL; } @@ -1557,9 +1556,8 @@ static bool find_internal_spring_target_vertex(BVHTreeFromMesh *treedata, *r_tar_v_idx = vert_idx; return true; } - - return false; - + + return false; } static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) @@ -1693,8 +1691,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW) { /* cloth->sew_edge_graph should not exist before this */ BLI_assert(cloth->sew_edge_graph == NULL); - cloth->sew_edge_graph = BLI_ghash_new( - BLI_ghashutil_inthash_v2_p, BLI_ghashutil_inthash_v2_cmp, "cloth_sewing_edges_graph"); + cloth->sew_edge_graph = BLI_edgeset_new("cloth_sewing_edges_graph"); } /* Structural springs. */ @@ -1709,18 +1706,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) spring->lin_stiffness = 1.0f; spring->type = CLOTH_SPRING_TYPE_SEWING; - /* set indices of verts of the sewing edge symmetrically in sew_edge_graph */ - unsigned int *vertex_index_pair = MEM_mallocN(sizeof(unsigned int) * 2, - "sewing_edge_index_pair_01"); - if (medge[i].v1 < medge[i].v2) { - vertex_index_pair[0] = medge[i].v1; - vertex_index_pair[1] = medge[i].v2; - } - else { - vertex_index_pair[0] = medge[i].v2; - vertex_index_pair[1] = medge[i].v1; - } - BLI_ghash_insert(cloth->sew_edge_graph, vertex_index_pair, NULL); + BLI_edgeset_insert(cloth->sew_edge_graph, medge[i].v1, medge[i].v2); } else { shrink_factor = cloth_shrink_factor(clmd, cloth->verts, spring->ij, spring->kl); |