diff options
author | Peter Klimenko <peterklimk@outlook.com> | 2020-07-31 11:45:15 +0300 |
---|---|---|
committer | Peter Klimenko <peterklimk@outlook.com> | 2020-07-31 11:45:15 +0300 |
commit | 97a4a8d0fb7fd9ac34f9f5d4d5a0689c01235e14 (patch) | |
tree | fc9746d2210eda08be9d44ae67d5e58d64b48b40 /source/blender/editors/space_outliner/outliner_tree.c | |
parent | 4a7c203e9ecc7c5b0370afc0fdd6bcc183dc00df (diff) | |
parent | f3e8326453ae856d7914e45e832a2ed80aa9a9b9 (diff) |
merge
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_tree.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tree.c | 93 |
1 files changed, 57 insertions, 36 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index d6efe683673..db42fb8f319 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -235,6 +235,17 @@ static TreeElement *outliner_add_element( /* -------------------------------------------------------- */ +/** + * Check if an element type needs a full rebuild if the open/collapsed state changes. + * These element types don't add children if collapsed. + * + * This current check isn't great really. A per element-type flag would be preferable. + */ +bool outliner_element_needs_rebuild_on_open_change(const TreeStoreElem *tselem) +{ + return ELEM(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_KEYMAP); +} + /* special handling of hierarchical non-lib data */ static void outliner_add_bone( SpaceOutliner *soops, ListBase *lb, ID *id, Bone *curBone, TreeElement *parent, int *a) @@ -329,7 +340,7 @@ static void outliner_add_scene_contents(SpaceOutliner *soops, } } -// can be inlined if necessary +/* Can be inlined if necessary. */ static void outliner_add_object_contents(SpaceOutliner *soops, TreeElement *te, TreeStoreElem *tselem, @@ -340,7 +351,7 @@ static void outliner_add_object_contents(SpaceOutliner *soops, } outliner_add_element( - soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this + soops, &te->subtree, ob->poselib, te, 0, 0); /* XXX FIXME.. add a special type for this. */ if (ob->proxy && !ID_IS_LINKED(ob)) { outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0); @@ -367,12 +378,12 @@ static void outliner_add_object_contents(SpaceOutliner *soops, pchan->temp = (void *)ten; if (pchan->constraints.first) { - // Object *target; + /* Object *target; */ bConstraint *con; TreeElement *ten1; TreeElement *tenla1 = outliner_add_element( soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); - // char *str; + /* char *str; */ tenla1->name = IFACE_("Constraints"); for (con = pchan->constraints.first; con; con = con->next, const_index++) { @@ -436,11 +447,11 @@ static void outliner_add_object_contents(SpaceOutliner *soops, } if (ob->constraints.first) { - // Object *target; + /* Object *target; */ bConstraint *con; TreeElement *ten; TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); - // char *str; + /* char *str; */ int a; tenla->name = IFACE_("Constraints"); @@ -524,7 +535,7 @@ static void outliner_add_object_contents(SpaceOutliner *soops, } } -// can be inlined if necessary +/* Can be inlined if necessary. */ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, TreeStoreElem *tselem, @@ -538,7 +549,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops, /* expand specific data always */ switch (GS(id->name)) { case ID_LI: { - te->name = ((Library *)id)->name; + te->name = ((Library *)id)->filepath; break; } case ID_SCE: { @@ -666,8 +677,8 @@ static void outliner_add_id_contents(SpaceOutliner *soops, break; } case ID_AC: { - // XXX do we want to be exposing the F-Curves here? - // bAction *act = (bAction *)id; + /* XXX do we want to be exposing the F-Curves here? */ + /* bAction *act = (bAction *)id; */ break; } case ID_AR: { @@ -741,7 +752,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops, outliner_add_element(soops, &te->subtree, gpd, te, TSE_ANIM_DATA, 0); } - // TODO: base element for layers? + /* TODO: base element for layers? */ for (gpl = gpd->layers.last; gpl; gpl = gpl->prev) { outliner_add_element(soops, &te->subtree, gpl, te, TSE_GP_LAYER, a); a++; @@ -758,20 +769,23 @@ static void outliner_add_id_contents(SpaceOutliner *soops, } case ID_HA: { Hair *hair = (Hair *)id; - if (outliner_animdata_test(hair->adt)) + if (outliner_animdata_test(hair->adt)) { outliner_add_element(soops, &te->subtree, hair, te, TSE_ANIM_DATA, 0); + } break; } case ID_PT: { PointCloud *pointcloud = (PointCloud *)id; - if (outliner_animdata_test(pointcloud->adt)) + if (outliner_animdata_test(pointcloud->adt)) { outliner_add_element(soops, &te->subtree, pointcloud, te, TSE_ANIM_DATA, 0); + } break; } case ID_VO: { Volume *volume = (Volume *)id; - if (outliner_animdata_test(volume->adt)) + if (outliner_animdata_test(volume->adt)) { outliner_add_element(soops, &te->subtree, volume, te, TSE_ANIM_DATA, 0); + } break; } case ID_SIM: { @@ -786,8 +800,13 @@ static void outliner_add_id_contents(SpaceOutliner *soops, } } -// TODO: this function needs to be split up! It's getting a bit too large... -// Note: "ID" is not always a real ID +/** + * TODO: this function needs to be split up! It's getting a bit too large... + * + * \note: "ID" is not always a real ID + * \note: If child items are only added to the tree if the item is open, the TSE_ type _must_ be + * added to #outliner_element_needs_rebuild_on_open_change(). + */ static TreeElement *outliner_add_element( SpaceOutliner *soops, ListBase *lb, void *idv, TreeElement *parent, short type, short index) { @@ -832,7 +851,7 @@ static TreeElement *outliner_add_element( } te->parent = parent; - te->index = index; // for data arrays + te->index = index; /* For data arrays. */ if (ELEM(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { /* pass */ } @@ -854,10 +873,10 @@ static TreeElement *outliner_add_element( else { /* do here too, for blend file viewer, own ID_LI then shows file name */ if (GS(id->name) == ID_LI) { - te->name = ((Library *)id)->name; + te->name = ((Library *)id)->filepath; } else { - te->name = id->name + 2; // default, can be overridden by Library or non-ID data + te->name = id->name + 2; /* Default, can be overridden by Library or non-ID data. */ } te->idcode = GS(id->name); } @@ -898,7 +917,7 @@ static TreeElement *outliner_add_element( /* loop over all targets used here */ DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) { if (lastadded != dtar->id) { - // XXX this lastadded check is rather lame, and also fails quite badly... + /* XXX this lastadded check is rather lame, and also fails quite badly... */ outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0); lastadded = dtar->id; } @@ -1510,7 +1529,7 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb) TreeStoreElem *tselem; /* build hierarchy */ - // XXX also, set extents here... + /* XXX also, set extents here... */ te = lb->first; while (te) { ten = te->next; @@ -1650,10 +1669,10 @@ static int treesort_alpha_ob(const void *v1, const void *v2) if (comp == 1) { return 1; } - else if (comp == 2) { + if (comp == 2) { return -1; } - else if (comp == 3) { + if (comp == 3) { /* Among objects first come the ones in the collection, followed by the ones not on it. * This way we can have the dashed lines in a separate style connecting the former. */ if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) != @@ -1666,7 +1685,7 @@ static int treesort_alpha_ob(const void *v1, const void *v2) if (comp > 0) { return 1; } - else if (comp < 0) { + if (comp < 0) { return -1; } return 0; @@ -1698,7 +1717,7 @@ static int treesort_alpha(const void *v1, const void *v2) if (comp > 0) { return 1; } - else if (comp < 0) { + if (comp < 0) { return -1; } return 0; @@ -1774,10 +1793,10 @@ static void outliner_sort(ListBase *lb) tp->idcode = te->idcode; if (tselem->type && tselem->type != TSE_DEFGROUP) { - tp->idcode = 0; // don't sort this + tp->idcode = 0; /* Don't sort this. */ } if (tselem->type == TSE_ID_BASE) { - tp->idcode = 1; // do sort this + tp->idcode = 1; /* Do sort this. */ } tp->id = tselem->id; @@ -1965,9 +1984,7 @@ static TreeElement *outliner_find_first_desired_element_at_y(const SpaceOutliner if (te->ys + UI_UNIT_Y > view_co_limit) { return te_sub; } - else { - return NULL; - } + return NULL; } if (te->next) { @@ -2175,7 +2192,9 @@ static bool outliner_element_is_collection_or_object(TreeElement *te) if ((tselem->type == 0) && (te->idcode == ID_OB)) { return true; } - else if (outliner_is_collection_tree_element(te)) { + + /* Collection instance datablocks should not be extracted. */ + if (outliner_is_collection_tree_element(te) && !(te->parent && te->parent->idcode == ID_OB)) { return true; } @@ -2225,7 +2244,7 @@ static int outliner_filter_subtree(SpaceOutliner *soops, te_next = outliner_extract_children_from_subtree(te, lb); continue; } - else if ((exclude_filter & SO_FILTER_SEARCH) == 0) { + if ((exclude_filter & SO_FILTER_SEARCH) == 0) { /* Filter subtree too. */ outliner_filter_subtree(soops, view_layer, &te->subtree, search_string, exclude_filter); continue; @@ -2290,8 +2309,8 @@ static void outliner_filter_tree(SpaceOutliner *soops, ViewLayer *view_layer) /* ======================================================= */ /* Main Tree Building API */ -/* Main entry point for building the tree data-structure that the outliner represents */ -// TODO: split each mode into its own function? +/* Main entry point for building the tree data-structure that the outliner represents. */ +/* TODO: split each mode into its own function? */ void outliner_build_tree( Main *mainvar, Scene *scene, ViewLayer *view_layer, SpaceOutliner *soops, ARegion *region) { @@ -2340,8 +2359,10 @@ void outliner_build_tree( for (lib = mainvar->libraries.first; lib; lib = lib->id.next) { ten = outliner_add_library_contents(mainvar, soops, &soops->tree, lib); - BLI_assert(ten != NULL); - lib->id.newid = (ID *)ten; + /* NULL-check matters, due to filtering there may not be a new element. */ + if (ten) { + lib->id.newid = (ID *)ten; + } } /* make hierarchy */ ten = soops->tree.first; |