diff options
Diffstat (limited to 'source/blender/blenkernel/intern/world.c')
-rw-r--r-- | source/blender/blenkernel/intern/world.c | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index d5142e2d1a4..7590afeaaff 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -99,12 +99,19 @@ static void world_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int { World *wrld_dst = (World *)id_dst; const World *wrld_src = (const World *)id_src; + + const bool is_localized = (flag & LIB_ID_CREATE_LOCAL) != 0; /* We always need allocation of our private ID data. */ const int flag_private_id_data = flag & ~LIB_ID_CREATE_NO_ALLOCATE; if (wrld_src->nodetree) { - BKE_id_copy_ex( - bmain, (ID *)wrld_src->nodetree, (ID **)&wrld_dst->nodetree, flag_private_id_data); + if (is_localized) { + wrld_dst->nodetree = ntreeLocalize(wrld_src->nodetree); + } + else { + BKE_id_copy_ex( + bmain, (ID *)wrld_src->nodetree, (ID **)&wrld_dst->nodetree, flag_private_id_data); + } } BLI_listbase_clear(&wrld_dst->gpumaterial); @@ -210,36 +217,6 @@ World *BKE_world_add(Main *bmain, const char *name) return wrld; } -World *BKE_world_localize(World *wrld) -{ - /* TODO(bastien): Replace with something like: - * - * World *wrld_copy; - * BKE_id_copy_ex(bmain, &wrld->id, (ID **)&wrld_copy, - * LIB_ID_COPY_NO_MAIN | LIB_ID_COPY_NO_PREVIEW | LIB_ID_COPY_NO_USER_REFCOUNT, - * false); - * return wrld_copy; - * - * NOTE: Only possible once nested node trees are fully converted to that too. */ - - World *wrldn; - - wrldn = BKE_libblock_copy_for_localize(&wrld->id); - - if (wrld->nodetree) { - wrldn->nodetree = ntreeLocalize(wrld->nodetree); - } - - wrldn->preview = NULL; - - BLI_listbase_clear(&wrldn->gpumaterial); - BLI_listbase_clear((ListBase *)&wrldn->drawdata); - - wrldn->id.tag |= LIB_TAG_LOCALIZED; - - return wrldn; -} - void BKE_world_eval(struct Depsgraph *depsgraph, World *world) { DEG_debug_print_eval(depsgraph, __func__, world->id.name, world); |