Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_relations.c
| Show First 20 Lines • Show All 354 Lines • ▼ Show 20 Lines | static int make_proxy_exec(bContext *C, wmOperator *op) | ||||
| if (ob) { | if (ob) { | ||||
| Object *newob; | Object *newob; | ||||
| char name[MAX_ID_NAME + 4]; | char name[MAX_ID_NAME + 4]; | ||||
| BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2); | BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2); | ||||
| /* Add new object for the proxy */ | /* Add new object for the proxy */ | ||||
| newob = BKE_object_add_from(bmain, scene, view_layer, OB_EMPTY, name, gob ? gob : ob); | newob = BKE_object_add_from(bmain, scene, view_layer, OB_EMPTY, name, gob ? gob : ob, CTX_wm_workspace(C)); | ||||
| /* set layers OK */ | /* set layers OK */ | ||||
| BKE_object_make_proxy(newob, ob, gob); | BKE_object_make_proxy(newob, ob, gob); | ||||
| /* Set back pointer immediately so dependency graph knows that this is | /* Set back pointer immediately so dependency graph knows that this is | ||||
| * is a proxy and will act accordingly. Otherwise correctness of graph | * is a proxy and will act accordingly. Otherwise correctness of graph | ||||
| * will depend on order of bases. | * will depend on order of bases. | ||||
| * | * | ||||
| ▲ Show 20 Lines • Show All 2,059 Lines • ▼ Show 20 Lines | if (!ID_IS_LINKED(obact) && obact->dup_group != NULL && ID_IS_LINKED(obact->dup_group)) { | ||||
| /* Intantiate our 'main' newly overridden object in scene, if not yet done. */ | /* Intantiate our 'main' newly overridden object in scene, if not yet done. */ | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Object *new_obact = (Object *)obact->id.newid; | Object *new_obact = (Object *)obact->id.newid; | ||||
| if (new_obact != NULL && (base = BKE_view_layer_base_find(view_layer, new_obact)) == NULL) { | if (new_obact != NULL && (base = BKE_view_layer_base_find(view_layer, new_obact)) == NULL) { | ||||
| BKE_collection_object_add_from(scene, obgroup, new_obact); | BKE_collection_object_add_from(scene, obgroup, new_obact); | ||||
| base = BKE_view_layer_base_find(view_layer, new_obact); | base = BKE_view_layer_base_find(view_layer, new_obact); | ||||
| BKE_view_layer_base_select(view_layer, base); | BKE_view_layer_base_select(view_layer, base, CTX_wm_workspace(C)); | ||||
| } | } | ||||
| /* Parent the group instantiating object to the new overridden one, or vice-versa, if possible. */ | /* Parent the group instantiating object to the new overridden one, or vice-versa, if possible. */ | ||||
| if (obgroup->parent == NULL) { | if (obgroup->parent == NULL) { | ||||
| obgroup->parent = new_obact; | obgroup->parent = new_obact; | ||||
| } | } | ||||
| else if (new_obact->parent == NULL) { | else if (new_obact->parent == NULL) { | ||||
| new_obact->parent = obgroup; | new_obact->parent = obgroup; | ||||
| ▲ Show 20 Lines • Show All 249 Lines • Show Last 20 Lines | |||||