[Bf-blender-cvs] [6292b60] master: Dyntopo: Minor display optimization.

Antony Riakiotakis noreply at git.blender.org
Thu Apr 10 21:31:50 CEST 2014


Commit: 6292b60a3f5b1c224ec78301c7830045560fa3b4
Author: Antony Riakiotakis
Date:   Thu Apr 10 22:31:39 2014 +0300
https://developer.blender.org/rB6292b60a3f5b1c224ec78301c7830045560fa3b4

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.

===================================================================

M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/editors/sculpt_paint/paint_hide.c
M	source/blender/gpu/intern/gpu_buffers.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 73ca60d..79a41f0 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -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);
 
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 432694f..ba38327 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -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
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index 6542bb2..fb3fd10 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -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);
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 82c1469..e1db9b6 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -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++;
 	}




More information about the Bf-blender-cvs mailing list