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

Jason Wilkins Jason.A.Wilkins at gmail.com
Sun Aug 7 18:11:56 CEST 2011


Revision: 39150
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39150
Author:   jwilkins
Date:     2011-08-07 16:11:56 +0000 (Sun, 07 Aug 2011)
Log Message:
-----------
Revision: 30856
Author: nicholasbishop
Date: 7:47:10 PM, Wednesday, July 28, 2010
Message:
== Paint ==

* Moved a bunch more sculpt stroke stuff into paint stroke
* Made all the sculpt stroke UI visible for vpaint too
* Most of sculpt's stroke features work in vpaint now

TODO:
* Drag dot for vpaint
* Anchored for vpaint
* Smooth stroke broken
----
Modified : /branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py
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_utils.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_scene_types.h

--
jwilkins: another patch that is more inspired by the original than anything.  mainly I renamed 'first_step' to 'first_dab' and added code to double the radius for the a grab or snake hook tools.  I also snipped some code from the patch and put it in come comments where I can use it to later without having to refer back to this patch.

BrushSpace largely covers the majority of this original patch.

The main difference is the 'set_modifier' functions.  I think that my approach makes those functions unneeded.  For example, snake hook and rotate tools need to use the original location instead of the current mouse location.  With BrushSpace they can use bspace_first instead of bspace_curr, and no special flag is needed in stroke to make this happen.  The other example is texture coordinates. Eventually there will be a set of callbacks for each texture mode.  In that case all the logic of texture lookups will be handled by a specialized function for each mode. The final modifier, the radius factor needed for grab and snakehook, is handled by passing a modified radius to paint_bspace_init and paint_bspace_update.

Modified Paths:
--------------
    branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.h
    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_tools.c

Modified: branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2011-08-07 16:10:14 UTC (rev 39149)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2011-08-07 16:11:56 UTC (rev 39150)
@@ -947,7 +947,7 @@
 
 
             # Mouse
-
+            # SNIP if (context.vertex_paint_object or brush.sculpt_tool not in ('GRAB', 'THUMB', 'SNAKE_HOOK', 'ROTATE')) and (not brush.use_anchor) and (not brush.restore_mesh):
             if not brush.use_anchored_stroke:
                 col.label("Position:")
                 col.prop(brush, "stroke_mouse_method", text="")

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-07 16:10:14 UTC (rev 39149)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c	2011-08-07 16:11:56 UTC (rev 39150)
@@ -493,6 +493,21 @@
 	return bspace_curr->hit;
 }
 
+#if 0 // SNIP From Nick's refactor, I'm putting this here for reference
+static void sculpt_stroke_set_modifiers(PaintStroke *stroke, Brush *brush)
+{
+	if(ELEM(brush->sculpt_tool, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_ROTATE))
+		paint_stroke_set_modifier_use_original_location(stroke);
+
+	if(ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
+		paint_stroke_set_modifier_initial_radius_factor(stroke, 2.0f);
+
+	if(ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK,
+		 SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE))
+		paint_stroke_set_modifier_use_original_texture_coords(stroke);
+}
+#endif
+
 #if 0
 //static float tex_strength(Brush *brush, PaintStroke *stroke,
 //			  float co[3], float mask, float len,

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c	2011-08-07 16:10:14 UTC (rev 39149)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c	2011-08-07 16:11:56 UTC (rev 39150)
@@ -89,8 +89,8 @@
 	   passes over the mesh */
 	int started;
 
-	/* non-zero on the first step, zero for subsequent steps */
-	int first_step;
+	/* non-zero on the first dab, zero for subsequent dabs */
+	int first_dab;
 
 	int one_time_init;
 
@@ -195,9 +195,9 @@
 	return &(stroke->params);
 }
 
-int paint_stroke_first_step(const PaintStroke *stroke)
+int paint_stroke_first_dab(const PaintStroke *stroke)
 {
-	return stroke->first_step;
+	return stroke->first_dab;
 }
 
 const ViewContext *paint_stroke_view_context(const PaintStroke *stroke)
@@ -358,6 +358,13 @@
 	return params->flag & STROKE_ANCHORED;
 }
 
