Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/scene.c
| Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) | Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) | ||||
| { | { | ||||
| Scene *scen; | Scene *scen; | ||||
| SceneRenderLayer *srl, *new_srl; | SceneRenderLayer *srl, *new_srl; | ||||
| FreestyleLineSet *lineset; | FreestyleLineSet *lineset; | ||||
| ToolSettings *ts; | ToolSettings *ts; | ||||
| Base *base, *obase; | Base *legacy_base, *olegacy_base; | ||||
| if (type == SCE_COPY_EMPTY) { | if (type == SCE_COPY_EMPTY) { | ||||
| ListBase rl, rv; | ListBase rl, rv; | ||||
| scen = BKE_scene_add(bmain, sce->id.name + 2); | scen = BKE_scene_add(bmain, sce->id.name + 2); | ||||
| rl = scen->r.layers; | rl = scen->r.layers; | ||||
| rv = scen->r.views; | rv = scen->r.views; | ||||
| curvemapping_free_data(&scen->r.mblur_shutter_curve); | curvemapping_free_data(&scen->r.mblur_shutter_curve); | ||||
| Show All 37 Lines | else { | ||||
| BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); | BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); | ||||
| if (sce->nodetree) { | if (sce->nodetree) { | ||||
| /* ID's are managed on both copy and switch */ | /* ID's are managed on both copy and switch */ | ||||
| scen->nodetree = ntreeCopyTree(bmain, sce->nodetree); | scen->nodetree = ntreeCopyTree(bmain, sce->nodetree); | ||||
| BKE_libblock_relink_ex(bmain, scen->nodetree, &sce->id, &scen->id, false); | BKE_libblock_relink_ex(bmain, scen->nodetree, &sce->id, &scen->id, false); | ||||
| } | } | ||||
| obase = sce->base.first; | olegacy_base = sce->base.first; | ||||
| base = scen->base.first; | legacy_base = scen->base.first; | ||||
| while (base) { | while (legacy_base) { | ||||
| id_us_plus(&base->object->id); | id_us_plus(&legacy_base->object->id); | ||||
| if (obase == sce->basact) scen->basact = base; | if (olegacy_base == sce->basact) scen->basact = legacy_base; | ||||
| obase = obase->next; | olegacy_base = olegacy_base->next; | ||||
| base = base->next; | legacy_base = legacy_base->next; | ||||
| } | } | ||||
| /* copy action and remove animation used by sequencer */ | /* copy action and remove animation used by sequencer */ | ||||
| BKE_animdata_copy_id_action(&scen->id, false); | BKE_animdata_copy_id_action(&scen->id, false); | ||||
| if (type != SCE_COPY_FULL) | if (type != SCE_COPY_FULL) | ||||
| remove_sequencer_fcurves(scen); | remove_sequencer_fcurves(scen); | ||||
| Show All 27 Lines | for (SceneLayer *sl = sce->render_layers.first; sl; sl = sl->next) { | ||||
| /* we start fresh with no overrides and no visibility flags set | /* we start fresh with no overrides and no visibility flags set | ||||
| * instead of syncing both trees we simply unlink and relink the scene collection */ | * instead of syncing both trees we simply unlink and relink the scene collection */ | ||||
| BLI_listbase_clear(&new_sl->layer_collections); | BLI_listbase_clear(&new_sl->layer_collections); | ||||
| BLI_listbase_clear(&new_sl->object_bases); | BLI_listbase_clear(&new_sl->object_bases); | ||||
| layer_collections_recreate(new_sl, &sl->layer_collections, mcn, mc); | layer_collections_recreate(new_sl, &sl->layer_collections, mcn, mc); | ||||
| if (sl->basact) { | if (sl->basact) { | ||||
| Object *active_ob = sl->basact->object; | Object *active_ob = sl->basact->object; | ||||
| for (ObjectBase *ob_base = new_sl->object_bases.first; ob_base; ob_base = ob_base->next) { | for (ObjectBase *base = new_sl->object_bases.first; base; base = base->next) { | ||||
| if (ob_base->object == active_ob) { | if (base->object == active_ob) { | ||||
| new_sl->basact = ob_base; | new_sl->basact = base; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| new_sl = new_sl->next; | new_sl = new_sl->next; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,348 Lines • Show Last 20 Lines | |||||