Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_tree.c
| Show First 20 Lines • Show All 1,248 Lines • ▼ Show 20 Lines | static bool outliner_library_id_show(Library *lib, ID *id, short filter_id_type) | ||||
| } | } | ||||
| if (filter_id_type == ID_GR) { | if (filter_id_type == ID_GR) { | ||||
| /* Don't show child collections of non-scene master collection, | /* Don't show child collections of non-scene master collection, | ||||
| * they are already shown as children. */ | * they are already shown as children. */ | ||||
| Collection *collection = (Collection *)id; | Collection *collection = (Collection *)id; | ||||
| bool has_non_scene_parent = false; | bool has_non_scene_parent = false; | ||||
| for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) { | LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { | ||||
| if (!(cparent->collection->flag & COLLECTION_IS_MASTER)) { | if (!(cparent->collection->flag & COLLECTION_IS_MASTER)) { | ||||
| has_non_scene_parent = true; | has_non_scene_parent = true; | ||||
| } | } | ||||
| } | } | ||||
| if (has_non_scene_parent) { | if (has_non_scene_parent) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | if (lbarray[a] && lbarray[a]->first) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void outliner_add_layer_collection_objects( | static void outliner_add_layer_collection_objects( | ||||
| SpaceOutliner *soops, ListBase *tree, ViewLayer *layer, LayerCollection *lc, TreeElement *ten) | SpaceOutliner *soops, ListBase *tree, ViewLayer *layer, LayerCollection *lc, TreeElement *ten) | ||||
| { | { | ||||
| for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) { | LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) { | ||||
| Base *base = BKE_view_layer_base_find(layer, cob->ob); | Base *base = BKE_view_layer_base_find(layer, cob->ob); | ||||
| TreeElement *te_object = outliner_add_element(soops, tree, base->object, ten, 0, 0); | TreeElement *te_object = outliner_add_element(soops, tree, base->object, ten, 0, 0); | ||||
| te_object->directdata = base; | te_object->directdata = base; | ||||
| if (!(base->flag & BASE_VISIBLE_DEPSGRAPH)) { | if (!(base->flag & BASE_VISIBLE_DEPSGRAPH)) { | ||||
| te_object->flag |= TE_DISABLED; | te_object->flag |= TE_DISABLED; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void outliner_add_layer_collections_recursive(SpaceOutliner *soops, | static void outliner_add_layer_collections_recursive(SpaceOutliner *soops, | ||||
| ListBase *tree, | ListBase *tree, | ||||
| ViewLayer *layer, | ViewLayer *layer, | ||||
| ListBase *layer_collections, | ListBase *layer_collections, | ||||
| TreeElement *parent_ten, | TreeElement *parent_ten, | ||||
| const bool show_objects) | const bool show_objects) | ||||
| { | { | ||||
| for (LayerCollection *lc = layer_collections->first; lc; lc = lc->next) { | LISTBASE_FOREACH (LayerCollection *, lc, layer_collections) { | ||||
| const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0; | const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0; | ||||
| TreeElement *ten; | TreeElement *ten; | ||||
| if (exclude && ((soops->show_restrict_flags & SO_RESTRICT_ENABLE) == 0)) { | if (exclude && ((soops->show_restrict_flags & SO_RESTRICT_ENABLE) == 0)) { | ||||
| ten = parent_ten; | ten = parent_ten; | ||||
| } | } | ||||
| else { | else { | ||||
| ID *id = &lc->collection->id; | ID *id = &lc->collection->id; | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | BLI_INLINE void outliner_add_collection_init(TreeElement *te, Collection *collection) | ||||
| te->directdata = collection; | te->directdata = collection; | ||||
| } | } | ||||
| BLI_INLINE void outliner_add_collection_objects(SpaceOutliner *soops, | BLI_INLINE void outliner_add_collection_objects(SpaceOutliner *soops, | ||||
| ListBase *tree, | ListBase *tree, | ||||
| Collection *collection, | Collection *collection, | ||||
| TreeElement *parent) | TreeElement *parent) | ||||
| { | { | ||||
| for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { | LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { | ||||
| outliner_add_element(soops, tree, cob->ob, parent, 0, 0); | outliner_add_element(soops, tree, cob->ob, parent, 0, 0); | ||||
| } | } | ||||
| } | } | ||||
| static TreeElement *outliner_add_collection_recursive(SpaceOutliner *soops, | static TreeElement *outliner_add_collection_recursive(SpaceOutliner *soops, | ||||
| Collection *collection, | Collection *collection, | ||||
| TreeElement *ten) | TreeElement *ten) | ||||
| { | { | ||||
| outliner_add_collection_init(ten, collection); | outliner_add_collection_init(ten, collection); | ||||
| for (CollectionChild *child = collection->children.first; child; child = child->next) { | LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { | ||||
| outliner_add_element(soops, &ten->subtree, &child->collection->id, ten, 0, 0); | outliner_add_element(soops, &ten->subtree, &child->collection->id, ten, 0, 0); | ||||
| } | } | ||||
| if (soops->outlinevis != SO_SCENES) { | if (soops->outlinevis != SO_SCENES) { | ||||
| outliner_add_collection_objects(soops, &ten->subtree, collection, ten); | outliner_add_collection_objects(soops, &ten->subtree, collection, ten); | ||||
| } | } | ||||
| return ten; | return ten; | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | GHASH_ITER (gh_iter, object_tree_elements_hash) { | ||||
| } | } | ||||
| ListBase *child_ob_tree_elements = BLI_ghashIterator_getValue(&gh_iter); | ListBase *child_ob_tree_elements = BLI_ghashIterator_getValue(&gh_iter); | ||||
| ListBase *parent_ob_tree_elements = BLI_ghash_lookup(object_tree_elements_hash, child->parent); | ListBase *parent_ob_tree_elements = BLI_ghash_lookup(object_tree_elements_hash, child->parent); | ||||
| if (parent_ob_tree_elements == NULL) { | if (parent_ob_tree_elements == NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| for (LinkData *link = parent_ob_tree_elements->first; link; link = link->next) { | LISTBASE_FOREACH (LinkData *, link, parent_ob_tree_elements) { | ||||
| TreeElement *parent_ob_tree_element = link->data; | TreeElement *parent_ob_tree_element = link->data; | ||||
| TreeElement *parent_ob_collection_tree_element = NULL; | TreeElement *parent_ob_collection_tree_element = NULL; | ||||
| bool found = false; | bool found = false; | ||||
| /* We always want to remove the child from the direct collection its parent is nested under. | /* We always want to remove the child from the direct collection its parent is nested under. | ||||
| * This is particularly important when dealing with multi-level nesting (grandchildren). */ | * This is particularly important when dealing with multi-level nesting (grandchildren). */ | ||||
| parent_ob_collection_tree_element = parent_ob_tree_element->parent; | parent_ob_collection_tree_element = parent_ob_tree_element->parent; | ||||
| while (!ELEM(TREESTORE(parent_ob_collection_tree_element)->type, | while (!ELEM(TREESTORE(parent_ob_collection_tree_element)->type, | ||||
| TSE_VIEW_COLLECTION_BASE, | TSE_VIEW_COLLECTION_BASE, | ||||
| TSE_LAYER_COLLECTION)) { | TSE_LAYER_COLLECTION)) { | ||||
| parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent; | parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent; | ||||
| } | } | ||||
| for (LinkData *link_iter = child_ob_tree_elements->first; link_iter; | LISTBASE_FOREACH (LinkData *, link_iter, child_ob_tree_elements) { | ||||
| link_iter = link_iter->next) { | |||||
| TreeElement *child_ob_tree_element = link_iter->data; | TreeElement *child_ob_tree_element = link_iter->data; | ||||
| if (child_ob_tree_element->parent == parent_ob_collection_tree_element) { | if (child_ob_tree_element->parent == parent_ob_collection_tree_element) { | ||||
| /* Move from the collection subtree into the parent object subtree. */ | /* Move from the collection subtree into the parent object subtree. */ | ||||
| BLI_remlink(&parent_ob_collection_tree_element->subtree, child_ob_tree_element); | BLI_remlink(&parent_ob_collection_tree_element->subtree, child_ob_tree_element); | ||||
| BLI_addtail(&parent_ob_tree_element->subtree, child_ob_tree_element); | BLI_addtail(&parent_ob_tree_element->subtree, child_ob_tree_element); | ||||
| child_ob_tree_element->parent = parent_ob_tree_element; | child_ob_tree_element->parent = parent_ob_tree_element; | ||||
| found = true; | found = true; | ||||
| Show All 15 Lines | |||||
| } | } | ||||
| /** | /** | ||||
| * Build a map from Object* to a list of TreeElement* matching the object. | * Build a map from Object* to a list of TreeElement* matching the object. | ||||
| */ | */ | ||||
| static void outliner_object_tree_elements_lookup_create_recursive(GHash *object_tree_elements_hash, | static void outliner_object_tree_elements_lookup_create_recursive(GHash *object_tree_elements_hash, | ||||
| TreeElement *te_parent) | TreeElement *te_parent) | ||||
| { | { | ||||
| for (TreeElement *te = te_parent->subtree.first; te; te = te->next) { | LISTBASE_FOREACH (TreeElement *, te, &te_parent->subtree) { | ||||
| TreeStoreElem *tselem = TREESTORE(te); | TreeStoreElem *tselem = TREESTORE(te); | ||||
| if (tselem->type == TSE_LAYER_COLLECTION) { | if (tselem->type == TSE_LAYER_COLLECTION) { | ||||
| outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te); | outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te); | ||||
| } | } | ||||
| else if (tselem->type == 0 && te->idcode == ID_OB) { | else if (tselem->type == 0 && te->idcode == ID_OB) { | ||||
| Object *ob = (Object *)tselem->id; | Object *ob = (Object *)tselem->id; | ||||
| ListBase *tree_elements = BLI_ghash_lookup(object_tree_elements_hash, ob); | ListBase *tree_elements = BLI_ghash_lookup(object_tree_elements_hash, ob); | ||||
| ▲ Show 20 Lines • Show All 821 Lines • ▼ Show 20 Lines | else if (soops->outlinevis == SO_DATA_API) { | ||||
| } | } | ||||
| } | } | ||||
| else if (soops->outlinevis == SO_ID_ORPHANS) { | else if (soops->outlinevis == SO_ID_ORPHANS) { | ||||
| outliner_add_orphaned_datablocks(mainvar, soops); | outliner_add_orphaned_datablocks(mainvar, soops); | ||||
| } | } | ||||
| else if (soops->outlinevis == SO_VIEW_LAYER) { | else if (soops->outlinevis == SO_VIEW_LAYER) { | ||||
| if (soops->filter & SO_FILTER_NO_COLLECTION) { | if (soops->filter & SO_FILTER_NO_COLLECTION) { | ||||
| /* Show objects in the view layer. */ | /* Show objects in the view layer. */ | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { | ||||
| TreeElement *te_object = outliner_add_element( | TreeElement *te_object = outliner_add_element( | ||||
| soops, &soops->tree, base->object, NULL, 0, 0); | soops, &soops->tree, base->object, NULL, 0, 0); | ||||
| te_object->directdata = base; | te_object->directdata = base; | ||||
| } | } | ||||
| outliner_make_object_parent_hierarchy(&soops->tree); | outliner_make_object_parent_hierarchy(&soops->tree); | ||||
| } | } | ||||
| else { | else { | ||||
| Show All 35 Lines | |||||