diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-05 06:07:01 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-05 06:13:30 +0300 |
commit | 143ece7199c20b231077273e4c16c7edd0bc4940 (patch) | |
tree | 046795b2e46defc6668fa1119a67716a537310a1 /source/blender | |
parent | c15439bcdc52f90570dd22fc0f61b94bdf56145d (diff) |
Tool System: initial support for UV-sculpt
This currently conflicts with the UV-sculpt toggle being manually set,
ideally this would work more like other paint modes in Blender.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/intern/rna_workspace_api.c | 17 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 51 |
2 files changed, 67 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c index 898dc296299..fb237299dd0 100644 --- a/source/blender/makesrna/intern/rna_workspace_api.c +++ b/source/blender/makesrna/intern/rna_workspace_api.c @@ -90,7 +90,10 @@ static void rna_WorkspaceTool_refresh_from_context( if (ob == NULL) { /* pass */ } - else if (ob->mode & OB_MODE_PARTICLE_EDIT) { + else if ((tref->space_type == SPACE_VIEW3D) && + (tref->mode == CTX_MODE_PARTICLE) && + (ob->mode & OB_MODE_PARTICLE_EDIT)) + { const EnumPropertyItem *items = rna_enum_particle_edit_hair_brush_items; const int i = RNA_enum_from_value(items, ts->particle.brushtype); const EnumPropertyItem *item = &items[i]; @@ -99,6 +102,18 @@ static void rna_WorkspaceTool_refresh_from_context( STRNCPY(tref->idname, item->name); } } + else if ((tref->space_type == SPACE_IMAGE) && + (tref->mode == SI_MODE_VIEW) && + (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); + STRNCPY(tref->idname, item->name); + } + } else { Paint *paint = BKE_paint_get_active(scene, view_layer); if (paint) { diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index 3a112ac0597..5584fada329 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -169,6 +169,14 @@ 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); +} + static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tref) { bToolRef_Runtime *tref_rt = tref->runtime; @@ -205,6 +213,30 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre } } } + if ((tref->space_type == SPACE_IMAGE) && + (tref->mode == SI_MODE_VIEW)) + { + /* 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 { struct Brush *brush = (struct Brush *)BKE_libblock_find_name(bmain, ID_BR, tref_rt->data_block); if (brush) { @@ -224,6 +256,25 @@ 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_VIEW)) + { + 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) |