Cleanup: Replace GSet with Edgeset in Cloth Brush

This commit is contained in:
Pablo Dobarro 2020-06-24 15:30:54 +10:00 committed by Campbell Barton
parent d295261330
commit 5c8e349c28
2 changed files with 7 additions and 24 deletions

@ -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;

@ -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,