[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30692] branches/soc-2010-nicolasbishop/ source/blender: == VPaint ==

Nicholas Bishop nicholasbishop at gmail.com
Sat Jul 24 19:18:42 CEST 2010


Revision: 30692
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30692
Author:   nicholasbishop
Date:     2010-07-24 19:18:42 +0200 (Sat, 24 Jul 2010)

Log Message:
-----------
== VPaint ==

Added partial redraw to vpaint.

Updated the PBVH docs in the wiki to include some info about partial redraw:
http://wiki.blender.org/index.php/Dev:2.5/Source/Modeling/PBVH#Partial_Redraw

* Moved some sculpt-pbvh functions to paint_util for general use
** sculpt_get_redraw_rect -> paint_get_redraw_rect
** sculpt_get_redraw_planes -> paint_get_redraw_planes
** Some of the code from sculpt_flush_update is now paint_tag_partial_redraw
* Added some debugging code to show the area being redraw during partial redraw
** Draws a box around the area being updated
** Set rt to 444 to see it

Modified Paths:
--------------
    branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
    branches/soc-2010-nicolasbishop/source/blender/editors/include/ED_sculpt.h
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_utils.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/view3d_draw.c

Modified: branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c	2010-07-24 16:35:58 UTC (rev 30691)
+++ branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c	2010-07-24 17:18:42 UTC (rev 30692)
@@ -1236,6 +1236,8 @@
 	if(nodes) MEM_freeN(nodes);
 }
 
+/* get the object-space bounding box containing all the nodes that
+   have been marked with PBVH_UpdateRedraw */
 void BLI_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3])
 {
 	PBVHIter iter;

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/include/ED_sculpt.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/include/ED_sculpt.h	2010-07-24 16:35:58 UTC (rev 30691)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/include/ED_sculpt.h	2010-07-24 17:18:42 UTC (rev 30692)
@@ -37,8 +37,6 @@
 
 /* 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);
 void ED_sculpt_force_update(struct bContext *C);
 
 /* paint_ops.c */
@@ -52,4 +50,9 @@
 int ED_undo_paint_step(struct bContext *C, int type, int step, const char *name);
 void ED_undo_paint_free(void);
 
+/* paint_util.c */
+void paint_get_redraw_planes(float planes[4][4], struct ARegion *ar,
+			     struct RegionView3D *rv3d, struct Object *ob);
+
+
 #endif

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h	2010-07-24 16:35:58 UTC (rev 30691)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h	2010-07-24 17:18:42 UTC (rev 30692)
@@ -132,6 +132,8 @@
 				     float center[3],
 				     float pixel_radius);
 
+void paint_tag_partial_redraw(struct bContext *C, struct Object *ob);
+
 struct MultiresModifierData *paint_multires_active(struct Scene *scene, struct Object *ob);
 
 /* stroke operator */

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_utils.c	2010-07-24 16:35:58 UTC (rev 30691)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_utils.c	2010-07-24 17:18:42 UTC (rev 30692)
@@ -25,6 +25,7 @@
 #include "BKE_utildefines.h"
 
 #include "BIF_gl.h"
+#include "BIF_glutil.h"
 
 #include "ED_view3d.h"
 #include "ED_screen.h"
@@ -348,3 +349,107 @@
 
 	return NULL;
 }
