Commit: 9c3be3335d52263db3284cff63cb1fbb1cd88d9a
Author: decoda
Date:   Sun Jun 18 13:29:30 2017 +0530
Branches: soc-2017-sculpting_brush
https://developer.blender.org/rB9c3be3335d52263db3284cff63cb1fbb1cd88d9a

Topograb Brush Initialization

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

M       .gitignore
M       source/blender/blenkernel/BKE_paint.h
M       source/blender/blenkernel/intern/brush.c
M       source/blender/blenloader/intern/versioning_defaults.c
M       source/blender/editors/datafiles/CMakeLists.txt
M       source/blender/editors/include/ED_datafiles.h
M       source/blender/editors/include/UI_icons.h
M       source/blender/editors/interface/interface_icons.c
M       source/blender/editors/sculpt_paint/paint_ops.c
M       source/blender/editors/sculpt_paint/paint_stroke.c
M       source/blender/editors/sculpt_paint/sculpt.c
M       source/blender/makesdna/DNA_brush_types.h
M       source/blender/makesrna/intern/rna_brush.c

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

diff --git a/.gitignore b/.gitignore
index 38dd7497d66..cf73979172c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,3 +40,4 @@ Desktop.ini
 /doc/python_api/rst/run_script.png
 /doc/python_api/rst/spacebar.png
 /release/datafiles/brushicons/clip.png
+/release/datafiles/brushicons/topograb.png
diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 0a3cc950f32..b8faece6929 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -198,7 +198,7 @@ typedef struct SculptSession {
 
        /* Layer brush persistence between strokes */
        float (*layer_co)[3]; /* Copy of the mesh vertices' locations */
-
+       int brush_size;
        struct SculptStroke *stroke;
        struct StrokeCache *cache;
 } SculptSession;
diff --git a/source/blender/blenkernel/intern/brush.c 
b/source/blender/blenkernel/intern/brush.c
index 0801e346107..540ef789e66 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -422,6 +422,7 @@ void BKE_brush_sculpt_reset(Brush *br)
                        br->add_col[2] = 0.750000;
                        break;
                case SCULPT_TOOL_GRAB:
+               case SCULPT_TOOL_TOPO_GRAB:
                case SCULPT_TOOL_SNAKE_HOOK:
                case SCULPT_TOOL_THUMB:
                        br->size = 75;
diff --git a/source/blender/blenloader/intern/versioning_defaults.c 
b/source/blender/blenloader/intern/versioning_defaults.c
index 41fceb951c2..bd71f6e75ea 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -274,6 +274,12 @@ void BLO_update_defaults_startup_blend(Main *bmain)
                        br->flag |= BRUSH_ORIGINAL_NORMAL;
                }
 
