Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_tools.cc
| Show First 20 Lines • Show All 323 Lines • ▼ Show 20 Lines | for (a = 0; a < totcol; a++) { | ||||
| id_us_min(&matar[a]->id); | id_us_min(&matar[a]->id); | ||||
| matar[a] = nullptr; | matar[a] = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void unlink_texture_fn(bContext * /*C*/, | static void unlink_texture_fn(bContext * /*C*/, | ||||
| ReportList * /*reports*/, | ReportList *reports, | ||||
| Scene * /*scene*/, | Scene * /*scene*/, | ||||
| TreeElement *te, | TreeElement *te, | ||||
| TreeStoreElem *tsep, | TreeStoreElem *tsep, | ||||
| TreeStoreElem * /*tselem*/, | TreeStoreElem *tselem, | ||||
| void * /*user_data*/) | void * /*user_data*/) | ||||
| { | { | ||||
| if (!tsep || !TSE_IS_REAL_ID(tsep)) { | |||||
| /* Valid case, no parent element of the texture or it is not an ID (could be a #TSE_ID_BASE | |||||
| * for example) so there's no data to unlink from. */ | |||||
| BKE_reportf(reports, | |||||
| RPT_WARNING, | |||||
| "Cannot unlink texture '%s'. It's not clear which freestyle line style it should " | |||||
| "be unlinked from, there's no freestyle line style as parent in the Outliner tree", | |||||
| tselem->id->name + 2); | |||||
| return; | |||||
| } | |||||
| MTex **mtex = nullptr; | MTex **mtex = nullptr; | ||||
| int a; | int a; | ||||
| if (GS(tsep->id->name) == ID_LS) { | if (GS(tsep->id->name) == ID_LS) { | ||||
| FreestyleLineStyle *ls = (FreestyleLineStyle *)tsep->id; | FreestyleLineStyle *ls = (FreestyleLineStyle *)tsep->id; | ||||
| mtex = ls->mtex; | mtex = ls->mtex; | ||||
| } | } | ||||
| else { | else { | ||||
| return; | return; | ||||
| } | } | ||||
| for (a = 0; a < MAX_MTEX; a++) { | for (a = 0; a < MAX_MTEX; a++) { | ||||
| if (a == te->index && mtex[a]) { | if (a == te->index && mtex[a]) { | ||||
| if (mtex[a]->tex) { | if (mtex[a]->tex) { | ||||
| id_us_min(&mtex[a]->tex->id); | id_us_min(&mtex[a]->tex->id); | ||||
| mtex[a]->tex = nullptr; | mtex[a]->tex = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void unlink_collection_fn(bContext *C, | static void unlink_collection_fn(bContext *C, | ||||
| ReportList * /*reports*/, | ReportList *reports, | ||||
| Scene * /*scene*/, | Scene * /*scene*/, | ||||
| TreeElement * /*te*/, | TreeElement * /*te*/, | ||||
| TreeStoreElem *tsep, | TreeStoreElem *tsep, | ||||
| TreeStoreElem *tselem, | TreeStoreElem *tselem, | ||||
| void * /*user_data*/) | void * /*user_data*/) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Collection *collection = (Collection *)tselem->id; | Collection *collection = (Collection *)tselem->id; | ||||
| if (!tsep || !TSE_IS_REAL_ID(tsep)) { | |||||
| /* Valid case, no parent element of the collection or it is not an ID (could be a #TSE_ID_BASE | |||||
| * for example) so there's no data to unlink from. */ | |||||
| BKE_reportf(reports, | |||||
| RPT_WARNING, | |||||
| "Cannot unlink collection '%s'. It's not clear which scene, collection or " | |||||
| "instance empties it should be unlinked from, there's no scene, collection or " | |||||
| "instance empties as parent in the Outliner tree", | |||||
| tselem->id->name + 2); | |||||
| return; | |||||
| } | |||||
| if (tsep) { | if (tsep) { | ||||
| if (GS(tsep->id->name) == ID_OB) { | if (GS(tsep->id->name) == ID_OB) { | ||||
| Object *ob = (Object *)tsep->id; | Object *ob = (Object *)tsep->id; | ||||
| ob->instance_collection = nullptr; | ob->instance_collection = nullptr; | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); | DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| } | } | ||||
| else if (GS(tsep->id->name) == ID_GR) { | else if (GS(tsep->id->name) == ID_GR) { | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | if (tsep && tsep->id) { | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); | DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void unlink_world_fn(bContext * /*C*/, | static void unlink_world_fn(bContext * /*C*/, | ||||
| ReportList * /*reports*/, | ReportList *reports, | ||||
| Scene * /*scene*/, | Scene * /*scene*/, | ||||
| TreeElement * /*te*/, | TreeElement * /*te*/, | ||||
| TreeStoreElem *tsep, | TreeStoreElem *tsep, | ||||
| TreeStoreElem *tselem, | TreeStoreElem *tselem, | ||||
| void * /*user_data*/) | void * /*user_data*/) | ||||
| { | { | ||||
| if (!tsep || !TSE_IS_REAL_ID(tsep)) { | |||||
| /* Valid case, no parent element of the world or it is not an ID (could be a #TSE_ID_BASE | |||||
| * for example) so there's no data to unlink from. */ | |||||
| BKE_reportf(reports, | |||||
| RPT_WARNING, | |||||
| "Cannot unlink world '%s'. It's not clear which scene it should be unlinked from, " | |||||
| "there's no scene as parent in the Outliner tree", | |||||
| tselem->id->name + 2); | |||||
| return; | |||||
| } | |||||
| Scene *parscene = (Scene *)tsep->id; | Scene *parscene = (Scene *)tsep->id; | ||||
| World *wo = (World *)tselem->id; | World *wo = (World *)tselem->id; | ||||
| /* need to use parent scene not just scene, otherwise may end up getting wrong one */ | /* need to use parent scene not just scene, otherwise may end up getting wrong one */ | ||||
| id_us_min(&wo->id); | id_us_min(&wo->id); | ||||
| parscene->world = nullptr; | parscene->world = nullptr; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 3,040 Lines • Show Last 20 Lines | |||||