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

Jason Wilkins Jason.A.Wilkins at gmail.com
Mon Jun 6 21:36:37 CEST 2011


Revision: 37268
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37268
Author:   jwilkins
Date:     2011-06-06 19:36:37 +0000 (Mon, 06 Jun 2011)
Log Message:
-----------
Revision: 30692
Author: nicholasbishop
Date: 12:18:42 PM, Saturday, July 24, 2010
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


** jwilkins:
** made sure that code from trunk, which makes sure shrinking redraw regions update correctly, was merged in with these changes

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h
    branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
    branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.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/space_view3d/drawobject.c
    branches/soc-2011-onion/source/blender/editors/space_view3d/view3d_draw.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-30676
/trunk/blender:36833-37206
   + /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30676,30692
/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 19:33:38 UTC (rev 37267)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h	2011-06-06 19:36:37 UTC (rev 37268)
@@ -32,6 +32,8 @@
  *  \ingroup bke
  */
 
+#include "DNA_vec_types.h"
+
 struct Brush;
 struct MFace;
 struct MultireModifierData;
@@ -104,6 +106,9 @@
 
 	/* Partial redraw */
 	int partial_redraw;
+
+	/* previous redraw rect */
+	rcti previous_r;
 } PaintSession;
 
 void create_paintsession(struct Object *ob);

Modified: branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c	2011-06-06 19:33:38 UTC (rev 37267)
+++ branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c	2011-06-06 19:36:37 UTC (rev 37268)
@@ -1253,6 +1253,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-2011-onion/source/blender/editors/include/ED_sculpt.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h	2011-06-06 19:33:38 UTC (rev 37267)
+++ branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h	2011-06-06 19:36:37 UTC (rev 37268)
@@ -41,8 +41,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);
 
 void ED_paint_modifiers_changed(struct Object *ob);
@@ -59,6 +57,11 @@
 void ED_undo_paint_free(void);
 int ED_undo_paint_valid(int type, const char *name);
 
+/* paint_util.c */
+void paint_get_redraw_planes(float planes[4][4], struct ARegion *ar,
+			     struct RegionView3D *rv3d, struct Object *ob);
+
+
 void ED_draw_paint_overlay(const struct bContext *C, struct ARegion *ar);
 void ED_draw_on_surface_cursor(float modelview[16], float projection[16], float col[3], float alpha, float size[3], int viewport[4], float location[3], float inner_radius, float outer_radius, int brush_size);
 void ED_draw_fixed_overlay_on_surface(float modelview[16], float projection[16], float size[3], int viewport[4], float location[3], float outer_radius, struct Sculpt *sd, struct Brush *brush, struct ViewContext *vc, float t, float b, float l, float r, float angle);

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-06-06 19:33:38 UTC (rev 37267)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h	2011-06-06 19:36:37 UTC (rev 37268)
@@ -140,6 +140,8 @@
 
 int facemask_paint_poll(struct bContext *C);
 
+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-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c	2011-06-06 19:33:38 UTC (rev 37267)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c	2011-06-06 19:36:37 UTC (rev 37268)
@@ -15,6 +15,7 @@
 
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
+#include "BLI_rect.h"
 
 #include "BKE_brush.h"
 #include "BKE_context.h"
@@ -459,3 +460,117 @@
 	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;
+
+	ED_view3d_ob_project_mat_get(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];
+				ED_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]);
+			}
+		}
+	}
+
+	if (rect->xmin < rect->xmax && rect->ymin < rect->ymax) {
+		/* expand redraw rect with redraw rect from previous step to prevent
+		   partial-redraw issues caused by fast strokes. This is needed here (not in sculpt_flush_update)
+		   as it was before because redraw rectangle should be the same in both of
+		   optimized PBVH draw function and 3d view redraw (if not -- some mesh parts could
+		   disapper from screen (sergey) */
+
+		if (!BLI_rcti_is_empty(&(ob->paint->previous_r)))
+			BLI_union_rcti(rect, &(ob->paint->previous_r));
+
+		return 1;
+	}
+	else {
+		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)) {
+		ob->paint->previous_r= r;
+
+		r.xmin += ar->winrct.xmin + 1;
+		r.xmax += ar->winrct.xmin - 1;
+		r.ymin += ar->winrct.ymin + 1;
+		r.ymax += ar->winrct.ymin - 1;
+
+		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 = {{0}};
+	bglMats mats;
+	rcti rect;
+
+	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
+
+	ED_view3d_calc_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-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c	2011-06-06 19:33:38 UTC (rev 37267)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c	2011-06-06 19:36:37 UTC (rev 37268)
@@ -2158,7 +2158,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-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c	2011-06-06 19:33:38 UTC (rev 37267)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c	2011-06-06 19:36:37 UTC (rev 37268)
@@ -269,113 +269,12 @@
 	float plane_trim_squared;
 
 	float frontface_start, frontface_range;
-
-	rcti previous_r; /* previous redraw rectangle */
 } StrokeCache;
 
 /* rotation direction is flipped in different symmetrical passes */
 static const int rotation_flip[8] = { 1, -1, -1, 1, -1, 1, 1, -1 };
 
 
-/*** BVH Tree ***/
-
-/* Get a screen-space rectangle of the modified area */
-static 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;
-
-	ED_view3d_ob_project_mat_get(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];
-				ED_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]);
-			}
-		}
-	}
-
-	if (rect->xmin < rect->xmax && rect->ymin < rect->ymax) {
-		/* expand redraw rect with redraw rect from previous step to prevent
-		   partial-redraw issues caused by fast strokes. This is needed here (not in sculpt_flush_update)
-		   as it was before because redraw rectangle should be the same in both of
-		   optimized PBVH draw function and 3d view redraw (if not -- some mesh parts could
-		   disapper from screen (sergey) */
-
-		if (ob->paint->sculpt->cache) {
-			rcti* previous_r = &(ob->paint->sculpt->cache->previous_r);
-
-			if (!BLI_rcti_is_empty(previous_r))
-				BLI_union_rcti(rect, previous_r);
-		}
-
-		return 1;
-	}
-	else {
-		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;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list