Revision: 29402
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29402
Author:   jwilkins
Date:     2010-06-11 12:27:02 +0200 (Fri, 11 Jun 2010)

Log Message:
-----------
== Grab, Nudge, and Thumb Brushes and Pen Fixes ==
* Removed 'yank' brush, its behavior is completely replicable with Grab
* Grab Brush Fix
** Grab brush now behaves much like the one in Sculptris with the "Limit" 
option turned on.
** there is now a slider that allows the surface normal to be added to the 
direction of the grab, good for pulling things more out then sideways
** the vector for the slider is determined by the setting of 'original normal'
** the direction when grab is negated is now more intuitive (only really has an 
effect if the surface normal is mixed in)
** radius of brush now temporarily increases 2x when using grab
** removed strength slider for grab
* Nudge Brush
** can be used to move geometry in the plane of the normal as determined by 
calc_area_normal (means that it obeys 'original normal'
** with a smooth curve it drags geometry around and distorts it
** wit a harder curve it moves geometry without distoring it much
* Thumb Brush
** like nudge, but anchored
** Pen
* Properly linked up pen pressure to the appearance of the cursor
* The spaced stroke tool now takes into account the change of size caused by 
pen pressure, resulting in much smoother lines at lower pressure
- This highlights the need for space to interpolate more than just spacing, it 
also needs to interpolate size and strength, so this will be implemented in the 
future.
- Also, pressure needs to be smoothed out, but this should probably be done at 
a lower level
* Misc.
** Increased the hard limit of strength from 1 to 10.  Keep in mind the the 
strength is squared so 10 is 100 times stronger.
** If strength is greater than one due to multiplier or exceeding the soft 
limit, the cursor does not get any thicker or darker than it is at one

Modified Paths:
--------------
    branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
    
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h
    branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c

Modified: branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py       
2010-06-11 09:09:57 UTC (rev 29401)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py       
2010-06-11 10:27:02 UTC (rev 29402)
@@ -555,19 +555,23 @@
             else:
                 row.prop(brush, "size", slider=True, text="Pixels")
 
-            if brush.sculpt_tool != 'GRAB' and not brush.lock_brush_size:
+            if brush.sculpt_tool not in ('GRAB', 'THUMB'):
                 row.prop(brush, "use_size_pressure", toggle=True, text="")
 
-            row = col.row(align=True)
-            row.prop(brush, "strength", slider=True)
-            row.prop(brush, "use_strength_pressure", text="")
-            col.prop(brush, "strength_multiplier", slider=True)
+                row = col.row(align=True)
+                row.prop(brush, "strength", slider=True)
+                row.prop(brush, "use_strength_pressure", text="")
+                col.prop(brush, "strength_multiplier", slider=True)
 
-            # XXX - TODO
-            #row = col.row(align=True)
-            #row.prop(brush, "jitter", slider=True)
-            #row.prop(brush, "use_jitter_pressure", toggle=True, text="")
+                # XXX - TODO
+                #row = col.row(align=True)
+                #row.prop(brush, "jitter", slider=True)
+                #row.prop(brush, "use_jitter_pressure", toggle=True, text="")
 
+            if brush.sculpt_tool == 'GRAB':
+                row = col.row(align=True)
+                row.prop(brush, "normal_weight", slider=True)
+
             if brush.sculpt_tool in ('CLAY', 'FLATTEN', 'FILL', 'SCRAPE'):
                 row = col.row(align=True)
                 row.prop(brush, "plane_offset", slider=True)

Modified: 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c   
    2010-06-11 09:09:57 UTC (rev 29401)
+++ 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c   
    2010-06-11 10:27:02 UTC (rev 29402)
@@ -469,32 +469,27 @@
                float unprojected_radius;
                int flip;
                int sign;
-               float visual_strength;
+               float visual_strength = brush->alpha * brush->alpha;
 
-               const float min_alpha = 0.30f;
-               const float max_alpha = 0.70f;
+               const float min_alpha = 0.20f;
+               const float max_alpha = 0.80f;
                float* col;
                float  alpha;
 
                // XXX duplicated from brush_strength & paint_stroke_add_step, 
refactor later
-               {
-                       float strength = brush->alpha * brush->alpha;
-                       float pressure = 1.0f;
-                       wmEvent* event = CTX_wm_window(C)->eventstate;
+               wmEvent* event = CTX_wm_window(C)->eventstate;
 
-                       flip = event->shift ? -1 : 1;
+               flip = event->shift ? -1 : 1;
 
-                       if(event->custom == EVT_DATA_TABLET) {
-                               wmTabletData *wmtab= event->customdata;
-                               if(wmtab->Active != EVT_TABLET_NONE)
-                                       pressure = brush->flag & 
BRUSH_ALPHA_PRESSURE ? wmtab->Pressure : 1;
-                               if(wmtab->Active == EVT_TABLET_ERASER)
-                                       flip = 1;
-                       }
+               if ( brush->draw_pressure && brush->flag & BRUSH_ALPHA_PRESSURE)
+                       visual_strength *= brush->pressure_value;
 
-                       visual_strength = strength * pressure;
-               }
+               // remove effect of strength multiplier
+               visual_strength /= brush->strength_multiplier;
 
+               // don't show effect of strength past the soft limit
+               if (visual_strength > 1) visual_strength = 1;
+
                view3d_set_viewcontext(C, &vc);
 
                if (brush->draw_anchored) {
@@ -507,6 +502,9 @@
                                unprojected_radius = 
unproject_brush_radius(CTX_data_active_object(C), &vc, location, brush->size);
                }
 
+               if (brush->draw_pressure && brush->flag & BRUSH_SIZE_PRESSURE)
+                       unprojected_radius *= brush->pressure_value;
+
                if (!(brush->flag & BRUSH_LOCK_SIZE)) 
                        sculpt_set_brush_unprojected_radius(C, brush, 
unprojected_radius);
 
@@ -750,36 +748,44 @@
    towards the final mouse location. */
 static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, 
const float final_mouse[2])
 {
-    PaintStroke *stroke = op->customdata;
-    int cnt = 0;
+       PaintStroke *stroke = op->customdata;
+       int cnt = 0;
 
-    if(paint_space_stroke_enabled(stroke->brush)) {
-        float mouse[2];
-        float vec[2];
-        float length, scale;
+       if(paint_space_stroke_enabled(stroke->brush)) {
+               float mouse[2];
+               float vec[2];
+               float length, scale;
 
-        copy_v2_v2(mouse, stroke->last_mouse_position);
-        sub_v2_v2v2(vec, final_mouse, mouse);
+               copy_v2_v2(mouse, stroke->last_mouse_position);
+               sub_v2_v2v2(vec, final_mouse, mouse);
 
-        length = len_v2(vec);
+               length = len_v2(vec);
 
-        if(length > FLT_EPSILON) {
-            int steps;
-            int i;
+               if(length > FLT_EPSILON) {
+                       int steps;
+                       int i;
+                       float pressure = 1;
 
-            scale = (stroke->brush->size*stroke->brush->spacing/50.0f) / 
length;
-            mul_v2_fl(vec, scale);
+                       // XXX duplicate code
+                       if(event->custom == EVT_DATA_TABLET) {
+                               wmTabletData *wmtab= event->customdata;
+                               if(wmtab->Active != EVT_TABLET_NONE)
+                                       pressure = stroke->brush->flag & 
BRUSH_SIZE_PRESSURE ? wmtab->Pressure : 1;
+                       }
 
-            steps = (int)(1.0f / scale);
+                       scale = 
(stroke->brush->size*pressure*stroke->brush->spacing/50.0f) / length;
+                       mul_v2_fl(vec, scale);
 
-            for(i = 0; i < steps; ++i, ++cnt) {
-                add_v2_v2(mouse, vec);
-                paint_brush_stroke_add_step(C, op, event, mouse);
-            }
-        }
-    }
+                       steps = (int)(1.0f / scale);
 
-    return cnt;
+                       for(i = 0; i < steps; ++i, ++cnt) {
+                               add_v2_v2(mouse, vec);
+                               paint_brush_stroke_add_step(C, op, event, 
mouse);
+                       }
+               }
+       }
+
+       return cnt;
 }
 
 /**** Public API ****/

