Dyntopo: Minor display optimization.

While hiding, flush the hidden flags to the faces. This avoids iterating
through all the loops while updating the GPU buffers.
This commit is contained in:
Antony Riakiotakis 2014-04-10 22:31:39 +03:00
parent 7bf62f0c60
commit 6292b60a3f
4 changed files with 26 additions and 2 deletions

View File

@ -185,6 +185,7 @@ bool BKE_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data);
struct GSet *BKE_pbvh_bmesh_node_unique_verts(PBVHNode *node);
struct GSet *BKE_pbvh_bmesh_node_other_verts(PBVHNode *node);
struct GSet *BKE_pbvh_bmesh_node_faces(PBVHNode *node);
void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node);
void BKE_pbvh_bmesh_after_stroke(PBVH *bvh);

View File

@ -1338,6 +1338,11 @@ GSet *BKE_pbvh_bmesh_node_other_verts(PBVHNode *node)
return node->bm_other_verts;
}
struct GSet *BKE_pbvh_bmesh_node_faces(PBVHNode *node)
{
return node->bm_faces;
}
/****************************** Debugging *****************************/
#if 0

View File

@ -253,6 +253,20 @@ static void partialvis_update_bmesh_verts(BMesh *bm,
}
}
static void partialvis_update_bmesh_faces(GSet *faces, PartialVisAction action)
{
GSetIterator gs_iter;
GSET_ITER (gs_iter, faces) {
BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
if ((action == PARTIALVIS_HIDE) && paint_is_bmesh_face_hidden(f))
BM_elem_flag_enable(f, BM_ELEM_HIDDEN);
else
BM_elem_flag_disable(f, BM_ELEM_HIDDEN);
}
}
static void partialvis_update_bmesh(Object *ob,
PBVH *pbvh,
PBVHNode *node,
@ -261,12 +275,13 @@ static void partialvis_update_bmesh(Object *ob,
float planes[4][4])
{
BMesh *bm;
GSet *unique, *other;
GSet *unique, *other, *faces;
bool any_changed = false, any_visible = false;
bm = BKE_pbvh_get_bmesh(pbvh);
unique = BKE_pbvh_bmesh_node_unique_verts(node);
other = BKE_pbvh_bmesh_node_other_verts(node);
faces = BKE_pbvh_bmesh_node_faces(node);
sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
@ -286,6 +301,9 @@ static void partialvis_update_bmesh(Object *ob,
&any_changed,
&any_visible);
/* finally loop over node faces and tag the ones that are fully hidden */
partialvis_update_bmesh_faces(faces, action);
if (any_changed) {
BKE_pbvh_node_mark_rebuild_draw(node);
BKE_pbvh_node_fully_hidden_set(node, !any_visible);

View File

@ -2056,7 +2056,7 @@ static int gpu_bmesh_face_visible_count(GSet *bm_faces)
GSET_ITER (gh_iter, bm_faces) {
BMFace *f = BLI_gsetIterator_getKey(&gh_iter);
if (!paint_is_bmesh_face_hidden(f))
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN))
totface++;
}