+               /* use original normal for topo grab brush (otherwise flickers 
with normal weighting). */
+               br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Topo");
+               if (br) {
+                       br->flag |= BRUSH_ORIGINAL_NORMAL;
+               }
+
                /* increase strength, better for smoothing method */
                br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Blur");
                if (br) {
diff --git a/source/blender/editors/datafiles/CMakeLists.txt 
b/source/blender/editors/datafiles/CMakeLists.txt
index 2c59a9e6756..7196625725e 100644
--- a/source/blender/editors/datafiles/CMakeLists.txt
+++ b/source/blender/editors/datafiles/CMakeLists.txt
@@ -97,6 +97,7 @@ if(WITH_BLENDER)
                
data_to_c_simple(../../../../release/datafiles/brushicons/texfill.png SRC)
                
data_to_c_simple(../../../../release/datafiles/brushicons/texmask.png SRC)
                
data_to_c_simple(../../../../release/datafiles/brushicons/thumb.png SRC)
+        data_to_c_simple(../../../../release/datafiles/brushicons/topograb.png 
SRC)
                
data_to_c_simple(../../../../release/datafiles/brushicons/twist.png SRC)
                
data_to_c_simple(../../../../release/datafiles/brushicons/vertexdraw.png SRC)
 
diff --git a/source/blender/editors/include/ED_datafiles.h 
b/source/blender/editors/include/ED_datafiles.h
index b1458bb08be..1fb549dd412 100644
--- a/source/blender/editors/include/ED_datafiles.h
+++ b/source/blender/editors/include/ED_datafiles.h
@@ -159,6 +159,9 @@ extern char datatoc_texfill_png[];
 extern int datatoc_texmask_png_size;
 extern char datatoc_texmask_png[];
 
+extern int datatoc_topograb_png_size;
+extern char datatoc_topograb_png[];
+
 extern int datatoc_thumb_png_size;
 extern char datatoc_thumb_png[];
 
diff --git a/source/blender/editors/include/UI_icons.h 
b/source/blender/editors/include/UI_icons.h
index 2c7032ca68a..8c604208041 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -974,6 +974,7 @@ DEF_ICON(BRUSH_SOFTEN)
 DEF_ICON(BRUSH_SUBTRACT)
 DEF_ICON(BRUSH_TEXDRAW)
 DEF_ICON(BRUSH_TEXFILL)
+DEF_ICON(BRUSH_TOPO_GRAB)
 DEF_ICON(BRUSH_TEXMASK)
 DEF_ICON(BRUSH_THUMB)
 DEF_ICON(BRUSH_ROTATE)
diff --git a/source/blender/editors/interface/interface_icons.c 
b/source/blender/editors/interface/interface_icons.c
index 6cc85fa065c..5f9a17891f3 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -391,6 +391,7 @@ static void init_brush_icons(void)
        INIT_BRUSH_ICON(ICON_BRUSH_SUBTRACT, subtract);
        INIT_BRUSH_ICON(ICON_BRUSH_TEXDRAW, texdraw);
        INIT_BRUSH_ICON(ICON_BRUSH_TEXFILL, texfill);
+       INIT_BRUSH_ICON(ICON_BRUSH_TOPO_GRAB, topograb);
        INIT_BRUSH_ICON(ICON_BRUSH_TEXMASK, texmask);
        INIT_BRUSH_ICON(ICON_BRUSH_THUMB, thumb);
        INIT_BRUSH_ICON(ICON_BRUSH_ROTATE, twist);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c 
b/source/blender/editors/sculpt_paint/paint_ops.c
index 6842e6a5fb8..55b119787ef 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -1598,6 +1598,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_CLAY, CKEY, 0);
        keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_CREASE, CKEY, 
KM_SHIFT);
        keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_SNAKE_HOOK, 
KKEY, 0);
+       keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_TOPO_GRAB, 
OKEY, 0);
        kmi = keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_MASK, 