Modified: 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c     
2010-06-11 09:09:57 UTC (rev 29401)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c     
2010-06-11 10:27:02 UTC (rev 29402)
@@ -754,18 +754,23 @@
                case SCULPT_TOOL_FILL:
                case SCULPT_TOOL_SCRAPE:
                case SCULPT_TOOL_FLATTEN:
-               case SCULPT_TOOL_GRAB:
                        return alpha * dir * flip * pressure * overlap;
 
                case SCULPT_TOOL_SMOOTH:
-                       return alpha * 4 * pressure * overlap;
+                       return alpha * 4.0f * pressure * overlap;
 
                case SCULPT_TOOL_PINCH:
-                       return alpha / 2 * dir * pressure * flip * overlap;
+                       return alpha / 2.0f * dir * pressure * flip * overlap;
 
-               case SCULPT_TOOL_YANK:
-                       return 1;
+               case SCULPT_TOOL_GRAB:
+                       return dir*flip > 0 ? 0.5f : -0.5f;
 
+               case SCULPT_TOOL_NUDGE:
+                       return alpha * pressure * overlap;
+
+               case SCULPT_TOOL_THUMB:
+                       return 0.5f;
+
                default:
                        return 0;
        }
@@ -1384,22 +1389,29 @@
        int n;
        float len;
 
