[Bf-blender-cvs] [fd8a07a] soc-2016-pbvh-painting: weight paint is now fading out according to the curve settings. Doing a partial redraw instead of a full screen redraw.

Nathan Vollmer noreply at git.blender.org
Wed Jul 13 01:30:08 CEST 2016


Commit: fd8a07aa1059c1e72d0c00a2700c1bc1bbb88590
Author: Nathan Vollmer
Date:   Sat Jul 9 20:24:42 2016 -0600
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rBfd8a07aa1059c1e72d0c00a2700c1bc1bbb88590

weight paint is now fading out according to the curve settings. Doing a partial redraw instead of a full screen redraw.

===================================================================

M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/editors/sculpt_paint/sculpt_undo.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index a1d2d38..69d6e89 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1,4 +1,3 @@
-#pragma optimize("", off)
 /*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
@@ -1568,8 +1567,7 @@ static void do_weight_paint_vertex_single(
 	{
 		dw->weight = wpaint_blend(wp, dw->weight, dw_prev->weight, alpha, paintweight,
 		                          wpi->brush_alpha_value, wpi->do_flip);
-    dw->weight = 1.0;
-    printf("Vertex weight: %f\n", dw->weight);
+
 		/* WATCH IT: take care of the ordering of applying mirror -> normalize,
 		 * can give wrong results [#26193], least confusing if normalize is done last */
 
@@ -2237,6 +2235,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
 	wpd->indexar = get_indexarray(me);
 	copy_wpaint_prev(wp, me->dvert, me->totvert);
 
+  //This will probably change!
 	if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
 		BKE_mesh_vert_edge_vert_map_create(
 		        &wpd->blur_data.vmap, &wpd->blur_data.vmap_mem,
@@ -2365,6 +2364,8 @@ static void do_wpaint_brush_draw_task_cb_ex(
   unsigned int *lcol = data->lcol;
 
   unsigned int *lcolorig = data->vp->vpaint_prev;
+  //data->nodes[n];
+  //data->nodes[n].flag &= PBVH_UpdateRedraw;
 
   //for each vertex
   PBVHVertexIter vd;
@@ -2377,13 +2378,13 @@ static void do_wpaint_brush_draw_task_cb_ex(
     if (sculpt_brush_test(&test, vd.co)) {
       const float fade = BKE_brush_curve_strength(brush, test.dist, cache->radius);
       int vertexIndex = vd.vert_indices[vd.i];
-      data->wpi->brush_alpha_value = 255.0;
 
-      MDeformWeight *dw;
+      MDeformWeight *dw, *dw_prev;
       MDeformVert *dv = &data->me->dvert[vertexIndex];
       dw = defvert_verify_index(dv, data->wpi->active.index);
-      dw->weight = paintweight;
-     // do_weight_paint_vertex(data->vp, data->ob, &data->wpi, vertexIndex, 255.0, paintweight);
+      dw_prev = defvert_verify_index(data->vp->wpaint_prev + vertexIndex, data->wpi->active.index);
+      dw->weight = wpaint_blend(data->vp, dw->weight, dw_prev->weight, fade, paintweight, data->wpi->brush_alpha_value, data->wpi->do_flip); 
+      //do_weight_paint_vertex(data->vp, data->ob, &data->wpi, vertexIndex, 255.0, paintweight);
 
       //if a vertex is within the brush region, then paint each loop that vertex owns.
       //for (int j = 0; j < ss->vert_to_loop[vertexIndex].count; ++j) {
@@ -2413,7 +2414,6 @@ static void wpaint_paint_leaves(bContext *C, Object *ob, Sculpt *sd, VPaint *vp,
   data.me = me;
   data.C = C;
 
-  printf("Painting leaves\n");
   //This might change to a case switch. 
   //if (brush->vertexpaint_tool == PAINT_BLEND_AVERAGE) {
   //  calculate_average_color(&data, nodes, totnode);
@@ -2547,7 +2547,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
 	/* load projection matrix */
 	mul_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat);
 
-	RNA_float_get_array(itemptr, "mouse", mval);
+	//RNA_float_get_array(itemptr, "mouse", mval);
 
 	/* *** setup WeightPaintInfo - pass onto do_weight_paint_vertex *** */
 	wpi.defbase_tot =        wpd->defbase_tot;
@@ -2726,7 +2726,29 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
 	}
 
 	DAG_id_tag_update(ob->data, 0);
-	ED_region_tag_redraw(vc->ar);
+
+  rcti r;
+  if (sculpt_get_redraw_rect(vc->ar, CTX_wm_region_view3d(C), ob, &r)) {
+    if (ss->cache) {
+      ss->cache->current_r = r;
+    }
+
+    /* previous is not set in the current cache else
+    * the partial rect will always grow */
+    if (ss->cache) {
+      if (!BLI_rcti_is_empty(&ss->cache->previous_r))
+        BLI_rcti_union(&r, &ss->cache->previous_r);
+    }
+
+    r.xmin += vc->ar->winrct.xmin - 2;
+    r.xmax += vc->ar->winrct.xmin + 2;
+    r.ymin += vc->ar->winrct.ymin - 2;
+    r.ymax += vc->ar->winrct.ymin + 2;
+
+    ss->partial_redraw = 1;
+    ED_region_tag_redraw_partial(vc->ar, &r);
+  }
+	//ED_region_tag_redraw(vc->ar);
 }
 
 static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index f3cf72c..ad9768a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -47,7 +47,6 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_node_types.h"
 #include "DNA_object_types.h"
-#include "DNA_scene_types.h"
 
 #include "BKE_pbvh.h"
 #include "BKE_brush.h"
@@ -446,7 +445,7 @@ static void sculpt_extend_redraw_rect_previous(Object *ob, rcti *rect)
 }
 
 /* Get a screen-space rectangle of the modified area */
-static bool sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
+bool sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
                                    Object *ob, rcti *rect)
 {
 	PBVH *pbvh = ob->sculpt->pbvh;
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 9a2d06c..fc0cd16 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -38,6 +38,8 @@
 #include "DNA_key_types.h"
 #include "DNA_brush_types.h"
 #include "DNA_view3d_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_scene_types.h"
 #include "DNA_mesh_types.h"
 
 #include "BLI_bitmap.h"
@@ -330,6 +332,8 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]);
 
 void sculpt_update_object_bounding_box(struct Object *ob);
 
+bool sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, Object *ob, rcti *rect);
+
 #define SCULPT_THREADED_LIMIT 4
 
 #endif
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 44bd872..2a8af93 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -46,7 +46,6 @@
 
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
-#include "DNA_scene_types.h"
 #include "DNA_mesh_types.h"
 
 #include "BKE_ccg.h"




More information about the Bf-blender-cvs mailing list