Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-08-26 00:03:45 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-08-26 00:03:45 +0400
commitbbce51d11691acc561f1684c20e60613941d4e9b (patch)
treeada2418ebb181015b561df9e9c92035ee2a84b43 /source/blender/bmesh/operators/bmo_beautify.c
parent1d5eff36f5bd7fc7986e59d4dbe7b885ccb50e61 (diff)
replace hashes with sets where possible.
Diffstat (limited to 'source/blender/bmesh/operators/bmo_beautify.c')
-rw-r--r--source/blender/bmesh/operators/bmo_beautify.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/source/blender/bmesh/operators/bmo_beautify.c b/source/blender/bmesh/operators/bmo_beautify.c
index 22b686db64e..3dbdb3ddc52 100644
--- a/source/blender/bmesh/operators/bmo_beautify.c
+++ b/source/blender/bmesh/operators/bmo_beautify.c
@@ -28,7 +28,7 @@
*
* In principle this is very simple however there is the possibility of
* going into an eternal loop where edges keep rotating.
- * To avoid this - each edge stores a hash of it previous
+ * To avoid this - each edge stores a set of it previous
* states so as not to rotate back.
*
* TODO
@@ -54,14 +54,14 @@ enum {
};
/* -------------------------------------------------------------------- */
-/* GHash for edge rotation */
+/* GSet for edge rotation */
typedef struct EdRotState {
int v1, v2; /* edge vert, small -> large */
int f1, f2; /* face vert, small -> large */
} EdRotState;
-static unsigned int erot_ghashutil_hash(const void *ptr)
+static unsigned int erot_gsetutil_hash(const void *ptr)
{
const EdRotState *e_state = (const EdRotState *)ptr;
unsigned int
@@ -71,7 +71,7 @@ static unsigned int erot_ghashutil_hash(const void *ptr)
hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->f2));
return hash;
}
-static int erot_ghashutil_cmp(const void *a, const void *b)
+static int erot_gsetutil_cmp(const void *a, const void *b)
{
const EdRotState *e_state_a = (const EdRotState *)a;
const EdRotState *e_state_b = (const EdRotState *)b;
@@ -86,9 +86,9 @@ static int erot_ghashutil_cmp(const void *a, const void *b)
else return 0;
}
-static GHash *erot_ghash_new(void)
+static GSet *erot_gset_new(void)
{
- return BLI_ghash_new(erot_ghashutil_hash, erot_ghashutil_cmp, __func__);
+ return BLI_gset_new(erot_gsetutil_hash, erot_gsetutil_cmp, __func__);
}
/* ensure v0 is smaller */
@@ -236,12 +236,12 @@ static float bm_edge_calc_rotate_beauty(const BMEdge *e, const int flag)
/* Update the edge cost of rotation in the heap */
/* recalc an edge in the heap (surrounding geometry has changed) */
-static void bm_edge_update_beauty_cost_single(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GHash **edge_state_arr,
+static void bm_edge_update_beauty_cost_single(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GSet **edge_state_arr,
const int flag)
{
if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
const int i = BM_elem_index_get(e);
- GHash *e_state_hash = edge_state_arr[i];
+ GSet *e_state_set = edge_state_arr[i];
if (eheap_table[i]) {
BLI_heap_remove(eheap, eheap_table[i]);
@@ -254,10 +254,10 @@ static void bm_edge_update_beauty_cost_single(BMEdge *e, Heap *eheap, HeapNode *
// BMO_elem_flag_test(bm, e->l->radial_next->f, FACE_MARK));
/* check we're not moving back into a state we have been in before */
- if (e_state_hash != NULL) {
+ if (e_state_set != NULL) {
EdRotState e_state_alt;
erot_state_alternate(e, &e_state_alt);
- if (BLI_ghash_haskey(e_state_hash, (void *)&e_state_alt)) {
+ if (BLI_gset_haskey(e_state_set, (void *)&e_state_alt)) {
// printf(" skipping, we already have this state\n");
return;
}
@@ -277,7 +277,7 @@ static void bm_edge_update_beauty_cost_single(BMEdge *e, Heap *eheap, HeapNode *
}
/* we have rotated an edge, tag other edges and clear this one */
-static void bm_edge_update_beauty_cost(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GHash **edge_state_arr,
+static void bm_edge_update_beauty_cost(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GSet **edge_state_arr,
const int flag)
{
BMLoop *l;
@@ -308,7 +308,7 @@ static void bm_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge
Heap *eheap; /* edge heap */
HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */
- GHash **edge_state_arr = MEM_callocN(edge_array_len * sizeof(GHash *), __func__);
+ GSet **edge_state_arr = MEM_callocN(edge_array_len * sizeof(GSet *), __func__);
BLI_mempool *edge_state_pool = BLI_mempool_create(sizeof(EdRotState), 512, 512, BLI_MEMPOOL_SYSMALLOC);
int i;
@@ -338,18 +338,18 @@ static void bm_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge
e = BM_edge_rotate(bm, e, false, BM_EDGEROT_CHECK_EXISTS);
if (LIKELY(e)) {
- GHash *e_state_hash = edge_state_arr[i];
+ GSet *e_state_set = edge_state_arr[i];
- /* add the new state into the hash so we don't move into this state again
+ /* add the new state into the set so we don't move into this state again
* note: we could add the previous state too but this isn't essential)
* for avoiding eternal loops */
EdRotState *e_state = BLI_mempool_alloc(edge_state_pool);
erot_state_current(e, e_state);
- if (UNLIKELY(e_state_hash == NULL)) {
- edge_state_arr[i] = e_state_hash = erot_ghash_new(); /* store previous state */
+ if (UNLIKELY(e_state_set == NULL)) {
+ edge_state_arr[i] = e_state_set = erot_gset_new(); /* store previous state */
}
- BLI_assert(BLI_ghash_haskey(e_state_hash, (void *)e_state) == false);
- BLI_ghash_insert(e_state_hash, e_state, NULL);
+ BLI_assert(BLI_gset_haskey(e_state_set, (void *)e_state) == false);
+ BLI_gset_insert(e_state_set, e_state);
// printf(" %d -> %d, %d\n", i, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2));
@@ -373,7 +373,7 @@ static void bm_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge
for (i = 0; i < edge_array_len; i++) {
if (edge_state_arr[i]) {
- BLI_ghash_free(edge_state_arr[i], NULL, NULL);
+ BLI_gset_free(edge_state_arr[i], NULL);
}
}