-       calc_area_normal(sd, ss, an, nodes, totnode);
+       if (brush->normal_weight > 0)
+               calc_area_normal(sd, ss, an, nodes, totnode);
 
        copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
 
        len = len_v3(grab_delta);
 
-       mul_v3_fl(an, len/2.0f);
-       mul_v3_fl(grab_delta, 0.5f);
-       add_v3_v3(grab_delta, an);
+       if (bstrength < 0)
+               negate_v3(grab_delta);
 
+       if (brush->normal_weight > 0) {
+               mul_v3_fl(an, len*brush->normal_weight);
+               mul_v3_fl(grab_delta, 1.0f - brush->normal_weight);
+               add_v3_v3(grab_delta, an);
+       }
+
        for(n=0; n<totnode; n++) {
                PBVHVertexIter vd;
                SculptBrushTest test;
                float (*origco)[3];
        
                origco= sculpt_undo_push_node(ss, nodes[n])->co;
+
                sculpt_brush_test_init(ss, &test);
 
                BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, 
PBVH_ITER_UNIQUE) {
@@ -1425,34 +1437,40 @@
        }
 }
 
-static void do_yank_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int 
totnode)
+static void do_nudge_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, 
int totnode)
 {
        Brush *brush = paint_brush(&sd->paint);
-       float bstrength= ss->cache->bstrength;
+       float bstrength = ss->cache->bstrength;
        float grab_delta[3];
        int n;
-       
+       float an[3];
+
        copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
 
-       //#pragma omp parallel for private(n) schedule(static)
-       for(n=0; n<totnode; n++) {
+       calc_area_normal(sd, ss, an, nodes, totnode);
+
+       for(n = 0; n < totnode; n++) {
                PBVHVertexIter vd;
                SculptBrushTest test;
-               float (*origco)[3];
-               
-               origco= sculpt_undo_push_node(ss, nodes[n])->co;
+
+               sculpt_undo_push_node(ss, nodes[n]);
                sculpt_brush_test_init(ss, &test);
 
                BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, 
PBVH_ITER_UNIQUE) {
-                       if(sculpt_brush_test(&test, origco[vd.i])) {
-                               float fade = tex_strength(ss, brush, 
origco[vd.i], test.dist)*bstrength;
+                       if(sculpt_brush_test(&test, vd.co)) {
+                               float fade = bstrength*tex_strength(ss, brush, 
vd.co, test.dist);
                                float val[3];
+                               float tmp[3];
 
+                               cross_v3_v3v3(tmp, an, grab_delta);
+                               cross_v3_v3v3(val, an, tmp);
+
                                mul_v3_v3fl(val, grab_delta, fade);
                                symmetry_feather(sd, ss, vd.co, val);
                                add_v3_v3(val, vd.co);
 
-                               sculpt_clip(sd, ss, vd.co, val);                
        
+                               sculpt_clip(sd, ss, vd.co, val);
+
                                if(vd.mvert) {
                                        vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
                                        if(brush->flag & BRUSH_SUBDIV) 
vd.mvert->flag = 1; 
@@ -1465,6 +1483,53 @@
        }
 }
 
+static void do_thumb_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, 
int totnode)
+{
+       Brush *brush = paint_brush(&sd->paint);
+       float bstrength = ss->cache->bstrength;
+       float grab_delta[3];
+       int n;
+       float an[3];
+
+       copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
+
+       calc_area_normal(sd, ss, an, nodes, totnode);
+
+       for(n = 0; n < totnode; n++) {
+               PBVHVertexIter vd;
+               SculptBrushTest test;
+               float (*origco)[3];
+
+               origco=sculpt_undo_push_node(ss, nodes[n])->co;
+               sculpt_brush_test_init(ss, &test);
+
+               BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, 
PBVH_ITER_UNIQUE) {
+                       if(sculpt_brush_test(&test, origco[vd.i])) {
+                               float fade = bstrength*tex_strength(ss, brush, 
origco[vd.i], test.dist);
+                               float val[3];
+                               float tmp[3];
+
+                               cross_v3_v3v3(tmp, an, grab_delta);
+                               cross_v3_v3v3(val, an, tmp);
+
+                               mul_v3_v3fl(val, grab_delta, fade);
+                               symmetry_feather(sd, ss, origco[vd.i], val);
+                               add_v3_v3(val, origco[vd.i]);
+
+                               sculpt_clip(sd, ss, vd.co, val);
+
+                               if(vd.mvert) {
+                                       vd.mvert->flag |= ME_VERT_PBVH_UPDATE;

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to