+static int anchored_snap_enabled(const PaintStrokeParams *params)
+{
+	return
+		(params->flag & STROKE_ANCHORED) && 
+		(params->flag & (STROKE_SNAP_TILT|STROKE_SNAP_RAKE));
+}
+
 static int snap_enabled(const PaintStrokeParams *params)
 {
 	const int snap_flags=
@@ -555,7 +562,7 @@
 	struct PaintStroke *stroke)
 {
 	stroke->started=    1;
-	stroke->first_step= 1;
+	stroke->first_dab= 1;
 
 	stroke->start_time= PIL_check_seconds_timer();
 
@@ -615,7 +622,7 @@
 		if (stroke->brushlib_surface && stroke->brushlib_brush) {
 			float dtime= (stroke->current.time) - (stroke->path.time);
 
-			if (stroke->first_step) {
+			if (stroke->first_dab) {
 				paint_brushlib_set_radius(stroke->brushlib_brush, stroke->params.radius2d);
 				paint_brushlib_set_color(stroke->brushlib_brush, stroke->params.rgb);
 			}
@@ -643,7 +650,7 @@
 
 	stroke->path= stroke->current;
 
-	stroke->first_step= 0;
+	stroke->first_dab= 0;
 }
 
 static void cache_rna(struct PaintStroke *stroke, struct PointerRNA *itemptr)
@@ -1243,13 +1250,20 @@
 
 	uv_frame(stroke);
 
+	/* XXX: needs rewrite so snap/smooth of position/tilt/pressure/rake
+	   are more clearly handled separately */
+
 	if (anchored_enabled(&(stroke->params))) {
-		return anchor_stroke(stroke);
+		int rv= 0;
+
+		if (anchored_snap_enabled(&(stroke->params)))
+			rv |= snap_stroke(stroke);
+
+		rv |= anchor_stroke(stroke);
+
+		return rv;
 	}
 	else {
-		/* XXX: needs rewrite so snap/smooth of position/tilt/pressure/rake
-		   are handled separately */
-
 		int snap_on= snap_enabled(&(stroke->params));
 		int smooth_on= smooth_enabled(&(stroke->params));
 

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.h	2011-08-07 16:10:14 UTC (rev 39149)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.h	2011-08-07 16:11:56 UTC (rev 39150)
@@ -97,7 +97,7 @@
 void *paint_stroke_mode_data(const struct PaintStroke *stroke);
 void paint_stroke_set_mode_data( struct PaintStroke *stroke, void *mode_data);
 const PaintStrokeParams *paint_stroke_params(const struct PaintStroke* stroke);
-int paint_stroke_first_step(const struct PaintStroke *stroke);
+int paint_stroke_first_dab(const struct PaintStroke *stroke);
 const struct ViewContext *paint_stroke_view_context(const struct PaintStroke *stroke);
 
 float paint_stroke_invert(const struct PaintStroke *stroke);

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-08-07 16:10:14 UTC (rev 39149)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c	2011-08-07 16:11:56 UTC (rev 39150)
@@ -2279,7 +2279,7 @@
 	Brush *brush= paint_brush(&(vp->paint));
 
 	/* first step is handled by paint_bspace_init */
-	if (!paint_stroke_first_step(stroke)) {
+	if (!paint_stroke_first_dab(stroke)) {
 		paint_bspace_update(C, stroke, vpaint_stroke_get_location, paint_stroke_mouse(stroke), brush_size(brush));
 	}
 
@@ -2335,7 +2335,7 @@
 	mouse[0]= x;
 	mouse[1]= y;
 
-	if (paint_stroke_first_step(stroke))
+	if (paint_stroke_first_dab(stroke))
 		paint_bspace_init(C, stroke, vpaint_stroke_get_location, mouse, radius);
 	else
 		paint_bspace_update(C, stroke, vpaint_stroke_get_location, mouse, radius);

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c	2011-08-07 16:10:14 UTC (rev 39149)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c	2011-08-07 16:11:56 UTC (rev 39150)
@@ -265,6 +265,8 @@
 	struct Brush      *brush= paint_brush(&(sd->paint));
 	struct SculptData *mode_data;
 
+	float radius_factor;
+
 	paint_cache_init(
 		CTX_wm_manager(C),
 		&(sd->paint),
@@ -291,7 +293,17 @@
 
 	sculpt_undo_push_begin(sculpt_tool_name(sd));
 
-	paint_bspace_init(C, stroke, sculpt_stroke_get_location, paint_stroke_mouse(stroke), brush_size(brush));
+	if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
+		radius_factor= 2.0f;
+	else
+		radius_factor= 1.0f;
+
+	paint_bspace_init(
+		C,
+		stroke,
+		sculpt_stroke_get_location,
+		paint_stroke_mouse(stroke),
+		radius_factor * brush_size(brush));
 }
 
 static void sculpt_stroke_done(

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c	2011-08-07 16:10:14 UTC (rev 39149)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c	2011-08-07 16:11:56 UTC (rev 39150)
@@ -1777,6 +1777,8 @@
 	struct Brush  *brush= paint_brush(&sd->paint);
 	struct SculptData *mode_data= paint_stroke_mode_data(stroke);
 
+	float radius_factor;
+
 	/* pay careful attention to the order of operations in this function
 	   update the mesh cache
 	   update brush space, which depends on an up-to-date mesh
@@ -1788,9 +1790,20 @@
 
 	paint_mesh_update_when_modifiers(C, sculpt_tool_need_fmap(brush));
 
+	if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
+		radius_factor= 2.0f;
+	else
+		radius_factor= 1.0f;
+
 	/* first step is handled by paint_bspace_init */
-	if (!paint_stroke_first_step(stroke))
-		paint_bspace_update(C, stroke, sculpt_stroke_get_location, paint_stroke_mouse(stroke), brush_size(brush));
+	if (!paint_stroke_first_dab(stroke)) {
+		paint_bspace_update(
+			C,
+			stroke,
+			sculpt_stroke_get_location,
+			paint_stroke_mouse(stroke),
+			radius_factor * brush_size(brush));
+	}
 
 	if (paint_bspace_hit(C)) {
 		struct BrushSpace *bspace= sd->paint.cache->bspace_curr;




More information about the Bf-blender-cvs mailing list