[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37234] branches/soc-2011-onion: Revision: 30093

Jason Wilkins Jason.A.Wilkins at gmail.com
Mon Jun 6 05:20:29 CEST 2011


Revision: 37234
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37234
Author:   jwilkins
Date:     2011-06-06 03:20:27 +0000 (Mon, 06 Jun 2011)
Log Message:
-----------
Revision: 30093
Author: nicholasbishop
Date: 2:11:55 PM, Wednesday, July 07, 2010
Message:
Some preparation for accelerating other paint modes than sculpt

* Replaced Object.sculpt with Object.paint. This new PaintSession type for now just contains the PBVH so it can be built more or less the same for different paint modes. It also contains the old SculptSession data.
* Removed a couple of unused fields from SculptSession.
* Changed a lot of sculpt functions to pass around the Object rather than SculptSession; made sense anyway because we added an Object field to SculptSession to work around that problem.
* There should be no visible changes from this commit.

** jwilkins:
** this took considerable effort to merge
** deformed mesh sculpting probably needs to be ported into deformed mesh painting, but I left it out for now
** will wait on deformed meshes until I see exactly what needs to be done for it

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h
    branches/soc-2011-onion/source/blender/blenkernel/intern/DerivedMesh.c
    branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c
    branches/soc-2011-onion/source/blender/blenkernel/intern/object.c
    branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c
    branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2011-onion/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_undo.c
    branches/soc-2011-onion/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2011-onion/source/blender/makesdna/DNA_object_types.h
    branches/soc-2011-onion/source/blender/modifiers/intern/MOD_multires.c

Property Changed:
----------------
    branches/soc-2011-onion/


Property changes on: branches/soc-2011-onion
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29913
/trunk/blender:36833-37206
   + /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29913,30093
/trunk/blender:36833-37206

Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h	2011-06-06 00:48:10 UTC (rev 37233)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h	2011-06-06 03:20:27 UTC (rev 37234)
@@ -62,8 +62,6 @@
 
 void paint_refresh_mask_display(struct Object *ob);
 
-/* Session data (mode-specific) */
-
 typedef struct SculptSession {
 	/* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */
 	struct MultiresModifierData *multires; /* Special handling for multires meshes */
@@ -76,18 +74,12 @@
 	/* Mesh connectivity */
 	struct ListBase *fmap;
 
-	/* PBVH acceleration structure */
-	struct PBVH *pbvh;
-
-	/* Paiting on deformed mesh */
+	/* Painting on deformed mesh */
 	int modifiers_active; /* object is deformed with some modifiers */
 	float (*orig_cos)[3]; /* coords of undeformed mesh */
 	float (*deform_cos)[3]; /* coords of deformed mesh but without stroke displacement */
 	float (*deform_imats)[3][3]; /* crazyspace deformation matricies */
 
-	/* Partial redraw */
-	int partial_redraw;
-
 	/* Area hiding */
 	ListBase hidden_areas;
 	
@@ -101,6 +93,18 @@
 	struct StrokeCache *cache;
 } SculptSession;
 
-void free_sculptsession(struct Object *ob);
+typedef struct PaintSession {
+	/* mode-specific data (just sculpt for now */
+	SculptSession *sculpt;
 
+	/* PBVH acceleration structure */
+	struct PBVH *pbvh;
+
+	/* Partial redraw */
+	int partial_redraw;
+} PaintSession;
+
+void create_paintsession(struct Object *ob);
+void free_paintsession(struct Object *ob);
+
 #endif

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/DerivedMesh.c	2011-06-06 00:48:10 UTC (rev 37233)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/DerivedMesh.c	2011-06-06 03:20:27 UTC (rev 37234)
@@ -71,7 +71,7 @@
 #include "GPU_extensions.h"
 #include "GPU_material.h"
 
-#include "ED_sculpt.h" /* for ED_sculpt_modifiers_changed */
+#include "ED_sculpt.h" /* for ED_paint_modifiers_changed */
 
 ///////////////////////////////////
 ///////////////////////////////////
@@ -1678,7 +1678,7 @@
 	int skipVirtualArmature = (useDeform < 0);
 	MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0);
 	int has_multires = mmd != NULL, multires_applied = 0;
-	int sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt;
+	int sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->paint && ob->paint->sculpt;
 
 	if(mmd && !mmd->sculptlvl)
 		has_multires = 0;
@@ -2246,9 +2246,8 @@
 		ob->derivedDeform= NULL;
 	}
 
