[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24124] branches/sculpt25/source/blender: Commit of the sculpt patch (#19672).

Nicholas Bishop nicholasbishop at gmail.com
Tue Oct 27 20:53:35 CET 2009


Revision: 24124
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24124
Author:   nicholasbishop
Date:     2009-10-27 20:53:34 +0100 (Tue, 27 Oct 2009)

Log Message:
-----------
Commit of the sculpt patch (#19672). Further development will be in this branch until we merge to trunk.

Modified Paths:
--------------
    branches/sculpt25/source/blender/blenkernel/BKE_DerivedMesh.h
    branches/sculpt25/source/blender/blenkernel/BKE_paint.h
    branches/sculpt25/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/sculpt25/source/blender/blenkernel/intern/object.c
    branches/sculpt25/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/sculpt25/source/blender/blenlib/CMakeLists.txt
    branches/sculpt25/source/blender/blenlib/SConscript
    branches/sculpt25/source/blender/blenlib/intern/arithb.c
    branches/sculpt25/source/blender/editors/include/ED_sculpt.h
    branches/sculpt25/source/blender/editors/include/ED_view3d.h
    branches/sculpt25/source/blender/editors/object/object_modifier.c
    branches/sculpt25/source/blender/editors/physics/particle_edit.c
    branches/sculpt25/source/blender/editors/sculpt_paint/paint_intern.h
    branches/sculpt25/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/sculpt25/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/sculpt25/source/blender/editors/sculpt_paint/sculpt.c
    branches/sculpt25/source/blender/editors/space_view3d/drawobject.c
    branches/sculpt25/source/blender/editors/space_view3d/view3d_draw.c
    branches/sculpt25/source/blender/editors/space_view3d/view3d_edit.c
    branches/sculpt25/source/blender/editors/space_view3d/view3d_select.c
    branches/sculpt25/source/blender/editors/space_view3d/view3d_view.c
    branches/sculpt25/source/blender/gpu/gpu_buffers.h
    branches/sculpt25/source/blender/gpu/intern/gpu_buffers.c

Modified: branches/sculpt25/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/sculpt25/source/blender/blenkernel/BKE_DerivedMesh.h	2009-10-27 19:32:22 UTC (rev 24123)
+++ branches/sculpt25/source/blender/blenkernel/BKE_DerivedMesh.h	2009-10-27 19:53:34 UTC (rev 24124)
@@ -204,7 +204,7 @@
 	 *
 	 * Also called for *final* editmode DerivedMeshes
 	 */
-	void (*drawFacesSolid)(DerivedMesh *dm,
+	void (*drawFacesSolid)(DerivedMesh *dm, void *tree, float (*partial_redraw_planes)[4],
 	                       int (*setMaterial)(int, void *attribs));
 
 	/* Draw all faces

Modified: branches/sculpt25/source/blender/blenkernel/BKE_paint.h
===================================================================
--- branches/sculpt25/source/blender/blenkernel/BKE_paint.h	2009-10-27 19:32:22 UTC (rev 24123)
+++ branches/sculpt25/source/blender/blenkernel/BKE_paint.h	2009-10-27 19:53:34 UTC (rev 24124)
@@ -34,6 +34,7 @@
 struct MVert;
 struct Object;
 struct Paint;
+struct PBVH;
 struct Scene;
 struct StrokeCache;
 
@@ -76,8 +77,10 @@
 
 	/* Used temporarily per-stroke */
 	float *vertexcosnos;
-	ListBase damaged_rects;
-	ListBase damaged_verts;
+
+	/* Partial redraw */
+	struct PBVH *tree;
+	int partial_redraw;
 	
 	/* Used to cache the render of the active texture */
 	unsigned int texcache_side, *texcache, texcache_actual;

Modified: branches/sculpt25/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/cdderivedmesh.c	2009-10-27 19:32:22 UTC (rev 24123)
+++ branches/sculpt25/source/blender/blenkernel/intern/cdderivedmesh.c	2009-10-27 19:53:34 UTC (rev 24124)
@@ -49,7 +49,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_edgehash.h"
 #include "BLI_editVert.h"
-#include "BLI_ghash.h"
+#include "BLI_pbvh.h"
 
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
@@ -360,8 +360,69 @@
 	}
 }
 
-static void cdDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int, void *attribs))
+static int nodes_drawn = 0;
+static int is_partial = 0;
+/* XXX: Just a temporary replacement for the real drawing code */
+static void draw_partial_cb(const int *face_indices,
+			    const int *vert_indices,
+			    int totface, int totvert, void *data_v)
 {
+	/* XXX: Just some quick code to show leaf nodes in different colors */
+	/*float col[3]; int i;
+	if(is_partial) {
+		col[0] = (rand() / (float)RAND_MAX); col[1] = col[2] = 0.6;
+	}
+	else {
+		srand((long long)data_v);
+		for(i = 0; i < 3; ++i)
+			col[i] = (rand() / (float)RAND_MAX) * 0.3 + 0.7;
+	}
+	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col);
+
+	glColor3f(1, 0, 0);*/
+	GPU_draw_buffers(data_v);
+	++nodes_drawn;
+}
+
+int find_all(float bb_min[3], float bb_max[3], void *data)
+{
+	return 1;
+}
+
+/* Adapted from:
+   http://www.gamedev.net/community/forums/topic.asp?topic_id=512123
+   Returns true if the AABB is at least partially within the frustum
+   (ok, not a real frustum), false otherwise.
+*/
+int planes_contain_AABB(float bb_min[3], float bb_max[3], void *data)
+{
+	float (*planes)[4] = data;
+	int i, axis;
+	float vmin[3], vmax[3];
+
+	for(i = 0; i < 4; ++i) { 
+		for(axis = 0; axis < 3; ++axis) {
+			if(planes[i][axis] > 0) { 
+				vmin[axis] = bb_min[axis];
+				vmax[axis] = bb_max[axis];
+			}
+			else {
+				vmin[axis] = bb_max[axis];
+				vmax[axis] = bb_min[axis];
+			}
+		}
+		
+		if(Inpf(planes[i], vmin) + planes[i][3] > 0)
+			return 0;
+	} 
+
+	return 1;
+}
+
+static void cdDM_drawFacesSolid(DerivedMesh *dm, void *tree,
+				float (*partial_redraw_planes)[4],
+				int (*setMaterial)(int, void *attribs))
+{
 	CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
 	MVert *mvert = cddm->mvert;
 	MFace *mface = cddm->mface;
@@ -376,6 +437,32 @@
 	glVertex3fv(mvert[index].co);	\
 }
 
