Use BKE_edgehash_ensure_p where possible
This commit is contained in:
parent
808de65d91
commit
5217d2bc0e
|
@ -2545,16 +2545,16 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
|
|||
const unsigned int v1 = (vtargetmap[med->v1] != -1) ? vtargetmap[med->v1] : med->v1;
|
||||
const unsigned int v2 = (vtargetmap[med->v2] != -1) ? vtargetmap[med->v2] : med->v2;
|
||||
if (LIKELY(v1 != v2)) {
|
||||
void **eh_p = BLI_edgehash_lookup_p(ehash, v1, v2);
|
||||
void **val_p;
|
||||
|
||||
if (eh_p) {
|
||||
newe[i] = GET_INT_FROM_POINTER(*eh_p);
|
||||
if (BLI_edgehash_ensure_p(ehash, v1, v2, &val_p)) {
|
||||
newe[i] = GET_INT_FROM_POINTER(*val_p);
|
||||
}
|
||||
else {
|
||||
STACK_PUSH(olde, i);
|
||||
STACK_PUSH(medge, *med);
|
||||
newe[i] = c;
|
||||
BLI_edgehash_insert(ehash, v1, v2, SET_INT_IN_POINTER(c));
|
||||
*val_p = SET_INT_IN_POINTER(c);
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1475,8 +1475,9 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool update, const bool select)
|
|||
int j, v_prev = (l + (mp->totloop - 1))->v;
|
||||
for (j = 0; j < mp->totloop; j++, l++) {
|
||||
if (v_prev != l->v) {
|
||||
if (!BLI_edgehash_haskey(eh, v_prev, l->v)) {
|
||||
BLI_edgehash_insert(eh, v_prev, l->v, NULL);
|
||||
void **val_p;
|
||||
if (!BLI_edgehash_ensure_p(eh, v_prev, l->v, &val_p)) {
|
||||
*val_p = NULL;
|
||||
}
|
||||
}
|
||||
v_prev = l->v;
|
||||
|
|
|
@ -430,17 +430,19 @@ void BLI_polyfill_beautify(
|
|||
}
|
||||
|
||||
if (!is_boundary_edge(e_pair[0], e_pair[1], coord_last)) {
|
||||
struct PolyEdge *e = BLI_edgehash_lookup(ehash, e_pair[0], e_pair[1]);
|
||||
if (e == NULL) {
|
||||
struct PolyEdge *e;
|
||||
void **val_p;
|
||||
|
||||
if (!BLI_edgehash_ensure_p(ehash, e_pair[0], e_pair[1], &val_p)) {
|
||||
e = &edges[edges_tot_used++];
|
||||
BLI_edgehash_insert(ehash, e_pair[0], e_pair[1], e);
|
||||
*val_p = e;
|
||||
memcpy(e->verts, e_pair, sizeof(e->verts));
|
||||
#ifndef NDEBUG
|
||||
e->faces[!e_index] = (unsigned int)-1;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
|
||||
e = *val_p;
|
||||
/* ensure each edge only ever has 2x users */
|
||||
#ifndef NDEBUG
|
||||
BLI_assert(e->faces[e_index] == (unsigned int)-1);
|
||||
|
|
|
@ -86,20 +86,19 @@ bool BM_mesh_validate(BMesh *bm)
|
|||
|
||||
/* check edges */
|
||||
BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) {
|
||||
BMEdge *e_other;
|
||||
void **val_p;
|
||||
|
||||
if (e->v1 == e->v2) {
|
||||
ERRMSG("edge %d: duplicate index: %d", i, BM_elem_index_get(e->v1));
|
||||
}
|
||||
|
||||
|
||||
/* build edgehash at the same time */
|
||||
e_other = BLI_edgehash_lookup(edge_hash, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2));
|
||||
if (e_other) {
|
||||
if (BLI_edgehash_ensure_p(edge_hash, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2), &val_p)) {
|
||||
BMEdge *e_other = *val_p;
|
||||
ERRMSG("edge %d, %d: are duplicates", i, BM_elem_index_get(e_other));
|
||||
}
|
||||
else {
|
||||
BLI_edgehash_insert(edge_hash, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2), e);
|
||||
*val_p = e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,12 +127,12 @@ struct LaplacianSystem {
|
|||
|
||||
static void laplacian_increase_edge_count(EdgeHash *edgehash, int v1, int v2)
|
||||
{
|
||||
void **p = BLI_edgehash_lookup_p(edgehash, v1, v2);
|
||||
void **p;
|
||||
|
||||
if (p)
|
||||
if (BLI_edgehash_ensure_p(edgehash, v1, v2, &p))
|
||||
*p = (void *)((intptr_t)*p + (intptr_t)1);
|
||||
else
|
||||
BLI_edgehash_insert(edgehash, v1, v2, (void *)(intptr_t)1);
|
||||
*p = (void *)((intptr_t)1);
|
||||
}
|
||||
|
||||
static int laplacian_edge_count(EdgeHash *edgehash, int v1, int v2)
|
||||
|
|
Loading…
Reference in New Issue