+
+/*** BVH Tree ***/
+
+/* Get a screen-space rectangle of the modified area */
+static int paint_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
+				 Object *ob, rcti *rect)
+{
+	PBVH *pbvh= ob->paint->pbvh;
+	float bb_min[3], bb_max[3], pmat[4][4];
+	int i, j, k;
+
+	view3d_get_object_project_mat(rv3d, ob, pmat);
+
+	if(!pbvh)
+		return 0;
+
+	BLI_pbvh_redraw_BB(pbvh, bb_min, bb_max);
+
+	rect->xmin = rect->ymin = INT_MAX;
+	rect->xmax = rect->ymax = INT_MIN;
+
+	if(bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2])
+		return 0;
+
+	for(i = 0; i < 2; ++i) {
+		for(j = 0; j < 2; ++j) {
+			for(k = 0; k < 2; ++k) {
+				float vec[3], proj[2];
+				vec[0] = i ? bb_min[0] : bb_max[0];
+				vec[1] = j ? bb_min[1] : bb_max[1];
+				vec[2] = k ? bb_min[2] : bb_max[2];
+				view3d_project_float(ar, vec, proj, pmat);
+				rect->xmin = MIN2(rect->xmin, proj[0]);
+				rect->xmax = MAX2(rect->xmax, proj[0]);
+				rect->ymin = MIN2(rect->ymin, proj[1]);
+				rect->ymax = MAX2(rect->ymax, proj[1]);
+			}
+		}
+	}
+	
+	return rect->xmin < rect->xmax && rect->ymin < rect->ymax;
+}
+
+void paint_tag_partial_redraw(bContext *C, Object *ob)
+{
+	RegionView3D *rv3d = CTX_wm_region_view3d(C);
+	ARegion *ar = CTX_wm_region(C);
+	rcti r;
+
+	if(paint_get_redraw_rect(ar, rv3d, ob, &r)) {
+		//rcti tmp;
+
+		r.xmin += ar->winrct.xmin + 1;
+		r.xmax += ar->winrct.xmin - 1;
+		r.ymin += ar->winrct.ymin + 1;
+		r.ymax += ar->winrct.ymin - 1;
+
+		//tmp = r;
+
+		//if (!BLI_rcti_is_empty(&ss->previous_r))
+		//	BLI_union_rcti(&r, &ss->previous_r);
+
+		//ss->previous_r= tmp;
+
+		ob->paint->partial_redraw = 1;
+		ED_region_tag_redraw_partial(ar, &r);
+	}
+}
+
+void paint_get_redraw_planes(float planes[4][4], ARegion *ar,
+			     RegionView3D *rv3d, Object *ob)
+{
+	PBVH *pbvh= ob->paint->pbvh;
+	BoundBox bb;
+	bglMats mats;
+	rcti rect;
+
+	memset(&bb, 0, sizeof(BoundBox));
+
+	view3d_get_transformation(ar, rv3d, ob, &mats);
+	paint_get_redraw_rect(ar, rv3d,ob, &rect);
+
+#if 1
+	/* use some extra space just in case */
+	rect.xmin -= 2;
+	rect.xmax += 2;
+	rect.ymin -= 2;
+	rect.ymax += 2;
+#else
+	/* it was doing this before, allows to redraw a smaller
+	   part of the screen but also gives artifaces .. */
+	rect.xmin += 2;
+	rect.xmax -= 2;
+	rect.ymin += 2;
+	rect.ymax -= 2;
+#endif
+
+	view3d_calculate_clipping(&bb, planes, &mats, &rect);
+	mul_m4_fl(planes, -1.0f);
+
+	/* clear redraw flag from nodes */
+	if(pbvh)
+		BLI_pbvh_update(pbvh, PBVH_UpdateRedraw, NULL);
+}

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c	2010-07-24 16:35:58 UTC (rev 30691)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c	2010-07-24 17:18:42 UTC (rev 30692)
@@ -2179,7 +2179,8 @@
 	if(brush->vertexpaint_tool == VP_BLUR)
 		do_shared_vertexcol(ob->data);
 
-	ED_region_tag_redraw(vc->ar);
+	/* partial redraw */
+	paint_tag_partial_redraw(C, ob);
 }
 
 static void vpaint_stroke_update_step(bContext *C, PaintStroke *stroke, PointerRNA *itemptr)

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c	2010-07-24 16:35:58 UTC (rev 30691)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c	2010-07-24 17:18:42 UTC (rev 30692)
@@ -247,84 +247,6 @@
 }
 */
 