+	if(tree) {
+		BLI_pbvh_search(tree, BLI_pbvh_update_search_cb,
+				PBVH_NodeData, NULL, NULL,
+				PBVH_SEARCH_UPDATE);
+
+		if(partial_redraw_planes) {
+			BLI_pbvh_search(tree, planes_contain_AABB,
+					partial_redraw_planes,
+					draw_partial_cb, PBVH_DrawData,
+					PBVH_SEARCH_MODIFIED);
+		}
+		else {
+			BLI_pbvh_search(tree, find_all, NULL,
+					draw_partial_cb, PBVH_DrawData,
+					PBVH_SEARCH_NORMAL);
+
+		}
+
+		is_partial = !!partial_redraw_planes;
+
+		//printf("nodes drawn=%d\n", nodes_drawn);
+		nodes_drawn = 0;
+
+		return;
+	}
+
 	if( GPU_buffer_legacy(dm) ) {
 		DEBUG_VBO( "Using legacy code. cdDM_drawFacesSolid\n" );
 		glBegin(glmode = GL_QUADS);

Modified: branches/sculpt25/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/object.c	2009-10-27 19:32:22 UTC (rev 24123)
+++ branches/sculpt25/source/blender/blenkernel/intern/object.c	2009-10-27 19:53:34 UTC (rev 24124)
@@ -72,6 +72,8 @@
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
 #include "BLI_editVert.h"
+#include "BLI_ghash.h"
+#include "BLI_pbvh.h"
 
 #include "BKE_utildefines.h"
 
@@ -228,8 +230,6 @@
 {
 	if(ssp && *ssp) {
 		SculptSession *ss = *ssp;
-		if(ss->projverts)
-			MEM_freeN(ss->projverts);
 
 		if(ss->fmap)
 			MEM_freeN(ss->fmap);
@@ -246,6 +246,12 @@
 		if(ss->mesh_co_orig)
 			MEM_freeN(ss->mesh_co_orig);
 
+		if(ss->tree)
+			BLI_pbvh_free(ss->tree);
+
+		if(ss->face_normals)
+			MEM_freeN(ss->face_normals);
+
 		MEM_freeN(ss);
 
 		*ssp = NULL;

Modified: branches/sculpt25/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/subsurf_ccg.c	2009-10-27 19:32:22 UTC (rev 24123)
+++ branches/sculpt25/source/blender/blenkernel/intern/subsurf_ccg.c	2009-10-27 19:53:34 UTC (rev 24124)
@@ -1615,7 +1615,7 @@
 }
 
 	/* Only used by non-editmesh types */
-static void ccgDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int, void *attribs)) {
+static void ccgDM_drawFacesSolid(DerivedMesh *dm, void *tree, float (*partial_redraw_planes)[4], int (*setMaterial)(int, void *attribs)) {
 	CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
 	CCGSubSurf *ss = ccgdm->ss;
 	CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);

Modified: branches/sculpt25/source/blender/blenlib/CMakeLists.txt
===================================================================
--- branches/sculpt25/source/blender/blenlib/CMakeLists.txt	2009-10-27 19:32:22 UTC (rev 24123)
+++ branches/sculpt25/source/blender/blenlib/CMakeLists.txt	2009-10-27 19:53:34 UTC (rev 24124)
@@ -28,6 +28,7 @@
 
 SET(INC 
 	. ../makesdna ../blenkernel ../../../intern/guardedalloc ../include
+	../gpu
 	${FREETYPE_INCLUDE_DIRS}
 	${ZLIB_INC}
 )

Modified: branches/sculpt25/source/blender/blenlib/SConscript
===================================================================
--- branches/sculpt25/source/blender/blenlib/SConscript	2009-10-27 19:32:22 UTC (rev 24123)
+++ branches/sculpt25/source/blender/blenlib/SConscript	2009-10-27 19:53:34 UTC (rev 24124)
@@ -4,7 +4,7 @@
 sources = env.Glob('intern/*.c')
 
 cflags=''
-incs = '. ../makesdna ../blenkernel #/intern/guardedalloc ../editors/include'
+incs = '. ../makesdna ../blenkernel #/intern/guardedalloc ../editors/include ../gpu'
 incs += ' ' + env['BF_FREETYPE_INC']
 incs += ' ' + env['BF_ZLIB_INC']
 defs = ''

Modified: branches/sculpt25/source/blender/blenlib/intern/arithb.c
===================================================================
--- branches/sculpt25/source/blender/blenlib/intern/arithb.c	2009-10-27 19:32:22 UTC (rev 24123)
+++ branches/sculpt25/source/blender/blenlib/intern/arithb.c	2009-10-27 19:53:34 UTC (rev 24124)
@@ -4324,7 +4324,7 @@
 	
 	Crossf(p, d, e2);
 	a = Inpf(e1, p);
-	if ((a > -0.000001) && (a < 0.000001)) return 0;
+	if ((a > -FLT_EPSILON) && (a < FLT_EPSILON)) return 0;
 	f = 1.0f/a;
 	
 	VecSubf(s, p1, v0);

Modified: branches/sculpt25/source/blender/editors/include/ED_sculpt.h
===================================================================
--- branches/sculpt25/source/blender/editors/include/ED_sculpt.h	2009-10-27 19:32:22 UTC (rev 24123)
+++ branches/sculpt25/source/blender/editors/include/ED_sculpt.h	2009-10-27 19:53:34 UTC (rev 24124)
@@ -28,12 +28,19 @@
 #ifndef ED_SCULPT_H
 #define ED_SCULPT_H
 
+struct ARegion;
 struct bContext;
+struct Object;
+struct RegionView3D;
 struct wmKeyConfig;
+struct wmWindowManager;
 
 /* sculpt.c */
 void ED_operatortypes_sculpt(void);
+void sculpt_get_redraw_planes(float planes[4][4], struct ARegion *ar,
+ 			      struct RegionView3D *rv3d, struct Object *ob);
 
+
 /* paint_ops.c */
 void ED_operatortypes_paint(void);
 void ED_keymap_paint(struct wmKeyConfig *keyconf);

Modified: branches/sculpt25/source/blender/editors/include/ED_view3d.h
===================================================================
--- branches/sculpt25/source/blender/editors/include/ED_view3d.h	2009-10-27 19:32:22 UTC (rev 24123)
+++ branches/sculpt25/source/blender/editors/include/ED_view3d.h	2009-10-27 19:53:34 UTC (rev 24124)
@@ -30,6 +30,7 @@
 
 /* ********* exports for space_view3d/ module ********** */
 struct ARegion;
+struct BoundBox;
 struct View3D;
 struct RegionView3D;
 struct ViewContext;
@@ -44,6 +45,7 @@
 struct Scene;
 struct bContext;
 struct Main;
+struct rcti;
 
 /* for derivedmesh drawing callbacks, for view3d_select, .... */
 typedef struct ViewContext {
@@ -80,6 +82,8 @@
 /* Projection */
 #define IS_CLIPPED        12000
 
+void view3d_calculate_clipping(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, struct rcti *rect);
+
 void project_short(struct ARegion *ar, float *vec, short *adr);
 void project_short_noclip(struct ARegion *ar, float *vec, short *adr);
 
@@ -125,7 +129,7 @@
 void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc);
 void view3d_operator_needs_opengl(const struct bContext *C);
 void view3d_get_view_aligned_coordinate(struct ViewContext *vc, float *fp, short mval[2]);
-void view3d_get_transformation(struct ViewContext *vc, struct Object *ob, struct bglMats *mats);
+void view3d_get_transformation(struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats);
 
 /* XXX should move to arithb.c */
 int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2);

Modified: branches/sculpt25/source/blender/editors/object/object_modifier.c
===================================================================

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list