Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-05-01 11:10:34 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-01 13:32:38 +0300
commit928becec60d16880838dd756cc8b6b5ee73f9b2d (patch)
treea54a8038c357c20d7b88a52d065b0f487480597d /source/blender/editors
parent5fd69f6bd8c91b73135d22b3cad829b0892dabca (diff)
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_image.h3
-rw-r--r--source/blender/editors/include/ED_uvedit.h1
-rw-r--r--source/blender/editors/object/object_edit.c2
-rw-r--r--source/blender/editors/screen/screen_context.c17
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h3
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c35
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c122
-rw-r--r--source/blender/editors/space_image/space_image.c5
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c6
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c11
10 files changed, 6 insertions, 199 deletions
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index ba5a6a8a339..5bd806b3dbf 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -71,9 +71,6 @@ void ED_space_image_scopes_update(const struct bContext *C,
void ED_space_image_paint_update(struct Main *bmain,
struct wmWindowManager *wm,
struct Scene *scene);
-void ED_space_image_uv_sculpt_update(struct Main *bmain,
- struct wmWindowManager *wm,
- struct Scene *scene);
void ED_image_get_uv_aspect(struct Image *ima, struct ImageUser *iuser, float *aspx, float *aspy);
void ED_image_mouse_pos(struct SpaceImage *sima,
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index 9259afd1d5f..8dd2dab5209 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -178,7 +178,6 @@ void ED_uvedit_add_simple_uvs(struct Main *bmain, struct Scene *scene, struct Ob
/* uvedit_draw.c */
void ED_image_draw_cursor(struct ARegion *ar, const float cursor[2]);
void ED_uvedit_draw_main(struct SpaceImage *sima,
- struct ARegion *ar,
struct Scene *scene,
struct ViewLayer *view_layer,
struct Object *obedit,
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 4bd6e8b3fa7..795e1dd66a5 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -703,8 +703,6 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
}
}
- ED_space_image_uv_sculpt_update(bmain, CTX_wm_manager(C), scene);
-
WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode);
if (G.background == false) {
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 6dcb9f8a82c..c60469e092f 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -98,7 +98,6 @@ const char *screen_context_dir[] = {
"weight_paint_object",
"image_paint_object",
"particle_edit_object",
- "uv_sculpt_object",
"pose_object",
"sequences",
"selected_sequences",
@@ -520,22 +519,6 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
- else if (CTX_data_equals(member, "uv_sculpt_object")) {
- /* TODO(campbell): most likely we change rules for uv_sculpt. */
- if (obact && (obact->mode & OB_MODE_EDIT)) {
- const ToolSettings *ts = scene->toolsettings;
- if (ts->use_uv_sculpt) {
- if (ED_uvedit_test(obedit)) {
- WorkSpace *workspace = CTX_wm_workspace(C);
- if ((workspace->tools_space_type == SPACE_IMAGE) &&
- (workspace->tools_mode == SI_MODE_UV)) {
- CTX_data_id_pointer_set(result, &obact->id);
- }
- }
- }
- }
- return 1;
- }
else if (CTX_data_equals(member, "pose_object")) {
Object *obpose = BKE_object_pose_armature_get(obact);
if (obpose) {
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 1a8d2f79290..ea4814857ba 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -279,9 +279,6 @@ struct ListBase *ED_image_undosys_step_get_tiles(struct UndoStep *us_p);
struct ListBase *ED_image_undo_get_tiles(void);
/* sculpt_uv.c */
-bool uv_sculpt_poll(struct bContext *C);
-bool uv_sculpt_keymap_poll(struct bContext *C);
-
void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot);
/* paint_utils.c */
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index a85a256c15f..f58afcdadc1 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -524,37 +524,6 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
-static int brush_uv_sculpt_tool_set_exec(bContext *C, wmOperator *op)
-{
- Brush *brush;
- Scene *scene = CTX_data_scene(C);
- ToolSettings *ts = scene->toolsettings;
- ts->uv_sculpt_tool = RNA_enum_get(op->ptr, "tool");
- brush = ts->uvsculpt->paint.brush;
- /* To update toolshelf */
- WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
-
- return OPERATOR_FINISHED;
-}
-
-static void BRUSH_OT_uv_sculpt_tool_set(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "UV Sculpt Tool Set";
- ot->description = "Set the UV sculpt tool";
- ot->idname = "BRUSH_OT_uv_sculpt_tool_set";
-
- /* api callbacks */
- ot->exec = brush_uv_sculpt_tool_set_exec;
- ot->poll = uv_sculpt_poll;
-
- /* flags */
- ot->flag = 0;
-
- /* props */
- ot->prop = RNA_def_enum(ot->srna, "tool", rna_enum_uv_sculpt_tool_items, 0, "Tool", "");
-}
-
/***** Stencil Control *****/
typedef enum {
@@ -1014,7 +983,6 @@ void ED_operatortypes_paint(void)
/* note, particle uses a different system, can be added with existing operators in wm.py */
WM_operatortype_append(PAINT_OT_brush_select);
- WM_operatortype_append(BRUSH_OT_uv_sculpt_tool_set);
/* image */
WM_operatortype_append(PAINT_OT_texture_paint_toggle);
@@ -1101,9 +1069,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap = WM_keymap_ensure(keyconf, "Face Mask", 0, 0);
keymap->poll = facemask_paint_poll;
- keymap = WM_keymap_ensure(keyconf, "UV Sculpt", 0, 0);
- keymap->poll = uv_sculpt_keymap_poll;
-
/* paint stroke */
keymap = paint_stroke_modal_keymap(keyconf);
WM_modalkeymap_assign(keymap, "SCULPT_OT_brush_stroke");
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 00336b02639..3356edd6b36 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -139,121 +139,6 @@ typedef struct UvSculptData {
char invert;
} UvSculptData;
-static Brush *uv_sculpt_brush(bContext *C)
-{
- Scene *scene = CTX_data_scene(C);
- ToolSettings *settings = scene->toolsettings;
-
- if (!settings->uvsculpt) {
- return NULL;
- }
- return BKE_paint_brush(&settings->uvsculpt->paint);
-}
-
-static bool uv_sculpt_brush_poll_do(bContext *C, const bool check_region)
-{
- BMEditMesh *em;
- int ret;
- Object *obedit = CTX_data_edit_object(C);
- SpaceImage *sima = CTX_wm_space_image(C);
- Scene *scene = CTX_data_scene(C);
- ToolSettings *toolsettings = scene->toolsettings;
-
- if (!uv_sculpt_brush(C) || !obedit || obedit->type != OB_MESH || !sima ||
- ED_space_image_show_render(sima) || (sima->mode == SI_MODE_PAINT)) {
- return 0;
- }
-
- em = BKE_editmesh_from_object(obedit);
- ret = EDBM_uv_check(em);
-
- if (ret) {
- ARegion *ar = CTX_wm_region(C);
- if ((!toolsettings->use_uv_sculpt) ||
- (check_region && ar && (ar->regiontype != RGN_TYPE_WINDOW))) {
- ret = 0;
- }
- }
-
- return ret;
-}
-
-static bool uv_sculpt_brush_poll(bContext *C)
-{
- return uv_sculpt_brush_poll_do(C, true);
-}
-
-static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(customdata))
-{
-#define PX_SIZE_FADE_MAX 12.0f
-#define PX_SIZE_FADE_MIN 4.0f
-
- Scene *scene = CTX_data_scene(C);
- // Brush *brush = image_paint_brush(C);
- Paint *paint = BKE_paint_get_active_from_context(C);
- Brush *brush = BKE_paint_brush(paint);
-
- if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) {
- const float size = (float)BKE_brush_size_get(scene, brush);
- float alpha = 0.5f;
-
- /* fade out the brush (cheap trick to work around brush interfering with sampling [#])*/
- if (size < PX_SIZE_FADE_MIN) {
- return;
- }
- else if (size < PX_SIZE_FADE_MAX) {
- alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN);
- }
-
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformColor3fvAlpha(brush->add_col, alpha);
-
- GPU_line_smooth(true);
- GPU_blend(true);
- imm_draw_circle_wire_2d(pos, (float)x, (float)y, size, 40);
- GPU_blend(false);
- GPU_line_smooth(false);
-
- immUnbindProgram();
- }
-#undef PX_SIZE_FADE_MAX
-#undef PX_SIZE_FADE_MIN
-}
-
-void ED_space_image_uv_sculpt_update(Main *bmain, wmWindowManager *wm, Scene *scene)
-{
- ToolSettings *settings = scene->toolsettings;
- if (settings->use_uv_sculpt) {
- if (settings->uvsculpt == NULL) {
- settings->uv_sculpt_tool = UV_SCULPT_TOOL_GRAB;
- settings->uv_sculpt_settings = UV_SCULPT_LOCK_BORDERS | UV_SCULPT_ALL_ISLANDS;
- settings->uv_relax_method = UV_SCULPT_TOOL_RELAX_LAPLACIAN;
- }
- BKE_paint_ensure(settings, (Paint **)&settings->uvsculpt);
- BKE_paint_init(bmain, scene, PAINT_MODE_SCULPT_UV, PAINT_CURSOR_SCULPT);
-
- settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate(
- wm, SPACE_IMAGE, RGN_TYPE_WINDOW, uv_sculpt_brush_poll, brush_drawcursor_uvsculpt, NULL);
- }
- else {
- if (settings->uvsculpt) {
- WM_paint_cursor_end(wm, settings->uvsculpt->paint.paint_cursor);
- settings->uvsculpt->paint.paint_cursor = NULL;
- }
- }
-}
-
-bool uv_sculpt_poll(bContext *C)
-{
- return uv_sculpt_brush_poll_do(C, true);
-}
-
-bool uv_sculpt_keymap_poll(bContext *C)
-{
- return uv_sculpt_brush_poll_do(C, false);
-}
-
/*********** Improved Laplacian Relaxation Operator ************************/
/* original code by Raul Fernandez Hernandez "farsthary" *
* adapted to uv smoothing by Antony Riakiatakis *
@@ -631,8 +516,9 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
int island_index = 0;
/* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/
int *uniqueUv;
- data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH) ? UV_SCULPT_TOOL_RELAX :
- ts->uv_sculpt_tool;
+ data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH) ?
+ UV_SCULPT_TOOL_RELAX :
+ ts->uvsculpt->paint.brush->uv_sculpt_tool;
data->invert = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT) ? 1 : 0;
data->uvsculpt = &ts->uvsculpt->paint;
@@ -951,7 +837,7 @@ void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot)
/* api callbacks */
ot->invoke = uv_sculpt_stroke_invoke;
ot->modal = uv_sculpt_stroke_modal;
- ot->poll = uv_sculpt_poll;
+ ot->poll = ED_operator_uvedit_space_image;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 248497a15ef..386e258a833 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -552,9 +552,6 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar)
keymap = WM_keymap_ensure(wm->defaultconf, "UV Editor", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
- keymap = WM_keymap_ensure(wm->defaultconf, "UV Sculpt", 0, 0);
- WM_event_add_keymap_handler(&ar->handlers, keymap);
-
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
@@ -608,7 +605,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
- ED_uvedit_draw_main(sima, ar, scene, view_layer, obedit, obact, depsgraph);
+ ED_uvedit_draw_main(sima, scene, view_layer, obedit, obact, depsgraph);
/* check for mask (delay draw) */
if (ED_space_image_show_uvedit(sima, obedit)) {
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 4fb2c6441a3..804b9c22104 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -479,14 +479,12 @@ static void draw_uv_shadows_get(
}
void ED_uvedit_draw_main(SpaceImage *sima,
- ARegion *ar,
Scene *scene,
ViewLayer *view_layer,
Object *obedit,
Object *obact,
Depsgraph *depsgraph)
{
- ToolSettings *toolsettings = scene->toolsettings;
bool show_uvedit, show_uvshadow, show_texpaint_uvshadow;
show_uvedit = ED_space_image_show_uvedit(sima, obedit);
@@ -509,9 +507,5 @@ void ED_uvedit_draw_main(SpaceImage *sima,
else {
draw_uvs_texpaint(scene, obact, depsgraph);
}
-
- if (show_uvedit && !(toolsettings->use_uv_sculpt)) {
- ED_image_draw_cursor(ar, sima->cursor);
- }
}
}
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index e6990430f0e..7de609a3559 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -128,15 +128,6 @@ bool ED_uvedit_test(Object *obedit)
return ret;
}
-static bool ED_operator_uvedit_can_uv_sculpt(struct bContext *C)
-{
- SpaceImage *sima = CTX_wm_space_image(C);
- ToolSettings *toolsettings = CTX_data_tool_settings(C);
- Object *obedit = CTX_data_edit_object(C);
-
- return ED_space_image_show_uvedit(sima, obedit) && !(toolsettings->use_uv_sculpt);
-}
-
static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C)
{
Object *ob = CTX_data_active_object(C);
@@ -5013,7 +5004,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
wmKeyMap *keymap;
keymap = WM_keymap_ensure(keyconf, "UV Editor", 0, 0);
- keymap->poll = ED_operator_uvedit_can_uv_sculpt;
+ keymap->poll = ED_operator_uvedit;
}
/** \} */