2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-23 19:47:33 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-23 19:47:33 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
2011-02-27 20:29:51 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup edobj
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <float.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <stddef.h> /* for offsetof */
|
2008-12-23 19:47:33 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2010-08-16 05:46:10 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_ghash.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2015-01-29 16:03:19 +11:00
|
|
|
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "DNA_armature_types.h"
|
2018-08-29 15:32:50 +02:00
|
|
|
#include "DNA_collection_types.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "DNA_curve_types.h"
|
2015-12-13 21:03:13 +13:00
|
|
|
#include "DNA_gpencil_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_lattice_types.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "DNA_material_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meshdata_types.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "DNA_meta_types.h"
|
2018-02-07 11:14:08 +11:00
|
|
|
#include "DNA_object_force_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "DNA_vfont_types.h"
|
2017-06-13 12:02:08 +02:00
|
|
|
#include "DNA_workspace_types.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2010-08-16 05:46:10 +00:00
|
|
|
#include "IMB_imbuf_types.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2020-04-03 11:35:04 +02:00
|
|
|
#include "BKE_anim_visualization.h"
|
2021-04-28 13:20:12 +10:00
|
|
|
#include "BKE_armature.h"
|
2018-03-28 14:54:17 -03:00
|
|
|
#include "BKE_collection.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "BKE_constraint.h"
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_curve.h"
|
2018-11-07 18:00:24 +01:00
|
|
|
#include "BKE_editlattice.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_editmesh.h"
|
2011-01-23 14:04:31 +00:00
|
|
|
#include "BKE_effect.h"
|
2015-05-12 13:29:00 +05:00
|
|
|
#include "BKE_global.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "BKE_image.h"
|
2015-02-23 23:05:54 +11:00
|
|
|
#include "BKE_lattice.h"
|
2018-11-07 18:00:24 +01:00
|
|
|
#include "BKE_layer.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_material.h"
|
|
|
|
#include "BKE_mball.h"
|
|
|
|
#include "BKE_mesh.h"
|
2018-11-07 18:00:24 +01:00
|
|
|
#include "BKE_modifier.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "BKE_object.h"
|
2018-02-22 18:15:34 +11:00
|
|
|
#include "BKE_paint.h"
|
2019-01-31 16:53:19 +01:00
|
|
|
#include "BKE_particle.h"
|
2009-09-16 17:43:09 +00:00
|
|
|
#include "BKE_pointcache.h"
|
2013-08-29 10:34:09 +00:00
|
|
|
#include "BKE_report.h"
|
2019-03-15 16:14:21 -03:00
|
|
|
#include "BKE_scene.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_softbody.h"
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
#include "BKE_workspace.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
#include "DEG_depsgraph_build.h"
|
|
|
|
|
2019-04-16 07:27:37 +02:00
|
|
|
#include "ED_anim_api.h"
|
2009-01-05 19:32:04 +00:00
|
|
|
#include "ED_armature.h"
|
2009-01-14 12:26:45 +00:00
|
|
|
#include "ED_curve.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_gpencil.h"
|
|
|
|
#include "ED_image.h"
|
2010-08-10 06:36:42 +00:00
|
|
|
#include "ED_lattice.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_mball.h"
|
|
|
|
#include "ED_mesh.h"
|
2009-01-01 18:05:12 +00:00
|
|
|
#include "ED_object.h"
|
2018-05-31 14:34:16 +02:00
|
|
|
#include "ED_outliner.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "ED_screen.h"
|
2018-04-02 15:02:08 +02:00
|
|
|
#include "ED_undo.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
2009-08-16 05:48:07 +00:00
|
|
|
#include "RNA_enum_types.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2020-09-15 12:22:03 -06:00
|
|
|
#include "UI_interface_icons.h"
|
|
|
|
|
2020-04-16 10:46:08 +10:00
|
|
|
#include "CLG_log.h"
|
|
|
|
|
2009-01-02 03:16:38 +00:00
|
|
|
/* for menu/popup icons etc etc*/
|
|
|
|
|
2010-05-19 09:40:45 +00:00
|
|
|
#include "UI_interface.h"
|
2018-03-28 14:54:17 -03:00
|
|
|
#include "UI_resources.h"
|
2018-05-08 07:22:52 +02:00
|
|
|
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "WM_api.h"
|
2018-05-08 07:22:52 +02:00
|
|
|
#include "WM_message.h"
|
2018-05-23 08:20:46 +02:00
|
|
|
#include "WM_toolsystem.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "WM_types.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
#include "object_intern.h" /* own include */
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2020-04-16 10:46:08 +10:00
|
|
|
static CLG_LogRef LOG = {"ed.object.edit"};
|
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
/* prototypes */
|
|
|
|
typedef struct MoveToCollectionData MoveToCollectionData;
|
|
|
|
static void move_to_collection_menus_items(struct uiLayout *layout,
|
|
|
|
struct MoveToCollectionData *menu);
|
2019-08-19 14:45:07 +02:00
|
|
|
static ListBase selected_objects_get(bContext *C);
|
2018-03-28 14:54:17 -03:00
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Internal Utilities
|
|
|
|
* \{ */
|
|
|
|
|
2020-07-03 11:58:43 -04:00
|
|
|
Object *ED_object_context(const bContext *C)
|
2012-01-02 17:15:24 +00:00
|
|
|
{
|
|
|
|
return CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
}
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2010-04-21 07:56:34 +00:00
|
|
|
/* find the correct active object per context
|
|
|
|
* note: context can be NULL when called from a enum with PROP_ENUM_NO_CONTEXT */
|
2020-07-03 11:58:43 -04:00
|
|
|
Object *ED_object_active_context(const bContext *C)
|
2008-12-29 12:15:42 +00:00
|
|
|
{
|
2012-04-28 15:42:27 +00:00
|
|
|
Object *ob = NULL;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (C) {
|
2012-04-28 15:42:27 +00:00
|
|
|
ob = ED_object_context(C);
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!ob) {
|
2012-04-28 15:42:27 +00:00
|
|
|
ob = CTX_data_active_object(C);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2010-04-21 07:56:34 +00:00
|
|
|
}
|
2010-03-31 00:55:01 +00:00
|
|
|
return ob;
|
2009-01-15 16:07:39 +00:00
|
|
|
}
|
|
|
|
|
2020-08-30 17:39:12 +10:00
|
|
|
/**
|
|
|
|
* Return an array of objects:
|
|
|
|
* - When in the property space, return the pinned or active object.
|
|
|
|
* - When in edit-mode/pose-mode, return an array of objects in the mode.
|
|
|
|
* - Otherwise return selected objects,
|
|
|
|
* the callers \a filter_fn needs to check of they are editable
|
|
|
|
* (assuming they need to be modified).
|
|
|
|
*/
|
|
|
|
Object **ED_object_array_in_mode_or_selected(bContext *C,
|
|
|
|
bool (*filter_fn)(Object *ob, void *user_data),
|
|
|
|
void *filter_user_data,
|
|
|
|
uint *r_objects_len)
|
|
|
|
{
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
Object *ob_active = OBACT(view_layer);
|
2020-10-28 17:22:56 +11:00
|
|
|
ID *id_pin = NULL;
|
|
|
|
const bool use_objects_in_mode = (ob_active != NULL) &&
|
|
|
|
(ob_active->mode & (OB_MODE_EDIT | OB_MODE_POSE));
|
|
|
|
const char space_type = area ? area->spacetype : SPACE_EMPTY;
|
2020-08-30 17:39:12 +10:00
|
|
|
Object **objects;
|
|
|
|
|
|
|
|
Object *ob = NULL;
|
|
|
|
bool use_ob = true;
|
2020-10-28 17:22:56 +11:00
|
|
|
|
|
|
|
if (space_type == SPACE_PROPERTIES) {
|
|
|
|
SpaceProperties *sbuts = area->spacedata.first;
|
|
|
|
id_pin = sbuts->pinid;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id_pin && (GS(id_pin->name) == ID_OB)) {
|
|
|
|
/* Pinned data takes priority, in this case ignore selection & other objects in the mode. */
|
|
|
|
ob = (Object *)id_pin;
|
|
|
|
}
|
|
|
|
else if ((space_type == SPACE_PROPERTIES) && (use_objects_in_mode == false)) {
|
|
|
|
/* When using the space-properties, we don't want to use the entire selection
|
|
|
|
* as the current active object may not be selected.
|
|
|
|
*
|
|
|
|
* This is not the case when we're in a mode that supports multi-mode editing,
|
|
|
|
* since the active object and all other objects in the mode will be included
|
|
|
|
* irrespective of selection. */
|
|
|
|
ob = ob_active;
|
2020-08-30 17:39:12 +10:00
|
|
|
}
|
|
|
|
else if (ob_active && (ob_active->mode &
|
|
|
|
(OB_MODE_ALL_PAINT | OB_MODE_ALL_SCULPT | OB_MODE_ALL_PAINT_GPENCIL))) {
|
|
|
|
/* When painting, limit to active. */
|
|
|
|
ob = ob_active;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Otherwise use full selection. */
|
|
|
|
use_ob = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_ob) {
|
|
|
|
if ((ob != NULL) && !filter_fn(ob, filter_user_data)) {
|
|
|
|
ob = NULL;
|
|
|
|
}
|
|
|
|
*r_objects_len = (ob != NULL) ? 1 : 0;
|
|
|
|
objects = MEM_mallocN(sizeof(*objects) * *r_objects_len, __func__);
|
|
|
|
if (ob != NULL) {
|
|
|
|
objects[0] = ob;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2020-10-28 17:22:56 +11:00
|
|
|
const View3D *v3d = (space_type == SPACE_VIEW3D) ? area->spacedata.first : NULL;
|
2020-08-30 17:39:12 +10:00
|
|
|
/* When in a mode that supports multiple active objects, use "objects in mode"
|
|
|
|
* instead of the object's selection. */
|
2020-10-28 17:22:56 +11:00
|
|
|
if (use_objects_in_mode) {
|
2020-09-15 11:50:46 +10:00
|
|
|
objects = BKE_view_layer_array_from_objects_in_mode(view_layer,
|
|
|
|
v3d,
|
|
|
|
r_objects_len,
|
|
|
|
{.object_mode = ob_active->mode,
|
|
|
|
.no_dup_data = true,
|
|
|
|
.filter_fn = filter_fn,
|
|
|
|
.filter_userdata = filter_user_data});
|
2020-08-30 17:39:12 +10:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
objects = BKE_view_layer_array_selected_objects(
|
|
|
|
view_layer,
|
|
|
|
v3d,
|
|
|
|
r_objects_len,
|
|
|
|
{.no_dup_data = true, .filter_fn = filter_fn, .filter_userdata = filter_user_data});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return objects;
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Hide Operator
|
|
|
|
* \{ */
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
|
2018-07-02 12:03:56 +02:00
|
|
|
static bool object_hide_poll(bContext *C)
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
{
|
|
|
|
if (CTX_wm_space_outliner(C) != NULL) {
|
|
|
|
return ED_outliner_collections_editor_poll(C);
|
|
|
|
}
|
2020-07-03 15:42:22 +02:00
|
|
|
return ED_operator_view3d_active(C);
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int object_hide_view_clear_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
const bool select = RNA_boolean_get(op->ptr, "select");
|
|
|
|
bool changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
|
2018-06-25 13:50:11 +02:00
|
|
|
if (base->flag & BASE_HIDDEN) {
|
|
|
|
base->flag &= ~BASE_HIDDEN;
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
changed = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
if (select) {
|
2019-03-15 16:14:21 -03:00
|
|
|
/* We cannot call `ED_object_base_select` because
|
|
|
|
* base is not selectable while it is hidden. */
|
|
|
|
base->flag |= BASE_SELECTED;
|
|
|
|
BKE_scene_object_base_flag_sync_from_base(base);
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
if (!changed) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
BKE_layer_collection_sync(scene, view_layer);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
2020-10-12 18:04:52 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_hide_view_clear(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Show Hidden Objects";
|
|
|
|
ot->description = "Reveal temporarily hidden objects";
|
|
|
|
ot->idname = "OBJECT_OT_hide_view_clear";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = object_hide_view_clear_exec;
|
|
|
|
ot->poll = object_hide_poll;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
2018-12-05 12:05:47 +11:00
|
|
|
PropertyRNA *prop = RNA_def_boolean(ot->srna, "select", true, "Select", "");
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int object_hide_view_set_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
const bool unselected = RNA_boolean_get(op->ptr, "unselected");
|
2019-02-14 17:50:41 +11:00
|
|
|
bool changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-20 16:17:12 +02:00
|
|
|
/* Hide selected or unselected objects. */
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
|
2020-01-15 12:06:21 +01:00
|
|
|
if (!(base->flag & BASE_VISIBLE_VIEWLAYER)) {
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
continue;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
if (!unselected) {
|
|
|
|
if (base->flag & BASE_SELECTED) {
|
|
|
|
ED_object_base_select(base, BA_DESELECT);
|
2018-06-25 13:50:11 +02:00
|
|
|
base->flag |= BASE_HIDDEN;
|
2019-02-14 17:50:41 +11:00
|
|
|
changed = true;
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!(base->flag & BASE_SELECTED)) {
|
|
|
|
ED_object_base_select(base, BA_DESELECT);
|
2018-06-25 13:50:11 +02:00
|
|
|
base->flag |= BASE_HIDDEN;
|
2019-02-14 17:50:41 +11:00
|
|
|
changed = true;
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-14 17:50:41 +11:00
|
|
|
if (!changed) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
BKE_layer_collection_sync(scene, view_layer);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
2020-10-12 18:04:52 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_hide_view_set(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Hide Objects";
|
|
|
|
ot->description = "Temporarily hide objects from the viewport";
|
|
|
|
ot->idname = "OBJECT_OT_hide_view_set";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = object_hide_view_set_exec;
|
|
|
|
ot->poll = object_hide_poll;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
PropertyRNA *prop;
|
|
|
|
prop = RNA_def_boolean(
|
|
|
|
ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects");
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int object_hide_collection_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2018-11-15 13:32:03 -02:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2019-08-19 14:25:29 -03:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2018-11-15 13:32:03 -02:00
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
int index = RNA_int_get(op->ptr, "collection_index");
|
2019-08-19 14:25:29 -03:00
|
|
|
const bool extend = (win->eventstate->shift != 0);
|
|
|
|
const bool toggle = RNA_boolean_get(op->ptr, "toggle");
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
|
2018-11-15 13:32:03 -02:00
|
|
|
if (win->eventstate->alt != 0) {
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
index += 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
LayerCollection *lc = BKE_layer_collection_from_index(view_layer, index);
|
|
|
|
|
|
|
|
if (!lc) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
|
2018-11-30 02:24:06 -02:00
|
|
|
|
2019-08-19 14:25:29 -03:00
|
|
|
if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
|
2019-10-03 19:22:36 -03:00
|
|
|
if (lc->runtime_flag & LAYER_COLLECTION_RESTRICT_VIEWPORT) {
|
2019-08-19 14:25:29 -03:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
if (toggle) {
|
|
|
|
lc->local_collections_bits ^= v3d->local_collections_uuid;
|
|
|
|
BKE_layer_collection_local_sync(view_layer, v3d);
|
|
|
|
}
|
|
|
|
else {
|
2019-10-03 19:22:36 -03:00
|
|
|
BKE_layer_collection_isolate_local(view_layer, v3d, lc, extend);
|
2019-08-19 14:25:29 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2019-10-03 19:22:36 -03:00
|
|
|
BKE_layer_collection_isolate_global(scene, view_layer, lc, extend);
|
2019-08-19 14:25:29 -03:00
|
|
|
}
|
2018-11-30 02:24:06 -02:00
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define COLLECTION_INVALID_INDEX -1
|
|
|
|
|
2018-12-14 10:30:06 +11:00
|
|
|
void ED_collection_hide_menu_draw(const bContext *C, uiLayout *layout)
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
{
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
LayerCollection *lc_scene = view_layer->layer_collections.first;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (LayerCollection *, lc, &lc_scene->layer_collections) {
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
int index = BKE_layer_collection_findindex(view_layer, lc);
|
|
|
|
uiLayout *row = uiLayoutRow(layout, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-15 10:00:21 -02:00
|
|
|
if (lc->flag & LAYER_COLLECTION_EXCLUDE) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-14 17:45:47 -03:00
|
|
|
if (lc->collection->flag & COLLECTION_RESTRICT_VIEWPORT) {
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
continue;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
int icon = ICON_NONE;
|
|
|
|
if (BKE_layer_collection_has_selected_objects(view_layer, lc)) {
|
|
|
|
icon = ICON_LAYER_ACTIVE;
|
|
|
|
}
|
|
|
|
else if (lc->runtime_flag & LAYER_COLLECTION_HAS_OBJECTS) {
|
|
|
|
icon = ICON_LAYER_USED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
uiItemIntO(row,
|
|
|
|
lc->collection->id.name + 2,
|
|
|
|
icon,
|
|
|
|
"OBJECT_OT_hide_collection",
|
|
|
|
"collection_index",
|
|
|
|
index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int object_hide_collection_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
|
|
|
{
|
|
|
|
/* Immediately execute if collection index was specified. */
|
|
|
|
int index = RNA_int_get(op->ptr, "collection_index");
|
|
|
|
if (index != COLLECTION_INVALID_INDEX) {
|
|
|
|
return object_hide_collection_exec(C, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Open popup menu. */
|
|
|
|
const char *title = CTX_IFACE_(op->type->translation_context, op->type->name);
|
2020-11-13 18:39:19 -07:00
|
|
|
uiPopupMenu *pup = UI_popup_menu_begin(C, title, ICON_OUTLINER_COLLECTION);
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
uiLayout *layout = UI_popup_menu_layout(pup);
|
|
|
|
|
2018-12-14 10:30:06 +11:00
|
|
|
ED_collection_hide_menu_draw(C, layout);
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
|
|
|
|
UI_popup_menu_end(C, pup);
|
|
|
|
|
|
|
|
return OPERATOR_INTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_hide_collection(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2018-11-28 00:49:36 -02:00
|
|
|
ot->name = "Hide Collection";
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
ot->description = "Show only objects in collection (Shift to extend)";
|
|
|
|
ot->idname = "OBJECT_OT_hide_collection";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = object_hide_collection_exec;
|
|
|
|
ot->invoke = object_hide_collection_invoke;
|
|
|
|
ot->poll = ED_operator_view3d_active;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
/* Properties. */
|
|
|
|
PropertyRNA *prop;
|
|
|
|
prop = RNA_def_int(ot->srna,
|
|
|
|
"collection_index",
|
|
|
|
COLLECTION_INVALID_INDEX,
|
|
|
|
COLLECTION_INVALID_INDEX,
|
|
|
|
INT_MAX,
|
|
|
|
"Collection Index",
|
|
|
|
"Index of the collection to change visibility",
|
|
|
|
0,
|
|
|
|
INT_MAX);
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
2018-11-15 13:32:03 -02:00
|
|
|
prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", "Toggle visibility");
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
Objects: restore H key per object hiding.
H hides selected objects, Shift+H hides unselected objects, and Alt+H
reveals hidden objects.
This hiding state is distinct from restrict viewport and render, and
meant for temporarily hiding objects without affecting more persistent
collection hiding.
Object hiding is per view-layer, same as selection. It affects the
viewport and any preview renders in there, but not final renders.
In the outliner, different icons are now used for temporary hiding, and
restrict viewport and render. Hidden objects are greyed out.
Remaining design issues:
* For lamps we probably still want to keep their effect on the scene,
currently they are fully disabled by hiding. Arguably mesh lights or
even objects being reflected or casting shadows are not that different
but perhaps the special lamp exception from local view should remain.
* We need a feature still to disabled this hiding for specific viewports,
for render or animation preview where you want to see the entire scene
while working in another view.
* We need a new icon for restrict viewport, for now it uses a grid similar
to the 2.4 icon.
* Hiding objects does not preserve selection state as it did in 2.7,
it's probably convenient to support this again?
2018-05-14 23:36:56 +02:00
|
|
|
}
|
2010-03-31 00:55:01 +00:00
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Toggle Edit-Mode Operator
|
|
|
|
* \{ */
|
2009-09-16 17:43:09 +00:00
|
|
|
|
2018-06-01 17:08:38 +02:00
|
|
|
static bool mesh_needs_keyindex(Main *bmain, const Mesh *me)
|
2016-04-29 22:33:06 +10:00
|
|
|
{
|
|
|
|
if (me->key) {
|
|
|
|
return false; /* will be added */
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-07 21:24:46 -06:00
|
|
|
LISTBASE_FOREACH (const Object *, ob, &bmain->objects) {
|
2016-04-29 22:33:06 +10:00
|
|
|
if ((ob->parent) && (ob->parent->data == me) && ELEM(ob->partype, PARVERT1, PARVERT3)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (ob->data == me) {
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (const ModifierData *, md, &ob->modifiers) {
|
2016-04-29 22:33:06 +10:00
|
|
|
if (md->type == eModifierType_Hook) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-21 14:12:04 +00:00
|
|
|
/**
|
2021-04-08 19:52:33 +10:00
|
|
|
* Load edit-mode data back into the object.
|
|
|
|
*
|
|
|
|
* \param load_data: Flush the edit-mode data back to the object.
|
|
|
|
* \param free_data: Free the edit-mode data.
|
2013-03-21 14:12:04 +00:00
|
|
|
*/
|
2021-04-08 19:52:33 +10:00
|
|
|
static bool ED_object_editmode_load_free_ex(Main *bmain,
|
|
|
|
Object *obedit,
|
|
|
|
const bool load_data,
|
|
|
|
const bool free_data)
|
2009-01-25 20:22:05 +00:00
|
|
|
{
|
2021-04-08 19:52:33 +10:00
|
|
|
BLI_assert(load_data || free_data);
|
|
|
|
|
2013-03-21 14:12:04 +00:00
|
|
|
if (obedit == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
if (obedit->type == OB_MESH) {
|
|
|
|
Mesh *me = obedit->data;
|
2019-02-17 18:05:18 +11:00
|
|
|
if (me->edit_mesh == NULL) {
|
2018-02-06 15:47:51 +11:00
|
|
|
return false;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-17 18:05:18 +11:00
|
|
|
if (me->edit_mesh->bm->totvert > MESH_MAX_VERTS) {
|
2020-04-16 10:46:08 +10:00
|
|
|
/* This used to be warned int the UI, we could warn again although it's quite rare. */
|
|
|
|
CLOG_WARN(&LOG,
|
|
|
|
"Too many vertices for mesh '%s' (%d)",
|
|
|
|
me->id.name + 2,
|
|
|
|
me->edit_mesh->bm->totvert);
|
2013-03-21 14:12:04 +00:00
|
|
|
return false;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-08 19:52:33 +10:00
|
|
|
if (load_data) {
|
|
|
|
EDBM_mesh_load_ex(bmain, obedit, free_data);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-08 19:41:51 +10:00
|
|
|
if (free_data) {
|
2019-02-17 18:05:18 +11:00
|
|
|
EDBM_mesh_free(me->edit_mesh);
|
|
|
|
MEM_freeN(me->edit_mesh);
|
|
|
|
me->edit_mesh = NULL;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2018-02-06 15:47:51 +11:00
|
|
|
/* will be recalculated as needed. */
|
|
|
|
{
|
2020-04-03 21:47:56 +11:00
|
|
|
ED_mesh_mirror_spatial_table_end(obedit);
|
|
|
|
ED_mesh_mirror_topo_table_end(obedit);
|
2010-03-31 07:22:18 +00:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
else if (obedit->type == OB_ARMATURE) {
|
2018-02-06 15:47:51 +11:00
|
|
|
const bArmature *arm = obedit->data;
|
|
|
|
if (arm->edbo == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-04-08 19:52:33 +10:00
|
|
|
|
|
|
|
if (load_data) {
|
|
|
|
ED_armature_from_edit(bmain, obedit->data);
|
|
|
|
}
|
|
|
|
|
2021-04-08 19:41:51 +10:00
|
|
|
if (free_data) {
|
2013-12-17 22:13:15 +11:00
|
|
|
ED_armature_edit_free(obedit->data);
|
2021-04-28 13:20:12 +10:00
|
|
|
|
|
|
|
if (load_data == false) {
|
|
|
|
/* Don't keep unused pose channels created by duplicating bones
|
|
|
|
* which may have been deleted/undone, see: T87631. */
|
2021-04-28 13:26:58 +10:00
|
|
|
if (obedit->pose != NULL) {
|
|
|
|
BKE_pose_channels_clear_with_null_bone(obedit->pose, true);
|
|
|
|
}
|
2021-04-28 13:20:12 +10:00
|
|
|
}
|
2018-02-06 15:47:51 +11:00
|
|
|
}
|
2015-05-12 13:29:00 +05:00
|
|
|
/* TODO(sergey): Pose channels might have been changed, so need
|
|
|
|
* to inform dependency graph about this. But is it really the
|
|
|
|
* best place to do this?
|
|
|
|
*/
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_relations_tag_update(bmain);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
|
2018-02-06 15:47:51 +11:00
|
|
|
const Curve *cu = obedit->data;
|
|
|
|
if (cu->editnurb == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-04-08 19:52:33 +10:00
|
|
|
|
|
|
|
if (load_data) {
|
|
|
|
ED_curve_editnurb_load(bmain, obedit);
|
|
|
|
}
|
|
|
|
|
2021-04-08 19:41:51 +10:00
|
|
|
if (free_data) {
|
2018-02-06 15:47:51 +11:00
|
|
|
ED_curve_editnurb_free(obedit);
|
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2013-11-21 04:32:28 +11:00
|
|
|
else if (obedit->type == OB_FONT) {
|
2018-02-06 15:47:51 +11:00
|
|
|
const Curve *cu = obedit->data;
|
|
|
|
if (cu->editfont == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-04-08 19:52:33 +10:00
|
|
|
|
|
|
|
if (load_data) {
|
|
|
|
ED_curve_editfont_load(obedit);
|
|
|
|
}
|
|
|
|
|
2021-04-08 19:41:51 +10:00
|
|
|
if (free_data) {
|
2018-02-06 15:47:51 +11:00
|
|
|
ED_curve_editfont_free(obedit);
|
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
else if (obedit->type == OB_LATTICE) {
|
2018-02-06 15:47:51 +11:00
|
|
|
const Lattice *lt = obedit->data;
|
|
|
|
if (lt->editlatt == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-04-08 19:52:33 +10:00
|
|
|
|
|
|
|
if (load_data) {
|
|
|
|
BKE_editlattice_load(obedit);
|
|
|
|
}
|
|
|
|
|
2021-04-08 19:41:51 +10:00
|
|
|
if (free_data) {
|
2018-03-19 14:49:59 +01:00
|
|
|
BKE_editlattice_free(obedit);
|
2018-02-06 15:47:51 +11:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
else if (obedit->type == OB_MBALL) {
|
2018-02-06 15:47:51 +11:00
|
|
|
const MetaBall *mb = obedit->data;
|
|
|
|
if (mb->editelems == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-04-08 19:52:33 +10:00
|
|
|
|
|
|
|
if (load_data) {
|
|
|
|
ED_mball_editmball_load(obedit);
|
|
|
|
}
|
|
|
|
|
2021-04-08 19:41:51 +10:00
|
|
|
if (free_data) {
|
2018-02-06 15:47:51 +11:00
|
|
|
ED_mball_editmball_free(obedit);
|
|
|
|
}
|
2009-01-26 15:23:29 +00:00
|
|
|
}
|
2019-12-09 20:10:22 +11:00
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-08 19:52:33 +10:00
|
|
|
if (load_data) {
|
|
|
|
char *needs_flush_ptr = BKE_object_data_editmode_flush_ptr_get(obedit->data);
|
|
|
|
if (needs_flush_ptr) {
|
|
|
|
*needs_flush_ptr = false;
|
|
|
|
}
|
2019-11-07 16:52:03 +11:00
|
|
|
}
|
|
|
|
|
2013-03-21 14:12:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-06-01 17:08:38 +02:00
|
|
|
bool ED_object_editmode_load(Main *bmain, Object *obedit)
|
2013-03-21 14:12:04 +00:00
|
|
|
{
|
2021-04-08 19:52:33 +10:00
|
|
|
return ED_object_editmode_load_free_ex(bmain, obedit, true, false);
|
2013-03-21 14:12:04 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 00:38:13 +11:00
|
|
|
/**
|
|
|
|
* \param flag:
|
|
|
|
* - If #EM_FREEDATA isn't in the flag, use ED_object_editmode_load directly.
|
|
|
|
*/
|
2018-06-06 15:50:24 +02:00
|
|
|
bool ED_object_editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int flag)
|
2013-03-21 14:12:04 +00:00
|
|
|
{
|
2021-04-08 19:41:51 +10:00
|
|
|
const bool free_data = (flag & EM_FREEDATA) != 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-08 19:52:33 +10:00
|
|
|
if (ED_object_editmode_load_free_ex(bmain, obedit, true, free_data) == false) {
|
2013-06-02 22:21:45 +00:00
|
|
|
/* in rare cases (background mode) its possible active object
|
2020-09-30 20:09:02 +10:00
|
|
|
* is flagged for editmode, without 'obedit' being set T35489. */
|
2018-04-16 16:27:55 +02:00
|
|
|
if (UNLIKELY(obedit && obedit->mode & OB_MODE_EDIT)) {
|
|
|
|
obedit->mode &= ~OB_MODE_EDIT;
|
2020-02-11 10:12:43 +01:00
|
|
|
/* Also happens when mesh is shared across multiple objects. [#T69834] */
|
|
|
|
DEG_id_tag_update(&obedit->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
|
2018-04-05 18:20:27 +02:00
|
|
|
}
|
2018-05-30 08:41:06 +02:00
|
|
|
return true;
|
2013-03-21 14:12:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-08 19:41:51 +10:00
|
|
|
/* `free_data` only false now on file saves and render. */
|
|
|
|
if (free_data) {
|
2009-09-12 20:47:53 +00:00
|
|
|
/* flag object caches as outdated */
|
2021-01-07 21:24:46 -06:00
|
|
|
ListBase pidlist;
|
2013-01-23 05:56:34 +00:00
|
|
|
BKE_ptcache_ids_from_object(&pidlist, obedit, scene, 0);
|
2021-01-07 21:24:46 -06:00
|
|
|
LISTBASE_FOREACH (PTCacheID *, pid, &pidlist) {
|
2019-01-15 23:24:20 +11:00
|
|
|
/* particles don't need reset on geometry change */
|
|
|
|
if (pid->type != PTCACHE_TYPE_PARTICLES) {
|
2009-09-12 20:47:53 +00:00
|
|
|
pid->cache->flag |= PTCACHE_OUTDATED;
|
2019-01-15 23:24:20 +11:00
|
|
|
}
|
2009-09-12 20:47:53 +00:00
|
|
|
}
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
BLI_freelistN(&pidlist);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-31 16:53:19 +01:00
|
|
|
BKE_particlesystem_reset_all(obedit);
|
2011-09-24 11:42:11 +00:00
|
|
|
BKE_ptcache_object_reset(scene, obedit, PTCACHE_RESET_OUTDATED);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
/* also flush ob recalc, doesn't take much overhead, but used for particles */
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&obedit->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-15 10:02:01 +02:00
|
|
|
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-05 18:20:27 +02:00
|
|
|
obedit->mode &= ~OB_MODE_EDIT;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-30 08:41:06 +02:00
|
|
|
return (obedit->mode & OB_MODE_EDIT) == 0;
|
2009-02-13 17:37:01 +00:00
|
|
|
}
|
|
|
|
|
2018-05-30 08:41:06 +02:00
|
|
|
bool ED_object_editmode_exit(bContext *C, int flag)
|
2018-02-14 00:38:13 +11:00
|
|
|
{
|
2018-06-06 15:50:24 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2018-02-14 00:38:13 +11:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2018-06-06 15:50:24 +02:00
|
|
|
return ED_object_editmode_exit_ex(bmain, scene, obedit, flag);
|
2018-02-14 00:38:13 +11:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
|
2021-04-08 19:52:33 +10:00
|
|
|
/**
|
|
|
|
* Support freeing edit-mode data without flushing it back to the object.
|
|
|
|
*
|
|
|
|
* \return true if data was freed.
|
|
|
|
*/
|
|
|
|
bool ED_object_editmode_free_ex(Main *bmain, Object *obedit)
|
|
|
|
{
|
|
|
|
return ED_object_editmode_load_free_ex(bmain, obedit, false, true);
|
|
|
|
}
|
|
|
|
|
2021-01-22 17:31:04 +11:00
|
|
|
bool ED_object_editmode_exit_multi_ex(Main *bmain, Scene *scene, ViewLayer *view_layer, int flag)
|
|
|
|
{
|
|
|
|
Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
|
|
|
|
if (obedit == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool changed = false;
|
|
|
|
const short obedit_type = obedit->type;
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
|
|
|
|
Object *ob = base->object;
|
|
|
|
if ((ob->type == obedit_type) && (ob->mode & OB_MODE_EDIT)) {
|
|
|
|
changed |= ED_object_editmode_exit_ex(bmain, scene, base->object, flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ED_object_editmode_exit_multi(bContext *C, int flag)
|
|
|
|
{
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
return ED_object_editmode_exit_multi_ex(bmain, scene, view_layer, flag);
|
|
|
|
}
|
|
|
|
|
2018-06-01 17:26:36 +02:00
|
|
|
bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag)
|
2009-02-13 17:37:01 +00:00
|
|
|
{
|
2014-04-11 11:25:41 +10:00
|
|
|
bool ok = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-30 17:51:41 +02:00
|
|
|
if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob) || ID_IS_OVERRIDE_LIBRARY(ob) ||
|
|
|
|
ID_IS_OVERRIDE_LIBRARY(ob->data)) {
|
2018-05-30 08:41:06 +02:00
|
|
|
return false;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-08 18:48:23 +10:00
|
|
|
/* This checks actual `ob->data`, for cases when other scenes have it in edit-mode context.
|
|
|
|
* Currently multiple objects sharing a mesh being in edit-mode at once isn't supported,
|
|
|
|
* see: T86767. */
|
|
|
|
if (BKE_object_is_in_editmode(ob)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
if (BKE_object_obdata_is_libdata(ob)) {
|
2020-04-16 10:46:08 +10:00
|
|
|
/* Ideally the caller should check this. */
|
|
|
|
CLOG_WARN(&LOG, "Unable to enter edit-mode on library data for object '%s'", ob->id.name + 2);
|
2018-05-30 08:41:06 +02:00
|
|
|
return false;
|
2009-07-29 12:35:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-08 18:48:23 +10:00
|
|
|
ob->restore_mode = ob->mode;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-08 18:48:23 +10:00
|
|
|
ob->mode = OB_MODE_EDIT;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
if (ob->type == OB_MESH) {
|
2020-12-22 14:58:57 -06:00
|
|
|
ok = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-01 17:08:38 +02:00
|
|
|
const bool use_key_index = mesh_needs_keyindex(bmain, ob->data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-14 02:02:05 +11:00
|
|
|
EDBM_mesh_make(ob, scene->toolsettings->selectmode, use_key_index);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-22 14:58:57 -06:00
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(ob);
|
2012-03-27 00:01:35 +00:00
|
|
|
if (LIKELY(em)) {
|
2021-06-14 22:56:03 +10:00
|
|
|
BKE_editmesh_looptri_and_normals_calc(em);
|
2012-03-27 00:01:35 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_MESH, NULL);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
else if (ob->type == OB_ARMATURE) {
|
2019-11-07 16:52:03 +11:00
|
|
|
bArmature *arm = ob->data;
|
2020-12-22 14:58:57 -06:00
|
|
|
ok = true;
|
2019-11-07 16:52:03 +11:00
|
|
|
ED_armature_to_edit(arm);
|
2020-03-06 11:40:37 +11:00
|
|
|
/* To ensure all goes in rest-position and without striding. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-11-07 16:52:03 +11:00
|
|
|
arm->needs_flush_to_id = 0;
|
|
|
|
|
2019-01-15 23:24:20 +11:00
|
|
|
/* XXX: should this be ID_RECALC_GEOMETRY? */
|
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_ARMATURE, scene);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
else if (ob->type == OB_FONT) {
|
2020-12-22 14:58:57 -06:00
|
|
|
ok = true;
|
2015-11-18 12:20:28 +11:00
|
|
|
ED_curve_editfont_make(ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_TEXT, scene);
|
2009-02-10 22:45:20 +00:00
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
else if (ob->type == OB_MBALL) {
|
2019-11-07 16:52:03 +11:00
|
|
|
MetaBall *mb = ob->data;
|
|
|
|
|
2020-12-22 14:58:57 -06:00
|
|
|
ok = true;
|
2015-11-18 12:20:28 +11:00
|
|
|
ED_mball_editmball_make(ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-11-07 16:52:03 +11:00
|
|
|
mb->needs_flush_to_id = 0;
|
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_MBALL, scene);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2012-04-28 15:42:27 +00:00
|
|
|
else if (ob->type == OB_LATTICE) {
|
2020-12-22 14:58:57 -06:00
|
|
|
ok = true;
|
2018-03-19 14:49:59 +01:00
|
|
|
BKE_editlattice_make(ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_LATTICE, scene);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2020-11-06 12:30:59 +11:00
|
|
|
else if (ELEM(ob->type, OB_SURF, OB_CURVE)) {
|
2020-12-22 14:58:57 -06:00
|
|
|
ok = true;
|
2015-11-18 12:20:28 +11:00
|
|
|
ED_curve_editnurb_make(ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_CURVE, scene);
|
2009-02-10 22:45:20 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ok) {
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-04-16 16:27:55 +02:00
|
|
|
if ((flag & EM_NO_CONTEXT) == 0) {
|
|
|
|
ob->mode &= ~OB_MODE_EDIT;
|
|
|
|
}
|
|
|
|
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-30 08:41:06 +02:00
|
|
|
return (ob->mode & OB_MODE_EDIT) != 0;
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
|
|
|
|
2018-05-30 08:49:34 +02:00
|
|
|
bool ED_object_editmode_enter(bContext *C, int flag)
|
2018-04-16 16:27:55 +02:00
|
|
|
{
|
2018-06-01 17:26:36 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2018-04-16 16:27:55 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-31 15:36:24 +11:00
|
|
|
/* Active layer checked here for view3d,
|
|
|
|
* callers that don't want view context can call the extended version. */
|
2020-06-30 17:51:41 +02:00
|
|
|
Object *ob = CTX_data_active_object(C);
|
2018-06-01 17:26:36 +02:00
|
|
|
return ED_object_editmode_enter_ex(bmain, scene, ob, flag);
|
2009-02-10 22:45:20 +00:00
|
|
|
}
|
|
|
|
|
2013-08-29 10:34:09 +00:00
|
|
|
static int editmode_toggle_exec(bContext *C, wmOperator *op)
|
2009-09-16 17:43:09 +00:00
|
|
|
{
|
2018-06-01 17:26:36 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2015-08-31 21:37:38 +03:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-11-25 09:50:34 -02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2020-09-11 19:50:38 +10:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2018-04-16 16:27:55 +02:00
|
|
|
Object *obact = OBACT(view_layer);
|
2020-09-11 19:50:38 +10:00
|
|
|
const int mode_flag = OB_MODE_EDIT;
|
|
|
|
const bool is_mode_set = (obact->mode & mode_flag) != 0;
|
|
|
|
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-08-29 10:34:09 +00:00
|
|
|
if (!is_mode_set) {
|
2018-04-16 16:27:55 +02:00
|
|
|
if (!ED_object_mode_compat_set(C, obact, mode_flag, op->reports)) {
|
2013-08-29 10:34:09 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
if (!is_mode_set) {
|
2020-09-11 19:50:38 +10:00
|
|
|
ED_object_editmode_enter_ex(bmain, scene, obact, 0);
|
2018-04-16 16:27:55 +02:00
|
|
|
if (obact->mode & mode_flag) {
|
2018-11-25 09:50:34 -02:00
|
|
|
FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob) {
|
2018-04-16 16:27:55 +02:00
|
|
|
if ((ob != obact) && (ob->type == obact->type)) {
|
2019-01-10 13:02:07 +11:00
|
|
|
ED_object_editmode_enter_ex(bmain, scene, ob, EM_NO_CONTEXT);
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
FOREACH_SELECTED_OBJECT_END;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2020-09-11 19:50:38 +10:00
|
|
|
ED_object_editmode_exit_ex(bmain, scene, obact, EM_FREEDATA);
|
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
if ((obact->mode & mode_flag) == 0) {
|
2018-05-29 14:11:34 +02:00
|
|
|
FOREACH_OBJECT_BEGIN (view_layer, ob) {
|
2018-04-16 16:27:55 +02:00
|
|
|
if ((ob != obact) && (ob->type == obact->type)) {
|
2019-01-10 13:02:07 +11:00
|
|
|
ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
2018-05-29 14:11:34 +02:00
|
|
|
FOREACH_OBJECT_END;
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-08 07:22:52 +02:00
|
|
|
WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-03 18:02:16 +02:00
|
|
|
if (G.background == false) {
|
|
|
|
WM_toolsystem_update_from_context_view3d(C);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2009-02-10 22:45:20 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool editmode_toggle_poll(bContext *C)
|
2009-01-25 20:22:05 +00:00
|
|
|
{
|
2009-09-16 17:43:09 +00:00
|
|
|
Object *ob = CTX_data_active_object(C);
|
|
|
|
|
2010-01-10 20:01:13 +00:00
|
|
|
/* covers proxies too */
|
2020-06-30 17:51:41 +02:00
|
|
|
if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob->data) || ID_IS_OVERRIDE_LIBRARY(ob) ||
|
|
|
|
ID_IS_OVERRIDE_LIBRARY(ob->data)) {
|
2020-12-22 14:58:57 -06:00
|
|
|
return false;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2010-01-10 20:01:13 +00:00
|
|
|
|
2012-11-21 03:33:34 +00:00
|
|
|
/* if hidden but in edit mode, we still display */
|
2019-05-14 17:45:47 -03:00
|
|
|
if ((ob->restrictflag & OB_RESTRICT_VIEWPORT) && !(ob->mode & OB_MODE_EDIT)) {
|
2020-12-22 14:58:57 -06:00
|
|
|
return false;
|
2018-02-06 19:34:36 +11:00
|
|
|
}
|
2010-01-10 20:01:13 +00:00
|
|
|
|
2014-08-05 10:57:54 -04:00
|
|
|
return OB_TYPE_SUPPORT_EDITMODE(ob->type);
|
2009-01-25 20:22:05 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
void OBJECT_OT_editmode_toggle(wmOperatorType *ot)
|
2009-01-25 20:22:05 +00:00
|
|
|
{
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-01-25 20:22:05 +00:00
|
|
|
/* identifiers */
|
2020-12-24 13:11:22 -06:00
|
|
|
ot->name = "Toggle Edit Mode";
|
|
|
|
ot->description = "Toggle object's edit mode";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_editmode_toggle";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-01-25 20:22:05 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = editmode_toggle_exec;
|
|
|
|
ot->poll = editmode_toggle_poll;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-01-25 20:22:05 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Toggle Pose-Mode Operator
|
|
|
|
* \{ */
|
2009-01-15 16:07:39 +00:00
|
|
|
|
2013-08-29 10:34:09 +00:00
|
|
|
static int posemode_exec(bContext *C, wmOperator *op)
|
2008-12-23 19:47:33 +00:00
|
|
|
{
|
2018-05-08 07:22:52 +02:00
|
|
|
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
|
2020-09-11 19:50:38 +10:00
|
|
|
struct Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2012-04-28 15:42:27 +00:00
|
|
|
Base *base = CTX_data_active_base(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-12 18:03:31 -03:00
|
|
|
/* If the base is NULL it means we have an active object, but the object itself is hidden. */
|
|
|
|
if (base == NULL) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
Object *obact = base->object;
|
2013-08-29 10:34:09 +00:00
|
|
|
const int mode_flag = OB_MODE_POSE;
|
2018-04-16 16:27:55 +02:00
|
|
|
bool is_mode_set = (obact->mode & mode_flag) != 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-08-29 10:34:09 +00:00
|
|
|
if (!is_mode_set) {
|
2018-04-16 16:27:55 +02:00
|
|
|
if (!ED_object_mode_compat_set(C, obact, mode_flag, op->reports)) {
|
2013-08-29 10:34:09 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2018-05-08 07:22:52 +02:00
|
|
|
if (obact->type != OB_ARMATURE) {
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-11 19:50:38 +10:00
|
|
|
{
|
|
|
|
Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
|
|
|
|
if (obact == obedit) {
|
|
|
|
ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA);
|
|
|
|
is_mode_set = false;
|
|
|
|
}
|
2018-05-08 07:22:52 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-08 07:22:52 +02:00
|
|
|
if (is_mode_set) {
|
|
|
|
bool ok = ED_object_posemode_exit(C, obact);
|
|
|
|
if (ok) {
|
2018-05-29 14:11:34 +02:00
|
|
|
FOREACH_OBJECT_BEGIN (view_layer, ob) {
|
2018-05-08 07:22:52 +02:00
|
|
|
if ((ob != obact) && (ob->type == OB_ARMATURE) && (ob->mode & mode_flag)) {
|
|
|
|
ED_object_posemode_exit_ex(bmain, ob);
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-05-29 14:11:34 +02:00
|
|
|
FOREACH_OBJECT_END;
|
2018-05-08 07:22:52 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-05-08 07:22:52 +02:00
|
|
|
else {
|
|
|
|
bool ok = ED_object_posemode_enter(C, obact);
|
|
|
|
if (ok) {
|
2020-09-11 19:50:38 +10:00
|
|
|
const View3D *v3d = CTX_wm_view3d(C);
|
2018-11-25 09:50:34 -02:00
|
|
|
FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob) {
|
2018-05-08 07:22:52 +02:00
|
|
|
if ((ob != obact) && (ob->type == OB_ARMATURE) && (ob->mode == OB_MODE_OBJECT) &&
|
|
|
|
(!ID_IS_LINKED(ob))) {
|
|
|
|
ED_object_posemode_enter_ex(bmain, ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
2018-05-08 07:22:52 +02:00
|
|
|
FOREACH_SELECTED_OBJECT_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-08 07:22:52 +02:00
|
|
|
WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-03 18:02:16 +02:00
|
|
|
if (G.background == false) {
|
|
|
|
WM_toolsystem_update_from_context_view3d(C);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-08 07:22:52 +02:00
|
|
|
return OPERATOR_FINISHED;
|
2009-02-04 17:40:50 +00:00
|
|
|
}
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
void OBJECT_OT_posemode_toggle(wmOperatorType *ot)
|
2009-02-04 17:40:50 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Toggle Pose Mode";
|
|
|
|
ot->idname = "OBJECT_OT_posemode_toggle";
|
|
|
|
ot->description = "Enable or disable posing/selecting bones";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = posemode_exec;
|
|
|
|
ot->poll = ED_operator_object_active_editable;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
/* flag */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2008-12-23 19:47:33 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Force Field Toggle Operator
|
|
|
|
* \{ */
|
2011-01-23 14:04:31 +00:00
|
|
|
|
2018-04-05 18:20:27 +02:00
|
|
|
void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object)
|
2013-11-19 17:19:06 +06:00
|
|
|
{
|
|
|
|
PartDeflect *pd = object->pd;
|
2020-05-08 10:14:02 +02:00
|
|
|
ModifierData *md = BKE_modifiers_findby_type(object, eModifierType_Surface);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-11-19 17:19:06 +06:00
|
|
|
/* add/remove modifier as needed */
|
|
|
|
if (!md) {
|
2017-08-27 12:20:21 +02:00
|
|
|
if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) &&
|
|
|
|
!ELEM(pd->forcefield, 0, PFIELD_GUIDE, PFIELD_TEXTURE)) {
|
|
|
|
if (ELEM(object->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE)) {
|
2018-04-05 18:20:27 +02:00
|
|
|
ED_object_modifier_add(NULL, bmain, scene, object, NULL, eModifierType_Surface);
|
2017-08-27 12:20:21 +02:00
|
|
|
}
|
|
|
|
}
|
2013-11-19 17:19:06 +06:00
|
|
|
}
|
|
|
|
else {
|
2017-08-27 12:20:21 +02:00
|
|
|
if (!pd || (pd->shape != PFIELD_SHAPE_SURFACE) ||
|
|
|
|
ELEM(pd->forcefield, 0, PFIELD_GUIDE, PFIELD_TEXTURE)) {
|
2020-07-09 11:44:11 +02:00
|
|
|
ED_object_modifier_remove(NULL, bmain, scene, object, md);
|
2017-08-27 12:20:21 +02:00
|
|
|
}
|
2013-11-19 17:19:06 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 14:04:31 +00:00
|
|
|
static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Object *ob = CTX_data_active_object(C);
|
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ob->pd == NULL) {
|
2018-12-02 14:14:51 +11:00
|
|
|
ob->pd = BKE_partdeflect_new(PFIELD_FORCE);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
else if (ob->pd->forcefield == 0) {
|
2011-01-23 14:04:31 +00:00
|
|
|
ob->pd->forcefield = PFIELD_FORCE;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
else {
|
2011-01-23 14:04:31 +00:00
|
|
|
ob->pd->forcefield = 0;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-02-09 22:14:17 +11:00
|
|
|
|
2018-04-05 18:20:27 +02:00
|
|
|
ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob);
|
2013-11-19 17:19:06 +06:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
|
2011-09-02 18:05:07 +00:00
|
|
|
|
2019-06-21 18:22:53 +02:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
|
|
|
|
|
2011-01-23 14:04:31 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_forcefield_toggle(wmOperatorType *ot)
|
|
|
|
{
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-01-23 14:04:31 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Toggle Force Field";
|
2011-01-23 14:04:31 +00:00
|
|
|
ot->description = "Toggle object's force field";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_forcefield_toggle";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-01-23 14:04:31 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = forcefield_toggle_exec;
|
|
|
|
ot->poll = ED_operator_object_active_editable;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-01-23 14:04:31 +00:00
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2011-01-23 14:04:31 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Calculate Motion Paths Operator
|
|
|
|
* \{ */
|
2010-01-19 11:31:49 +00:00
|
|
|
|
2019-09-20 12:48:28 +02:00
|
|
|
static eAnimvizCalcRange object_path_convert_range(eObjectPathCalcRange range)
|
|
|
|
{
|
|
|
|
switch (range) {
|
|
|
|
case OBJECT_PATH_CALC_RANGE_CURRENT_FRAME:
|
|
|
|
return ANIMVIZ_CALC_RANGE_CURRENT_FRAME;
|
|
|
|
case OBJECT_PATH_CALC_RANGE_CHANGED:
|
|
|
|
return ANIMVIZ_CALC_RANGE_CHANGED;
|
|
|
|
case OBJECT_PATH_CALC_RANGE_FULL:
|
|
|
|
return ANIMVIZ_CALC_RANGE_FULL;
|
|
|
|
}
|
|
|
|
return ANIMVIZ_CALC_RANGE_FULL;
|
|
|
|
}
|
|
|
|
|
2012-05-01 13:51:50 +00:00
|
|
|
/* For the objects with animation: update paths for those that have got them
|
2010-01-19 11:31:49 +00:00
|
|
|
* This should selectively update paths that exist...
|
|
|
|
*
|
2018-06-01 18:19:39 +02:00
|
|
|
* To be called from various tools that do incremental updates
|
2010-01-19 11:31:49 +00:00
|
|
|
*/
|
2019-09-20 12:48:28 +02:00
|
|
|
void ED_objects_recalculate_paths(bContext *C, Scene *scene, eObjectPathCalcRange range)
|
2010-01-19 11:31:49 +00:00
|
|
|
{
|
2018-09-27 15:49:59 +02:00
|
|
|
/* Transform doesn't always have context available to do update. */
|
2018-09-14 14:03:31 +02:00
|
|
|
if (C == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-09-14 14:03:31 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2019-09-20 17:38:32 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-09-20 17:38:32 +02:00
|
|
|
ListBase targets = {NULL, NULL};
|
2010-01-19 11:31:49 +00:00
|
|
|
/* loop over objects in scene */
|
2012-06-05 21:54:21 +00:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
|
2012-05-01 13:51:50 +00:00
|
|
|
/* set flag to force recalc, then grab path(s) from object */
|
2010-01-19 11:31:49 +00:00
|
|
|
ob->avs.recalc |= ANIMVIZ_RECALC_PATHS;
|
|
|
|
animviz_get_object_motionpaths(ob, &targets);
|
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-09-20 17:38:32 +02:00
|
|
|
Depsgraph *depsgraph;
|
|
|
|
bool free_depsgraph = false;
|
|
|
|
/* For a single frame update it's faster to re-use existing dependency graph and avoid overhead
|
|
|
|
* of building all the relations and so on for a temporary one. */
|
|
|
|
if (range == OBJECT_PATH_CALC_RANGE_CURRENT_FRAME) {
|
|
|
|
/* NOTE: Dependency graph will be evaluated at all the frames, but we first need to access some
|
|
|
|
* nested pointers, like animation data. */
|
|
|
|
depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
|
|
|
free_depsgraph = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
depsgraph = animviz_depsgraph_build(bmain, scene, view_layer, &targets);
|
|
|
|
free_depsgraph = true;
|
|
|
|
}
|
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* recalculate paths, then free */
|
2019-09-20 12:48:28 +02:00
|
|
|
animviz_calc_motionpaths(
|
|
|
|
depsgraph, bmain, scene, &targets, object_path_convert_range(range), true);
|
2010-01-19 11:31:49 +00:00
|
|
|
BLI_freelistN(&targets);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-09-20 12:48:28 +02:00
|
|
|
if (range != OBJECT_PATH_CALC_RANGE_CURRENT_FRAME) {
|
2018-09-14 14:03:31 +02:00
|
|
|
/* Tag objects for copy on write - so paths will draw/redraw
|
|
|
|
* For currently frame only we update evaluated object directly. */
|
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
|
|
|
|
if (ob->mpath) {
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
|
2018-09-14 14:03:31 +02:00
|
|
|
}
|
2018-06-01 16:38:21 +02:00
|
|
|
}
|
2018-09-14 14:03:31 +02:00
|
|
|
CTX_DATA_END;
|
2018-06-01 16:38:21 +02:00
|
|
|
}
|
2019-09-20 17:38:32 +02:00
|
|
|
|
|
|
|
/* Free temporary depsgraph. */
|
|
|
|
if (free_depsgraph) {
|
|
|
|
DEG_graph_free(depsgraph);
|
|
|
|
}
|
2010-01-19 11:31:49 +00:00
|
|
|
}
|
|
|
|
|
2012-05-01 16:19:13 +00:00
|
|
|
/* show popup to determine settings */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
2012-05-01 16:19:13 +00:00
|
|
|
{
|
|
|
|
Object *ob = CTX_data_active_object(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ob == NULL) {
|
2012-05-01 16:19:13 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-01 16:19:13 +00:00
|
|
|
/* set default settings from existing/stored settings */
|
|
|
|
{
|
|
|
|
bAnimVizSettings *avs = &ob->avs;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-01 16:19:13 +00:00
|
|
|
RNA_int_set(op->ptr, "start_frame", avs->path_sf);
|
|
|
|
RNA_int_set(op->ptr, "end_frame", avs->path_ef);
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-01 16:19:13 +00:00
|
|
|
/* show popup dialog to allow editing of range... */
|
2020-04-16 10:58:09 +10:00
|
|
|
/* FIXME: hard-coded dimensions here are just arbitrary. */
|
2020-01-28 10:49:05 +01:00
|
|
|
return WM_operator_props_dialog_popup(C, op, 200);
|
2012-05-01 16:19:13 +00:00
|
|
|
}
|
|
|
|
|
2012-05-01 13:51:50 +00:00
|
|
|
/* Calculate/recalculate whole paths (avs.path_sf to avs.path_ef) */
|
2012-04-28 15:42:27 +00:00
|
|
|
static int object_calculate_paths_exec(bContext *C, wmOperator *op)
|
2010-01-19 11:31:49 +00:00
|
|
|
{
|
2012-04-28 15:42:27 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2012-05-01 16:19:13 +00:00
|
|
|
int start = RNA_int_get(op->ptr, "start_frame");
|
|
|
|
int end = RNA_int_get(op->ptr, "end_frame");
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* set up path data for bones being calculated */
|
2012-06-05 21:54:21 +00:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
|
2012-05-01 16:19:13 +00:00
|
|
|
bAnimVizSettings *avs = &ob->avs;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-01 16:19:13 +00:00
|
|
|
/* grab baking settings from operator settings */
|
|
|
|
avs->path_sf = start;
|
|
|
|
avs->path_ef = end;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-01 13:51:50 +00:00
|
|
|
/* verify that the selected object has the appropriate settings */
|
2011-11-12 04:40:53 +00:00
|
|
|
animviz_verify_motionpaths(op->reports, scene, ob, NULL);
|
2010-01-19 11:31:49 +00:00
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-01 13:51:50 +00:00
|
|
|
/* calculate the paths for objects that have them (and are tagged to get refreshed) */
|
2019-09-20 12:48:28 +02:00
|
|
|
ED_objects_recalculate_paths(C, scene, OBJECT_PATH_CALC_RANGE_FULL);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* notifiers for updates */
|
2012-05-01 13:51:50 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2010-01-19 11:31:49 +00:00
|
|
|
}
|
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
void OBJECT_OT_paths_calculate(wmOperatorType *ot)
|
2010-01-19 11:31:49 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Calculate Object Paths";
|
|
|
|
ot->idname = "OBJECT_OT_paths_calculate";
|
2012-05-01 13:51:50 +00:00
|
|
|
ot->description = "Calculate motion paths for the selected objects";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* api callbacks */
|
2012-05-01 16:19:13 +00:00
|
|
|
ot->invoke = object_calculate_paths_invoke;
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = object_calculate_paths_exec;
|
|
|
|
ot->poll = ED_operator_object_active_editable;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-01 16:19:13 +00:00
|
|
|
/* properties */
|
2018-06-04 09:31:30 +02:00
|
|
|
RNA_def_int(ot->srna,
|
|
|
|
"start_frame",
|
|
|
|
1,
|
|
|
|
MINAFRAME,
|
|
|
|
MAXFRAME,
|
|
|
|
"Start",
|
2012-06-05 21:54:21 +00:00
|
|
|
"First frame to calculate object paths on",
|
|
|
|
MINFRAME,
|
|
|
|
MAXFRAME / 2.0);
|
2018-06-04 09:31:30 +02:00
|
|
|
RNA_def_int(ot->srna,
|
|
|
|
"end_frame",
|
|
|
|
250,
|
|
|
|
MINAFRAME,
|
|
|
|
MAXFRAME,
|
|
|
|
"End",
|
2012-06-05 21:54:21 +00:00
|
|
|
"Last frame to calculate object paths on",
|
|
|
|
MINFRAME,
|
|
|
|
MAXFRAME / 2.0);
|
2010-01-19 11:31:49 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Update Motion Paths Operator
|
|
|
|
* \{ */
|
2010-01-19 11:31:49 +00:00
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool object_update_paths_poll(bContext *C)
|
2016-02-06 17:57:50 +13:00
|
|
|
{
|
|
|
|
if (ED_operator_object_active_editable(C)) {
|
2016-02-27 11:30:23 +01:00
|
|
|
Object *ob = ED_object_active_context(C);
|
2016-02-06 17:57:50 +13:00
|
|
|
return (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2016-02-06 17:57:50 +13:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-05-06 04:18:13 +00:00
|
|
|
static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (scene == NULL) {
|
2012-05-06 04:18:13 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-06 04:18:13 +00:00
|
|
|
/* calculate the paths for objects that have them (and are tagged to get refreshed) */
|
2019-09-20 12:48:28 +02:00
|
|
|
ED_objects_recalculate_paths(C, scene, OBJECT_PATH_CALC_RANGE_FULL);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-06 04:18:13 +00:00
|
|
|
/* notifiers for updates */
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-06 04:18:13 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_paths_update(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Update Object Paths";
|
|
|
|
ot->idname = "OBJECT_OT_paths_update";
|
|
|
|
ot->description = "Recalculate paths for selected objects";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-08-01 13:53:25 +10:00
|
|
|
/* api callbacks */
|
2012-05-06 04:18:13 +00:00
|
|
|
ot->exec = object_update_paths_exec;
|
2016-02-06 17:57:50 +13:00
|
|
|
ot->poll = object_update_paths_poll;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-06 04:18:13 +00:00
|
|
|
/* flags */
|
2012-06-05 21:54:21 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-05-06 04:18:13 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Clear Motion Paths Operator
|
|
|
|
* \{ */
|
2012-05-06 04:18:13 +00:00
|
|
|
|
2016-02-26 01:07:26 +13:00
|
|
|
/* Helper for ED_objects_clear_paths() */
|
|
|
|
static void object_clear_mpath(Object *ob)
|
|
|
|
{
|
|
|
|
if (ob->mpath) {
|
|
|
|
animviz_free_motionpath(ob->mpath);
|
|
|
|
ob->mpath = NULL;
|
|
|
|
ob->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-08-01 01:27:47 +12:00
|
|
|
/* tag object for copy on write - so removed paths don't still show */
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
|
2016-02-26 01:07:26 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-06 13:04:20 +13:00
|
|
|
/* Clear motion paths for all objects */
|
2016-02-26 01:07:26 +13:00
|
|
|
void ED_objects_clear_paths(bContext *C, bool only_selected)
|
2010-01-19 11:31:49 +00:00
|
|
|
{
|
2016-02-26 01:07:26 +13:00
|
|
|
if (only_selected) {
|
2020-04-16 10:58:09 +10:00
|
|
|
/* Loop over all selected + editable objects in scene. */
|
2016-02-26 01:07:26 +13:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
|
|
|
|
object_clear_mpath(ob);
|
2010-01-19 11:31:49 +00:00
|
|
|
}
|
2016-02-26 01:07:26 +13:00
|
|
|
CTX_DATA_END;
|
|
|
|
}
|
|
|
|
else {
|
2020-04-16 10:58:09 +10:00
|
|
|
/* Loop over all editable objects in scene. */
|
2016-02-26 01:07:26 +13:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, editable_objects) {
|
|
|
|
object_clear_mpath(ob);
|
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
2010-01-19 11:31:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* operator callback for this */
|
2016-02-26 01:07:26 +13:00
|
|
|
static int object_clear_paths_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* use the backend function for this */
|
2016-02-26 01:07:26 +13:00
|
|
|
ED_objects_clear_paths(C, only_selected);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* notifiers for updates */
|
2012-05-01 13:51:50 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2010-01-19 11:31:49 +00:00
|
|
|
}
|
|
|
|
|
2016-02-26 01:07:26 +13:00
|
|
|
/* operator callback/wrapper */
|
2021-03-05 14:03:20 +11:00
|
|
|
static int object_clear_paths_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2016-02-26 01:07:26 +13:00
|
|
|
{
|
2021-03-05 14:03:20 +11:00
|
|
|
if ((event->shift) && !RNA_struct_property_is_set(op->ptr, "only_selected")) {
|
2016-02-26 01:07:26 +13:00
|
|
|
RNA_boolean_set(op->ptr, "only_selected", true);
|
|
|
|
}
|
|
|
|
return object_clear_paths_exec(C, op);
|
|
|
|
}
|
|
|
|
|
2012-04-28 15:42:27 +00:00
|
|
|
void OBJECT_OT_paths_clear(wmOperatorType *ot)
|
2010-01-19 11:31:49 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Clear Object Paths";
|
|
|
|
ot->idname = "OBJECT_OT_paths_clear";
|
2016-02-26 01:07:26 +13:00
|
|
|
ot->description = "Clear path caches for all objects, hold Shift key for selected objects only";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* api callbacks */
|
2016-02-26 01:07:26 +13:00
|
|
|
ot->invoke = object_clear_paths_invoke;
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = object_clear_paths_exec;
|
|
|
|
ot->poll = ED_operator_object_active_editable;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-02-26 01:07:26 +13:00
|
|
|
/* properties */
|
|
|
|
ot->prop = RNA_def_boolean(
|
|
|
|
ot->srna, "only_selected", false, "Only Selected", "Only clear paths from selected objects");
|
|
|
|
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
|
2010-01-19 11:31:49 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Update Motion Paths Range from Scene Operator
|
|
|
|
* \{ */
|
2018-08-20 16:12:37 +12:00
|
|
|
|
|
|
|
static int object_update_paths_range_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/* Loop over all editable objects in scene. */
|
2018-08-20 16:12:37 +12:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, editable_objects) {
|
|
|
|
/* use Preview Range or Full Frame Range - whichever is in use */
|
|
|
|
ob->avs.path_sf = PSFRA;
|
|
|
|
ob->avs.path_ef = PEFRA;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-08-20 16:12:37 +12:00
|
|
|
/* tag for updates */
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
|
2018-08-20 16:12:37 +12:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
|
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-08-20 16:12:37 +12:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_paths_range_update(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Update Range from Scene";
|
|
|
|
ot->idname = "OBJECT_OT_paths_range_update";
|
|
|
|
ot->description = "Update frame range for motion paths from the Scene's current frame range";
|
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
ot->exec = object_update_paths_range_exec;
|
|
|
|
ot->poll = ED_operator_object_active_editable;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Object Shade Smooth/Flat Operator
|
|
|
|
* \{ */
|
2009-07-21 00:36:07 +00:00
|
|
|
|
|
|
|
static int shade_smooth_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2020-04-16 11:43:19 +10:00
|
|
|
const bool use_smooth = STREQ(op->idname, "OBJECT_OT_shade_smooth");
|
|
|
|
bool changed_multi = false;
|
|
|
|
bool has_linked_data = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-16 11:43:19 +10:00
|
|
|
ListBase ctx_objects = {NULL, NULL};
|
|
|
|
CollectionPointerLink ctx_ob_single_active = {NULL};
|
|
|
|
|
|
|
|
/* For modes that only use an active object, don't handle the whole selection. */
|
|
|
|
{
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
Object *obact = OBACT(view_layer);
|
|
|
|
if (obact && ((obact->mode & OB_MODE_ALL_PAINT))) {
|
|
|
|
ctx_ob_single_active.ptr.data = obact;
|
|
|
|
BLI_addtail(&ctx_objects, &ctx_ob_single_active);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx_objects.first != &ctx_ob_single_active) {
|
|
|
|
CTX_data_selected_editable_objects(C, &ctx_objects);
|
|
|
|
}
|
|
|
|
|
2021-01-07 21:24:46 -06:00
|
|
|
LISTBASE_FOREACH (CollectionPointerLink *, ctx_ob, &ctx_objects) {
|
2020-04-16 11:43:19 +10:00
|
|
|
Object *ob = ctx_ob->ptr.data;
|
|
|
|
ID *data = ob->data;
|
|
|
|
if (data != NULL) {
|
|
|
|
data->tag |= LIB_TAG_DOIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-07 21:24:46 -06:00
|
|
|
LISTBASE_FOREACH (CollectionPointerLink *, ctx_ob, &ctx_objects) {
|
2020-04-16 11:43:19 +10:00
|
|
|
/* Always un-tag all object data-blocks irrespective of our ability to operate on them. */
|
|
|
|
Object *ob = ctx_ob->ptr.data;
|
|
|
|
ID *data = ob->data;
|
|
|
|
if ((data == NULL) || ((data->tag & LIB_TAG_DOIT) == 0)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
data->tag &= ~LIB_TAG_DOIT;
|
|
|
|
/* Finished un-tagging, continue with regular logic. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-11-06 17:17:10 +01:00
|
|
|
if (data && ID_IS_LINKED(data)) {
|
2020-04-16 11:43:19 +10:00
|
|
|
has_linked_data = true;
|
2014-01-15 16:01:40 +01:00
|
|
|
continue;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-16 11:43:19 +10:00
|
|
|
bool changed = false;
|
2012-04-28 15:42:27 +00:00
|
|
|
if (ob->type == OB_MESH) {
|
2020-04-16 11:43:19 +10:00
|
|
|
BKE_mesh_smooth_flag_set(ob->data, use_smooth);
|
2018-08-23 10:14:29 -03:00
|
|
|
BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
|
2020-04-16 11:43:19 +10:00
|
|
|
changed = true;
|
2009-07-21 00:36:07 +00:00
|
|
|
}
|
2012-03-25 22:35:18 +00:00
|
|
|
else if (ELEM(ob->type, OB_SURF, OB_CURVE)) {
|
2020-04-16 11:43:19 +10:00
|
|
|
BKE_curve_smooth_flag_set(ob->data, use_smooth);
|
|
|
|
changed = true;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-16 11:43:19 +10:00
|
|
|
if (changed) {
|
|
|
|
changed_multi = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2012-04-28 15:42:27 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
|
2009-07-21 00:36:07 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-16 11:43:19 +10:00
|
|
|
if (ctx_objects.first != &ctx_ob_single_active) {
|
|
|
|
BLI_freelistN(&ctx_objects);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_linked_data) {
|
2014-01-21 20:18:07 +01:00
|
|
|
BKE_report(op->reports, RPT_WARNING, "Can't edit linked mesh or curve data");
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-16 11:43:19 +10:00
|
|
|
return (changed_multi) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
|
2009-07-21 00:36:07 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool shade_poll(bContext *C)
|
2010-06-27 06:15:36 +00:00
|
|
|
{
|
2020-04-16 12:06:50 +10:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
Object *obact = OBACT(view_layer);
|
|
|
|
if (obact != NULL) {
|
|
|
|
/* Doesn't handle edit-data, sculpt dynamic-topology, or their undo systems. */
|
2020-06-30 17:51:41 +02:00
|
|
|
if (obact->mode & (OB_MODE_EDIT | OB_MODE_SCULPT) || obact->data == NULL ||
|
|
|
|
ID_IS_OVERRIDE_LIBRARY(obact) || ID_IS_OVERRIDE_LIBRARY(obact->data)) {
|
2020-04-16 12:06:50 +10:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2010-06-27 06:15:36 +00:00
|
|
|
}
|
|
|
|
|
2009-07-21 00:36:07 +00:00
|
|
|
void OBJECT_OT_shade_flat(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Shade Flat";
|
2013-04-13 09:32:27 +00:00
|
|
|
ot->description = "Render and display faces uniform, using Face Normals";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_shade_flat";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-21 00:36:07 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = shade_poll;
|
|
|
|
ot->exec = shade_smooth_exec;
|
2009-07-21 00:36:07 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-07-21 00:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_shade_smooth(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Shade Smooth";
|
2013-04-13 09:32:27 +00:00
|
|
|
ot->description = "Render and display faces smooth, using interpolated Vertex Normals";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_shade_smooth";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-21 00:36:07 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = shade_poll;
|
|
|
|
ot->exec = shade_smooth_exec;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-21 00:36:07 +00:00
|
|
|
/* flags */
|
2012-04-28 15:42:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-07-21 00:36:07 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Object Mode Set Operator
|
|
|
|
* \{ */
|
2009-01-17 18:35:33 +00:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem *object_mode_set_itemsf(bContext *C,
|
|
|
|
PointerRNA *UNUSED(ptr),
|
|
|
|
PropertyRNA *UNUSED(prop),
|
|
|
|
bool *r_free)
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem *input = rna_enum_object_mode_items;
|
2012-04-28 15:42:27 +00:00
|
|
|
EnumPropertyItem *item = NULL;
|
|
|
|
int totitem = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!C) { /* needed for docs */
|
2015-11-23 13:49:52 +11:00
|
|
|
return rna_enum_object_mode_items;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-05-07 10:44:13 +10:00
|
|
|
const Object *ob = CTX_data_active_object(C);
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
if (ob) {
|
|
|
|
while (input->identifier) {
|
2021-05-07 11:16:58 +10:00
|
|
|
if (ED_object_mode_compat_test(ob, input->value)) {
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
RNA_enum_item_add(&item, &totitem, input);
|
|
|
|
}
|
|
|
|
input++;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
else {
|
|
|
|
/* We need at least this one! */
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, input, OB_MODE_OBJECT);
|
2009-08-16 05:48:07 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-08-16 05:48:07 +00:00
|
|
|
RNA_enum_item_end(&item, &totitem);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-04 18:08:43 +11:00
|
|
|
*r_free = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-08-16 05:48:07 +00:00
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2020-07-15 13:09:06 +10:00
|
|
|
static bool object_mode_set_poll(bContext *C)
|
|
|
|
{
|
|
|
|
/* Needed as #ED_operator_object_active_editable doesn't call use 'active_object'. */
|
|
|
|
Object *ob = CTX_data_active_object(C);
|
|
|
|
return ED_operator_object_active_editable_ex(C, ob);
|
|
|
|
}
|
|
|
|
|
2009-08-16 05:48:07 +00:00
|
|
|
static int object_mode_set_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2020-06-02 16:01:46 +10:00
|
|
|
const bool use_submode = STREQ(op->idname, "OBJECT_OT_mode_set_with_submode");
|
2012-04-28 15:42:27 +00:00
|
|
|
Object *ob = CTX_data_active_object(C);
|
2017-10-17 13:43:10 +11:00
|
|
|
eObjectMode mode = RNA_enum_get(op->ptr, "mode");
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool toggle = RNA_boolean_get(op->ptr, "toggle");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
/* by default the operator assume is a mesh, but if gp object change mode */
|
2020-05-18 17:04:48 +10:00
|
|
|
if ((ob->type == OB_GPENCIL) && (mode == OB_MODE_EDIT)) {
|
2018-12-14 16:45:57 +01:00
|
|
|
mode = OB_MODE_EDIT_GPENCIL;
|
2015-12-13 21:03:13 +13:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-18 17:04:48 +10:00
|
|
|
if (!ED_object_mode_compat_test(ob, mode)) {
|
2011-09-24 11:42:11 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-02 16:01:46 +10:00
|
|
|
/**
|
|
|
|
* Mode Switching Logic (internal details).
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* - Code below avoids calling mode switching functions more than once,
|
|
|
|
* as this causes unnecessary calculations and undo steps to be added.
|
|
|
|
* - The previous mode (#Object.restore_mode) is object mode by default.
|
|
|
|
*
|
|
|
|
* Supported Cases:
|
|
|
|
* - Setting the mode (when the 'toggle' setting is off).
|
|
|
|
* - Toggle the mode:
|
|
|
|
* - Toggle between object mode and non-object mode property.
|
|
|
|
* - Toggle between the previous mode (#Object.restore_mode) and the mode property.
|
|
|
|
* - Toggle object mode.
|
|
|
|
* While this is similar to regular toggle,
|
|
|
|
* this operator depends on there being a previous mode set
|
|
|
|
* (this isn't bound to a key with the default key-map).
|
|
|
|
*/
|
2020-05-13 23:04:47 +10:00
|
|
|
if (toggle == false) {
|
|
|
|
if (ob->mode != mode) {
|
2020-06-03 15:23:26 +10:00
|
|
|
ED_object_mode_set_ex(C, mode, true, op->reports);
|
2020-05-13 23:04:47 +10:00
|
|
|
}
|
2013-08-26 15:43:34 +00:00
|
|
|
}
|
2020-05-13 23:04:47 +10:00
|
|
|
else {
|
2020-06-02 16:01:46 +10:00
|
|
|
const eObjectMode mode_prev = ob->mode;
|
|
|
|
/* When toggling object mode, we always use the restore mode,
|
|
|
|
* otherwise there is nothing to do. */
|
2020-06-01 17:38:35 +10:00
|
|
|
if (mode == OB_MODE_OBJECT) {
|
|
|
|
if (ob->mode != OB_MODE_OBJECT) {
|
2020-06-03 15:23:26 +10:00
|
|
|
if (ED_object_mode_set_ex(C, OB_MODE_OBJECT, true, op->reports)) {
|
2020-06-02 16:01:46 +10:00
|
|
|
/* Store old mode so we know what to go back to. */
|
|
|
|
ob->restore_mode = mode_prev;
|
2020-06-01 17:38:35 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (ob->restore_mode != OB_MODE_OBJECT) {
|
2020-06-03 15:23:26 +10:00
|
|
|
ED_object_mode_set_ex(C, ob->restore_mode, true, op->reports);
|
2020-06-01 17:38:35 +10:00
|
|
|
}
|
|
|
|
}
|
2013-08-26 15:43:34 +00:00
|
|
|
}
|
2020-06-01 17:38:35 +10:00
|
|
|
else {
|
2020-06-02 16:01:46 +10:00
|
|
|
/* Non-object modes, enter the 'mode' unless it's already set,
|
|
|
|
* in that case use restore mode. */
|
2020-06-01 17:38:35 +10:00
|
|
|
if (ob->mode != mode) {
|
2020-06-03 15:23:26 +10:00
|
|
|
if (ED_object_mode_set_ex(C, mode, true, op->reports)) {
|
2020-06-02 16:01:46 +10:00
|
|
|
/* Store old mode so we know what to go back to. */
|
|
|
|
ob->restore_mode = mode_prev;
|
2020-06-01 17:38:35 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (ob->restore_mode != OB_MODE_OBJECT) {
|
2020-06-03 15:23:26 +10:00
|
|
|
ED_object_mode_set_ex(C, ob->restore_mode, true, op->reports);
|
2020-06-01 17:38:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2020-06-03 15:23:26 +10:00
|
|
|
ED_object_mode_set_ex(C, OB_MODE_OBJECT, true, op->reports);
|
2020-06-01 17:38:35 +10:00
|
|
|
}
|
|
|
|
}
|
2009-08-21 17:35:35 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-09-06 04:21:39 +10:00
|
|
|
if (use_submode) {
|
|
|
|
if (ob->type == OB_MESH) {
|
|
|
|
if (ob->mode & OB_MODE_EDIT) {
|
|
|
|
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "mesh_select_mode");
|
|
|
|
if (RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
int mesh_select_mode = RNA_property_enum_get(op->ptr, prop);
|
|
|
|
if (mesh_select_mode != 0) {
|
|
|
|
EDBM_selectmode_set_multi(C, mesh_select_mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-16 05:48:07 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_mode_set(wmOperatorType *ot)
|
|
|
|
{
|
2013-08-26 15:43:34 +00:00
|
|
|
PropertyRNA *prop;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-08-16 05:48:07 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Set Object Mode";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description = "Sets the object interaction mode";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_mode_set";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-08-16 05:48:07 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = object_mode_set_exec;
|
2020-07-15 13:09:06 +10:00
|
|
|
ot->poll = object_mode_set_poll;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-08-16 05:48:07 +00:00
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0; /* no register/undo here, leave it to operators being called */
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2015-11-23 13:49:52 +11:00
|
|
|
ot->prop = RNA_def_enum(
|
|
|
|
ot->srna, "mode", rna_enum_object_mode_items, OB_MODE_OBJECT, "Mode", "");
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
RNA_def_enum_funcs(ot->prop, object_mode_set_itemsf);
|
2013-08-26 15:43:34 +00:00
|
|
|
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
|
2009-08-21 17:35:35 +00:00
|
|
|
|
2013-08-26 15:43:34 +00:00
|
|
|
prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", "");
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2009-08-16 05:48:07 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 04:21:39 +10:00
|
|
|
void OBJECT_OT_mode_set_with_submode(wmOperatorType *ot)
|
2018-05-29 17:25:19 +02:00
|
|
|
{
|
2019-09-06 00:57:20 +10:00
|
|
|
OBJECT_OT_mode_set(ot);
|
2018-05-29 17:25:19 +02:00
|
|
|
|
|
|
|
/* identifiers */
|
2019-09-06 04:21:39 +10:00
|
|
|
ot->name = "Set Object Mode with Submode";
|
|
|
|
ot->idname = "OBJECT_OT_mode_set_with_submode";
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
/* we could add other types - particle for eg. */
|
|
|
|
PropertyRNA *prop;
|
|
|
|
prop = RNA_def_enum_flag(
|
|
|
|
ot->srna, "mesh_select_mode", rna_enum_mesh_select_mode_items, 0, "Mesh Mode", "");
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2018-05-29 17:25:19 +02:00
|
|
|
}
|
|
|
|
|
2020-04-16 10:58:09 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Object Link/Move to Collection Operator
|
|
|
|
* \{ */
|
|
|
|
|
2019-08-19 14:45:07 +02:00
|
|
|
static ListBase selected_objects_get(bContext *C)
|
|
|
|
{
|
|
|
|
ListBase objects = {NULL};
|
|
|
|
|
|
|
|
if (CTX_wm_space_outliner(C) != NULL) {
|
|
|
|
ED_outliner_selected_objects_get(C, &objects);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
|
|
|
|
BLI_addtail(&objects, BLI_genericNodeN(ob));
|
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
return objects;
|
|
|
|
}
|
|
|
|
|
2018-07-02 12:03:56 +02:00
|
|
|
static bool move_to_collection_poll(bContext *C)
|
2018-05-31 14:34:16 +02:00
|
|
|
{
|
|
|
|
if (CTX_wm_space_outliner(C) != NULL) {
|
|
|
|
return ED_outliner_collections_editor_poll(C);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-03 15:42:22 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-03 15:42:22 +02:00
|
|
|
if (v3d && v3d->localvd) {
|
|
|
|
return false;
|
2018-05-31 14:34:16 +02:00
|
|
|
}
|
2020-07-03 15:42:22 +02:00
|
|
|
|
|
|
|
return ED_operator_objectmode(C);
|
2018-05-31 14:34:16 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
static int move_to_collection_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2018-03-28 14:54:17 -03:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "collection_index");
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
const bool is_link = STREQ(op->idname, "OBJECT_OT_link_to_collection");
|
2018-03-28 17:14:40 -03:00
|
|
|
const bool is_new = RNA_boolean_get(op->ptr, "is_new");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
if (!RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "No collection selected");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
int collection_index = RNA_property_int_get(op->ptr, prop);
|
2020-12-22 14:58:57 -06:00
|
|
|
Collection *collection = BKE_collection_from_index(scene, collection_index);
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
if (collection == NULL) {
|
2018-03-28 14:54:17 -03:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Unexpected error, collection not found");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-22 14:58:57 -06:00
|
|
|
ListBase objects = selected_objects_get(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 17:14:40 -03:00
|
|
|
if (is_new) {
|
2018-04-02 16:19:58 -03:00
|
|
|
char new_collection_name[MAX_NAME];
|
|
|
|
RNA_string_get(op->ptr, "new_collection_name", new_collection_name);
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
collection = BKE_collection_add(bmain, collection, new_collection_name);
|
2018-03-28 17:14:40 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-31 14:34:16 +02:00
|
|
|
Object *single_object = BLI_listbase_is_single(&objects) ? ((LinkData *)objects.first)->data :
|
|
|
|
NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
if ((single_object != NULL) && is_link &&
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
BLI_findptr(&collection->gobject, single_object, offsetof(CollectionObject, ob))) {
|
|
|
|
BKE_reportf(op->reports,
|
|
|
|
RPT_ERROR,
|
|
|
|
"%s already in %s",
|
|
|
|
single_object->id.name + 2,
|
|
|
|
collection->id.name + 2);
|
2018-05-31 14:34:16 +02:00
|
|
|
BLI_freelistN(&objects);
|
2018-03-28 14:54:17 -03:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (LinkData *, link, &objects) {
|
2018-05-31 14:34:16 +02:00
|
|
|
Object *ob = link->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
if (!is_link) {
|
|
|
|
BKE_collection_object_move(bmain, scene, collection, NULL, ob);
|
2018-03-28 14:54:17 -03:00
|
|
|
}
|
|
|
|
else {
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
BKE_collection_object_add(bmain, collection, ob);
|
2018-03-28 14:54:17 -03:00
|
|
|
}
|
|
|
|
}
|
2018-05-31 14:34:16 +02:00
|
|
|
BLI_freelistN(&objects);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
BKE_reportf(op->reports,
|
|
|
|
RPT_INFO,
|
|
|
|
"%s %s to %s",
|
|
|
|
(single_object != NULL) ? single_object->id.name + 2 : "Objects",
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
is_link ? "linked" : "moved",
|
|
|
|
collection->id.name + 2);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-20 17:43:56 +02:00
|
|
|
DEG_relations_tag_update(bmain);
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
struct MoveToCollectionData {
|
2018-03-28 14:54:17 -03:00
|
|
|
struct MoveToCollectionData *next, *prev;
|
|
|
|
int index;
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
struct Collection *collection;
|
2018-03-28 14:54:17 -03:00
|
|
|
struct ListBase submenus;
|
2018-03-28 17:14:40 -03:00
|
|
|
PointerRNA ptr;
|
|
|
|
struct wmOperatorType *ot;
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
};
|
2018-03-28 14:54:17 -03:00
|
|
|
|
2018-03-28 17:14:40 -03:00
|
|
|
static int move_to_collection_menus_create(wmOperator *op, MoveToCollectionData *menu)
|
2018-03-28 14:54:17 -03:00
|
|
|
{
|
|
|
|
int index = menu->index;
|
2021-01-07 21:24:46 -06:00
|
|
|
LISTBASE_FOREACH (CollectionChild *, child, &menu->collection->children) {
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
Collection *collection = child->collection;
|
2021-01-07 21:24:46 -06:00
|
|
|
MoveToCollectionData *submenu = MEM_callocN(sizeof(MoveToCollectionData), __func__);
|
2018-03-28 14:54:17 -03:00
|
|
|
BLI_addtail(&menu->submenus, submenu);
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
submenu->collection = collection;
|
2018-03-28 14:54:17 -03:00
|
|
|
submenu->index = ++index;
|
2018-03-28 17:14:40 -03:00
|
|
|
index = move_to_collection_menus_create(op, submenu);
|
|
|
|
submenu->ot = op->type;
|
2018-03-28 14:54:17 -03:00
|
|
|
}
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2018-04-02 18:49:00 -03:00
|
|
|
static void move_to_collection_menus_free_recursive(MoveToCollectionData *menu)
|
2018-03-28 14:54:17 -03:00
|
|
|
{
|
2021-01-07 21:24:46 -06:00
|
|
|
LISTBASE_FOREACH (MoveToCollectionData *, submenu, &menu->submenus) {
|
2018-04-02 18:49:00 -03:00
|
|
|
move_to_collection_menus_free_recursive(submenu);
|
2018-03-28 14:54:17 -03:00
|
|
|
}
|
|
|
|
BLI_freelistN(&menu->submenus);
|
|
|
|
}
|
|
|
|
|
2018-04-02 18:49:00 -03:00
|
|
|
static void move_to_collection_menus_free(MoveToCollectionData **menu)
|
|
|
|
{
|
|
|
|
if (*menu == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
move_to_collection_menus_free_recursive(*menu);
|
|
|
|
MEM_freeN(*menu);
|
|
|
|
*menu = NULL;
|
|
|
|
}
|
|
|
|
|
2020-09-15 12:22:03 -06:00
|
|
|
static void move_to_collection_menu_create(bContext *C, uiLayout *layout, void *menu_v)
|
2018-03-28 14:54:17 -03:00
|
|
|
{
|
|
|
|
MoveToCollectionData *menu = menu_v;
|
2018-11-13 18:10:30 -02:00
|
|
|
const char *name = BKE_collection_ui_name_get(menu->collection);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-14 12:56:21 -03:00
|
|
|
UI_block_flag_enable(uiLayoutGetBlock(layout), UI_BLOCK_IS_FLIP);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 17:14:40 -03:00
|
|
|
WM_operator_properties_create_ptr(&menu->ptr, menu->ot);
|
|
|
|
RNA_int_set(&menu->ptr, "collection_index", menu->index);
|
|
|
|
RNA_boolean_set(&menu->ptr, "is_new", true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 17:14:40 -03:00
|
|
|
uiItemFullO_ptr(
|
|
|
|
layout, menu->ot, "New Collection", ICON_ADD, menu->ptr.data, WM_OP_INVOKE_DEFAULT, 0, NULL);
|
2020-06-18 17:00:05 +02:00
|
|
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
2020-09-15 12:22:03 -06:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
const int icon = (menu->collection == scene->master_collection) ?
|
|
|
|
ICON_SCENE_DATA :
|
2020-09-18 10:24:14 +10:00
|
|
|
UI_icon_color_from_collection(menu->collection);
|
2020-09-15 12:22:03 -06:00
|
|
|
uiItemIntO(layout, name, icon, menu->ot->idname, "collection_index", menu->index);
|
2020-06-18 17:00:05 +02:00
|
|
|
|
2021-01-07 21:24:46 -06:00
|
|
|
LISTBASE_FOREACH (MoveToCollectionData *, submenu, &menu->submenus) {
|
2020-06-18 17:00:05 +02:00
|
|
|
move_to_collection_menus_items(layout, submenu);
|
|
|
|
}
|
2018-03-28 14:54:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void move_to_collection_menus_items(uiLayout *layout, MoveToCollectionData *menu)
|
|
|
|
{
|
2020-09-18 10:24:14 +10:00
|
|
|
const int icon = UI_icon_color_from_collection(menu->collection);
|
2020-09-15 12:22:03 -06:00
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
if (BLI_listbase_is_empty(&menu->submenus)) {
|
|
|
|
uiItemIntO(layout,
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
menu->collection->id.name + 2,
|
2020-09-15 12:22:03 -06:00
|
|
|
icon,
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
menu->ot->idname,
|
2018-03-28 14:54:17 -03:00
|
|
|
"collection_index",
|
|
|
|
menu->index);
|
|
|
|
}
|
|
|
|
else {
|
2020-09-15 12:22:03 -06:00
|
|
|
uiItemMenuF(layout, menu->collection->id.name + 2, icon, move_to_collection_menu_create, menu);
|
2018-03-28 14:54:17 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-02 18:49:00 -03:00
|
|
|
/* This is allocated statically because we need this available for the menus creation callback. */
|
|
|
|
static MoveToCollectionData *master_collection_menu = NULL;
|
|
|
|
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
static int move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
2018-03-28 14:54:17 -03:00
|
|
|
{
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
2019-08-19 14:45:07 +02:00
|
|
|
ListBase objects = selected_objects_get(C);
|
|
|
|
if (BLI_listbase_is_empty(&objects)) {
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "No objects selected");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
BLI_freelistN(&objects);
|
|
|
|
|
2018-04-02 18:49:00 -03:00
|
|
|
/* Reset the menus data for the current master collection, and free previously allocated data. */
|
|
|
|
move_to_collection_menus_free(&master_collection_menu);
|
2018-04-02 16:19:58 -03:00
|
|
|
|
2018-04-02 18:49:00 -03:00
|
|
|
PropertyRNA *prop;
|
2018-04-02 16:19:58 -03:00
|
|
|
prop = RNA_struct_find_property(op->ptr, "collection_index");
|
2018-03-28 14:54:17 -03:00
|
|
|
if (RNA_property_is_set(op->ptr, prop)) {
|
2018-04-02 17:12:08 -03:00
|
|
|
int collection_index = RNA_property_int_get(op->ptr, prop);
|
2018-04-02 16:19:58 -03:00
|
|
|
|
|
|
|
if (RNA_boolean_get(op->ptr, "is_new")) {
|
|
|
|
prop = RNA_struct_find_property(op->ptr, "new_collection_name");
|
|
|
|
if (!RNA_property_is_set(op->ptr, prop)) {
|
2018-04-02 17:12:08 -03:00
|
|
|
char name[MAX_NAME];
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
Collection *collection;
|
2018-04-02 17:12:08 -03:00
|
|
|
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
collection = BKE_collection_from_index(scene, collection_index);
|
|
|
|
BKE_collection_new_name_get(collection, name);
|
2018-04-02 17:12:08 -03:00
|
|
|
|
|
|
|
RNA_property_string_set(op->ptr, prop, name);
|
2020-01-28 10:49:05 +01:00
|
|
|
return WM_operator_props_dialog_popup(C, op, 200);
|
2018-04-02 16:19:58 -03:00
|
|
|
}
|
|
|
|
}
|
2018-03-28 14:54:17 -03:00
|
|
|
return move_to_collection_exec(C, op);
|
|
|
|
}
|
|
|
|
|
2019-09-02 14:31:19 +02:00
|
|
|
Collection *master_collection = scene->master_collection;
|
2018-03-28 14:54:17 -03:00
|
|
|
|
|
|
|
/* We need the data to be allocated so it's available during menu drawing.
|
2021-01-13 13:21:29 +11:00
|
|
|
* Technically we could use #wmOperator.customdata. However there is no free callback
|
2018-03-28 14:54:17 -03:00
|
|
|
* called to an operator that exit with OPERATOR_INTERFACE to launch a menu.
|
|
|
|
*
|
|
|
|
* So we are left with a memory that will necessarily leak. It's a small leak though.*/
|
|
|
|
if (master_collection_menu == NULL) {
|
|
|
|
master_collection_menu = MEM_callocN(sizeof(MoveToCollectionData),
|
2018-04-02 18:49:00 -03:00
|
|
|
"MoveToCollectionData menu - expected eventual memleak");
|
2018-03-28 14:54:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
master_collection_menu->collection = master_collection;
|
2018-03-28 17:14:40 -03:00
|
|
|
master_collection_menu->ot = op->type;
|
|
|
|
move_to_collection_menus_create(op, master_collection_menu);
|
2018-03-28 14:54:17 -03:00
|
|
|
|
|
|
|
uiPopupMenu *pup;
|
|
|
|
uiLayout *layout;
|
|
|
|
|
|
|
|
/* Build the menus. */
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
const char *title = CTX_IFACE_(op->type->translation_context, op->type->name);
|
|
|
|
pup = UI_popup_menu_begin(C, title, ICON_NONE);
|
2018-03-28 14:54:17 -03:00
|
|
|
layout = UI_popup_menu_layout(pup);
|
2018-03-28 17:14:40 -03:00
|
|
|
|
|
|
|
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
|
2018-03-28 14:54:17 -03:00
|
|
|
|
2018-03-28 15:25:35 -03:00
|
|
|
move_to_collection_menu_create(C, layout, master_collection_menu);
|
2018-03-28 14:54:17 -03:00
|
|
|
|
|
|
|
UI_popup_menu_end(C, pup);
|
|
|
|
|
|
|
|
return OPERATOR_INTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_move_to_collection(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Move to Collection";
|
2019-06-18 20:45:48 -03:00
|
|
|
ot->description = "Move objects to a collection";
|
2018-03-28 14:54:17 -03:00
|
|
|
ot->idname = "OBJECT_OT_move_to_collection";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = move_to_collection_exec;
|
|
|
|
ot->invoke = move_to_collection_invoke;
|
2018-05-31 14:34:16 +02:00
|
|
|
ot->poll = move_to_collection_poll;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-28 14:54:17 -03:00
|
|
|
prop = RNA_def_int(ot->srna,
|
|
|
|
"collection_index",
|
|
|
|
COLLECTION_INVALID_INDEX,
|
|
|
|
COLLECTION_INVALID_INDEX,
|
|
|
|
INT_MAX,
|
|
|
|
"Collection Index",
|
|
|
|
"Index of the collection to move to",
|
|
|
|
0,
|
|
|
|
INT_MAX);
|
2018-04-02 16:19:58 -03:00
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
prop = RNA_def_boolean(ot->srna, "is_new", false, "New", "Move objects to a new collection");
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
|
|
|
prop = RNA_def_string(ot->srna,
|
|
|
|
"new_collection_name",
|
|
|
|
NULL,
|
|
|
|
MAX_NAME,
|
|
|
|
"Name",
|
|
|
|
"Name of the newly added collection");
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2019-03-22 00:30:17 +11:00
|
|
|
ot->prop = prop;
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_link_to_collection(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Link to Collection";
|
|
|
|
ot->description = "Link objects to a collection";
|
|
|
|
ot->idname = "OBJECT_OT_link_to_collection";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = move_to_collection_exec;
|
|
|
|
ot->invoke = move_to_collection_invoke;
|
2018-05-31 14:34:16 +02:00
|
|
|
ot->poll = move_to_collection_poll;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
prop = RNA_def_int(ot->srna,
|
|
|
|
"collection_index",
|
|
|
|
COLLECTION_INVALID_INDEX,
|
|
|
|
COLLECTION_INVALID_INDEX,
|
|
|
|
INT_MAX,
|
|
|
|
"Collection Index",
|
|
|
|
"Index of the collection to move to",
|
|
|
|
0,
|
|
|
|
INT_MAX);
|
2018-04-02 16:19:58 -03:00
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
2018-03-28 17:14:40 -03:00
|
|
|
prop = RNA_def_boolean(ot->srna, "is_new", false, "New", "Move objects to a new collection");
|
2018-04-02 16:19:58 -03:00
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
|
|
|
prop = RNA_def_string(ot->srna,
|
|
|
|
"new_collection_name",
|
|
|
|
NULL,
|
|
|
|
MAX_NAME,
|
|
|
|
"Name",
|
|
|
|
"Name of the newly added collection");
|
2018-03-28 17:14:40 -03:00
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2019-05-17 10:01:19 +02:00
|
|
|
ot->prop = prop;
|
2018-03-28 14:54:17 -03:00
|
|
|
}
|
2020-04-16 10:58:09 +10:00
|
|
|
|
|
|
|
/** \} */
|