Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_select.c
| Show First 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | static eOLDrawState tree_element_set_active_object(bContext *C, | ||||
| Scene *scene, | Scene *scene, | ||||
| ViewLayer *view_layer, | ViewLayer *view_layer, | ||||
| SpaceOutliner *soops, | SpaceOutliner *soops, | ||||
| TreeElement *te, | TreeElement *te, | ||||
| const eOLSetState set, | const eOLSetState set, | ||||
| bool recursive) | bool recursive) | ||||
| { | { | ||||
| TreeStoreElem *tselem = TREESTORE(te); | TreeStoreElem *tselem = TREESTORE(te); | ||||
| TreeStoreElem *parent_tselem; | |||||
| Scene *sce; | Scene *sce; | ||||
| Base *base; | Base *base; | ||||
| Object *ob = NULL; | Object *ob = NULL; | ||||
| /* if id is not object, we search back */ | /* if id is not object, we search back */ | ||||
| if (te->idcode == ID_OB) { | if (te->idcode == ID_OB) { | ||||
| ob = (Object *)tselem->id; | ob = (Object *)tselem->id; | ||||
| } | } | ||||
| else { | else { | ||||
| ob = (Object *)outliner_search_back(soops, te, ID_OB); | ob = (Object *)outliner_search_back(soops, te, ID_OB); | ||||
| if (ob == OBACT(view_layer)) { | if (ob == OBACT(view_layer) && set == OL_SETSEL_NONE) { | ||||
natecraddock: This is needed if the previous selected object was the parent. For example, if an armature was… | |||||
sybrenUnsubmitted Done Inline ActionsSuch comments should be code comments; your explanation is clear, and IMO really belongs in the code, not in the tracker. sybren: Such comments should be code comments; your explanation is clear, and IMO really belongs in the… | |||||
natecraddockAuthorUnsubmitted Done Inline ActionsI should have phrased it as a question. The reason I made the patch was because I was unsure of the lines I commented on. Seems like its okay though. natecraddock: I should have phrased it as a question. The reason I made the patch was because I was unsure of… | |||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| } | } | ||||
| if (ob == NULL) { | if (ob == NULL) { | ||||
| return OL_DRAWSEL_NONE; | return OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| sce = (Scene *)outliner_search_back(soops, te, ID_SCE); | sce = (Scene *)outliner_search_back(soops, te, ID_SCE); | ||||
| Show All 17 Lines | if (base != NULL) { | ||||
| } | } | ||||
| if (!BKE_object_is_mode_compat(base->object, object_mode)) { | if (!BKE_object_is_mode_compat(base->object, object_mode)) { | ||||
| base = NULL; | base = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| parent_tselem = TREESTORE(outliner_find_id(soops, &soops->tree, (ID *)ob)); | |||||
natecraddockAuthorUnsubmitted Done Inline ActionsThis could be optimized by searching back for a treestore rather than ID on line 321. natecraddock: This could be optimized by searching back for a treestore rather than ID on line 321. | |||||
sybrenUnsubmitted Not Done Inline ActionsProbably a good idea for a different patch. sybren: Probably a good idea for a different patch. | |||||
| if (base) { | if (base) { | ||||
| if (set == OL_SETSEL_EXTEND) { | if (set == OL_SETSEL_EXTEND) { | ||||
| /* swap select */ | /* swap select */ | ||||
| if (base->flag & BASE_SELECTED) { | if (base->flag & BASE_SELECTED) { | ||||
| ED_object_base_select(base, BA_DESELECT); | ED_object_base_select(base, BA_DESELECT); | ||||
| parent_tselem->flag &= ~TSE_SELECTED; | |||||
| } | } | ||||
| else { | else { | ||||
| ED_object_base_select(base, BA_SELECT); | ED_object_base_select(base, BA_SELECT); | ||||
| parent_tselem->flag |= TSE_SELECTED; | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* deleselect all */ | /* deleselect all */ | ||||
| /* Only in object mode so we can switch the active object, | /* Only in object mode so we can switch the active object, | ||||
| * keeping all objects in the current 'mode' selected, useful for multi-pose/edit mode. | * keeping all objects in the current 'mode' selected, useful for multi-pose/edit mode. | ||||
| * This keeps the convention that all objects in the current mode are also selected. | * This keeps the convention that all objects in the current mode are also selected. | ||||
| * see T55246. */ | * see T55246. */ | ||||
| if ((scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) ? | if ((scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) ? | ||||
| (ob->mode == OB_MODE_OBJECT) : | (ob->mode == OB_MODE_OBJECT) : | ||||
| true) { | true) { | ||||
| BKE_view_layer_base_deselect_all(view_layer); | BKE_view_layer_base_deselect_all(view_layer); | ||||
| } | } | ||||
| ED_object_base_select(base, BA_SELECT); | ED_object_base_select(base, BA_SELECT); | ||||
| parent_tselem->flag |= TSE_SELECTED; | |||||
| } | } | ||||
| if (recursive) { | if (recursive) { | ||||
| /* Recursive select/deselect for Object hierarchies */ | /* Recursive select/deselect for Object hierarchies */ | ||||
| do_outliner_object_select_recursive(view_layer, ob, (base->flag & BASE_SELECTED) != 0); | do_outliner_object_select_recursive(view_layer, ob, (base->flag & BASE_SELECTED) != 0); | ||||
| } | } | ||||
| if (set != OL_SETSEL_NONE) { | if (set != OL_SETSEL_NONE) { | ||||
| ▲ Show 20 Lines • Show All 1,387 Lines • Show Last 20 Lines | |||||
This is needed if the previous selected object was the parent. For example, if an armature was selected, then the pose bone was selected, the armature would then be deselected because it was active.