Commit: 840612bd9d2ecff65cf14492375c8618f4c49a04 Author: Joshua Leung Date: Fri Feb 9 19:32:17 2018 +1300 Branches: greasepencil-object https://developer.blender.org/rB840612bd9d2ecff65cf14492375c8618f4c49a04
More compile Fixes for object->mode refactor TODO: I've come across some rather fishy-looking code in a few places that will need more careful review later * gpencil-select.c - 1181 * object_edit.c - 1596 * view3d_select.c - 1626 * undo.c - 230 =================================================================== M source/blender/editors/gpencil/gpencil_brush.c M source/blender/editors/gpencil/gpencil_paint.c M source/blender/editors/gpencil/gpencil_select.c M source/blender/editors/object/object_edit.c M source/blender/editors/object/object_modifier.c M source/blender/editors/space_outliner/outliner_select.c M source/blender/editors/space_view3d/view3d_select.c M source/blender/editors/util/undo.c =================================================================== diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index bc1a0ceba46..401e2566a78 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -194,11 +194,11 @@ static GP_BrushEdit_Settings *gpsculpt_get_settings(Scene *scene) } /* Get the active brush */ -static GP_EditBrush_Data *gpsculpt_get_brush(Scene *scene, Object *ob) +static GP_EditBrush_Data *gpsculpt_get_brush(Scene *scene, bool is_weight_mode) { GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt; GP_EditBrush_Data *brush = NULL; - if ((ob) && (ob->mode == OB_MODE_GPENCIL_WEIGHT)) { + if (is_weight_mode) { brush = &gset->brush[gset->weighttype]; } else { @@ -1136,6 +1136,9 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); ToolSettings *ts = CTX_data_tool_settings(C); Object *ob = CTX_data_active_object(C); + + WorkSpace *workspace = CTX_wm_workspace(C); + const bool is_weight_mode = (workspace->object_mode == OB_MODE_GPENCIL_WEIGHT); tGP_BrushEditData *gso; @@ -1145,9 +1148,9 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) /* store state */ gso->settings = gpsculpt_get_settings(scene); - gso->brush = gpsculpt_get_brush(scene, ob); + gso->brush = gpsculpt_get_brush(scene, is_weight_mode); - if ((ob) && (ob->mode == OB_MODE_GPENCIL_WEIGHT)) { + if (is_weight_mode) { gso->brush_type = gso->settings->weighttype; } else { diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 8738fd11a1d..2f2b55086cf 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -2489,6 +2489,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); WorkSpace *workspace = CTX_wm_workspace(C); + ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene); if (ob && (ob->type == OB_GPENCIL) && ((p->gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0)) { /* Just set paintmode flag... */ p->gpd->flag |= GP_DATA_STROKE_PAINTMODE; @@ -2496,9 +2497,10 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event p->gpd->flag &= ~GP_DATA_STROKE_EDITMODE; p->gpd->flag &= ~GP_DATA_STROKE_SCULPTMODE; p->gpd->flag &= ~GP_DATA_STROKE_WEIGHTMODE; - ob->mode = OB_MODE_GPENCIL_PAINT; /* set workspace mode */ - BKE_workspace_object_mode_set(workspace, scene, ob->mode); + workspace->object_mode_restore = workspace->object_mode; + workspace->object_mode = OB_MODE_GPENCIL_PAINT; + ED_object_base_activate(C, view_layer->basact); // XXX /* redraw mode on screen */ WM_event_add_notifier(C, NC_SCENE | ND_MODE, NULL); } diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index f03f33ef086..2e924a7be0f 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1176,20 +1176,22 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot) static int gpencil_select_exec(bContext *C, wmOperator *op) { ScrArea *sa = CTX_wm_area(C); + bGPdata *gpd = ED_gpencil_data_get_active(C); + +#if 0 // XXX: This is some weird hacked-on stuff... Needs careful review (Aligorith) /* if not edit mode, can select other objects */ if ((sa) && (sa->spacetype == SPACE_VIEW3D)) { - Object *ob = CTX_data_active_object(C); - if ((ob) && (ob->mode != OB_MODE_GPENCIL_EDIT)) { + WorkSpace *workspace = CTX_wm_workspace(C); + if (workspace->object_mode != OB_MODE_GPENCIL_EDIT) { return OPERATOR_PASS_THROUGH; } } - bGPdata *gpd = ED_gpencil_data_get_active(C); /* if not edit mode, the event is catched but not processed */ if ((!gpd) || (gpd->flag & GP_DATA_STROKE_EDITMODE) == 0) { return OPERATOR_CANCELLED; } - +#endif /* "radius" is simply a threshold (screen space) to make it easier to test with a tolerance */ const float radius = 0.75f * U.widget_unit; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 56fd67977f6..dd41cd0900a 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1593,42 +1593,43 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) eObjectMode restore_mode = workspace->object_mode; const bool toggle = RNA_boolean_get(op->ptr, "toggle"); - /* if type is OB_GPENCIL, select mode for grease pencil strokes */ + /* if type is OB_GPENCIL, select mode for grease pencil strokes */ + // XXX: Review this behaviour... something seems sketchy here (Aligorith) if ((ob) && (ob->type == OB_GPENCIL)) { if ((ob->data) && (ob->data == gpd)) { if (ELEM(mode, OB_MODE_OBJECT, OB_MODE_EDIT, OB_MODE_POSE)) { - ob->restore_mode = OB_MODE_OBJECT; - if (ELEM(ob->mode, OB_MODE_OBJECT, OB_MODE_EDIT, OB_MODE_GPENCIL_EDIT)) { + workspace->object_mode_restore = OB_MODE_OBJECT; + if (ELEM(workspace->object_mode, OB_MODE_OBJECT, OB_MODE_EDIT, OB_MODE_GPENCIL_EDIT)) { WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); } - if (ob->mode == OB_MODE_GPENCIL_PAINT) { + if (workspace->object_mode == OB_MODE_GPENCIL_PAINT) { WM_operator_name_call(C, "GPENCIL_OT_paintmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); } - if (ob->mode == OB_MODE_GPENCIL_SCULPT) { + if (workspace->object_mode == OB_MODE_GPENCIL_SCULPT) { WM_operator_name_call(C, "GPENCIL_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); } - if (ob->mode == OB_MODE_GPENCIL_WEIGHT) { + if (workspace->object_mode == OB_MODE_GPENCIL_WEIGHT) { WM_operator_name_call(C, "GPENCIL_OT_weightmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); } return OPERATOR_FINISHED; } if (mode == OB_MODE_GPENCIL_EDIT) { - ob->restore_mode = ob->mode; + workspace->object_mode_restore = workspace->object_mode; WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); return OPERATOR_FINISHED; } if (mode == OB_MODE_GPENCIL_PAINT) { - ob->restore_mode = ob->mode; + workspace->object_mode_restore = workspace->object_mode; WM_operator_name_call(C, "GPENCIL_OT_paintmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); return OPERATOR_FINISHED; } if (mode == OB_MODE_GPENCIL_SCULPT) { - ob->restore_mode = ob->mode; + workspace->object_mode_restore = workspace->object_mode; WM_operator_name_call(C, "GPENCIL_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); return OPERATOR_FINISHED; } if (mode == OB_MODE_GPENCIL_WEIGHT) { - ob->restore_mode = ob->mode; + workspace->object_mode_restore = workspace->object_mode; WM_operator_name_call(C, "GPENCIL_OT_weightmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 58da1f748e0..402acdecbf3 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -717,7 +717,7 @@ int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scen return 0; } else if (ob->type == OB_GPENCIL) { - if (ob->mode != OB_MODE_OBJECT) { + if (eval_ctx.object_mode != OB_MODE_OBJECT) { BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in paint, sculpt or edit mode"); return 0; } diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 0ff61403032..81c93b0c56c 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -200,25 +200,30 @@ static eOLDrawState tree_element_set_active_object( /* set special grease pencil modes */ if (ob->type == OB_GPENCIL) { + WorkSpace *workspace = CTX_wm_workspace(C); + wmWindow *win = CTX_wm_window(C); + /* set cursor */ - if (ob->mode == OB_MODE_GPENCIL_PAINT) { - WM_cursor_modal_set(CTX_wm_window(C), BC_PAINTBRUSHCURSOR); + if (workspace->object_mode == OB_MODE_GPENCIL_PAINT) { + WM_cursor_modal_set(win, BC_PAINTBRUSHCURSOR); ED_gpencil_toggle_brush_cursor(C, false, NULL); } - else if (ob->mode == OB_MODE_GPENCIL_SCULPT) { - WM_cursor_modal_set(CTX_wm_window(C), BC_CROSSCURSOR); + else if (workspace->object_mode == OB_MODE_GPENCIL_SCULPT) { + WM_cursor_modal_set(win, BC_CROSSCURSOR); ED_gpencil_toggle_brush_cursor(C, true, NULL); } - else if (ob->mode == OB_MODE_GPENCIL_WEIGHT) { - WM_cursor_modal_set(CTX_wm_window(C), BC_CROSSCURSOR); + else if (workspace->object_mode == OB_MODE_GPENCIL_WEIGHT) { + WM_cursor_modal_set(win, BC_CROSSCURSOR); ED_gpencil_toggle_brush_cursor(C, true, NULL); } else { - WM_cursor_modal_set(CTX_wm_window(C), CURSOR_STD); + WM_cursor_modal_set(win, CURSOR_STD); ED_gpencil_toggle_brush_cursor(C, false, NULL); } /* set workspace mode */ - BKE_workspace_object_mode_set(CTX_wm_workspace(C), scene, ob->mode); + workspace->object_mode_restore = workspace->object_mode; + workspace->object_mode = OB_MODE_GPENCIL_PAINT; + ED_object_base_activate(C, view_layer->basact); // XXX } if (ob != scene->obedit) diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 5284835d70c..0c424a9e674 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1623,6 +1623,8 @@ static bool ed_object_select_pick( /* Set special modes for grease pencil The grease pencil modes are not real modes, but a hack to make the interface consistent, so need some tricks to keep UI synchronized */ + // XXX: This stuff neeeds reviewing (Aligorith) +#if 0 if (((oldbasact) && oldbasact->object->type == OB_GPENCIL) || (basact->object->type == OB_GPENCIL)) { /* set cursor */ if @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs