diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 16 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 158 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_nodes.cc | 8 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_relations.cc | 6 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.c | 37 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_group.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 20 |
8 files changed, 109 insertions, 162 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index dfb43812b49..eef4a6210c8 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -309,15 +309,21 @@ static void collection_object_cache_fill(ListBase *lb, Collection *collection, i if (base == NULL) { base = MEM_callocN(sizeof(Base), "Object Base"); base->object = cob->ob; + BLI_addtail(lb, base); + } - if ((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) { - base->flag |= BASE_VISIBLE_VIEWPORT; - } - if ((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) { - base->flag |= BASE_VISIBLE_RENDER; - } + int object_restrict = base->object->restrictflag; - BLI_addtail(lb, base); + if (((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) && + ((object_restrict & OB_RESTRICT_VIEW) == 0)) + { + base->flag |= BASE_VISIBLE_VIEWPORT; + } + + if (((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) && + ((object_restrict & OB_RESTRICT_RENDER) == 0)) + { + base->flag |= BASE_VISIBLE_RENDER; } } diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 090be7e0fe5..84915e628df 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -647,14 +647,24 @@ static void layer_collection_sync( BLI_ghash_insert(view_layer->object_bases_hash, base->object, base); } - if ((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) { + int object_restrict = base->object->restrictflag; + + if (((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) && + ((object_restrict & OB_RESTRICT_VIEW) == 0)) + { base->flag |= BASE_VISIBLED | BASE_VISIBLE_VIEWPORT; - if ((child_restrict & COLLECTION_RESTRICT_SELECT) == 0) { + if (((child_restrict & COLLECTION_RESTRICT_SELECT) == 0) && + ((object_restrict & OB_RESTRICT_SELECT) == 0)) + { base->flag |= BASE_SELECTABLED; } } - if ((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) { + + if (((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) && + ((object_restrict & OB_RESTRICT_RENDER) == 0)) + + { base->flag |= BASE_VISIBLE_RENDER; } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 74ff53a45d9..190b9d86d59 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -355,13 +355,6 @@ static void do_version_scene_collection_to_collection(Main *bmain, Scene *scene) #endif -enum { - DO_VERSION_COLLECTION_VISIBLE = 0, - DO_VERSION_COLLECTION_HIDE = 1, - DO_VERSION_COLLECTION_HIDE_RENDER = 2, - DO_VERSION_COLLECTION_HIDE_ALL = 3, -}; - static void do_version_layers_to_collections(Main *bmain, Scene *scene) { /* Since we don't have access to FileData we check the (always valid) first @@ -376,99 +369,26 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) /* Create collections from layers. */ Collection *collection_master = BKE_collection_master(scene); - - struct DoVersionSceneCollections { - Collection *collections[20]; - int created; - const char *suffix; - int flag; - } collections[] = - { - { - .collections = {NULL}, - .created = 0, - .suffix = "", - .flag = 0, - }, - { - .collections = {NULL}, - .created = 0, - .suffix = " - Hide Viewport", - .flag = COLLECTION_RESTRICT_VIEW, - }, - { - .collections = {NULL}, - .created = 0, - .suffix = " - Hide Render", - .flag = COLLECTION_RESTRICT_RENDER, - }, - { - .collections = {NULL}, - .created = 0, - .suffix = " - Hide Render All", - .flag = COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER, - } - }; + Collection *collections[20] = {NULL}; for (int layer = 0; layer < 20; layer++) { for (Base *base = scene->base.first; base; base = base->next) { if (base->lay & (1 << layer)) { - int collection_index = -1; - if ((base->object->restrictflag & OB_RESTRICT_VIEW) && - (base->object->restrictflag & OB_RESTRICT_RENDER)) - { - collection_index = DO_VERSION_COLLECTION_HIDE_ALL; - } - else if (base->object->restrictflag & OB_RESTRICT_VIEW) { - collection_index = DO_VERSION_COLLECTION_HIDE; - } - else if (base->object->restrictflag & OB_RESTRICT_RENDER) { - collection_index = DO_VERSION_COLLECTION_HIDE_RENDER; - } - else { - collection_index = DO_VERSION_COLLECTION_VISIBLE; - } - /* Create collections when needed only. */ - if ((collections[collection_index].created & (1 << layer)) == 0) { + if (collections[layer] == NULL) { char name[MAX_NAME]; - if ((collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) == 0) { - BLI_snprintf(name, - sizeof(collection_master->id.name), - "Collection %d%s", - layer + 1, - collections[DO_VERSION_COLLECTION_VISIBLE].suffix); - - Collection *collection = BKE_collection_add(bmain, collection_master, name); - collection->id.lib = scene->id.lib; - collection->flag |= collections[DO_VERSION_COLLECTION_VISIBLE].flag; - collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer] = collection; - collections[DO_VERSION_COLLECTION_VISIBLE].created |= (1 << layer); - - if (!(scene->lay & (1 << layer))) { - collection->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER; - } - } + BLI_snprintf(name, + sizeof(collection_master->id.name), + "Collection %d", + layer + 1); - if (collection_index != DO_VERSION_COLLECTION_VISIBLE) { - Collection *collection_parent; - collection_parent = collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer]; - BLI_snprintf(name, - sizeof(collection_master->id.name), - "Collection %d%s", - layer + 1, - collections[collection_index].suffix); - - Collection *collection = BKE_collection_add(bmain, collection_parent, name); - collection->id.lib = scene->id.lib; - collection->flag |= collections[collection_index].flag; - collections[collection_index].collections[layer] = collection; - collections[collection_index].created |= (1 << layer); - - if (!(scene->lay & (1 << layer))) { - collection->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER; - } + Collection *collection = BKE_collection_add(bmain, collection_master, name); + collection->id.lib = scene->id.lib; + collections[layer] = collection; + + if (!(scene->lay & (1 << layer))) { + collection->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER; } } @@ -476,7 +396,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) * but since no view layers exists yet at this point it's fast. */ BKE_collection_object_add( bmain, - collections[collection_index].collections[layer], base->object); + collections[layer], base->object); } if (base->flag & SELECT) { @@ -488,46 +408,6 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) } } - /* Re-order the nested hidden collections. */ - CollectionChild *child_parent = collection_master->children.first; - Collection *collection_parent = (child_parent) ? child_parent->collection : NULL; - - for (int layer = 0; layer < 20; layer++) { - if (collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) { - CollectionChild *hide_child = BLI_findptr( - &collection_parent->children, - collections[DO_VERSION_COLLECTION_HIDE].collections[layer], - offsetof(CollectionChild, collection)); - - if ((collections[DO_VERSION_COLLECTION_HIDE].created & (1 << layer)) && - (hide_child != collection_parent->children.first)) - { - BLI_listbase_swaplinks( - &collection_parent->children, - hide_child, - collection_parent->children.first); - } - - CollectionChild *hide_all_child = BLI_findptr( - &collection_parent->children, - collections[DO_VERSION_COLLECTION_HIDE_ALL].collections[layer], - offsetof(CollectionChild, collection)); - - if ((collections[DO_VERSION_COLLECTION_HIDE_ALL].created & (1 << layer)) && - (hide_all_child != collection_parent->children.last)) - { - BLI_listbase_swaplinks( - &collection_parent->children, - hide_all_child, - collection_parent->children.last); - } - - child_parent = child_parent->next; - collection_parent = (child_parent) ? child_parent->collection : NULL; - } - } - BLI_assert(collection_parent == NULL); - /* Handle legacy render layers. */ bool have_override = false; @@ -577,8 +457,8 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) /* Set exclusion and overrides. */ for (int layer = 0; layer < 20; layer++) { - if (collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) { - Collection *collection = collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer]; + Collection *collection = collections[layer]; + if (collection) { LayerCollection *lc = BKE_layer_collection_first_from_scene_collection(view_layer, collection); if (srl->lay_exclude & (1 << layer)) { @@ -612,14 +492,6 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) false); } } - - LayerCollection *nlc = lc->layer_collections.first; - for (int j = 1; j < 4; j++) { - if (collections[j].created & (1 << layer)) { - nlc = nlc->next; - } - } - BLI_assert(nlc == NULL); } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index d4a115cfb8b..9b0c3354c47 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -458,6 +458,14 @@ void DepsgraphNodeBuilder::build_collection( add_id_node(&collection->id); /* Build collection objects. */ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { + if (allow_restrict_flags) { + const int restrict_flag = (graph_->mode == DAG_EVAL_VIEWPORT) + ? OB_RESTRICT_VIEW + : OB_RESTRICT_RENDER; + if (cob->ob->restrictflag & restrict_flag) { + continue; + } + } build_object(-1, cob->ob, DEG_ID_LINKED_INDIRECTLY); } /* Build child collections. */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index a092902ee48..e728ae787c2 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -469,6 +469,12 @@ void DepsgraphRelationBuilder::build_collection( DEG_OPCODE_TRANSFORM_LOCAL); if (!group_done) { LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { + const int restrict_flag = (graph_->mode == DAG_EVAL_VIEWPORT) + ? OB_RESTRICT_VIEW + : OB_RESTRICT_RENDER; + if (cob->ob->restrictflag & restrict_flag) { + continue; + } build_object(NULL, cob->ob); } LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 5108843ebfa..88fa9afd116 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -450,13 +450,20 @@ static void outliner_draw_restrictbuts( uiBut *bt; /* get RNA properties (once for speed) */ - PropertyRNA *collection_prop_hide_viewport; - PropertyRNA *collection_prop_hide_select; - PropertyRNA *collection_prop_hide_render; + PropertyRNA *object_prop_hide_viewport, *object_prop_hide_select, *object_prop_hide_render; + PropertyRNA *collection_prop_hide_viewport, *collection_prop_hide_select, *collection_prop_hide_render; + + object_prop_hide_viewport = RNA_struct_type_find_property(&RNA_Object, "hide_viewport"); + object_prop_hide_select = RNA_struct_type_find_property(&RNA_Object, "hide_select"); + object_prop_hide_render = RNA_struct_type_find_property(&RNA_Object, "hide_render"); collection_prop_hide_select = RNA_struct_type_find_property(&RNA_Collection, "hide_select"); collection_prop_hide_viewport = RNA_struct_type_find_property(&RNA_Collection, "hide_viewport"); collection_prop_hide_render = RNA_struct_type_find_property(&RNA_Collection, "hide_render"); - BLI_assert(collection_prop_hide_viewport && + + BLI_assert(object_prop_hide_viewport && + object_prop_hide_select && + object_prop_hide_render && + collection_prop_hide_viewport && collection_prop_hide_select && collection_prop_hide_render); @@ -486,6 +493,28 @@ static void outliner_draw_restrictbuts( UI_but_func_set(bt, hidebutton_base_flag_cb, scene, view_layer); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); } + + PointerRNA ptr; + RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ptr); + + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_VIEW_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, + &ptr, object_prop_hide_viewport, -1, 0, 0, -1, -1, + TIP_("Restrict viewport visibility")); + UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); + + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_SELECT_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, + &ptr, object_prop_hide_select, -1, 0, 0, -1, -1, + TIP_("Restrict viewport selection")); + UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); + + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_RENDER_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y, + &ptr, object_prop_hide_render, -1, 0, 0, -1, -1, + TIP_("Restrict render visibility")); + UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); + } else if (tselem->type == TSE_MODIFIER) { ModifierData *md = (ModifierData *)te->directdata; diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index de6c6883977..7266c7578c8 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -260,21 +260,21 @@ void RNA_def_collections(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_SELECT); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1); - RNA_def_property_ui_text(prop, "Restrict Select", "Disable collection object selection in the 3D viewport"); + RNA_def_property_ui_text(prop, "Restrict Select", "Disable collection for viewport selection"); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update"); prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_VIEW); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); - RNA_def_property_ui_text(prop, "Restrict Viewport", "Hide collection objects in the 3D viewport"); + RNA_def_property_ui_text(prop, "Restrict Viewport", "Disable collection in viewport"); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update"); prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_RENDER); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - RNA_def_property_ui_text(prop, "Restrict Render", "Hide collection objects in renders"); + RNA_def_property_ui_text(prop, "Restrict Render", "Disable collection in renders"); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update"); } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index a9b87ea0703..73a2b293c22 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -46,6 +46,7 @@ #include "BKE_paint.h" #include "BKE_editlattice.h" #include "BKE_editmesh.h" +#include "BKE_layer.h" #include "BKE_object_deform.h" #include "BKE_object_facemap.h" @@ -219,9 +220,12 @@ static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA rna_Object_internal_update(bmain, scene, ptr); } -static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { - DEG_id_type_tag(bmain, ID_OB); + Object *ob = ptr->id.data; + BKE_main_collection_sync(bmain); + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id); } static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) @@ -2293,6 +2297,18 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Rigid Body Constraint", "Constraint constraining rigid bodies"); /* restrict */ + prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW); + RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update"); + + prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT); + RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER); RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability"); |