[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39265] branches/soc-2011-onion/source/ blender: Revision: 30884

Jason Wilkins Jason.A.Wilkins at gmail.com
Wed Aug 10 20:21:26 CEST 2011


Revision: 39265
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39265
Author:   jwilkins
Date:     2011-08-10 18:21:26 +0000 (Wed, 10 Aug 2011)
Log Message:
-----------
Revision: 30884
Author: nicholasbishop
Date: 7:55:37 PM, Thursday, July 29, 2010
Message:
== Paint/PBVH ==

Undo refactor

* Renamed sculpt_undo.c to pbvh_undo.c
* Modified node push take a flag (PBVHUndoFlag) that controls what data gets pushed
* Changed sculpt code to only push coords, changed masking to only push paint masks
* Added undo code to save/restore mcols too, but not used yet
* Fixed a weight paint crash

----
Modified : /branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_dmgrid.h
Modified : /branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_mask.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
Added : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/pbvh_undo.c (Copy from path: /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt_undo.c, Revision, 30791)
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt_intern.h
Deleted : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt_undo.c

-- 
jwilkins:
Complicated merge.  Mainly needed to preserve modifier changes from trunk, to fix bugs in sculpt undo that were introduced, and some changes due to factoring out 'meshcache' stuff from sculpt and sculpt_undo.  Also, fixed problem with ESC not immediately redrawing mesh to show the stroke you were drawing had been canceled.  That did not seem to be a problem before and I'm afraid my solution of explicitly telling it to rebuild VBO may be slow for the 'Drag Dot' style stroke.

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h
    branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/CMakeLists.txt
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/SConscript
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_meshcache.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_intern.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c

Added Paths:
-----------
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/pbvh_undo.c

Removed Paths:
-------------
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_undo.c

Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h	2011-08-10 17:51:18 UTC (rev 39264)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h	2011-08-10 18:21:26 UTC (rev 39265)
@@ -45,4 +45,8 @@
 #define GRIDELEM_MASK_AT(_grid, _elem, _key) GRIDELEM_MASK(GRIDELEM_AT(_grid, _elem, _key), _key)
 #define GRIDELEM_NO_AT(_grid, _elem, _key) GRIDELEM_NO(GRIDELEM_AT(_grid, _elem, _key), _key)
 
+/* returns the active gridelem layer offset for either colors
+   or masks, -1 if not found */
+int gridelem_active_offset(struct CustomData *data, struct GridKey *gridkey, int type);
+
 #endif

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c	2011-08-10 17:51:18 UTC (rev 39264)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c	2011-08-10 18:21:26 UTC (rev 39265)
@@ -61,8 +61,8 @@
 #include "BKE_paint.h"
 #include "BKE_scene.h"
 #include "BKE_subsurf.h"
+#include "BKE_dmgrid.h"
 
-
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
@@ -73,6 +73,38 @@
 
 #include "CCGSubSurf.h"
 
+/* From BKE_dmgrid.h */
+int gridelem_active_offset(CustomData *data, GridKey *gridkey, int type)
+{
+	char (*names)[32] = NULL;
+	int active, tot, i;
+
+	active = CustomData_get_active_layer_index(data, type);
+	
+	if(active == -1)
+		return -1;
+
+	switch(type) {
+	case CD_MCOL:
+		tot = gridkey->color;
+		names = gridkey->color_names;
+		break;
+	case CD_PAINTMASK:
+		tot = gridkey->mask;
+		names = gridkey->mask_names;
+		break;
+	default:
+		return -1;
+	}
+
+	for(i = 0; i < tot; ++i) {
+		if(!strcmp(names[i], data->layers[active].name))
+			return i;
+	}
+
+	return -1;
+}
+
 static int ccgDM_getVertMapIndex(CCGSubSurf *ss, CCGVert *v);
 static int ccgDM_getEdgeMapIndex(CCGSubSurf *ss, CCGEdge *e);
 static int ccgDM_getFaceMapIndex(CCGSubSurf *ss, CCGFace *f);

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/CMakeLists.txt
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/CMakeLists.txt	2011-08-10 17:51:18 UTC (rev 39264)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/CMakeLists.txt	2011-08-10 18:21:26 UTC (rev 39265)
@@ -55,10 +55,12 @@
 	paint_texcache.c
 	paint_uv.c
 	paint_brushlib.cpp
+
 	sculpt.c
-	sculpt_undo.c
 	sculpt_tools.c
 
