[Bf-blender-cvs] [26aeb81] master: Slightly improve undo performance in dyntopo when last operator was mask modification. In that case no pbvh needs to be freed and recreated and we can get away just with draw buffer update (all of them for now. When pbvh nodes get logged for undo we will be able to only update the affected ones).

Antony Riakiotakis noreply at git.blender.org
Fri Dec 20 14:42:09 CET 2013


Commit: 26aeb81d003278e30fc36255ba90ca81c3a655e6
Author: Antony Riakiotakis
Date:   Fri Dec 20 13:41:38 2013 +0200
http://developer.blender.org/rB26aeb81d003278e30fc36255ba90ca81c3a655e6

Slightly improve undo performance in dyntopo when last operator was mask
modification. In that case no pbvh needs to be freed and recreated and
we can get away just with draw buffer update (all of them for now. When
pbvh nodes get logged for undo we will be able to only update the
affected ones).

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

M	source/blender/editors/sculpt_paint/sculpt_undo.c

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

diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 846801a..e011e0f 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -266,7 +266,8 @@ static int sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNode
 	return 1;
 }
 
-static void sculpt_undo_bmesh_restore_generic(SculptUndoNode *unode,
+static void sculpt_undo_bmesh_restore_generic(bContext *C,
+                                              SculptUndoNode *unode,
                                               Object *ob,
                                               SculptSession *ss)
 {
@@ -279,9 +280,27 @@ static void sculpt_undo_bmesh_restore_generic(SculptUndoNode *unode,
 		unode->applied = TRUE;
 	}
 
-	/* A bit lame, but for now just recreate the PBVH. The alternative
-	 * is to store changes to the PBVH in the undo stack. */
-	sculpt_pbvh_clear(ob);
+	if (unode->type == SCULPT_UNDO_MASK) {
+		int i, totnode;
+		PBVHNode **nodes;
+
+		#ifdef _OPENMP
+		Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+		#else
+		(void)C;
+		#endif
+
+		BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
+
+		#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
+		for (i = 0; i < totnode; i++)
+			BKE_pbvh_node_mark_redraw(nodes[i]);
+	}
+	else {
+		/* A bit lame, but for now just recreate the PBVH. The alternative
+		 * is to store changes to the PBVH in the undo stack. */
+		sculpt_pbvh_clear(ob);
+	}
 }
 
 /* Create empty sculpt BMesh and enable logging */
@@ -362,7 +381,7 @@ static int sculpt_undo_bmesh_restore(bContext *C,
 
 		default:
 			if (ss->bm_log) {
-				sculpt_undo_bmesh_restore_generic(unode, ob, ss);
+				sculpt_undo_bmesh_restore_generic(C, unode, ob, ss);
 				return TRUE;
 			}
 			break;




More information about the Bf-blender-cvs mailing list