diff options
author | decoda <rajakedia2222@gmail.com> | 2017-06-18 10:59:30 +0300 |
---|---|---|
committer | decoda <rajakedia2222@gmail.com> | 2017-06-18 10:59:30 +0300 |
commit | 9c3be3335d52263db3284cff63cb1fbb1cd88d9a (patch) | |
tree | 740c12d20402d80be539c96e0a544e97883d57aa | |
parent | f691de8b679bec65b09c578babfb6b22fa879aec (diff) |
Topograb Brush Initialization
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_defaults.c | 6 | ||||
-rw-r--r-- | source/blender/editors/datafiles/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/include/ED_datafiles.h | 3 | ||||
-rw-r--r-- | source/blender/editors/include/UI_icons.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 87 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_brush_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 9 |
13 files changed, 109 insertions, 13 deletions
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; case SCULPT_TOOL_FLATTEN: do_flatten_brush(sd, ob, nodes, totnode); break; @@ -3682,7 +3753,8 @@ static void sculpt_combine_proxies_task_cb(void *userdata, const int n) Object *ob = data->ob; /* these brushes start from original coordinates */ - const bool use_orco = ELEM(data->brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB, SCULPT_TOOL_CLIP); + const bool use_orco = ELEM(data->brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_TOPO_GRAB, + SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB, SCULPT_TOOL_CLIP); PBVHVertexIter vd; PBVHProxyNode *proxies; @@ -4096,6 +4168,8 @@ static const char *sculpt_tool_name(Sculpt *sd) return "Rotate Brush"; case SCULPT_TOOL_MASK: return "Mask Brush"; + case SCULPT_TOOL_TOPO_GRAB: + return "Mask Brush"; case SCULPT_TOOL_SIMPLIFY: return "Simplify Brush"; } @@ -4331,7 +4405,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru int tool = brush->sculpt_tool; if (ELEM(tool, - SCULPT_TOOL_GRAB, SCULPT_TOOL_NUDGE, + SCULPT_TOOL_GRAB, SCULPT_TOOL_NUDGE, SCULPT_TOOL_TOPO_GRAB, SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)) { @@ -4352,6 +4426,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru if (!cache->first_time) { switch (tool) { case SCULPT_TOOL_GRAB: + case SCULPT_TOOL_TOPO_GRAB: case SCULPT_TOOL_THUMB: case SCULPT_TOOL_CLIP: sub_v3_v3v3(delta, grab_location, cache->old_grab_location); @@ -4383,12 +4458,12 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru copy_v3_v3(cache->old_grab_location, grab_location); - if (tool == SCULPT_TOOL_GRAB) + if (tool == SCULPT_TOOL_GRAB || tool == SCULPT_TOOL_TOPO_GRAB) copy_v3_v3(cache->anchored_location, cache->true_location); else if (tool == SCULPT_TOOL_THUMB) copy_v3_v3(cache->anchored_location, cache->orig_grab_location); - if (ELEM(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB)) { + if (ELEM(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_TOPO_GRAB, SCULPT_TOOL_THUMB)) { /* location stays the same for finding vertices in brush radius */ copy_v3_v3(cache->true_location, cache->orig_grab_location); diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 4d4d6a2cf9d..4e9534d2d15 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -253,7 +253,8 @@ typedef enum BrushSculptTool { SCULPT_TOOL_BLOB = 17, SCULPT_TOOL_CLAY_STRIPS = 18, SCULPT_TOOL_MASK = 19, - SCULPT_TOOL_CLIP = 20 + SCULPT_TOOL_CLIP = 20, + SCULPT_TOOL_TOPO_GRAB = 21 } BrushSculptTool; /** When #BRUSH_ACCUMULATE is used */ @@ -271,6 +272,7 @@ typedef enum BrushSculptTool { #define SCULPT_TOOL_HAS_NORMAL_WEIGHT(t) ELEM(t, \ SCULPT_TOOL_GRAB, \ + SCULPT_TOOL_TOPO_GRAB, \ SCULPT_TOOL_SNAKE_HOOK \ ) @@ -281,6 +283,7 @@ typedef enum BrushSculptTool { #define SCULPT_TOOL_HAS_DYNTOPO(t) (ELEM(t, \ /* These brushes, as currently coded, cannot support dynamic topology */ \ SCULPT_TOOL_GRAB, \ + SCULPT_TOOL_TOPO_GRAB, \ SCULPT_TOOL_ROTATE, \ SCULPT_TOOL_THUMB, \ SCULPT_TOOL_LAYER, \ diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index fab4ccc1d75..671b78e36df 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -81,6 +81,7 @@ EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = { {SCULPT_TOOL_SCRAPE, "SCRAPE", ICON_BRUSH_SCRAPE, "Scrape", ""}, {SCULPT_TOOL_SIMPLIFY, "SIMPLIFY", ICON_BRUSH_SUBTRACT /* icon TODO */, "Simplify", ""}, {SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_SMOOTH, "Smooth", ""}, + {SCULPT_TOOL_TOPO_GRAB, "TOPO_GRAB", ICON_BRUSH_TOPO_GRAB, "Topo", "" }, {SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake Hook", ""}, {SCULPT_TOOL_THUMB, "THUMB", ICON_BRUSH_THUMB, "Thumb", ""}, {0, NULL, 0, NULL, NULL} @@ -145,7 +146,7 @@ static int rna_SculptToolCapabilities_has_jitter_get(PointerRNA *ptr) return (!(br->flag & BRUSH_ANCHORED) && !(br->flag & BRUSH_DRAG_DOT) && !ELEM(br->sculpt_tool, - SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_GRAB, SCULPT_TOOL_TOPO_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } @@ -193,7 +194,7 @@ static int rna_SculptToolCapabilities_has_random_texture_angle_get(PointerRNA *p { Brush *br = (Brush *)ptr->data; return (!ELEM(br->sculpt_tool, - SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_GRAB, SCULPT_TOOL_TOPO_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } @@ -256,7 +257,7 @@ static int rna_SculptToolCapabilities_has_space_attenuation_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return ((br->flag & (BRUSH_SPACE | BRUSH_LINE | BRUSH_CURVE)) && - !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_TOPO_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK)); } @@ -276,7 +277,7 @@ static int rna_BrushCapabilities_has_spacing_get(PointerRNA *ptr) static int rna_SculptToolCapabilities_has_strength_pressure_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; - return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK); + return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_TOPO_GRAB, SCULPT_TOOL_SNAKE_HOOK); } static int rna_TextureCapabilities_has_texture_angle_get(PointerRNA *ptr) |