2011-10-10 09:38:02 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <math.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2018-04-01 11:03:25 +02:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2020-09-10 17:06:35 +02:00
|
|
|
/* Allow using deprecated functionality for .blend file I/O. */
|
|
|
|
|
#define DNA_DEPRECATED_ALLOW
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_defaults.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_texture_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_world_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-12-11 14:35:10 +01:00
|
|
|
#include "BLI_listbase.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2011-04-26 07:17:21 +00:00
|
|
|
|
2020-09-10 17:06:35 +02:00
|
|
|
#include "BKE_anim_data.h"
|
2005-12-21 22:21:43 +00:00
|
|
|
#include "BKE_icons.h"
|
2020-03-06 11:51:17 +01:00
|
|
|
#include "BKE_idtype.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
2020-05-13 19:22:46 +02:00
|
|
|
#include "BKE_lib_query.h"
|
2011-11-02 18:55:32 +00:00
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_node.h"
|
|
|
|
|
#include "BKE_world.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2020-03-06 11:51:17 +01:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
|
2018-07-10 14:14:55 +02:00
|
|
|
#include "DRW_engine.h"
|
|
|
|
|
|
2018-06-07 19:15:36 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
|
2014-11-24 17:18:56 +01:00
|
|
|
#include "GPU_material.h"
|
|
|
|
|
|
2020-09-10 17:06:35 +02:00
|
|
|
#include "BLO_read_write.h"
|
|
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
/** Free (or release) any data used by this world (does not free the world itself). */
|
2020-03-06 11:51:17 +01:00
|
|
|
static void world_free_data(ID *id)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-03-06 11:51:17 +01:00
|
|
|
World *wrld = (World *)id;
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
|
2020-03-06 11:51:17 +01:00
|
|
|
DRW_drawdata_free(id);
|
2018-07-10 14:14:55 +02:00
|
|
|
|
2011-11-02 18:55:32 +00:00
|
|
|
/* is no lib link block, but world extension */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (wrld->nodetree) {
|
2020-04-20 16:14:45 +02:00
|
|
|
ntreeFreeEmbeddedTree(wrld->nodetree);
|
2011-11-02 18:55:32 +00:00
|
|
|
MEM_freeN(wrld->nodetree);
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
wrld->nodetree = NULL;
|
2011-11-02 18:55:32 +00:00
|
|
|
}
|
|
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
GPU_material_free(&wrld->gpumaterial);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2015-05-11 16:29:12 +02:00
|
|
|
BKE_icon_id_delete((struct ID *)wrld);
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
BKE_previewimg_free(&wrld->preview);
|
2012-08-29 12:47:42 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2020-03-06 11:51:17 +01:00
|
|
|
static void world_init_data(ID *id)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-03-06 11:51:17 +01:00
|
|
|
World *wrld = (World *)id;
|
2019-03-12 16:59:04 +11:00
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(wrld, id));
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-09-12 04:34:55 +10:00
|
|
|
MEMCPY_STRUCT_AFTER(wrld, DNA_struct_default_get(World), id);
|
First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.
That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.
Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.
Future plans are also to be able to relocate missing libs and reload them at runtime.
Code notes:
- Placeholder ID is just a regular datablock of same type as expected linked one,
with 'default' data, and a LIB_MISSING bitflag set.
- To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
+ Allocation of memory itself.
+ Setting of all internal data to default values.
See also the design task (T43351).
Reviewed by @campbellbarton, thanks a bunch!
Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
|
|
|
}
|
|
|
|
|
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
/**
|
2019-04-27 12:07:07 +10:00
|
|
|
* Only copy internal data of World ID from source
|
|
|
|
|
* to already allocated/initialized destination.
|
|
|
|
|
* You probably never want to use that directly,
|
|
|
|
|
* use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
*
|
|
|
|
|
* WARNING! This function will not handle ID user count!
|
|
|
|
|
*
|
2020-02-10 12:58:59 +01:00
|
|
|
* \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
*/
|
2020-03-06 11:51:17 +01:00
|
|
|
static void world_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-03-06 11:51:17 +01:00
|
|
|
World *wrld_dst = (World *)id_dst;
|
|
|
|
|
const World *wrld_src = (const World *)id_src;
|
2020-10-06 17:43:12 +02:00
|
|
|
|
|
|
|
|
const bool is_localized = (flag & LIB_ID_CREATE_LOCAL) != 0;
|
2019-09-02 17:34:56 +02:00
|
|
|
/* We always need allocation of our private ID data. */
|
2019-09-12 12:24:24 +02:00
|
|
|
const int flag_private_id_data = flag & ~LIB_ID_CREATE_NO_ALLOCATE;
|
2019-09-02 17:34:56 +02:00
|
|
|
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
if (wrld_src->nodetree) {
|
2020-10-06 17:43:12 +02:00
|
|
|
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);
|
|
|
|
|
}
|
2012-08-21 14:43:51 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
BLI_listbase_clear(&wrld_dst->gpumaterial);
|
2018-07-10 14:14:55 +02:00
|
|
|
BLI_listbase_clear((ListBase *)&wrld_dst->drawdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
|
|
|
|
|
BKE_previewimg_id_copy(&wrld_dst->id, &wrld_src->id);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
wrld_dst->preview = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-09 09:52:51 +01:00
|
|
|
|
2020-05-13 19:22:46 +02:00
|
|
|
static void world_foreach_id(ID *id, LibraryForeachIDData *data)
|
|
|
|
|
{
|
|
|
|
|
World *world = (World *)id;
|
|
|
|
|
|
|
|
|
|
if (world->nodetree) {
|
|
|
|
|
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
|
|
|
|
|
BKE_library_foreach_ID_embedded(data, (ID **)&world->nodetree);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-10 17:06:35 +02:00
|
|
|
static void world_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
|
|
|
|
{
|
|
|
|
|
World *wrld = (World *)id;
|
|
|
|
|
if (wrld->id.us > 0 || BLO_write_is_undo(writer)) {
|
|
|
|
|
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
|
|
|
|
|
BLI_listbase_clear(&wrld->gpumaterial);
|
|
|
|
|
|
|
|
|
|
/* write LibData */
|
|
|
|
|
BLO_write_id_struct(writer, World, id_address, &wrld->id);
|
|
|
|
|
BKE_id_blend_write(writer, &wrld->id);
|
|
|
|
|
|
|
|
|
|
if (wrld->adt) {
|
|
|
|
|
BKE_animdata_blend_write(writer, wrld->adt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* nodetree is integral part of world, no libdata */
|
|
|
|
|
if (wrld->nodetree) {
|
|
|
|
|
BLO_write_struct(writer, bNodeTree, wrld->nodetree);
|
|
|
|
|
ntreeBlendWrite(writer, wrld->nodetree);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_previewimg_blend_write(writer, wrld->preview);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void world_blend_read_data(BlendDataReader *reader, ID *id)
|
|
|
|
|
{
|
|
|
|
|
World *wrld = (World *)id;
|
|
|
|
|
BLO_read_data_address(reader, &wrld->adt);
|
|
|
|
|
BKE_animdata_blend_read_data(reader, wrld->adt);
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &wrld->preview);
|
|
|
|
|
BKE_previewimg_blend_read(reader, wrld->preview);
|
|
|
|
|
BLI_listbase_clear(&wrld->gpumaterial);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void world_blend_read_lib(BlendLibReader *reader, ID *id)
|
|
|
|
|
{
|
|
|
|
|
World *wrld = (World *)id;
|
|
|
|
|
BLO_read_id_address(reader, wrld->id.lib, &wrld->ipo); /* XXX deprecated, old animation system */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void world_blend_read_expand(BlendExpander *expander, ID *id)
|
|
|
|
|
{
|
|
|
|
|
World *wrld = (World *)id;
|
|
|
|
|
BLO_expand(expander, wrld->ipo); /* XXX deprecated, old animation system */
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-13 19:11:19 +02:00
|
|
|
IDTypeInfo IDType_ID_WO = {
|
|
|
|
|
.id_code = ID_WO,
|
|
|
|
|
.id_filter = FILTER_ID_WO,
|
|
|
|
|
.main_listbase_index = INDEX_ID_WO,
|
|
|
|
|
.struct_size = sizeof(World),
|
|
|
|
|
.name = "World",
|
|
|
|
|
.name_plural = "worlds",
|
|
|
|
|
.translation_context = BLT_I18NCONTEXT_ID_WORLD,
|
|
|
|
|
.flags = 0,
|
|
|
|
|
|
|
|
|
|
.init_data = world_init_data,
|
|
|
|
|
.copy_data = world_copy_data,
|
|
|
|
|
.free_data = world_free_data,
|
|
|
|
|
.make_local = NULL,
|
2020-05-13 19:22:46 +02:00
|
|
|
.foreach_id = world_foreach_id,
|
2020-08-28 13:05:48 +02:00
|
|
|
.foreach_cache = NULL,
|
|
|
|
|
|
2020-09-10 17:06:35 +02:00
|
|
|
.blend_write = world_blend_write,
|
|
|
|
|
.blend_read_data = world_blend_read_data,
|
|
|
|
|
.blend_read_lib = world_blend_read_lib,
|
|
|
|
|
.blend_read_expand = world_blend_read_expand,
|
2020-11-03 11:39:36 +01:00
|
|
|
|
|
|
|
|
.blend_read_undo_preserve = NULL,
|
2020-05-13 19:11:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
World *BKE_world_add(Main *bmain, const char *name)
|
|
|
|
|
{
|
|
|
|
|
World *wrld;
|
|
|
|
|
|
2020-10-08 12:50:04 +02:00
|
|
|
wrld = BKE_id_new(bmain, ID_WO, name);
|
2020-05-13 19:11:19 +02:00
|
|
|
|
|
|
|
|
return wrld;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-08 15:56:56 +01:00
|
|
|
void BKE_world_eval(struct Depsgraph *depsgraph, World *world)
|
|
|
|
|
{
|
|
|
|
|
DEG_debug_print_eval(depsgraph, __func__, world->id.name, world);
|
|
|
|
|
GPU_material_free(&world->gpumaterial);
|
|
|
|
|
}
|