Cleanup: Add & use enum value for ID Outliner element type
Code to check if the Outliner tree-element type was the general ID one would always check against "0" (explicity or even implicitly). For somebody unfamiliar with the code this is very confusing. Instead the value should be given a name, e.g. through an enum. Adds `TSE_SOME_ID` as the "default" ID tree-element type. Other types may still represent IDs, as I explained in a comment at the definition. There may also still be cases where the type is checked against "0". I noted in the comment that such cases should be cleaned up if found.
This commit is contained in:
@@ -101,7 +101,7 @@ static unsigned int tse_hash(const void *ptr)
|
||||
unsigned int u_int;
|
||||
} hash;
|
||||
|
||||
BLI_assert(tse->type || !tse->nr);
|
||||
BLI_assert((tse->type != TSE_SOME_ID) || !tse->nr);
|
||||
|
||||
hash.h_pair[0] = tse->type;
|
||||
hash.h_pair[1] = tse->nr;
|
||||
@@ -193,7 +193,7 @@ static TseGroup *BKE_outliner_treehash_lookup_group(GHash *th, short type, short
|
||||
{
|
||||
TreeStoreElem tse_template;
|
||||
tse_template.type = type;
|
||||
tse_template.nr = type ? nr : 0; /* we're picky! :) */
|
||||
tse_template.nr = (type == TSE_SOME_ID) ? 0 : nr; /* we're picky! :) */
|
||||
tse_template.id = id;
|
||||
|
||||
BLI_assert(th);
|
||||
|
||||
@@ -71,7 +71,7 @@ bool outliner_is_collection_tree_element(const TreeElement *te)
|
||||
TSE_VIEW_COLLECTION_BASE)) {
|
||||
return true;
|
||||
}
|
||||
if (tselem->type == 0 && te->idcode == ID_GR) {
|
||||
if ((tselem->type == TSE_SOME_ID) && te->idcode == ID_GR) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ Collection *outliner_collection_from_tree_element(const TreeElement *te)
|
||||
Scene *scene = (Scene *)tselem->id;
|
||||
return scene->master_collection;
|
||||
}
|
||||
if (tselem->type == 0 && te->idcode == ID_GR) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_GR)) {
|
||||
return (Collection *)tselem->id;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ TreeTraversalAction outliner_find_selected_collections(TreeElement *te, void *cu
|
||||
return TRAVERSE_CONTINUE;
|
||||
}
|
||||
|
||||
if (tselem->type || (tselem->id && GS(tselem->id->name) != ID_GR)) {
|
||||
if ((tselem->type != TSE_SOME_ID) || (tselem->id && GS(tselem->id->name) != ID_GR)) {
|
||||
return TRAVERSE_SKIP_CHILDS;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ TreeTraversalAction outliner_find_selected_objects(TreeElement *te, void *custom
|
||||
return TRAVERSE_CONTINUE;
|
||||
}
|
||||
|
||||
if (tselem->type || (tselem->id == NULL) || (GS(tselem->id->name) != ID_OB)) {
|
||||
if ((tselem->type != TSE_SOME_ID) || (tselem->id == NULL) || (GS(tselem->id->name) != ID_OB)) {
|
||||
return TRAVERSE_SKIP_CHILDS;
|
||||
}
|
||||
|
||||
@@ -1458,7 +1458,7 @@ static TreeTraversalAction outliner_hide_find_data_to_edit(TreeElement *te, void
|
||||
BLI_gset_add(data->collections_to_edit, lc);
|
||||
}
|
||||
}
|
||||
else if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
else if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
Object *ob = (Object *)tselem->id;
|
||||
Base *base = BKE_view_layer_base_find(data->view_layer, ob);
|
||||
BLI_gset_add(data->bases_to_edit, base);
|
||||
|
||||
@@ -34,7 +34,7 @@ static void outliner_context_selected_ids_recursive(const ListBase *subtree,
|
||||
{
|
||||
LISTBASE_FOREACH (const TreeElement *, te, subtree) {
|
||||
const TreeStoreElem *tse = TREESTORE(te);
|
||||
if ((tse->flag & TSE_SELECTED) && (ELEM(tse->type, 0, TSE_LAYER_COLLECTION))) {
|
||||
if ((tse->flag & TSE_SELECTED) && (ELEM(tse->type, TSE_SOME_ID, TSE_LAYER_COLLECTION))) {
|
||||
CTX_data_id_list_add(result, tse->id);
|
||||
}
|
||||
outliner_context_selected_ids_recursive(&te->subtree, result);
|
||||
|
||||
@@ -124,7 +124,7 @@ static ID *outliner_ID_drop_find(bContext *C, const wmEvent *event, short idcode
|
||||
TreeElement *te = outliner_drop_find(C, event);
|
||||
TreeStoreElem *tselem = (te) ? TREESTORE(te) : NULL;
|
||||
|
||||
if (te && te->idcode == idcode && tselem->type == 0) {
|
||||
if (te && (te->idcode == idcode) && (tselem->type == TSE_SOME_ID)) {
|
||||
return tselem->id;
|
||||
}
|
||||
return NULL;
|
||||
@@ -215,7 +215,7 @@ static bool is_collection_element(TreeElement *te)
|
||||
static bool is_object_element(TreeElement *te)
|
||||
{
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
return tselem->type == 0 && te->idcode == ID_OB;
|
||||
return (tselem->type == TSE_SOME_ID) && te->idcode == ID_OB;
|
||||
}
|
||||
|
||||
static bool is_pchan_element(TreeElement *te)
|
||||
@@ -281,7 +281,7 @@ static int outliner_get_insert_index(TreeElement *drag_te,
|
||||
static bool parent_drop_allowed(TreeElement *te, Object *potential_child)
|
||||
{
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
if (te->idcode != ID_OB || tselem->type != 0) {
|
||||
if ((te->idcode != ID_OB) || (tselem->type != TSE_SOME_ID)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
TreeElement *te = outliner_drop_find(C, event);
|
||||
TreeStoreElem *tselem = te ? TREESTORE(te) : NULL;
|
||||
|
||||
if (!(te && te->idcode == ID_OB && tselem->type == 0)) {
|
||||
if (!(te && (te->idcode == ID_OB) && (tselem->type == TSE_SOME_ID))) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
||||
@@ -675,7 +675,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname)
|
||||
if (ts && tselem) {
|
||||
TreeElement *te = outliner_find_tree_element(&space_outliner->tree, tselem);
|
||||
|
||||
if (tselem->type == 0) {
|
||||
if (tselem->type == TSE_SOME_ID) {
|
||||
BLI_libblock_ensure_unique_name(bmain, tselem->id->name);
|
||||
|
||||
switch (GS(tselem->id->name)) {
|
||||
@@ -1100,11 +1100,11 @@ static void outliner_draw_restrictbuts(uiBlock *block,
|
||||
UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE);
|
||||
}
|
||||
}
|
||||
else if ((tselem->type == 0 && te->idcode == ID_OB) &&
|
||||
else if (((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) &&
|
||||
(te->flag & TE_CHILD_NOT_IN_COLLECTION)) {
|
||||
/* Don't show restrict columns for children that are not directly inside the collection. */
|
||||
}
|
||||
else if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
else if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
PointerRNA ptr;
|
||||
Object *ob = (Object *)tselem->id;
|
||||
RNA_id_pointer_create(&ob->id, &ptr);
|
||||
@@ -1699,7 +1699,7 @@ static void outliner_draw_userbuts(uiBlock *block,
|
||||
LISTBASE_FOREACH (TreeElement *, te, lb) {
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) {
|
||||
if (tselem->type == 0) {
|
||||
if (tselem->type == TSE_SOME_ID) {
|
||||
uiBut *bt;
|
||||
ID *id = tselem->id;
|
||||
const char *tip = NULL;
|
||||
@@ -1949,7 +1949,7 @@ static void outliner_draw_mode_column_toggle(uiBlock *block,
|
||||
TreeStoreElem *tselem,
|
||||
const bool lock_object_modes)
|
||||
{
|
||||
if (tselem->type != 0 || te->idcode != ID_OB) {
|
||||
if ((tselem->type != TSE_SOME_ID) || (te->idcode != ID_OB)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2046,7 +2046,7 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
|
||||
{
|
||||
TreeElementIcon data = {0};
|
||||
|
||||
if (tselem->type) {
|
||||
if (tselem->type != TSE_SOME_ID) {
|
||||
switch (tselem->type) {
|
||||
case TSE_ANIM_DATA:
|
||||
data.icon = ICON_ANIM_DATA; /* XXX */
|
||||
@@ -2825,7 +2825,8 @@ int tree_element_id_type_to_index(TreeElement *te)
|
||||
{
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
const int id_index = tselem->type == 0 ? BKE_idtype_idcode_to_index(te->idcode) : INDEX_ID_GR;
|
||||
const int id_index = (tselem->type == TSE_SOME_ID) ? BKE_idtype_idcode_to_index(te->idcode) :
|
||||
INDEX_ID_GR;
|
||||
if (id_index < INDEX_ID_OB) {
|
||||
return id_index;
|
||||
}
|
||||
@@ -2862,9 +2863,9 @@ static void outliner_draw_iconrow(bContext *C,
|
||||
te->flag &= ~(TE_ICONROW | TE_ICONROW_MERGED);
|
||||
|
||||
/* object hierarchy always, further constrained on level */
|
||||
if (level < 1 || (tselem->type == 0 && te->idcode == ID_OB)) {
|
||||
if ((level < 1) || ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB))) {
|
||||
/* active blocks get white circle */
|
||||
if (tselem->type == 0) {
|
||||
if (tselem->type == TSE_SOME_ID) {
|
||||
if (te->idcode == ID_OB) {
|
||||
active = (tvc->obact == (Object *)tselem->id) ? OL_DRAWSEL_NORMAL : OL_DRAWSEL_NONE;
|
||||
}
|
||||
@@ -2879,7 +2880,7 @@ static void outliner_draw_iconrow(bContext *C,
|
||||
active = tree_element_type_active_state_get(C, tvc, te, tselem);
|
||||
}
|
||||
|
||||
if (!ELEM(tselem->type, 0, TSE_LAYER_COLLECTION, TSE_R_LAYER, TSE_GP_LAYER)) {
|
||||
if (!ELEM(tselem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION, TSE_R_LAYER, TSE_GP_LAYER)) {
|
||||
outliner_draw_iconrow_doit(block, te, fstyle, xmax, offsx, ys, alpha_fac, active, 1);
|
||||
}
|
||||
else {
|
||||
@@ -2954,7 +2955,7 @@ static bool element_should_draw_faded(const TreeViewContext *tvc,
|
||||
const TreeElement *te,
|
||||
const TreeStoreElem *tselem)
|
||||
{
|
||||
if (tselem->type == 0) {
|
||||
if (tselem->type == TSE_SOME_ID) {
|
||||
switch (te->idcode) {
|
||||
case ID_OB: {
|
||||
const Object *ob = (const Object *)tselem->id;
|
||||
@@ -3023,7 +3024,7 @@ static void outliner_draw_tree_element(bContext *C,
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
||||
/* Colors for active/selected data. */
|
||||
if (tselem->type == 0) {
|
||||
if (tselem->type == TSE_SOME_ID) {
|
||||
if (te->idcode == ID_OB) {
|
||||
Object *ob = (Object *)tselem->id;
|
||||
Base *base = (te->directdata) ? (Base *)te->directdata :
|
||||
@@ -3080,7 +3081,7 @@ static void outliner_draw_tree_element(bContext *C,
|
||||
if (tselem->type == TSE_VIEW_COLLECTION_BASE) {
|
||||
/* Scene collection in view layer can't expand/collapse. */
|
||||
}
|
||||
else if (te->subtree.first || (tselem->type == 0 && te->idcode == ID_SCE) ||
|
||||
else if (te->subtree.first || ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_SCE)) ||
|
||||
(te->flag & TE_LAZY_CLOSED)) {
|
||||
/* Open/close icon, only when sub-levels, except for scene. */
|
||||
int icon_x = startx;
|
||||
@@ -3117,7 +3118,7 @@ static void outliner_draw_tree_element(bContext *C,
|
||||
offsx += 2 * ufac;
|
||||
}
|
||||
|
||||
if (ELEM(tselem->type, 0, TSE_LAYER_COLLECTION) ||
|
||||
if (ELEM(tselem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION) ||
|
||||
((tselem->type == TSE_RNA_STRUCT) && RNA_struct_is_ID(te->rnaptr.type))) {
|
||||
const BIFIconID lib_icon = UI_icon_from_library(tselem->id);
|
||||
if (lib_icon != ICON_NONE) {
|
||||
@@ -3143,7 +3144,7 @@ static void outliner_draw_tree_element(bContext *C,
|
||||
/* Closed item, we draw the icons, not when it's a scene, or master-server list though. */
|
||||
if (!TSELEM_OPEN(tselem, space_outliner)) {
|
||||
if (te->subtree.first) {
|
||||
if (tselem->type == 0 && te->idcode == ID_SCE) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_SCE)) {
|
||||
/* Pass. */
|
||||
}
|
||||
/* this tree element always has same amount of branches, so don't draw */
|
||||
@@ -3210,7 +3211,7 @@ static bool subtree_contains_object(ListBase *lb)
|
||||
{
|
||||
LISTBASE_FOREACH (TreeElement *, te, lb) {
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3265,7 +3266,7 @@ static void outliner_draw_hierarchy_lines_recursive(uint pos,
|
||||
|
||||
y = *starty;
|
||||
}
|
||||
else if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
else if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
if (subtree_contains_object(&te->subtree)) {
|
||||
draw_hierarchy_line = true;
|
||||
is_object_line = true;
|
||||
|
||||
@@ -638,7 +638,7 @@ static bool outliner_id_remap_find_tree_element(bContext *C,
|
||||
if (y > te->ys && y < te->ys + UI_UNIT_Y) {
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
if (tselem->type == 0 && tselem->id) {
|
||||
if ((tselem->type == TSE_SOME_ID) && tselem->id) {
|
||||
printf("found id %s (%p)!\n", tselem->id->name, tselem->id);
|
||||
|
||||
RNA_enum_set(op->ptr, "id_type", GS(tselem->id->name));
|
||||
@@ -763,7 +763,7 @@ static int outliner_id_copy_tag(SpaceOutliner *space_outliner, ListBase *tree)
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
/* if item is selected and is an ID, tag it as needing to be copied. */
|
||||
if (tselem->flag & TSE_SELECTED && ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) {
|
||||
if (tselem->flag & TSE_SELECTED && ELEM(tselem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION)) {
|
||||
ID *id = tselem->id;
|
||||
if (!(id->tag & LIB_TAG_DOIT)) {
|
||||
BKE_copybuffer_tag_ID(tselem->id);
|
||||
@@ -1640,7 +1640,7 @@ static int subtree_has_objects(ListBase *lb)
|
||||
{
|
||||
LISTBASE_FOREACH (TreeElement *, te, lb) {
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
return 1;
|
||||
}
|
||||
if (subtree_has_objects(&te->subtree)) {
|
||||
@@ -1658,7 +1658,7 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOutliner *space_outli
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
if (ELEM(tselem->type,
|
||||
0,
|
||||
TSE_SOME_ID,
|
||||
TSE_SCENE_OBJECTS_BASE,
|
||||
TSE_VIEW_COLLECTION_BASE,
|
||||
TSE_LAYER_COLLECTION)) {
|
||||
|
||||
@@ -198,7 +198,7 @@ void outliner_item_mode_toggle(bContext *C,
|
||||
{
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
Object *ob = (Object *)tselem->id;
|
||||
Base *base = BKE_view_layer_base_find(tvc->view_layer, ob);
|
||||
|
||||
@@ -301,7 +301,7 @@ static void tree_element_object_activate(bContext *C,
|
||||
Object *ob = NULL;
|
||||
|
||||
/* if id is not object, we search back */
|
||||
if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
ob = (Object *)tselem->id;
|
||||
}
|
||||
else {
|
||||
@@ -443,7 +443,7 @@ static void tree_element_world_activate(bContext *C, Scene *scene, TreeElement *
|
||||
TreeElement *tep = te->parent;
|
||||
if (tep) {
|
||||
TreeStoreElem *tselem = TREESTORE(tep);
|
||||
if (tselem->type == 0) {
|
||||
if (tselem->type == TSE_SOME_ID) {
|
||||
sce = (Scene *)tselem->id;
|
||||
}
|
||||
}
|
||||
@@ -1165,7 +1165,7 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE
|
||||
int context = 0;
|
||||
|
||||
/* ID Types */
|
||||
if (tselem->type == 0) {
|
||||
if (tselem->type == TSE_SOME_ID) {
|
||||
RNA_id_pointer_create(tselem->id, &ptr);
|
||||
|
||||
switch (te->idcode) {
|
||||
@@ -1374,12 +1374,12 @@ static void do_outliner_item_activate_tree_element(bContext *C,
|
||||
tvc->scene,
|
||||
tvc->view_layer,
|
||||
te,
|
||||
(extend && tselem->type == 0) ? OL_SETSEL_EXTEND :
|
||||
(extend && tselem->type == TSE_SOME_ID) ? OL_SETSEL_EXTEND :
|
||||
OL_SETSEL_NORMAL,
|
||||
recursive && tselem->type == 0);
|
||||
recursive && tselem->type == TSE_SOME_ID);
|
||||
}
|
||||
|
||||
if (tselem->type == 0) { /* The lib blocks. */
|
||||
if (tselem->type == TSE_SOME_ID) { /* The lib blocks. */
|
||||
if (do_activate_data == false) {
|
||||
/* Only select in outliner. */
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ static void outliner_sync_selection_from_outliner(Scene *scene,
|
||||
LISTBASE_FOREACH (TreeElement *, te, tree) {
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
if (sync_types->object) {
|
||||
outliner_select_sync_to_object(view_layer, te, tselem, selected_items->objects);
|
||||
}
|
||||
@@ -503,7 +503,7 @@ static void outliner_sync_selection_to_outliner(ViewLayer *view_layer,
|
||||
LISTBASE_FOREACH (TreeElement *, te, tree) {
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
if ((tselem->type == TSE_SOME_ID) && te->idcode == ID_OB) {
|
||||
if (sync_types->object) {
|
||||
outliner_select_sync_from_object(view_layer, active_data->object, te, tselem);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ static void get_element_operation_type(
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
if (tselem->flag & TSE_SELECTED) {
|
||||
/* Layer collection points to collection ID. */
|
||||
if (!ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) {
|
||||
if (!ELEM(tselem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION)) {
|
||||
if (*datalevel == 0) {
|
||||
*datalevel = tselem->type;
|
||||
}
|
||||
@@ -402,7 +402,8 @@ static void outliner_do_libdata_operation(bContext *C,
|
||||
LISTBASE_FOREACH (TreeElement *, te, lb) {
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
if (tselem->flag & TSE_SELECTED) {
|
||||
if ((tselem->type == 0 && te->idcode != 0) || tselem->type == TSE_LAYER_COLLECTION) {
|
||||
if (((tselem->type == TSE_SOME_ID) && (te->idcode != 0)) ||
|
||||
tselem->type == TSE_LAYER_COLLECTION) {
|
||||
TreeStoreElem *tsep = te->parent ? TREESTORE(te->parent) : NULL;
|
||||
operation_fn(C, reports, scene, te, tsep, tselem, user_data);
|
||||
}
|
||||
@@ -1044,7 +1045,7 @@ void outliner_do_object_operation_ex(bContext *C,
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
bool select_handled = false;
|
||||
if (tselem->flag & TSE_SELECTED) {
|
||||
if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
/* When objects selected in other scenes... dunno if that should be allowed. */
|
||||
Scene *scene_owner = (Scene *)outliner_search_back(te, ID_SCE);
|
||||
if (scene_owner && scene_act != scene_owner) {
|
||||
@@ -1601,7 +1602,7 @@ static TreeTraversalAction outliner_find_objects_to_delete(TreeElement *te, void
|
||||
return TRAVERSE_CONTINUE;
|
||||
}
|
||||
|
||||
if (tselem->type || (tselem->id == NULL) || (GS(tselem->id->name) != ID_OB)) {
|
||||
if ((tselem->type != TSE_SOME_ID) || (tselem->id == NULL) || (GS(tselem->id->name) != ID_OB)) {
|
||||
return TRAVERSE_SKIP_CHILDS;
|
||||
}
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ static void outliner_add_line_styles(SpaceOutliner *space_outliner,
|
||||
continue;
|
||||
}
|
||||
linestyle->id.tag &= ~LIB_TAG_DOIT;
|
||||
outliner_add_element(space_outliner, lb, linestyle, te, 0, 0);
|
||||
outliner_add_element(space_outliner, lb, linestyle, te, TSE_SOME_ID, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -332,7 +332,7 @@ static void outliner_add_scene_contents(SpaceOutliner *space_outliner,
|
||||
}
|
||||
|
||||
/* World */
|
||||
outliner_add_element(space_outliner, lb, sce->world, te, 0, 0);
|
||||
outliner_add_element(space_outliner, lb, sce->world, te, TSE_SOME_ID, 0);
|
||||
|
||||
/* Collections */
|
||||
ten = outliner_add_element(space_outliner, lb, &sce->id, te, TSE_SCENE_COLLECTION_BASE, 0);
|
||||
@@ -343,7 +343,7 @@ static void outliner_add_scene_contents(SpaceOutliner *space_outliner,
|
||||
ten = outliner_add_element(space_outliner, lb, sce, te, TSE_SCENE_OBJECTS_BASE, 0);
|
||||
ten->name = IFACE_("Objects");
|
||||
FOREACH_SCENE_OBJECT_BEGIN (sce, ob) {
|
||||
outliner_add_element(space_outliner, &ten->subtree, ob, ten, 0, 0);
|
||||
outliner_add_element(space_outliner, &ten->subtree, ob, ten, TSE_SOME_ID, 0);
|
||||
}
|
||||
FOREACH_SCENE_OBJECT_END;
|
||||
outliner_make_object_parent_hierarchy(&ten->subtree);
|
||||
@@ -368,14 +368,14 @@ static void outliner_add_object_contents(SpaceOutliner *space_outliner,
|
||||
&te->subtree,
|
||||
ob->poselib,
|
||||
te,
|
||||
0,
|
||||
TSE_SOME_ID,
|
||||
0); /* XXX FIXME.. add a special type for this. */
|
||||
|
||||
if (ob->proxy && !ID_IS_LINKED(ob)) {
|
||||
outliner_add_element(space_outliner, &te->subtree, ob->proxy, te, TSE_PROXY, 0);
|
||||
}
|
||||
|
||||
outliner_add_element(space_outliner, &te->subtree, ob->data, te, 0, 0);
|
||||
outliner_add_element(space_outliner, &te->subtree, ob->data, te, TSE_SOME_ID, 0);
|
||||
|
||||
if (ob->pose) {
|
||||
bArmature *arm = ob->data;
|
||||
@@ -458,7 +458,7 @@ static void outliner_add_object_contents(SpaceOutliner *space_outliner,
|
||||
}
|
||||
|
||||
for (int a = 0; a < ob->totcol; a++) {
|
||||
outliner_add_element(space_outliner, &te->subtree, ob->mat[a], te, 0, a);
|
||||
outliner_add_element(space_outliner, &te->subtree, ob->mat[a], te, TSE_SOME_ID, a);
|
||||
}
|
||||
|
||||
if (!BLI_listbase_is_empty(&ob->constraints)) {
|
||||
@@ -624,7 +624,8 @@ static void outliner_add_object_contents(SpaceOutliner *space_outliner,
|
||||
|
||||
/* duplicated group */
|
||||
if (ob->instance_collection && (ob->transflag & OB_DUPLICOLLECTION)) {
|
||||
outliner_add_element(space_outliner, &te->subtree, ob->instance_collection, te, 0, 0);
|
||||
outliner_add_element(
|
||||
space_outliner, &te->subtree, ob->instance_collection, te, TSE_SOME_ID, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -686,9 +687,9 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
|
||||
outliner_add_element(space_outliner, &te->subtree, me, te, TSE_ANIM_DATA, 0);
|
||||
}
|
||||
|
||||
outliner_add_element(space_outliner, &te->subtree, me->key, te, 0, 0);
|
||||
outliner_add_element(space_outliner, &te->subtree, me->key, te, TSE_SOME_ID, 0);
|
||||
for (int a = 0; a < me->totcol; a++) {
|
||||
outliner_add_element(space_outliner, &te->subtree, me->mat[a], te, 0, a);
|
||||
outliner_add_element(space_outliner, &te->subtree, me->mat[a], te, TSE_SOME_ID, a);
|
||||
}
|
||||
/* could do tfaces with image links, but the images are not grouped nicely.
|
||||
* would require going over all tfaces, sort images in use. etc... */
|
||||
@@ -702,7 +703,7 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
|
||||
}
|
||||
|
||||
for (int a = 0; a < cu->totcol; a++) {
|
||||
outliner_add_element(space_outliner, &te->subtree, cu->mat[a], te, 0, a);
|
||||
outliner_add_element(space_outliner, &te->subtree, cu->mat[a], te, TSE_SOME_ID, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -714,7 +715,7 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
|
||||
}
|
||||
|
||||
for (int a = 0; a < mb->totcol; a++) {
|
||||
outliner_add_element(space_outliner, &te->subtree, mb->mat[a], te, 0, a);
|
||||
outliner_add_element(space_outliner, &te->subtree, mb->mat[a], te, TSE_SOME_ID, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -730,7 +731,7 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
|
||||
if (outliner_animdata_test(tex->adt)) {
|
||||
outliner_add_element(space_outliner, &te->subtree, tex, te, TSE_ANIM_DATA, 0);
|
||||
}
|
||||
outliner_add_element(space_outliner, &te->subtree, tex->ima, te, 0, 0);
|
||||
outliner_add_element(space_outliner, &te->subtree, tex->ima, te, TSE_SOME_ID, 0);
|
||||
break;
|
||||
}
|
||||
case ID_CA: {
|
||||
@@ -1008,7 +1009,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
|
||||
if (te->type) {
|
||||
outliner_tree_element_type_expand(te->type, space_outliner);
|
||||
}
|
||||
else if (type == 0) {
|
||||
else if (type == TSE_SOME_ID) {
|
||||
TreeStoreElem *tsepar = parent ? TREESTORE(parent) : NULL;
|
||||
|
||||
/* ID data-block. */
|
||||
@@ -1229,7 +1230,7 @@ BLI_INLINE void outliner_add_collection_objects(SpaceOutliner *space_outliner,
|
||||
TreeElement *parent)
|
||||
{
|
||||
LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
|
||||
outliner_add_element(space_outliner, tree, cob->ob, parent, 0, 0);
|
||||
outliner_add_element(space_outliner, tree, cob->ob, parent, TSE_SOME_ID, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1240,7 +1241,8 @@ static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outli
|
||||
outliner_add_collection_init(ten, collection);
|
||||
|
||||
LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
|
||||
outliner_add_element(space_outliner, &ten->subtree, &child->collection->id, ten, 0, 0);
|
||||
outliner_add_element(
|
||||
space_outliner, &ten->subtree, &child->collection->id, ten, TSE_SOME_ID, 0);
|
||||
}
|
||||
|
||||
if (space_outliner->outlinevis != SO_SCENES) {
|
||||
@@ -1265,7 +1267,7 @@ void outliner_make_object_parent_hierarchy(ListBase *lb)
|
||||
TreeElement *ten = te->next;
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
if ((tselem->type == TSE_SOME_ID) && te->idcode == ID_OB) {
|
||||
Object *ob = (Object *)tselem->id;
|
||||
if (ob->parent && ob->parent->id.newid) {
|
||||
BLI_remlink(lb, te);
|
||||
@@ -1406,7 +1408,7 @@ static void outliner_sort(ListBase *lb)
|
||||
|
||||
/* sorting rules; only object lists, ID lists, or deformgroups */
|
||||
if (ELEM(tselem->type, TSE_DEFGROUP, TSE_ID_BASE) ||
|
||||
(tselem->type == 0 && te->idcode == ID_OB)) {
|
||||
((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB))) {
|
||||
int totelem = BLI_listbase_count(lb);
|
||||
|
||||
if (totelem > 1) {
|
||||
@@ -1420,7 +1422,7 @@ static void outliner_sort(ListBase *lb)
|
||||
tp->name = te->name;
|
||||
tp->idcode = te->idcode;
|
||||
|
||||
if (tselem->type && tselem->type != TSE_DEFGROUP) {
|
||||
if ((tselem->type != TSE_SOME_ID) && tselem->type != TSE_DEFGROUP) {
|
||||
tp->idcode = 0; /* Don't sort this. */
|
||||
}
|
||||
if (tselem->type == TSE_ID_BASE) {
|
||||
@@ -1471,7 +1473,7 @@ static void outliner_collections_children_sort(ListBase *lb)
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
/* Sorting rules: only object lists. */
|
||||
if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
int totelem = BLI_listbase_count(lb);
|
||||
|
||||
if (totelem > 1) {
|
||||
@@ -1546,7 +1548,7 @@ static bool test_collection_callback(TreeElement *te)
|
||||
static bool test_object_callback(TreeElement *te)
|
||||
{
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
return ((tselem->type == 0) && (te->idcode == ID_OB));
|
||||
return ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1707,7 +1709,7 @@ static bool outliner_element_visible_get(ViewLayer *view_layer,
|
||||
}
|
||||
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
if ((tselem->type == 0) && (te->idcode == ID_OB)) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
if ((exclude_filter & SO_FILTER_OB_TYPE) == SO_FILTER_OB_TYPE) {
|
||||
return false;
|
||||
}
|
||||
@@ -1790,14 +1792,15 @@ static bool outliner_element_visible_get(ViewLayer *view_layer,
|
||||
return is_visible;
|
||||
}
|
||||
|
||||
if ((te->parent != NULL) && (TREESTORE(te->parent)->type == 0) &&
|
||||
if ((te->parent != NULL) && (TREESTORE(te->parent)->type == TSE_SOME_ID) &&
|
||||
(te->parent->idcode == ID_OB)) {
|
||||
if (exclude_filter & SO_FILTER_NO_CHILDREN) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (te->parent != NULL && TREESTORE(te->parent)->type == 0 && te->parent->idcode == ID_OB) {
|
||||
else if ((te->parent != NULL) && (TREESTORE(te->parent)->type == TSE_SOME_ID) &&
|
||||
(te->parent->idcode == ID_OB)) {
|
||||
if (exclude_filter & SO_FILTER_NO_OB_CONTENT) {
|
||||
return false;
|
||||
}
|
||||
@@ -1821,7 +1824,7 @@ static bool outliner_element_is_collection_or_object(TreeElement *te)
|
||||
{
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
if ((tselem->type == 0) && (te->idcode == ID_OB)) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ TreeElement *outliner_find_id(SpaceOutliner *space_outliner, ListBase *lb, const
|
||||
{
|
||||
LISTBASE_FOREACH (TreeElement *, te, lb) {
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
if (tselem->type == 0) {
|
||||
if (tselem->type == TSE_SOME_ID) {
|
||||
if (tselem->id == id) {
|
||||
return te;
|
||||
}
|
||||
@@ -266,7 +266,7 @@ TreeElement *outliner_find_editbone(ListBase *lb, const EditBone *ebone)
|
||||
}
|
||||
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
if (ELEM(tselem->type, 0, TSE_EBONE)) {
|
||||
if (ELEM(tselem->type, TSE_SOME_ID, TSE_EBONE)) {
|
||||
TreeElement *tes = outliner_find_editbone(&te->subtree, ebone);
|
||||
if (tes) {
|
||||
return tes;
|
||||
@@ -283,7 +283,7 @@ TreeElement *outliner_search_back_te(TreeElement *te, short idcode)
|
||||
|
||||
while (te) {
|
||||
tselem = TREESTORE(te);
|
||||
if (tselem->type == 0 && te->idcode == idcode) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == idcode)) {
|
||||
return te;
|
||||
}
|
||||
te = te->parent;
|
||||
@@ -510,7 +510,7 @@ Base *ED_outliner_give_base_under_cursor(bContext *C, const int mval[2])
|
||||
te = outliner_find_item_at_y(space_outliner, &space_outliner->tree, view_mval[1]);
|
||||
if (te) {
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
if ((tselem->type == 0) && (te->idcode == ID_OB)) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
Object *ob = (Object *)tselem->id;
|
||||
base = (te->directdata) ? (Base *)te->directdata : BKE_view_layer_base_find(view_layer, ob);
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ TreeElement *TreeDisplayLibraries::add_library_contents(Main &mainvar,
|
||||
if (!tenlib) {
|
||||
/* Create library tree element on demand, depending if there are any data-blocks. */
|
||||
if (lib) {
|
||||
tenlib = outliner_add_element(&space_outliner_, &lb, lib, nullptr, 0, 0);
|
||||
tenlib = outliner_add_element(&space_outliner_, &lb, lib, nullptr, TSE_SOME_ID, 0);
|
||||
}
|
||||
else {
|
||||
tenlib = outliner_add_element(&space_outliner_, &lb, &mainvar, nullptr, TSE_ID_BASE, 0);
|
||||
@@ -168,7 +168,7 @@ TreeElement *TreeDisplayLibraries::add_library_contents(Main &mainvar,
|
||||
|
||||
for (ID *id : List<ID>(lbarray[a])) {
|
||||
if (library_id_filter_poll(lib, id)) {
|
||||
outliner_add_element(&space_outliner_, &ten->subtree, id, ten, 0, 0);
|
||||
outliner_add_element(&space_outliner_, &ten->subtree, id, ten, TSE_SOME_ID, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,8 @@ ListBase TreeDisplayIDOrphans::buildTree(const TreeSourceData &source_data)
|
||||
/* Add the orphaned data-blocks - these will not be added with any subtrees attached. */
|
||||
for (ID *id : List<ID>(lbarray[a])) {
|
||||
if (ID_REAL_USERS(id) <= 0) {
|
||||
outliner_add_element(&space_outliner_, (te) ? &te->subtree : &tree, id, te, 0, 0);
|
||||
outliner_add_element(
|
||||
&space_outliner_, (te) ? &te->subtree : &tree, id, te, TSE_SOME_ID, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ ListBase TreeDisplayScenes::buildTree(const TreeSourceData &source_data)
|
||||
|
||||
for (ID *id : List<ID>(source_data.bmain->scenes)) {
|
||||
Scene *scene = reinterpret_cast<Scene *>(id);
|
||||
TreeElement *te = outliner_add_element(&space_outliner_, &tree, scene, nullptr, 0, 0);
|
||||
TreeElement *te = outliner_add_element(
|
||||
&space_outliner_, &tree, scene, nullptr, TSE_SOME_ID, 0);
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
/* New scene elements open by default */
|
||||
|
||||
@@ -80,7 +80,7 @@ ListBase TreeDisplayViewLayer::buildTree(const TreeSourceData &source_data)
|
||||
/* Show objects in the view layer. */
|
||||
for (Base *base : List<Base>(view_layer_->object_bases)) {
|
||||
TreeElement *te_object = outliner_add_element(
|
||||
&space_outliner_, &tree, base->object, nullptr, 0, 0);
|
||||
&space_outliner_, &tree, base->object, nullptr, TSE_SOME_ID, 0);
|
||||
te_object->directdata = base;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ void TreeDisplayViewLayer::add_layer_collection_objects(ListBase &tree,
|
||||
for (CollectionObject *cob : List<CollectionObject>(lc.collection->gobject)) {
|
||||
Base *base = BKE_view_layer_base_find(view_layer_, cob->ob);
|
||||
TreeElement *te_object = outliner_add_element(
|
||||
&space_outliner_, &tree, base->object, &ten, 0, 0);
|
||||
&space_outliner_, &tree, base->object, &ten, TSE_SOME_ID, 0);
|
||||
te_object->directdata = base;
|
||||
}
|
||||
}
|
||||
@@ -203,7 +203,7 @@ void ObjectsChildrenBuilder::object_tree_elements_lookup_create_recursive(TreeEl
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tselem->type == 0 && te->idcode == ID_OB) {
|
||||
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
|
||||
Object *ob = (Object *)tselem->id;
|
||||
/* Lookup children or add new, empty children vector. */
|
||||
Vector<TreeElement *> &tree_elements = object_tree_elements_map_.lookup_or_add(ob, {});
|
||||
@@ -261,8 +261,12 @@ void ObjectsChildrenBuilder::make_object_parent_hierarchy_collections()
|
||||
if (!found) {
|
||||
/* We add the child in the tree even if it is not in the collection.
|
||||
* We deliberately clear its sub-tree though, to make it less prominent. */
|
||||
TreeElement *child_ob_tree_element = outliner_add_element(
|
||||
&outliner_, &parent_ob_tree_element->subtree, child, parent_ob_tree_element, 0, 0);
|
||||
TreeElement *child_ob_tree_element = outliner_add_element(&outliner_,
|
||||
&parent_ob_tree_element->subtree,
|
||||
child,
|
||||
parent_ob_tree_element,
|
||||
TSE_SOME_ID,
|
||||
0);
|
||||
outliner_free_tree(&child_ob_tree_element->subtree);
|
||||
child_ob_tree_element->flag |= TE_CHILD_NOT_IN_COLLECTION;
|
||||
child_ob_tree_elements.append(child_ob_tree_element);
|
||||
|
||||
@@ -44,7 +44,8 @@ TreeElementAnimData::TreeElementAnimData(TreeElement &legacy_te, ID &id)
|
||||
void TreeElementAnimData::expand(SpaceOutliner &space_outliner) const
|
||||
{
|
||||
/* Animation data-block itself. */
|
||||
outliner_add_element(&space_outliner, &legacy_te_.subtree, anim_data_.action, &legacy_te_, 0, 0);
|
||||
outliner_add_element(
|
||||
&space_outliner, &legacy_te_.subtree, anim_data_.action, &legacy_te_, TSE_SOME_ID, 0);
|
||||
|
||||
expand_drivers(space_outliner);
|
||||
expand_NLA_tracks(space_outliner);
|
||||
|
||||
@@ -73,6 +73,16 @@ enum {
|
||||
|
||||
/** #TreeStoreElem.types */
|
||||
typedef enum eTreeStoreElemType {
|
||||
/**
|
||||
* If an element is of this type, `TreeStoreElem.id` points to a valid ID and the ID-type can be
|
||||
* received through `TreeElement.idcode` (or `GS(TreeStoreElem.id->name)`). Note however that the
|
||||
* types below may also have a valid ID pointer (see #TSE_IS_REAL_ID()).
|
||||
*
|
||||
* In cases where the type is still checked against "0" (even implicitly), please replace it with
|
||||
* an explicit check against `TSE_SOME_ID`.
|
||||
*/
|
||||
TSE_SOME_ID = 0,
|
||||
|
||||
TSE_NLA = 1, /* NO ID */
|
||||
TSE_NLA_ACTION = 2,
|
||||
TSE_DEFGROUP_BASE = 3,
|
||||
|
||||
Reference in New Issue
Block a user