diff options
author | Jacques Lucke <jacques@blender.org> | 2022-02-21 14:49:36 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-02-21 14:49:36 +0300 |
commit | e2ffe88983938651a641e3d1be65f43c65a54901 (patch) | |
tree | bc39a92ae6afd0300fc9df38c740835cb173a758 /source/blender/editors/sculpt_paint | |
parent | fcb84e32e007fffeb9bcc573917d31857c9dd0cc (diff) |
Curves: use paint cursor in curves sculpt mode
Also adds radius and strength control to the tool settings in the ui.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/curves_sculpt_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/curves_sculpt_ops.cc | 37 |
2 files changed, 33 insertions, 5 deletions
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_intern.h b/source/blender/editors/sculpt_paint/curves_sculpt_intern.h index 6a96a8e0e9f..0d99e61192f 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/curves_sculpt_intern.h @@ -9,6 +9,7 @@ extern "C" { #endif bool CURVES_SCULPT_mode_poll(struct bContext *C); +bool CURVES_SCULPT_mode_poll_view3d(struct bContext *C); #ifdef __cplusplus } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 3f732f6ac79..fb5b1d338a6 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -14,12 +14,23 @@ #include "curves_sculpt_intern.h" #include "paint_intern.h" -bool CURVES_SCULPT_mode_poll(struct bContext *C) +bool CURVES_SCULPT_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); return ob && ob->mode & OB_MODE_SCULPT_CURVES; } +bool CURVES_SCULPT_mode_poll_view3d(bContext *C) +{ + if (!CURVES_SCULPT_mode_poll(C)) { + return false; + } + if (CTX_wm_region_view3d(C) == nullptr) { + return false; + } + return true; +} + namespace blender::ed::sculpt_paint { /* -------------------------------------------------------------------- @@ -108,10 +119,27 @@ static bool curves_sculptmode_toggle_poll(bContext *C) return true; } -static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op) +static void curves_sculptmode_enter(bContext *C) { Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); + BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->curves_sculpt); + CurvesSculpt *curves_sculpt = scene->toolsettings->curves_sculpt; + + ob->mode = OB_MODE_SCULPT_CURVES; + + paint_cursor_start(&curves_sculpt->paint, CURVES_SCULPT_mode_poll_view3d); +} + +static void curves_sculptmode_exit(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + ob->mode = OB_MODE_OBJECT; +} + +static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op) +{ + Object *ob = CTX_data_active_object(C); const bool is_mode_set = ob->mode == OB_MODE_SCULPT_CURVES; if (is_mode_set) { @@ -121,11 +149,10 @@ static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op) } if (is_mode_set) { - ob->mode = OB_MODE_OBJECT; + curves_sculptmode_exit(C); } else { - BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->curves_sculpt); - ob->mode = OB_MODE_SCULPT_CURVES; + curves_sculptmode_enter(C); } WM_toolsystem_update_from_context_view3d(C); |