From 4c3ed98ca27667c3403361199096e31eaa93cce2 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 25 Nov 2018 09:50:34 -0200 Subject: Local View Bring back per-viewport localview. This is based on Blender 2.79. We have a limit of 16 different local view viewports. We are using both the numpad /, as well as the regular /. Missing features: * Hack to make sure lights are always visible. * Make rendered mode with external engines to support this as well (probably just need to support this in the RNA iterators). * Support over 16 viewports by taking existing viewports out of local view. The code can use a cleanup pass in the future to unify the test to see if an object is visible (or we can use TESTBASE in more places). --- source/blender/editors/lattice/editlattice_select.c | 14 +++++++------- source/blender/editors/lattice/editlattice_tools.c | 7 ++++--- source/blender/editors/lattice/editlattice_undo.c | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'source/blender/editors/lattice') diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c index f342cefa362..bf5844cdafb 100644 --- a/source/blender/editors/lattice/editlattice_select.c +++ b/source/blender/editors/lattice/editlattice_select.c @@ -95,7 +95,7 @@ static int lattice_select_random_exec(bContext *C, wmOperator *op) ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; @@ -201,7 +201,7 @@ static int lattice_select_mirror_exec(bContext *C, wmOperator *op) ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; @@ -271,7 +271,7 @@ static int lattice_select_more_less(bContext *C, const bool select) uint objects_len; bool changed = false; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; @@ -387,7 +387,7 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op) int action = RNA_enum_get(op->ptr, "action"); uint objects_len = 0; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len); if (action == SEL_TOGGLE) { action = SEL_SELECT; @@ -467,7 +467,7 @@ static int lattice_select_ungrouped_exec(bContext *C, wmOperator *op) const bool is_extend = RNA_boolean_get(op->ptr, "extend"); bool changed = false; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt; @@ -566,7 +566,7 @@ static BPoint *findnearestLattvert(ViewContext *vc, int sel, Base **r_base) data.mval_fl[1] = vc->mval[1]; uint bases_len; - Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc->view_layer, &bases_len); + Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc->view_layer, vc->v3d, &bases_len); for (uint base_index = 0; base_index < bases_len; base_index++) { Base *base = bases[base_index]; data.is_changed = false; @@ -600,7 +600,7 @@ bool ED_lattice_select_pick(bContext *C, const int mval[2], bool extend, bool de if (!extend && !deselect && !toggle) { uint objects_len = 0; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, &objects_len); + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; ED_lattice_flags_set(ob, 0); diff --git a/source/blender/editors/lattice/editlattice_tools.c b/source/blender/editors/lattice/editlattice_tools.c index 01211a436a4..8cb3666c2af 100644 --- a/source/blender/editors/lattice/editlattice_tools.c +++ b/source/blender/editors/lattice/editlattice_tools.c @@ -73,11 +73,12 @@ static bool make_regular_poll(bContext *C) static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) { ViewLayer *view_layer = CTX_data_view_layer(C); + View3D *v3d = CTX_wm_view3d(C); const bool is_editmode = CTX_data_edit_object(C) != NULL; if (is_editmode) { uint objects_len; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; Lattice *lt = ob->data; @@ -94,7 +95,7 @@ static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) MEM_freeN(objects); } else { - FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob) { + FOREACH_SELECTED_OBJECT_BEGIN(view_layer, v3d, ob) { if (ob->type != OB_LATTICE) { continue; } @@ -218,7 +219,7 @@ static int lattice_flip_exec(bContext *C, wmOperator *op) bool changed = false; const eLattice_FlipAxes axis = RNA_enum_get(op->ptr, "axis"); - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; Lattice *lt; diff --git a/source/blender/editors/lattice/editlattice_undo.c b/source/blender/editors/lattice/editlattice_undo.c index cbd89016b44..c1a10843460 100644 --- a/source/blender/editors/lattice/editlattice_undo.c +++ b/source/blender/editors/lattice/editlattice_undo.c @@ -157,7 +157,7 @@ static bool lattice_undosys_step_encode(struct bContext *C, UndoStep *us_p) ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len); us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__); us->elems_len = objects_len; -- cgit v1.2.3