-	if(ob->sculpt) {
-		ED_sculpt_modifiers_changed(ob);
-	}
+	if(ob->paint && ob->paint->sculpt)
+		ED_paint_modifiers_changed(ob);
 }
 
 static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask)

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c	2011-06-06 00:48:10 UTC (rev 37233)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c	2011-06-06 03:20:27 UTC (rev 37234)
@@ -198,21 +198,25 @@
 	/* active modifiers means extra deformation, which can't be handled correct
 	   on bith of PBVH and sculpt "layer" levels, so use PBVH only for internal brush
 	   stuff and show final DerivedMesh so user would see actual object shape */
-	deformed|= ob->sculpt->modifiers_active;
+	deformed|= ob->paint->sculpt->modifiers_active;
 
+	if(ob->paint->sculpt && ob->paint->sculpt->modifiers_active)
+		return 0;
+
 	/* as in case with modifiers, we can't synchronize deformation made against
 	   PBVH and non-locked keyblock, so also use PBVH only for brushes and
 	   final DM to give final result to user */
-	deformed|= ob->sculpt->kb && (ob->shapeflag&OB_SHAPE_LOCK) == 0;
+	deformed|= ob->paint->sculpt->kb && (ob->shapeflag&OB_SHAPE_LOCK) == 0;
 
 	if(deformed)
 		return 0;
 
-	return (cddm->mvert == me->mvert) || ob->sculpt->kb;
+	return (cddm->mvert == me->mvert) || ob->paint->sculpt->kb;
 }
 
 static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
 {
+	SculptSession *ss;
 	CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
 
 	if(!ob) {
@@ -220,10 +224,12 @@
 		return NULL;
 	}
 
-	if(!ob->sculpt)
+	if(!ob->paint)
 		return NULL;
-	if(ob->sculpt->pbvh) {
-		cddm->pbvh= ob->sculpt->pbvh;
+	ss = ob->paint->sculpt;
+
+	if(ob->paint->pbvh) {
+		cddm->pbvh= ob->paint->pbvh;
 		cddm->pbvh_draw = can_pbvh_draw(ob, dm);
 	}
 
@@ -231,13 +237,13 @@
 	   this derivedmesh is just original mesh. it's the multires subsurf dm
 	   that this is actually for, to support a pbvh on a modified mesh */
 	if(!cddm->pbvh && ob->type == OB_MESH) {
-		SculptSession *ss= ob->sculpt;
+		SculptSession *ss= ob->paint->sculpt;
 		Mesh *me= ob->data;
 		cddm->pbvh = BLI_pbvh_new();
 		cddm->pbvh_draw = can_pbvh_draw(ob, dm);
 		BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
 				    &me->vdata, me->totface, me->totvert,
-				    &ob->sculpt->hidden_areas);
+				    ss ? &ss->hidden_areas : NULL);
 
 		if(ss->modifiers_active && ob->derivedDeform) {
 			DerivedMesh *deformdm= ob->derivedDeform;

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c	2011-06-06 00:48:10 UTC (rev 37233)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c	2011-06-06 03:20:27 UTC (rev 37234)
@@ -174,9 +174,9 @@
 			ob->derivedFinal->release(ob->derivedFinal);
 			ob->derivedFinal = NULL;
 		}
-		if(ob->sculpt && ob->sculpt->pbvh) {
-			BLI_pbvh_free(ob->sculpt->pbvh);
-			ob->sculpt->pbvh= NULL;
+		if(ob->paint && ob->paint->pbvh) {
+			BLI_pbvh_free(ob->paint->pbvh);
+			ob->paint->pbvh= NULL;
 		}
 	}
 }

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/object.c	2011-06-06 00:48:10 UTC (rev 37233)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/object.c	2011-06-06 03:20:27 UTC (rev 37234)
@@ -233,39 +233,6 @@
 	freedisplist(&ob->disp);
 }
 