MKEY, 0);
        RNA_boolean_set(kmi->ptr, "toggle", 1);
        RNA_boolean_set(kmi->ptr, "create_missing", 1);
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c 
b/source/blender/editors/sculpt_paint/paint_stroke.c
index 05270dbfa09..96b5f49bf37 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -196,7 +196,7 @@ static bool paint_tool_require_location(Brush *brush, 
PaintMode mode)
 {
        switch (mode) {
                case ePaintSculpt:
-                       if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, 
SCULPT_TOOL_ROTATE,
+                       if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, 
SCULPT_TOOL_TOPO_GRAB, SCULPT_TOOL_CLIP, SCULPT_TOOL_ROTATE,
                                                     SCULPT_TOOL_SNAKE_HOOK, 
SCULPT_TOOL_THUMB))
                        {
                                return false;
@@ -763,6 +763,8 @@ static bool sculpt_is_grab_tool(Brush *br)
 {
        return ELEM(br->sculpt_tool,
                     SCULPT_TOOL_GRAB,
+                                SCULPT_TOOL_TOPO_GRAB,
+                                SCULPT_TOOL_CLIP,
                     SCULPT_TOOL_THUMB,
                     SCULPT_TOOL_ROTATE,
                     SCULPT_TOOL_SNAKE_HOOK);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index a8dac5ad6d5..e5f3137c237 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -127,6 +127,7 @@ static bool sculpt_tool_needs_original(const char 
sculpt_tool)
 {
        return ELEM(sculpt_tool,
                                SCULPT_TOOL_GRAB,
+                               SCULPT_TOOL_TOPO_GRAB,
                                SCULPT_TOOL_ROTATE,
                                SCULPT_TOOL_THUMB,
                                SCULPT_TOOL_LAYER,
@@ -1244,6 +1245,9 @@ static float brush_strength(
 
                case SCULPT_TOOL_GRAB:
                        return root_alpha * feather;
+               
+               case SCULPT_TOOL_TOPO_GRAB:
+                       return root_alpha * feather;
 
                case SCULPT_TOOL_ROTATE:
                        return alpha * pressure * feather;
@@ -3088,7 +3092,7 @@ float dist_squared_to_line_direction_v3v3(const float 
v1[3], const float v2[3],
        cross_v3_v3v3(e, v2v1, dir);
        return len_squared_v3(e);
 }
-static bool sculpt_brush_test_clippc(SculptBrushTest *test, const float co[], 
float radius)
+static bool sculpt_brush_test_clippc(SculptBrushTest *test, const float co[])
 {
        calc_foot_perp_v3_v3v3v3(test->foot, co, test->normal, test->location);
        test->radius =paint_calc_object_space_radius(test->vc,
@@ -3140,7 +3144,7 @@ static void do_clip_brush_task_cb_ex(
        {
                sculpt_orig_vert_data_update(&orig_data, &vd);
 
-               if (sculpt_brush_test_clippc(&test, vd.co, 
ss->cache->radius_squared)){ /*initially vd = orig_data*/
+               if (sculpt_brush_test_clippc(&test, vd.co)){ /*initially vd = 
orig_data*/
                        /*
                        float vec[3] = { 0 };
                        const float fade = bstrength * tex_strength(
@@ -3207,6 +3211,70 @@ static void do_clip_brush(Sculpt *sd, Object *ob, 
PBVHNode **nodes, int totnode)
                ((sd->flags & SCULPT_USE_OPENMP) && totnode > 
SCULPT_THREADED_LIMIT), false);
 }
 
+static void do_topo_grab_brush_task_cb_ex(
+       void *userdata, void *UNUSED(userdata_chunk), const int n, const int 
thread_id)
+{
+       SculptThreadedTaskData *data = userdata;
+       SculptSession *ss = data->ob->sculpt;
+       Brush *brush = data->brush;
+       const float *grab_delta = data->grab_delta;
+
+       PBVHVertexIter vd;
+       SculptBrushTest test;
+       SculptOrigVertData orig_data;
+       float(*proxy)[3];
+       const float bstrength = ss->cache->bstrength;
+
+       sculpt_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]);
+
+       proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
+
+       sculpt_brush_test_init(ss, &test);
+       int ip = 0;
+       BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, 
PBVH_ITER_UNIQUE)
+       {
+               sculpt_orig_vert_data_update(&orig_data, &vd);
+
+               if (sculpt_brush_test(&test, orig_data.co)) {
+                       const float fade = bstrength * tex_strength(
+                               ss, brush, orig_data.co, test.dist, 
orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f,
+                               thread_id);
+
+
+                       mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
+
+                       if (vd.mvert){
+                               vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+                               if(ip < 10) vd.mvert->flag |= SELECT;
+                               ip += 1;
+                       }
+               }
+       }
+       BKE_pbvh_vertex_iter_end;
+}
+
+static void do_topo_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int 
totnode)
+{
+       SculptSession *ss = ob->sculpt;
+       Brush *brush = BKE_paint_brush(&sd->paint);
+       float grab_delta[3];
+
+       copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
+
+       if (ss->cache->normal_weight > 0.0f) {
+               sculpt_project_v3_normal_align(ss, ss->cache->normal_weight, 
grab_delta);
+       }
+
+       SculptThreadedTaskData data = {
+               .sd = sd, .ob = ob, .brush = brush, .nodes = nodes,
+               .grab_delta = grab_delta,
+       };
+
+       BLI_task_parallel_range_ex(
+               0, totnode, &data, NULL, 0, do_topo_grab_brush_task_cb_ex,
+               ((sd->flags & SCULPT_USE_OPENMP) && totnode > 
SCULPT_THREADED_LIMIT), false);
+}
+
 static void do_fill_brush_task_cb_ex(
         void *userdata, void *UNUSED(userdata_chunk), const int n, const int 
thread_id)
 {
@@ -3608,6 +3676,9 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush 
*brush, UnifiedPaintSe
                        case SCULPT_TOOL_LAYER:
                                do_layer_brush(sd, ob, nodes, totnode);
                                break;
+                       case SCULPT_TOOL_TOPO_GRAB:
+                               do_topo_grab_brush(sd, ob, nodes, totnode);
+                               break;

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to