Revision: 57780
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57780
Author:   psy-fi
Date:     2013-06-26 18:26:41 +0000 (Wed, 26 Jun 2013)
Log Message:
-----------
Necromancy exercice no #$%^&@!**#$>:3. Resurrect feature from old GSOC
onion branch that applies gravity after each dab in sculpt mode. I am
not very fond of the result, it will need artist feedback and testing.

Modified Paths:
--------------
    
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h
    branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c

Modified: 
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- 
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py   
    2013-06-26 16:59:58 UTC (rev 57779)
+++ 
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py   
    2013-06-26 18:26:41 UTC (rev 57780)
@@ -673,15 +673,10 @@
                     col.prop(brush, "use_persistent")
                     col.operator("sculpt.set_persistent_base")
 
-            col = layout.column(align=True)
-            col.label(text="Overlay:")
-
-            row = col.row()
-            if brush.use_cursor_overlay:
-                row.prop(brush, "use_cursor_overlay", toggle=True, text="", 
icon='RESTRICT_VIEW_OFF')
-            else:
-                row.prop(brush, "use_cursor_overlay", toggle=True, text="", 
icon='RESTRICT_VIEW_ON')
-
+            if capabilities.has_gravity:
+                col.separator()
+                
+                col.prop(brush, "gravity", slider=True)
         # Texture Paint Mode #
 
         elif context.image_paint_object and brush:
@@ -716,16 +711,7 @@
 
                 col.prop(brush, "use_accumulate")
 
-            col = layout.column(align=True)
-            col.label(text="Overlay:")
 
-            row = col.row()            
-            if brush.use_cursor_overlay:
-                row.prop(brush, "use_cursor_overlay", toggle=True, text="", 
icon='RESTRICT_VIEW_OFF')
-            else:
-                row.prop(brush, "use_cursor_overlay", toggle=True, text="", 
icon='RESTRICT_VIEW_ON')
-
-
         # Weight Paint Mode #
         elif context.weight_paint_object and brush:
             layout.prop(toolsettings, "use_auto_normalize", text="Auto 
Normalize")
@@ -769,16 +755,7 @@
 
             col.prop(brush, "vertex_tool", text="Blend")
 
-            col = layout.column(align=True)
-            col.label(text="Overlay:")
 
-            row = col.row()
-            if brush.use_cursor_overlay:
-                row.prop(brush, "use_cursor_overlay", toggle=True, text="", 
icon='RESTRICT_VIEW_OFF')
-            else:
-                row.prop(brush, "use_cursor_overlay", toggle=True, text="", 
icon='RESTRICT_VIEW_ON')
-
-
 class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
     bl_label = "Texture"
     bl_options = {'DEFAULT_CLOSED'}
@@ -966,17 +943,26 @@
 
         layout.template_curve_mapping(brush, "curve", brush=True)
 
-        row = layout.row(align=True)
+        col = layout.column(align=True)
+        row = col.row(align=True)
         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape 
= 'SMOOTH'
         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape 
= 'ROUND'
         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 
'ROOT'
         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 
'SHARP'
         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 
'LINE'
         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 
'MAX'
+                   
+        col = layout.column(align=True)
+        col.separator()
         
-        sub = row.row()
-        sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
-        sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", 
icon='BRUSH_DATA')
+        col.label(text="Overlay:")
+        row = col.row(align=True)
+        if brush.use_cursor_overlay:
+            row.prop(brush, "use_cursor_overlay", toggle=True, text="", 
icon='RESTRICT_VIEW_OFF')
+        else:
+            row.prop(brush, "use_cursor_overlay", toggle=True, text="", 
icon='RESTRICT_VIEW_ON')
+        row.prop(brush, "cursor_overlay_alpha", text="Alpha")
+        row.prop(brush, "use_cursor_overlay_override", toggle=True, text="", 
icon='BRUSH_DATA')
 
 
 class VIEW3D_PT_sculpt_topology(Panel, View3DPaintPanel):

Modified: branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c    
2013-06-26 16:59:58 UTC (rev 57779)
+++ branches/soc-2013-paint/source/blender/blenkernel/intern/brush.c    
2013-06-26 18:26:41 UTC (rev 57780)
@@ -135,6 +135,8 @@
 
        brush->stencil_dimension[0] = 256;
        brush->stencil_dimension[1] = 256;
+
+       brush->gravity_factor = 0.0;
 }
 
 /* Datablock add/copy/free/make_local */

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/sculpt.c        
2013-06-26 16:59:58 UTC (rev 57779)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/sculpt.c        
2013-06-26 18:26:41 UTC (rev 57780)
@@ -866,6 +866,7 @@
                case SCULPT_TOOL_CLAY:
                case SCULPT_TOOL_CLAY_STRIPS:
                case SCULPT_TOOL_DRAW:
+               case SCULPT_TOOL_GRAVITY:
                case SCULPT_TOOL_LAYER:
                        return alpha * flip * pressure * overlap * feather;
                        
@@ -1286,14 +1287,15 @@
                 ((brush->normal_weight > 0) ||
                  (brush->flag & BRUSH_FRONTFACE))) ||
 
-               ELEM7(brush->sculpt_tool,
+               ELEM8(brush->sculpt_tool,
                      SCULPT_TOOL_BLOB,
                      SCULPT_TOOL_CREASE,
                      SCULPT_TOOL_DRAW,
                      SCULPT_TOOL_LAYER,
                      SCULPT_TOOL_NUDGE,
                      SCULPT_TOOL_ROTATE,
-                     SCULPT_TOOL_THUMB) ||
+                     SCULPT_TOOL_THUMB,
+                     SCULPT_TOOL_GRAVITY) ||
 
                (brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA));
 }
