Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_utils.c
| Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | TreeElement *outliner_find_tree_element(ListBase *lb, const TreeStoreElem *store_elem) | ||||
| for (te = lb->first; te; te = te->next) { | for (te = lb->first; te; te = te->next) { | ||||
| if (te->store_elem == store_elem) return te; | if (te->store_elem == store_elem) return te; | ||||
| tes = outliner_find_tree_element(&te->subtree, store_elem); | tes = outliner_find_tree_element(&te->subtree, store_elem); | ||||
| if (tes) return tes; | if (tes) return tes; | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* Find parent element of te */ | |||||
| TreeElement *outliner_find_parent_element(ListBase *lb, TreeElement *parent_te, const TreeElement *child_te) | |||||
| { | |||||
| TreeElement *te; | |||||
| for (te = lb->first; te; te = te->next) { | |||||
| if (te == child_te) { | |||||
| return parent_te; | |||||
| } | |||||
| TreeElement *find_te = outliner_find_parent_element(&te->subtree, te, child_te); | |||||
| if (find_te) { | |||||
| return find_te; | |||||
| } | |||||
| } | |||||
| return NULL; | |||||
| } | |||||
| /* tse is not in the treestore, we use its contents to find a match */ | /* tse is not in the treestore, we use its contents to find a match */ | ||||
| TreeElement *outliner_find_tse(SpaceOops *soops, const TreeStoreElem *tse) | TreeElement *outliner_find_tse(SpaceOops *soops, const TreeStoreElem *tse) | ||||
| { | { | ||||
| TreeStoreElem *tselem; | TreeStoreElem *tselem; | ||||
| if (tse->id == NULL) return NULL; | if (tse->id == NULL) return NULL; | ||||
| /* check if 'tse' is in treestore */ | /* check if 'tse' is in treestore */ | ||||
| tselem = BKE_outliner_treehash_lookup_any(soops->treehash, tse->type, tse->nr, tse->id); | tselem = BKE_outliner_treehash_lookup_any(soops->treehash, tse->type, tse->nr, tse->id); | ||||
| if (tselem) | if (tselem) | ||||
| return outliner_find_tree_element(&soops->tree, tselem); | return outliner_find_tree_element(&soops->tree, tselem); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* Find treestore that refers to given ID */ | /* Find treestore that refers to given ID */ | ||||
| TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, const ID *id) | TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, const ID *id) | ||||
| { | { | ||||
| for (TreeElement *te = lb->first; te; te = te->next) { | for (TreeElement *te = lb->first; te; te = te->next) { | ||||
| TreeStoreElem *tselem = TREESTORE(te); | TreeStoreElem *tselem = TREESTORE(te); | ||||
| if (tselem->type == 0) { | if (tselem->type == 0) { | ||||
| if (tselem->id == id) { | if (tselem->id == id) { | ||||
| return te; | return te; | ||||
| } | } | ||||
| /* only deeper on scene or object */ | /* only deeper on scene collection or object */ | ||||
| if (ELEM(te->idcode, ID_OB, ID_SCE) || | if (ELEM(te->idcode, ID_OB, ID_SCE, ID_GR)) { | ||||
| ((soops->outlinevis == SO_GROUPS) && (te->idcode == ID_GR))) | |||||
| { | |||||
| TreeElement *tes = outliner_find_id(soops, &te->subtree, id); | TreeElement *tes = outliner_find_id(soops, &te->subtree, id); | ||||
| if (tes) { | if (tes) { | ||||
| return tes; | return tes; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| ▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines | |||||