+	pbvh_undo.c
+
 	paint_intern.h
 	paint_inline.h
 	paint_stroke.h

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/SConscript
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/SConscript	2011-08-10 17:51:18 UTC (rev 39264)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/SConscript	2011-08-10 18:21:26 UTC (rev 39265)
@@ -18,11 +18,14 @@
 sources.append('paint_meshcache.c')
 sources.append('paint_texcache.c')
 sources.append('paint_brushlib.cpp')
+
 sources.append('sculpt.c')
-sources.append('sculpt_undo.c')
 sources.append('sculpt_tools.c')
 
+sources.append('pbvh_undo.c')
 
+
+
 defs = []
 
 incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c	2011-08-10 17:51:18 UTC (rev 39264)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c	2011-08-10 18:21:26 UTC (rev 39265)
@@ -1010,19 +1010,19 @@
 	for(n=0; n<totnode; n++) {
 		PBVHVertexIter vd;
 		PaintStrokeTest test;
-		SculptUndoNode *unode;
+		PBVHUndoNode *unode;
 		float private_out[3] = {0.0f, 0.0f, 0.0f};
 		float private_out_flip[3] = {0.0f, 0.0f, 0.0f};
 
-		unode = sculpt_undo_push_node(ob, nodes[n]);
+		unode = pbvh_undo_push_node(nodes[n], PBVH_UNDO_CO_NO, ob);
 		paint_stroke_test_init(&test, bspace->symm_location, bspace->radius3d_sq*bspace->area_range_sq);
 
 		if(ss->cache->original) {
 			BLI_pbvh_vertex_iter_begin(ob->paint->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
-				if(paint_stroke_test_fast(&test, unode->co[vd.i])) {
+				if(paint_stroke_test_fast(&test, pbvh_undo_node_co(unode)[vd.i])) {
 					float fno[3];
 
-					normal_short_to_float_v3(fno, unode->no[vd.i]);
+					normal_short_to_float_v3(fno, pbvh_undo_node_no(unode)[vd.i]);
 					add_norm_if(bspace->symm_view_vector, private_out, private_out_flip, fno);
 				}
 			}
@@ -1132,16 +1132,16 @@
 	for(n=0; n<totnode; n++) {
 		PBVHVertexIter vd;
 		PaintStrokeTest test;
-		SculptUndoNode *unode;
+		PBVHUndoNode *unode;
 		float private_fc[3] = {0.0f, 0.0f, 0.0f};
 		int private_count = 0;
 
-		unode = sculpt_undo_push_node(ob, nodes[n]);
+		unode = pbvh_undo_push_node(nodes[n], PBVH_UNDO_CO_NO, ob);
 		paint_stroke_test_init(&test, bspace->symm_location, bspace->radius3d_sq);
 
 		if(ss->cache->original) {
 			BLI_pbvh_vertex_iter_begin(ob->paint->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
-				if(paint_stroke_test_fast(&test, unode->co[vd.i])) {
+				if(paint_stroke_test_fast(&test, pbvh_undo_node_co(unode)[vd.i])) {
 					add_v3_v3(private_fc, vd.co);
 					private_count++;
 				}
@@ -1194,22 +1194,22 @@
 	for(n=0; n<totnode; n++) {
 		PBVHVertexIter vd;
 		PaintStrokeTest test;
-		SculptUndoNode *unode;
+		PBVHUndoNode *unode;
 		float private_out[3] = {0.0f, 0.0f, 0.0f};
 		float private_out_flip[3] = {0.0f, 0.0f, 0.0f};
 		float private_fc[3] = {0.0f, 0.0f, 0.0f};
 		int private_count = 0;
 
-		unode = sculpt_undo_push_node(ob, nodes[n]);
+		unode = pbvh_undo_push_node(nodes[n], PBVH_UNDO_CO_NO, ob);
 		paint_stroke_test_init(&test, bspace->symm_location, bspace->radius3d_sq*bspace->area_range_sq);
 
 		if(ss->cache->original) {
 			BLI_pbvh_vertex_iter_begin(ob->paint->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
-				if(paint_stroke_test_fast(&test, unode->co[vd.i])) {
+				if(paint_stroke_test_fast(&test, pbvh_undo_node_co(unode)[vd.i])) {
 					// an
 					float fno[3];
 
-					normal_short_to_float_v3(fno, unode->no[vd.i]);
+					normal_short_to_float_v3(fno, pbvh_undo_node_no(unode)[vd.i]);
 					add_norm_if(bspace->symm_view_vector, private_out, private_out_flip, fno);
 
 					// fc
@@ -1419,7 +1419,7 @@
 	for (n= 0; n < totnode; n++) {
 		PBVHVertexIter vd;
 		PaintStrokeTest test;
-		SculptUndoNode *unode;
+		PBVHUndoNode *unode;
 		float private_out[3]=      {0.0f, 0.0f, 0.0f};
 		float private_out_flip[3]= {0.0f, 0.0f, 0.0f};
 
@@ -1428,10 +1428,10 @@
 
 		if (use_original) {
 			BLI_pbvh_vertex_iter_begin(ob->paint->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
-				if(paint_stroke_test_fast(&test, unode->co[vd.i])) {
+				if(paint_stroke_test_fast(&test, pbvh_undo_node_co(unode)[vd.i])) {
 					float fno[3];
 
-					normal_short_to_float_v3(fno, unode->no[vd.i]);
+					normal_short_to_float_v3(fno, pbvh_undo_node_no(unode)[vd.i]);
 					add_norm_if(private_out, private_out_flip, cull_vector, fno);
 				}
 			}

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h	2011-08-10 17:51:18 UTC (rev 39264)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h	2011-08-10 18:21:26 UTC (rev 39265)
@@ -51,7 +51,7 @@
 struct Scene;
 struct BrushSpace;
 struct PaintSessionMeshcache;
-struct SculptUndoNode;
+struct PBVHUndoNode;
 struct KeyBlock;
 struct PaintSession;
 struct PaintSessionTexcache;
@@ -372,7 +372,7 @@
 void paint_mesh_update(const struct bContext *C, int need_fmap);
 void paint_mesh_update_when_modifiers(const struct bContext *C, int need_fmap);
 int paint_mesh_has_active_modifiers(struct bContext *C);
-void paint_mesh_undo_restore(struct bContext *C, struct SculptUndoNode *unode);
+void paint_mesh_undo_restore_co(struct bContext *C, struct PBVHUndoNode *unode);
 float *paint_mesh_orig_co(const struct Object *ob, int i);
 int paint_mesh_totvert(const struct Object *ob);
 void paint_mesh_restore_co(const struct bContext *C);
@@ -479,4 +479,43 @@
 	int x,
 	int y);
 
+/* pbvh_undo.c */
+typedef enum {
+	PBVH_UNDO_CO_NO = (1<<0),
+	PBVH_UNDO_PMASK = (1<<1),
+	PBVH_UNDO_COLOR = (1<<2)
+} PBVHUndoFlag;
+
+typedef struct PBVHUndoNode PBVHUndoNode;
+
+PBVHUndoNode *pbvh_undo_push_node(PBVHNode *node, PBVHUndoFlag flag, const struct Object *ob);
+void pbvh_undo_push_begin(const char *name);
+void pbvh_undo_push_end(void);
+/* undo node access */
+PBVHUndoNode *pbvh_undo_get_node(struct PBVHNode *node);
+typedef float (*pbvh_undo_f3)[3];
+typedef short (*pbvh_undo_s3)[3];
+int pbvh_undo_node_totvert(PBVHUndoNode *unode);
+pbvh_undo_f3 pbvh_undo_node_co(PBVHUndoNode *unode);
+pbvh_undo_s3 pbvh_undo_node_no(PBVHUndoNode *unode);
+
+void pbvh_undo_get_multiple_nodes(
+	struct PBVHUndoNode*** unodes,
+	struct Object *ob,
+	struct PBVHNode **nodes,
+	int totnode,
+	PBVHUndoFlag flag,
+	int use_threaded);
+
+pbvh_undo_f3 pbvh_undo_node_orig_co(PBVHUndoNode *unode);
+const char *pbvh_undo_node_shape_name(PBVHUndoNode *unode);
+int pbvh_undo_node_maxvert(PBVHUndoNode *unode);
+int *pbvh_undo_node_vert_index_ref(PBVHUndoNode *unode);
+int *pbvh_undo_node_face_index_ref(PBVHUndoNode *unode);
+
+void paint_mesh_copy_active_shape_key_name(
+	const struct Object *ob,
+	char *out,
+	int maxcopy);
+
 #endif /* ED_PAINT_INTERN_H */

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c	2011-08-10 17:51:18 UTC (rev 39264)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c	2011-08-10 18:21:26 UTC (rev 39265)
@@ -138,7 +138,8 @@
 		PBVHVertexIter vd;
 		PaintStrokeTest test;
 
-		/* XXX: sculpt_undo_push_node(ob, nodes[n]); */
+		pbvh_undo_push_node(nodes[n], PBVH_UNDO_PMASK, ob);
+
 		paint_stroke_test_init(&test, location, radius_squared);
 
 		BLI_pbvh_vertex_iter_begin(ob->paint->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
@@ -291,8 +292,7 @@
 	me = get_mesh(ob);
 	mmd = paint_mesh_get_active_multires(C);
 	
-	if(ob->mode & OB_MODE_SCULPT) // TODO

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list