bmesh: speedup for deselecting all, (avoid topology loops since all get deselected anyway).

& some ascii art to explain BM_face_other_vert_loop() behavior.
This commit is contained in:
Campbell Barton
2012-03-06 16:17:55 +00:00
parent 0deeab95be
commit 5ba020da4f
4 changed files with 56 additions and 20 deletions

View File

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

View File

@@ -44,15 +44,21 @@
*
* Turns the face region surrounding a manifold vertex into a single polygon.
*
* \par Example:
*
* +---------+ +---------+
* | \ / | | |
* Before: | v | After: | |
* | / \ | | |
* +---------+ +---------+
*
*
* This function can also collapse edges too
* in cases when it cant merge into faces.
*
* \par Example:
*
* |=========| |=========|
* | \ / | | |
* Before: | V | After: | |
* | / \ | | |
* |=========| |=========|
*
* 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);

View File

@@ -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.
*

View File

@@ -38,7 +38,6 @@
/**
* MISC utility functions.
*
*/
int bmesh_vert_in_edge(BMEdge *e, BMVert *v)