@@ -2909,6 +2911,61 @@
        }
 }
 
+static void gravity(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, 
float bstrength)
+{
+       SculptSession *ss = ob->sculpt;
+       Brush *brush = BKE_paint_brush(&sd->paint);
+
+       float offset[3]/*, an[3]*/;
+       int n;
+       float gravity[3];
+
+       gravity[0]= gravity[1]= 0;
+       gravity[2]= -ss->cache->radius_squared;
+
+       /* offset with as much as possible factored in already */
+       mul_v3_v3v3(offset, gravity, ss->cache->scale);
+       mul_v3_fl(offset, bstrength);
+
+       /* threaded loop over nodes */
+       #pragma omp parallel for schedule(guided) if (sd->flags & 
SCULPT_USE_OPENMP)
+       for(n=0; n<totnode; n++) {
+               PBVHVertexIter vd;
+               SculptBrushTest test;
+               float (*proxy)[3];
+
+               proxy = BKE_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+
+               sculpt_brush_test_init(ss, &test);
+
+               BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, 
PBVH_ITER_UNIQUE) {
+                       if (sculpt_brush_test_sq(&test, vd.co)) {
+                       //if(paint_stroke_test_cyl(&test, vd.co, 
bspace->location, an)) {
+                               /* offset vertex */
+                               //float fade = tex_strength(stroke, brush, 
vd.co, vd.mask_combined, test.dist)*frontface(brush, bspace->frontface_start, 
bspace->frontface_range, an, orig_no[vd.i]);
+                               const float fade = bstrength * tex_strength(ss, 
brush, vd.co,
+                                                                           
sqrt(test.dist),
+                                                                           
ss->cache->sculpt_normal_symm, vd.no,
+                                                                           
vd.fno, vd.mask ? *vd.mask : 0.0f);
+
+                               mul_v3_v3fl(proxy[vd.i], offset, fade);
+
+                               if(vd.mvert)
+                                       vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+                       }
+               }
+               BKE_pbvh_vertex_iter_end;
+       }
+}
+
+static void do_gravity_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int 
totnode)
+{
+       SculptSession *ss = ob->sculpt;
+
+       gravity(sd, ob, nodes, totnode, ss->cache->bstrength);
+}
+
+
 void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
 {
        Mesh *me = (Mesh *)ob->data;
@@ -3119,6 +3176,9 @@
                        case SCULPT_TOOL_MASK:
                                do_mask_brush(sd, ob, nodes, totnode);
                                break;
+                       case SCULPT_TOOL_GRAVITY:
+                               do_gravity_brush(sd, ob, nodes, totnode);
+                               break;
                }
 
                if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, 
SCULPT_TOOL_MASK) &&
@@ -3132,6 +3192,9 @@
                        }
                }
 
+               if (brush->sculpt_tool != SCULPT_TOOL_GRAVITY && 
brush->gravity_factor > 0)
+                       gravity(sd, ob, nodes, totnode, brush->gravity_factor);
+
                MEM_freeN(nodes);
 
                /* update average stroke position */
@@ -3585,6 +3648,8 @@
                        return "Mask Brush";
                case SCULPT_TOOL_SIMPLIFY:
                        return "Simplify Brush";
+               case SCULPT_TOOL_GRAVITY:
+                       return "Gravity Brush";
        }
 
        return "Sculpting";
@@ -3809,10 +3874,10 @@
                cache->original = 1;
        }
 
-       if (ELEM8(brush->sculpt_tool,
+       if (ELEM9(brush->sculpt_tool,
                  SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB,
                  SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
-                 SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_ROTATE))
+                 SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_ROTATE, 
SCULPT_TOOL_GRAVITY))
        {
                if (!(brush->flag & BRUSH_ACCUMULATE)) {
                        cache->original = 1;

Modified: branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h   
2013-06-26 16:59:58 UTC (rev 57779)
+++ branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h   
2013-06-26 18:26:41 UTC (rev 57780)
@@ -89,6 +89,9 @@
 
        float plane_offset;     /* offset for plane brushes (clay, flatten, 
fill, scrape) */
 
+       float gravity_factor;   /* gravity factor for sculpting */
+       int pad;
+
        char sculpt_tool;       /* active sculpt tool */
        char vertexpaint_tool;  /* active vertex/weight paint blend mode 
(poorly named) */
        char imagepaint_tool;   /* active image paint tool */
@@ -195,7 +198,8 @@
        SCULPT_TOOL_CREASE = 16,
        SCULPT_TOOL_BLOB = 17,
        SCULPT_TOOL_CLAY_STRIPS = 18,
-       SCULPT_TOOL_MASK = 19
+       SCULPT_TOOL_MASK = 19,
+       SCULPT_TOOL_GRAVITY = 20
 } BrushSculptTool;
 
 /* ImagePaintSettings.tool */

Modified: branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c  
2013-06-26 16:59:58 UTC (rev 57779)
+++ branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c  
2013-06-26 18:26:41 UTC (rev 57780)
@@ -68,6 +68,7 @@
        {SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_SMOOTH, "Smooth", ""},
        {SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake 
Hook", ""},
        {SCULPT_TOOL_THUMB, "THUMB", ICON_BRUSH_THUMB, "Thumb", ""},
+       {SCULPT_TOOL_GRAVITY, "GRAVITY", ICON_BRUSH_SCULPT_DRAW, "Gravity", ""},
        {0, NULL, 0, NULL, NULL}
 };
 
@@ -236,6 +237,12 @@

@@ 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