[Bf-blender-cvs] [5c8e349c285] master: Cleanup: Replace GSet with Edgeset in Cloth Brush

Pablo Dobarro noreply at git.blender.org
Wed Jun 24 07:32:14 CEST 2020


Commit: 5c8e349c28582fa86e767cafcbd6e8474300d81f
Author: Pablo Dobarro
Date:   Wed Jun 24 15:30:54 2020 +1000
Branches: master
https://developer.blender.org/rB5c8e349c28582fa86e767cafcbd6e8474300d81f

Cleanup: Replace GSet with Edgeset in Cloth Brush

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

M	source/blender/blenkernel/BKE_paint.h
M	source/blender/editors/sculpt_paint/sculpt_cloth.c

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

diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 56503a0bcc6..d3718b70c96 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -37,8 +37,8 @@ struct Brush;
 struct CurveMapping;
 struct Depsgraph;
 struct EnumPropertyItem;
+struct EdgeSet;
 struct GHash;
-struct GSet;
 struct GridPaintMask;
 struct ImagePool;
 struct MLoop;
@@ -269,7 +269,7 @@ typedef struct SculptClothLengthConstraint {
 typedef struct SculptClothSimulation {
   SculptClothLengthConstraint *length_constraints;
   int tot_length_constraints;
-  struct GSet *created_length_constraints;
+  struct EdgeSet *created_length_constraints;
   int capacity_length_constraints;
   float *length_constraint_tweak;
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index 318919f0d48..552080fce9d 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -25,7 +25,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_dial_2d.h"
-#include "BLI_ghash.h"
+#include "BLI_edgehash.h"
 #include "BLI_gsqueue.h"
 #include "BLI_hash.h"
 #include "BLI_math.h"
@@ -106,25 +106,11 @@
 #define CLOTH_MAX_CONSTRAINTS_PER_VERTEX 1024
 #define CLOTH_SIMULATION_TIME_STEP 0.01f
 
-static void cloth_brush_constraint_key_get(int r_key[2], const int v1, const int v2)
-{
-  if (v1 < v2) {
-    r_key[0] = v1;
-    r_key[1] = v2;
-  }
-  else {
-    r_key[0] = v2;
-    r_key[1] = v1;
-  }
-}
-
 static bool cloth_brush_sim_has_length_constraint(SculptClothSimulation *cloth_sim,
                                                   const int v1,
                                                   const int v2)
 {
-  int constraint[2];
-  cloth_brush_constraint_key_get(constraint, v1, v2);
-  return BLI_gset_haskey(cloth_sim->created_length_constraints, constraint);
+  return BLI_edgeset_haskey(cloth_sim->created_length_constraints, v1, v2);
 }
 
 static void cloth_brush_add_length_constraint(SculptSession *ss,
@@ -149,9 +135,7 @@ static void cloth_brush_add_length_constraint(SculptSession *ss,
   }
 
   /* Add the constraint to the GSet to avoid creating it again. */
-  int constraint[2];
-  cloth_brush_constraint_key_get(constraint, v1, v2);
-  BLI_gset_add(cloth_sim->created_length_constraints, constraint);
+  BLI_edgeset_add(cloth_sim->created_length_constraints, v1, v2);
 }
 
 static void do_cloth_brush_build_constraints_task_cb_ex(
@@ -472,8 +456,7 @@ static void cloth_brush_build_nodes_constraints(Sculpt *sd,
   TaskParallelSettings settings;
   BKE_pbvh_parallel_range_settings(&settings, false, totnode);
 
-  cloth_sim->created_length_constraints = BLI_gset_new(
-      BLI_ghashutil_inthash_v2_p, BLI_ghashutil_inthash_v2_cmp, "created length constraints");
+  cloth_sim->created_length_constraints = BLI_edgeset_new("created length constraints");
 
   SculptThreadedTaskData build_constraints_data = {
       .sd = sd,
@@ -487,7 +470,7 @@ static void cloth_brush_build_nodes_constraints(Sculpt *sd,
   BLI_task_parallel_range(
       0, totnode, &build_constraints_data, do_cloth_brush_build_constraints_task_cb_ex, &settings);
 
-  BLI_gset_free(cloth_sim->created_length_constraints, NULL);
+  BLI_edgeset_free(cloth_sim->created_length_constraints);
 }
 
 static void cloth_brush_satisfy_constraints(SculptSession *ss,



More information about the Bf-blender-cvs mailing list