diff options
Diffstat (limited to 'source/blender/modifiers/intern/MOD_skin.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_skin.c | 92 |
1 files changed, 37 insertions, 55 deletions
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 222f13185ea..38ec0e8bb4c 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -77,7 +77,8 @@ #include "BKE_DerivedMesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" -#include "BKE_tessmesh.h" + +#include "bmesh.h" #include "MOD_util.h" @@ -143,6 +144,7 @@ static int is_quad_symmetric(BMVert *quad[4], const SkinModifierData *smd) { const float threshold = 0.0001f; + const float threshold_squared = threshold * threshold; int axis; for (axis = 0; axis < 3; axis++) { @@ -152,16 +154,16 @@ static int is_quad_symmetric(BMVert *quad[4], copy_v3_v3(a, quad[0]->co); a[axis] = -a[axis]; - if (len_v3v3(a, quad[1]->co) < threshold) { + if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) { copy_v3_v3(a, quad[2]->co); a[axis] = -a[axis]; - if (len_v3v3(a, quad[3]->co) < threshold) + if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) return 1; } - else if (len_v3v3(a, quad[3]->co) < threshold) { + else if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) { copy_v3_v3(a, quad[2]->co); a[axis] = -a[axis]; - if (len_v3v3(a, quad[1]->co) < threshold) + if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) return 1; } } @@ -178,13 +180,13 @@ static int quad_crosses_symmetry_plane(BMVert *quad[4], for (axis = 0; axis < 3; axis++) { if (smd->symmetry_axes & (1 << axis)) { - int i, left = 0, right = 0; + int i, left = FALSE, right = FALSE; for (i = 0; i < 4; i++) { - if (quad[i]->co[axis] < 0) - left = 1; - else if (quad[i]->co[axis] > 0) - right = 1; + if (quad[i]->co[axis] < 0.0f) + left = TRUE; + else if (quad[i]->co[axis] > 0.0f) + right = TRUE; if (left && right) return TRUE; @@ -355,7 +357,7 @@ static void merge_frame_corners(Frame **frames, int totframe) BLI_assert(frames[i] != frames[k]); side_b = frame_len(frames[k]); - thresh = minf(side_a, side_b) / 2.0f; + thresh = min_ff(side_a, side_b) / 2.0f; /* Compare with each corner of all other frames... */ for (l = 0; l < 4; l++) { @@ -642,8 +644,8 @@ typedef struct { } EdgeStackElem; static void build_emats_stack(BLI_Stack *stack, int *visited_e, EMat *emat, - const MeshElemMap *emap, const MEdge *medge, - const MVertSkin *vs, const MVert *mvert) + const MeshElemMap *emap, const MEdge *medge, + const MVertSkin *vs, const MVert *mvert) { EdgeStackElem stack_elem; float axis[3], angle; @@ -671,7 +673,7 @@ static void build_emats_stack(BLI_Stack *stack, int *visited_e, EMat *emat, /* If parent is a branch node, start a new edge chain */ if (parent_is_branch) { calc_edge_mat(emat[e].mat, mvert[parent_v].co, - mvert[v].co); + mvert[v].co); } else { /* Build edge matrix guided by parent matrix */ @@ -695,11 +697,11 @@ static void build_emats_stack(BLI_Stack *stack, int *visited_e, EMat *emat, } static EMat *build_edge_mats(const MVertSkin *vs, - const MVert *mvert, - int totvert, + const MVert *mvert, + int totvert, const MEdge *medge, - const MeshElemMap *emap, - int totedge) + const MeshElemMap *emap, + int totedge) { BLI_Stack *stack; EMat *emat; @@ -957,12 +959,12 @@ static void add_poly(SkinOutput *so, static void connect_frames(SkinOutput *so, BMVert *frame1[4], - BMVert *frame2[4]) +BMVert *frame2[4]) { BMVert *q[4][4] = {{frame2[0], frame2[1], frame1[1], frame1[0]}, - {frame2[1], frame2[2], frame1[2], frame1[1]}, - {frame2[2], frame2[3], frame1[3], frame1[2]}, - {frame2[3], frame2[0], frame1[0], frame1[3]}}; + {frame2[1], frame2[2], frame1[2], frame1[1]}, + {frame2[2], frame2[3], frame1[3], frame1[2]}, + {frame2[3], frame2[0], frame1[0], frame1[3]}}; float p[3], no[3]; int i, swap; @@ -1352,24 +1354,6 @@ static void add_quad_from_tris(SkinOutput *so, BMEdge *e, BMFace *adj[2]) add_poly(so, quad[0], quad[1], quad[2], quad[3]); } -/* Returns the number of faces that are adjacent to both f1 and f2 */ -static int BM_face_share_face_count(BMFace *f1, BMFace *f2) -{ - BMIter iter1, iter2; - BMEdge *e; - BMFace *f; - int count = 0; - - BM_ITER_ELEM (e, &iter1, f1, BM_EDGES_OF_FACE) { - BM_ITER_ELEM (f, &iter2, e, BM_FACES_OF_EDGE) { - if (f != f1 && f != f2 && BM_face_share_edge_count(f, f2)) - count++; - } - } - - return count; -} - static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd) { BMIter iter; @@ -1422,7 +1406,7 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd) } } - while (!BLI_heap_empty(heap)) { + while (!BLI_heap_is_empty(heap)) { BMFace *adj[2]; e = BLI_heap_popmin(heap); @@ -1432,7 +1416,7 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd) * share a border with another face, output as a quad */ if (!BM_elem_flag_test(adj[0], BM_ELEM_TAG) && !BM_elem_flag_test(adj[1], BM_ELEM_TAG) && - !BM_face_share_face_count(adj[0], adj[1])) + !BM_face_share_face_check(adj[0], adj[1])) { add_quad_from_tris(so, e, adj); BM_elem_flag_enable(adj[0], BM_ELEM_TAG); @@ -1544,23 +1528,23 @@ static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes, if (sn->flag & CAP_START) { if (sn->flag & ROOT) { add_poly(so, - sn->frames[0].verts[0], - sn->frames[0].verts[1], - sn->frames[0].verts[2], - sn->frames[0].verts[3]); + sn->frames[0].verts[0], + sn->frames[0].verts[1], + sn->frames[0].verts[2], + sn->frames[0].verts[3]); } else { add_poly(so, - sn->frames[0].verts[3], - sn->frames[0].verts[2], - sn->frames[0].verts[1], - sn->frames[0].verts[0]); + sn->frames[0].verts[3], + sn->frames[0].verts[2], + sn->frames[0].verts[1], + sn->frames[0].verts[0]); } } if (sn->flag & CAP_END) { add_poly(so, sn->frames[1].verts[0], - sn->frames[1].verts[1], + sn->frames[1].verts[1], sn->frames[1].verts[2], sn->frames[1].verts[3]); } @@ -1770,7 +1754,6 @@ static void skin_set_orig_indices(DerivedMesh *dm) static DerivedMesh *base_skin(DerivedMesh *origdm, SkinModifierData *smd) { - BMEditMesh fake_em; DerivedMesh *result; MVertSkin *nodes; BMesh *bm; @@ -1807,8 +1790,7 @@ static DerivedMesh *base_skin(DerivedMesh *origdm, if (!bm) return NULL; - fake_em.bm = bm; - result = CDDM_from_BMEditMesh(&fake_em, NULL, FALSE, FALSE); + result = CDDM_from_bmesh(bm, FALSE); BM_mesh_free(bm); CDDM_calc_edges(result); @@ -1861,7 +1843,7 @@ static void copyData(ModifierData *md, ModifierData *target) static DerivedMesh *applyModifierEM(ModifierData *md, Object *UNUSED(ob), - BMEditMesh *UNUSED(em), + struct BMEditMesh *UNUSED(em), DerivedMesh *dm) { DerivedMesh *result; |