-void free_sculptsession(Object *ob)
-{
-	if(ob && ob->sculpt) {
-		SculptSession *ss = ob->sculpt;
-		DerivedMesh *dm= ob->derivedFinal;
-
-		if(ss->pbvh)
-			BLI_pbvh_free(ss->pbvh);
-
-		BLI_freelistN(&ss->hidden_areas);
-
-		if(dm && dm->getPBVH)
-			dm->getPBVH(NULL, dm); /* signal to clear */
-
-		if(ss->texcache)
-			MEM_freeN(ss->texcache);
-
-		if(ss->layer_co)
-			MEM_freeN(ss->layer_co);
-
-		if(ss->orig_cos)
-			MEM_freeN(ss->orig_cos);
-		if(ss->deform_cos)
-			MEM_freeN(ss->deform_cos);
-		if(ss->deform_imats)
-			MEM_freeN(ss->deform_imats);
-
-		MEM_freeN(ss);
-
-		ob->sculpt = NULL;
-	}
-}
-
 /* do not free object itself */
 void free_object(Object *ob)
 {
@@ -320,7 +287,7 @@
 	if(ob->bsoft) bsbFree(ob->bsoft);
 	if(ob->gpulamp.first) GPU_lamp_free(ob);
 
-	free_sculptsession(ob);
+	free_paintsession(ob);
 
 	if(ob->pc_ids.first) BLI_freelistN(&ob->pc_ids);
 }
@@ -1353,7 +1320,7 @@
 	copy_constraints(&obn->constraints, &ob->constraints, TRUE);
 
 	obn->mode = 0;
-	obn->sculpt = NULL;
+	obn->paint = NULL;
 
 	/* increase user numbers */
 	id_us_plus((ID *)obn->data);

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c	2011-06-06 00:48:10 UTC (rev 37233)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/paint.c	2011-06-06 03:20:27 UTC (rev 37234)
@@ -32,6 +32,7 @@
  */
 
 
+#include "MEM_guardedalloc.h"
 
 #include "DNA_object_types.h"
 #include "DNA_mesh_types.h"
@@ -43,10 +44,12 @@
 #include "BLO_sys_types.h" // XXX: for intptr_t
 
 #include "BKE_brush.h"
+#include "BKE_DerivedMesh.h"
 #include "BKE_library.h"
 #include "BKE_paint.h"
 #include "BKE_utildefines.h"
 
+#include "BLI_listbase.h"
 #include "BLI_pbvh.h"
 
 #include <stdlib.h>
@@ -127,9 +130,73 @@
 /* Update the mask without doing a full object recalc */
 void paint_refresh_mask_display(Object *ob)
 {
-	if(ob && ob->sculpt && ob->sculpt->pbvh) {
-		BLI_pbvh_search_callback(ob->sculpt->pbvh, NULL, NULL,
+	if(ob && ob->paint && ob->paint->pbvh) {
+		BLI_pbvh_search_callback(ob->paint->pbvh, NULL, NULL,
 					 BLI_pbvh_node_set_flags,
 					 SET_INT_IN_POINTER(PBVH_UpdateColorBuffers));
 	}
 }
+
+void create_paintsession(Object *ob)
+{
+	if(ob->paint)
+		free_paintsession(ob);
+
+	ob->paint = MEM_callocN(sizeof(PaintSession), "PaintSession");
+}
+
+static void free_sculptsession(PaintSession *ps)
+{
+	if(ps && ps->sculpt) {
+		SculptSession *ss = ps->sculpt;
+
+		/* free hidden node list */
+		BLI_freelistN(&ss->hidden_areas);
+
+		/* free texture cache */
+		if(ss->texcache)
+			MEM_freeN(ss->texcache);
+
+		/* free layer cache*/
+		if(ss->layer_co)
+			MEM_freeN(ss->layer_co);
+
+		/* free deformed verts */
+
+		if(ss->orig_cos)
+			MEM_freeN(ss->orig_cos);
+
+		if(ss->deform_cos)
+			MEM_freeN(ss->deform_cos);
+
+		if(ss->deform_imats)
+			MEM_freeN(ss->deform_imats);
+
+		/* free SculptSession */
+		MEM_freeN(ss);
+		ps->sculpt = NULL;
+	}
+}
+
+void free_paintsession(Object *ob)
+{
+	if(ob && ob->paint) {
+		PaintSession *ps = ob->paint;
+		DerivedMesh *dm= ob->derivedFinal;
+
+		free_sculptsession(ps);
+
+		/* free PBVH */
+
+		if(ps->pbvh)
+			BLI_pbvh_free(ps->pbvh);
+
+		if(dm && dm->getPBVH)
+			dm->getPBVH(NULL, dm); /* signal to clear PBVH */
+
+		/* free PaintSession */
+		MEM_freeN(ps);
+		ob->paint = NULL;
+	}
+}
+

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c	2011-06-06 00:48:10 UTC (rev 37233)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list