-/*** BVH Tree ***/
-
-/* Get a screen-space rectangle of the modified area */
-int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
-				Object *ob, rcti *rect)
-{
-	PBVH *pbvh= ob->paint->pbvh;
-	float bb_min[3], bb_max[3], pmat[4][4];
-	int i, j, k;
-
-	view3d_get_object_project_mat(rv3d, ob, pmat);
-
-	if(!pbvh)
-		return 0;
-
-	BLI_pbvh_redraw_BB(pbvh, bb_min, bb_max);
-
-	rect->xmin = rect->ymin = INT_MAX;
-	rect->xmax = rect->ymax = INT_MIN;
-
-	if(bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2])
-		return 0;
-
-	for(i = 0; i < 2; ++i) {
-		for(j = 0; j < 2; ++j) {
-			for(k = 0; k < 2; ++k) {
-				float vec[3], proj[2];
-				vec[0] = i ? bb_min[0] : bb_max[0];
-				vec[1] = j ? bb_min[1] : bb_max[1];
-				vec[2] = k ? bb_min[2] : bb_max[2];
-				view3d_project_float(ar, vec, proj, pmat);
-				rect->xmin = MIN2(rect->xmin, proj[0]);
-				rect->xmax = MAX2(rect->xmax, proj[0]);
-				rect->ymin = MIN2(rect->ymin, proj[1]);
-				rect->ymax = MAX2(rect->ymax, proj[1]);
-			}
-		}
-	}
-	
-	return rect->xmin < rect->xmax && rect->ymin < rect->ymax;
-}
-
-void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar,
-				  RegionView3D *rv3d, Object *ob)
-{
-	PBVH *pbvh= ob->paint->pbvh;
-	BoundBox bb;
-	bglMats mats;
-	rcti rect;
-
-	memset(&bb, 0, sizeof(BoundBox));
-
-	view3d_get_transformation(ar, rv3d, ob, &mats);
-	sculpt_get_redraw_rect(ar, rv3d,ob, &rect);
-
-#if 1
-	/* use some extra space just in case */
-	rect.xmin -= 2;
-	rect.xmax += 2;
-	rect.ymin -= 2;
-	rect.ymax += 2;
-#else
-	/* it was doing this before, allows to redraw a smaller
-	   part of the screen but also gives artifaces .. */
-	rect.xmin += 2;
-	rect.xmax -= 2;
-	rect.ymin += 2;
-	rect.ymax -= 2;
-#endif
-
-	view3d_calculate_clipping(&bb, planes, &mats, &rect);
-	mul_m4_fl(planes, -1.0f);
-
-	/* clear redraw flag from nodes */
-	if(pbvh)
-		BLI_pbvh_update(pbvh, PBVH_UpdateRedraw, NULL);
-}
-
 /************************ Brush Testing *******************/
 
 typedef struct SculptBrushTest {
@@ -3292,28 +3214,9 @@
 		ED_region_tag_redraw(ar);
 	}
 	else {
-		rcti r;
-
 		BLI_pbvh_update(ob->paint->pbvh, PBVH_UpdateBB, NULL);
 
-		if (sculpt_get_redraw_rect(ar, CTX_wm_region_view3d(C), ob, &r)) {
-			//rcti tmp;
-
-			r.xmin += ar->winrct.xmin + 1;
-			r.xmax += ar->winrct.xmin - 1;
-			r.ymin += ar->winrct.ymin + 1;
-			r.ymax += ar->winrct.ymin - 1;
-
-			//tmp = r;
-
-			//if (!BLI_rcti_is_empty(&ss->previous_r))
-			//	BLI_union_rcti(&r, &ss->previous_r);
-
-			//ss->previous_r= tmp;
-
-			ob->paint->partial_redraw = 1;
-			ED_region_tag_redraw_partial(ar, &r);
-		}
+		paint_tag_partial_redraw(C, ob);
 	}
 }
 

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawobject.c	2010-07-24 16:35:58 UTC (rev 30691)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawobject.c	2010-07-24 17:18:42 UTC (rev 30692)
@@ -2491,7 +2491,7 @@
 	totface = dm->getNumFaces(dm);
 
 	/* setup for fast paint/sculpt drawing */
-	if((ob->mode & (OB_MODE_SCULPT)) &&
+	if((ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT)) &&
 	   (p=paint_get_active(scene))) {
 		/* drop down to a low multires level during navigation */
 		fast_navigate = (p->flags & PAINT_FAST_NAVIGATE) &&
@@ -2499,7 +2499,7 @@
 
 		if(ob->paint && ob->paint->partial_redraw) {
 			if(ar->do_draw & RGN_DRAW_PARTIAL) {
-				sculpt_get_redraw_planes(planes, ar, rv3d, ob);
+				paint_get_redraw_planes(planes, ar, rv3d, ob);
 				paint_redraw_planes = planes;
 				ob->paint->partial_redraw = 0;
 			}

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/view3d_draw.c	2010-07-24 16:35:58 UTC (rev 30691)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list