[Bf-blender-cvs] [7776f03] master: Changes around update normals from PBVH to CDDM

Sergey Sharybin noreply at git.blender.org
Fri Jan 15 12:32:22 CET 2016


Commit: 7776f03873e47c2327d1d2fdb980a12cb99407de
Author: Sergey Sharybin
Date:   Fri Jan 15 16:29:57 2016 +0500
Branches: master
https://developer.blender.org/rB7776f03873e47c2327d1d2fdb980a12cb99407de

Changes around update normals from PBVH to CDDM

- Only do this if PBVH is not used for display, this should correspond
  to whats' happening in sculpt.c now.

- No need to do such synchronization for solid drawing, it supports
  optimal display from PBVH.

In fact, such synchronization is only needed in the following case:

Drawing callback does not support PBVH draw and sculpt session is
configured to use PBVH for display and related operations.

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

M	source/blender/blenkernel/intern/cdderivedmesh.c

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

diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index eacacdd..245c846 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -343,8 +343,19 @@ static void cdDM_update_normals_from_pbvh(DerivedMesh *dm)
 	CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
 	float (*face_nors)[3];
 
-	/* constructive modifiers handle their own normals */
-	if (!dm->deformedOnly) {
+	/* Some callbacks do not use optimal PBVH draw, so needs all the
+	 * possible data (like normals) to be copied from PBVH back to DM.
+	 *
+	 * This is safe to do if PBVH and DM are representing the same mesh,
+	 * which could be wrong when modifiers are enabled for sculpt.
+	 * So here we only doing update when there's no modifiers applied
+	 * during sculpt.
+	 *
+	 * It's safe to do nothing if there are modifiers, because in this
+	 * case modifier stack is re-constructed from scratch on every
+	 * update.
+	 */
+	if(!cddm->pbvh_draw) {
 		return;
 	}
 
@@ -456,9 +467,6 @@ static void cdDM_drawFacesSolid(
 			glShadeModel(GL_FLAT);
 			return;
 		}
-		else {
-			cdDM_update_normals_from_pbvh(dm);
-		}
 	}
 	
 	GPU_vertex_setup(dm);




More information about the Bf-blender-cvs mailing list