diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-06 20:17:55 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-06 20:17:55 +0400 |
commit | 5ba020da4f3316c631d7c982a82e52d494930f20 (patch) | |
tree | 1b42970d4c317306c697c7e2a48517d172de1050 | |
parent | 0deeab95be36c0bedfb3dcb4fbeb8b981abfce78 (diff) |
bmesh: speedup for deselecting all, (avoid topology loops since all get deselected anyway).
& some ascii art to explain BM_face_other_vert_loop() behavior.
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.c | 27 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mods.c | 29 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 15 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_structure.c | 1 |
4 files changed, 54 insertions, 18 deletions
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 7f221381e93..f05a75e74bf 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -757,14 +757,27 @@ void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag BM_select_history_clear(bm); } - for (i = 0; i < 3; i++) { - if (htype & iter_types[i]) { + if (htype == (BM_VERT | BM_EDGE | BM_FACE) && (hflag == BM_ELEM_SELECT)) { + /* fast path for deselect all, avoid topology loops + * since we know all will be de-selected anyway. */ + for (i = 0; i < 3; i++) { ele = BM_iter_new(&iter, bm, iter_types[i], NULL); for ( ; ele; ele = BM_iter_step(&iter)) { - if (hflag & BM_ELEM_SELECT) { - BM_elem_select_set(bm, ele, FALSE); + BM_elem_flag_disable(ele, BM_ELEM_SELECT); + } + } + bm->totvertsel = bm->totedgesel = bm->totfacesel = 0; + } + else { + for (i = 0; i < 3; i++) { + if (htype & iter_types[i]) { + ele = BM_iter_new(&iter, bm, iter_types[i], NULL); + for ( ; ele; ele = BM_iter_step(&iter)) { + if (hflag & BM_ELEM_SELECT) { + BM_elem_select_set(bm, ele, FALSE); + } + BM_elem_flag_disable(ele, hflag); } - BM_elem_flag_disable(ele, hflag); } } } @@ -783,6 +796,10 @@ void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag) BM_select_history_clear(bm); } + /* note, better not attempt a fast path for selection as done with de-select + * because hidden geometry and different selection modes can give different results, + * we could ofcourse check for no hiddent faces and then use quicker method but its not worth it. */ + for (i = 0; i < 3; i++) { if (htype & iter_types[i]) { ele = BM_iter_new(&iter, bm, iter_types[i], NULL); diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 102dec7a4b4..f6bbf6b6421 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -44,15 +44,21 @@ * * Turns the face region surrounding a manifold vertex into a single polygon. * - * * \par Example: * - * |=========| |=========| + * +---------+ +---------+ * | \ / | | | - * Before: | V | After: | | + * Before: | v | After: | | * | / \ | | | - * |=========| |=========| + * +---------+ +---------+ + * * + * This function can also collapse edges too + * in cases when it cant merge into faces. + * + * \par Example: + * + * Before: +----v----+ After: +---------+ * * \note dissolves vert, in more situations then BM_disk_dissolve * (e.g. if the vert is part of a wire edge, etc). @@ -218,7 +224,6 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v) * * \return pointer to the combined face */ - BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e, const short do_del) { @@ -274,7 +279,6 @@ BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e, * * \return The newly created edge. */ - BMEdge *BM_verts_connect(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f) { BMIter fiter; @@ -562,7 +566,6 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, * * \return The New Edge */ - BMEdge *BM_vert_collapse_edge(BMesh *bm, BMEdge *ke, BMVert *kv, const short kill_degenerate_faces) { @@ -722,7 +725,9 @@ BMVert *BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **r_e, float perce return nv; } -/* split an edge multiple times evenly */ +/** + * \brief Split an edge multiple times evenly + */ BMVert *BM_edge_split_n(BMesh *bm, BMEdge *e, int numcuts) { int i; @@ -736,7 +741,9 @@ BMVert *BM_edge_split_n(BMesh *bm, BMEdge *e, int numcuts) return nv; } -/* checks if a face is valid in the data structure */ +/** + * Checks if a face is valid in the data structure + */ int BM_face_validate(BMesh *bm, BMFace *face, FILE *err) { BMIter iter; @@ -1062,7 +1069,9 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const short ccw, const short check_ return nl->e; } -/* Rip a single face from a vertex fan */ +/** + * \brief Rip a single face from a vertex fan + */ BMVert *BM_vert_rip(BMesh *bm, BMFace *sf, BMVert *sv) { return bmesh_urmv(bm, sf, sv); diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 986a60a221e..7211d080841 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -63,9 +63,20 @@ int BM_vert_in_edge(BMEdge *e, BMVert *v) } /** - * \brief BMESH OTHER EDGE IN FACE SHARING A VERTEX + * \brief Other Loop in Face Sharing an Edge * * Finds the other loop that shares \a v with \a e loop in \a f. + * + * +----------+ + * | | + * | f | + * | | + * +----------+ <-- return the face loop of this vertex. + * v --> e + * ^ ^ <------- These vert args define direction + * in the face to check. + * The faces loop direction is ignored. + * */ BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v) { @@ -86,7 +97,7 @@ BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v) } /** - * \brief BMESH NEXT LOOP IN FACE SHARING A VERTEX + * \brief Other Loop in Face Sharing a Vertex * * Finds the other loop in a face. * diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c index abce7780e79..5b4a06e372a 100644 --- a/source/blender/bmesh/intern/bmesh_structure.c +++ b/source/blender/bmesh/intern/bmesh_structure.c @@ -38,7 +38,6 @@ /** * MISC utility functions. - * */ int bmesh_vert_in_edge(BMEdge *e, BMVert *v) |