UV Sculpt: improve tool-system integration
In 2.7x UV sculpt was a kind of sub-mode (a toggle with it's own key-map & drawing code). Move this to an operator that uses the tool-system, this simplifies internal logic, especially brush selection which now matches sculpt and other paint modes. - Remove toggle used to enable uv sculpt. - Expose the brush, which was already used but there was no way to select different brushes. - Make UV sculpt use paint paint tool slots (using brushes how all other paint mode currently do). - Move UV Sculpt keymap to the tools keymap. - Remove Q to toggle UV sculpt mode, S/P/G keys to switch tools.
This commit is contained in:
@@ -169,14 +169,6 @@ void WM_toolsystem_unlink(bContext *C, WorkSpace *workspace, const bToolKey *tke
|
||||
}
|
||||
}
|
||||
|
||||
static void toolsystem_ref_link__refresh_image_uv_sculpt(bContext *C, Scene *scene)
|
||||
{
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &ptr);
|
||||
PropertyRNA *prop = RNA_struct_find_property(&ptr, "use_uv_sculpt");
|
||||
RNA_property_update(C, &ptr, prop);
|
||||
}
|
||||
|
||||
/**
|
||||
* \see #toolsystem_ref_link
|
||||
*/
|
||||
@@ -244,29 +236,6 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((tref->space_type == SPACE_IMAGE) && (tref->mode == SI_MODE_UV)) {
|
||||
/* Note that switching uv-sculpt boolean is a hack at the moment.
|
||||
* It would be best to make this either an operator or a higher level mode
|
||||
* (like mesh-object sculpt mode). */
|
||||
const EnumPropertyItem *items = rna_enum_uv_sculpt_tool_items;
|
||||
const int i = RNA_enum_from_identifier(items, tref_rt->data_block);
|
||||
if (i != -1) {
|
||||
const int value = items[i].value;
|
||||
wmWindowManager *wm = bmain->wm.first;
|
||||
for (wmWindow *win = wm->windows.first; win; win = win->next) {
|
||||
if (workspace == WM_window_get_active_workspace(win)) {
|
||||
Scene *scene = WM_window_get_active_scene(win);
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
ts->uv_sculpt_tool = value;
|
||||
|
||||
if (ts->use_uv_sculpt == false) {
|
||||
ts->use_uv_sculpt = true;
|
||||
toolsystem_ref_link__refresh_image_uv_sculpt(C, scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const ePaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
|
||||
BLI_assert(paint_mode != PAINT_MODE_INVALID);
|
||||
@@ -280,6 +249,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
||||
for (wmWindow *win = wm->windows.first; win; win = win->next) {
|
||||
if (workspace == WM_window_get_active_workspace(win)) {
|
||||
Scene *scene = WM_window_get_active_scene(win);
|
||||
BKE_paint_ensure_from_paintmode(scene, paint_mode);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
|
||||
struct Brush *brush = BKE_paint_toolslots_brush_get(paint, slot_index);
|
||||
if (brush == NULL) {
|
||||
@@ -300,23 +270,6 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* XXX, this part is weak, disables uv_sculpt when non uv-tool set. */
|
||||
if ((tref->space_type == SPACE_IMAGE) && (tref->mode == SI_MODE_UV)) {
|
||||
Main *bmain = CTX_data_main(C);
|
||||
wmWindowManager *wm = bmain->wm.first;
|
||||
for (wmWindow *win = wm->windows.first; win; win = win->next) {
|
||||
if (workspace == WM_window_get_active_workspace(win)) {
|
||||
Scene *scene = WM_window_get_active_scene(win);
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
if (ts->use_uv_sculpt == true) {
|
||||
ts->use_uv_sculpt = false;
|
||||
toolsystem_ref_link__refresh_image_uv_sculpt(C, scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void toolsystem_refresh_ref(bContext *C, WorkSpace *workspace, bToolRef *tref)
|
||||
@@ -489,17 +442,6 @@ void WM_toolsystem_ref_sync_from_context(Main *bmain, WorkSpace *workspace, bToo
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((tref->space_type == SPACE_IMAGE) && (tref->mode == SI_MODE_UV)) {
|
||||
if (ob->mode & OB_MODE_EDIT) {
|
||||
const EnumPropertyItem *items = rna_enum_uv_sculpt_tool_items;
|
||||
const int i = RNA_enum_from_value(items, ts->uv_sculpt_tool);
|
||||
const EnumPropertyItem *item = &items[i];
|
||||
if (!STREQ(tref_rt->data_block, item->identifier)) {
|
||||
STRNCPY(tref_rt->data_block, item->identifier);
|
||||
SNPRINTF(tref->idname, "builtin_brush.%s", item->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const ePaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
|
||||
|
||||
Reference in New Issue
Block a user