Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2020-03-06 13:51:17 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-03-06 14:19:11 +0300
commite96b1035364122178d5fcec7cf4d4bab7c8cb051 (patch)
tree2aaf2403e276bac6285f5b5788105775e62cb634 /source/blender
parent297261eb906c56c7decf4401e6a3e06cec1691e8 (diff)
Cleanup: move camera, lights, world to IDTypeInfo
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_camera.h7
-rw-r--r--source/blender/blenkernel/BKE_idtype.h33
-rw-r--r--source/blender/blenkernel/BKE_light.h7
-rw-r--r--source/blender/blenkernel/BKE_lightprobe.h7
-rw-r--r--source/blender/blenkernel/BKE_world.h7
-rw-r--r--source/blender/blenkernel/intern/camera.c45
-rw-r--r--source/blender/blenkernel/intern/idtype.c33
-rw-r--r--source/blender/blenkernel/intern/lib_id.c32
-rw-r--r--source/blender/blenkernel/intern/lib_id_delete.c8
-rw-r--r--source/blender/blenkernel/intern/light.c37
-rw-r--r--source/blender/blenkernel/intern/lightprobe.c40
-rw-r--r--source/blender/blenkernel/intern/world.c39
-rw-r--r--source/blender/editors/render/render_preview.c18
13 files changed, 208 insertions, 105 deletions
diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h
index 558ffd9e7c7..aebe04f3a7a 100644
--- a/source/blender/blenkernel/BKE_camera.h
+++ b/source/blender/blenkernel/BKE_camera.h
@@ -40,15 +40,8 @@ struct rctf;
/* Camera Datablock */
-void BKE_camera_init(struct Camera *cam);
void *BKE_camera_add(struct Main *bmain, const char *name);
-void BKE_camera_copy_data(struct Main *bmain,
- struct Camera *cam_dst,
- const struct Camera *cam_src,
- const int flag);
struct Camera *BKE_camera_copy(struct Main *bmain, const struct Camera *cam);
-void BKE_camera_make_local(struct Main *bmain, struct Camera *cam, const int flags);
-void BKE_camera_free(struct Camera *ca);
/* Camera Usage */
diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index 2e8b39c938c..ec7c5cafbcf 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -127,6 +127,39 @@ typedef struct IDTypeInfo {
extern IDTypeInfo IDType_ID_SCE;
extern IDTypeInfo IDType_ID_LI;
extern IDTypeInfo IDType_ID_OB;
+// extern IDTypeInfo IDType_ID_ME;
+// extern IDTypeInfo IDType_ID_CU;
+// extern IDTypeInfo IDType_ID_MB;
+// extern IDTypeInfo IDType_ID_MA;
+// extern IDTypeInfo IDType_ID_TE;
+// extern IDTypeInfo IDType_ID_IM;
+// extern IDTypeInfo IDType_ID_LT;
+extern IDTypeInfo IDType_ID_LA;
+extern IDTypeInfo IDType_ID_CA;
+// extern IDTypeInfo IDType_ID_IP;
+// extern IDTypeInfo IDType_ID_KE;
+extern IDTypeInfo IDType_ID_WO;
+// extern IDTypeInfo IDType_ID_SCR;
+// extern IDTypeInfo IDType_ID_VF;
+// extern IDTypeInfo IDType_ID_TXT;
+// extern IDTypeInfo IDType_ID_SPK;
+// extern IDTypeInfo IDType_ID_SO;
+// extern IDTypeInfo IDType_ID_GR;
+// extern IDTypeInfo IDType_ID_AR;
+// extern IDTypeInfo IDType_ID_AC;
+// extern IDTypeInfo IDType_ID_NT;
+// extern IDTypeInfo IDType_ID_BR;
+// extern IDTypeInfo IDType_ID_PA;
+// extern IDTypeInfo IDType_ID_GD;
+// extern IDTypeInfo IDType_ID_WM;
+// extern IDTypeInfo IDType_ID_MC;
+// extern IDTypeInfo IDType_ID_MSK;
+// extern IDTypeInfo IDType_ID_LS;
+// extern IDTypeInfo IDType_ID_PAL;
+// extern IDTypeInfo IDType_ID_PC;
+// extern IDTypeInfo IDType_ID_CF;
+// extern IDTypeInfo IDType_ID_WS;
+extern IDTypeInfo IDType_ID_LP;
/* ********** Helpers/Utils API. ********** */
diff --git a/source/blender/blenkernel/BKE_light.h b/source/blender/blenkernel/BKE_light.h
index 932881ce4ad..a6f0fdbc8a3 100644
--- a/source/blender/blenkernel/BKE_light.h
+++ b/source/blender/blenkernel/BKE_light.h
@@ -33,16 +33,9 @@ extern "C" {
struct Light;
struct Main;
-void BKE_light_init(struct Light *la);
struct Light *BKE_light_add(struct Main *bmain, const char *name) ATTR_WARN_UNUSED_RESULT;
-void BKE_light_copy_data(struct Main *bmain,
- struct Light *la_dst,
- const struct Light *la_src,
- const int flag);
struct Light *BKE_light_copy(struct Main *bmain, const struct Light *la) ATTR_WARN_UNUSED_RESULT;
struct Light *BKE_light_localize(struct Light *la) ATTR_WARN_UNUSED_RESULT;
-void BKE_light_make_local(struct Main *bmain, struct Light *la, const int flags);
-void BKE_light_free(struct Light *la);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_lightprobe.h b/source/blender/blenkernel/BKE_lightprobe.h
index a294750fa9e..6304f61a1f4 100644
--- a/source/blender/blenkernel/BKE_lightprobe.h
+++ b/source/blender/blenkernel/BKE_lightprobe.h
@@ -32,16 +32,9 @@ extern "C" {
struct LightProbe;
struct Main;
-void BKE_lightprobe_init(struct LightProbe *probe);
void BKE_lightprobe_type_set(struct LightProbe *probe, const short lightprobe_type);
void *BKE_lightprobe_add(struct Main *bmain, const char *name);
-void BKE_lightprobe_copy_data(struct Main *bmain,
- struct LightProbe *probe_dst,
- const struct LightProbe *probe_src,
- const int flag);
struct LightProbe *BKE_lightprobe_copy(struct Main *bmain, const struct LightProbe *probe);
-void BKE_lightprobe_make_local(struct Main *bmain, struct LightProbe *probe, const int flags);
-void BKE_lightprobe_free(struct LightProbe *probe);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h
index 070ae2c045e..3c8f8547b46 100644
--- a/source/blender/blenkernel/BKE_world.h
+++ b/source/blender/blenkernel/BKE_world.h
@@ -31,16 +31,9 @@ struct Depsgraph;
struct Main;
struct World;
-void BKE_world_free(struct World *sc);
-void BKE_world_init(struct World *wrld);
struct World *BKE_world_add(struct Main *bmain, const char *name);
-void BKE_world_copy_data(struct Main *bmain,
- struct World *wrld_dst,
- const struct World *wrld_src,
- const int flag);
struct World *BKE_world_copy(struct Main *bmain, const struct World *wrld);
struct World *BKE_world_localize(struct World *wrld);
-void BKE_world_make_local(struct Main *bmain, struct World *wrld, const int flags);
void BKE_world_eval(struct Depsgraph *depsgraph, struct World *world);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index e21e093517e..d2829bc1cd6 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -40,6 +40,7 @@
#include "BKE_animsys.h"
#include "BKE_camera.h"
+#include "BKE_idtype.h"
#include "BKE_object.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
@@ -47,14 +48,17 @@
#include "BKE_scene.h"
#include "BKE_screen.h"
+#include "BLT_translation.h"
+
#include "DEG_depsgraph_query.h"
#include "MEM_guardedalloc.h"
/****************************** Camera Datablock *****************************/
-void BKE_camera_init(Camera *cam)
+static void camera_init_data(ID *id)
{
+ Camera *cam = (Camera *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cam, id));
MEMCPY_STRUCT_AFTER(cam, DNA_struct_default_get(Camera), id);
@@ -66,7 +70,7 @@ void *BKE_camera_add(Main *bmain, const char *name)
cam = BKE_libblock_alloc(bmain, ID_CA, name, 0);
- BKE_camera_init(cam);
+ camera_init_data(&cam->id);
return cam;
}
@@ -81,11 +85,13 @@ void *BKE_camera_add(Main *bmain, const char *name)
*
* \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
*/
-void BKE_camera_copy_data(Main *UNUSED(bmain),
- Camera *cam_dst,
- const Camera *cam_src,
- const int UNUSED(flag))
+static void camera_copy_data(Main *UNUSED(bmain),
+ ID *id_dst,
+ const ID *id_src,
+ const int UNUSED(flag))
{
+ Camera *cam_dst = (Camera *)id_dst;
+ const Camera *cam_src = (const Camera *)id_src;
BLI_duplicatelist(&cam_dst->bg_images, &cam_src->bg_images);
}
@@ -96,19 +102,36 @@ Camera *BKE_camera_copy(Main *bmain, const Camera *cam)
return cam_copy;
}
-void BKE_camera_make_local(Main *bmain, Camera *cam, const int flags)
+static void camera_make_local(Main *bmain, ID *id, const int flags)
{
- BKE_lib_id_make_local_generic(bmain, &cam->id, flags);
+ BKE_lib_id_make_local_generic(bmain, id, flags);
}
/** Free (or release) any data used by this camera (does not free the camera itself). */
-void BKE_camera_free(Camera *ca)
+static void camera_free_data(ID *id)
{
- BLI_freelistN(&ca->bg_images);
+ Camera *cam = (Camera *)id;
+ BLI_freelistN(&cam->bg_images);
- BKE_animdata_free((ID *)ca, false);
+ BKE_animdata_free(id, false);
}
+IDTypeInfo IDType_ID_CA = {
+ .id_code = ID_CA,
+ .id_filter = FILTER_ID_CA,
+ .main_listbase_index = INDEX_ID_CA,
+ .struct_size = sizeof(Camera),
+ .name = "Camera",
+ .name_plural = "cameras",
+ .translation_context = BLT_I18NCONTEXT_ID_CAMERA,
+ .flags = 0,
+
+ .init_data = camera_init_data,
+ .copy_data = camera_copy_data,
+ .free_data = camera_free_data,
+ .make_local = camera_make_local,
+};
+
/******************************** Camera Usage *******************************/
/* get the camera's dof value, takes the dof object into account */
diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c
index 1453234d577..2193ff2165c 100644
--- a/source/blender/blenkernel/intern/idtype.c
+++ b/source/blender/blenkernel/intern/idtype.c
@@ -54,6 +54,39 @@ static void id_type_init(void)
INIT_TYPE(ID_SCE);
INIT_TYPE(ID_LI);
INIT_TYPE(ID_OB);
+ // INIT_TYPE(ID_ME);
+ // INIT_TYPE(ID_CU);
+ // INIT_TYPE(ID_MB);
+ // INIT_TYPE(ID_MA);
+ // INIT_TYPE(ID_TE);
+ // INIT_TYPE(ID_IM);
+ // INIT_TYPE(ID_LT);
+ INIT_TYPE(ID_LA);
+ INIT_TYPE(ID_CA);
+ // INIT_TYPE(ID_IP);
+ // INIT_TYPE(ID_KE);
+ INIT_TYPE(ID_WO);
+ // INIT_TYPE(ID_SCR);
+ // INIT_TYPE(ID_VF);
+ // INIT_TYPE(ID_TXT);
+ // INIT_TYPE(ID_SPK);
+ // INIT_TYPE(ID_SO);
+ // INIT_TYPE(ID_GR);
+ // INIT_TYPE(ID_AR);
+ // INIT_TYPE(ID_AC);
+ // INIT_TYPE(ID_NT);
+ // INIT_TYPE(ID_BR);
+ // INIT_TYPE(ID_PA);
+ // INIT_TYPE(ID_GD);
+ // INIT_TYPE(ID_WM);
+ // INIT_TYPE(ID_MC);
+ // INIT_TYPE(ID_MSK);
+ // INIT_TYPE(ID_LS);
+ // INIT_TYPE(ID_PAL);
+ // INIT_TYPE(ID_PC);
+ // INIT_TYPE(ID_CF);
+ // INIT_TYPE(ID_WS);
+ INIT_TYPE(ID_LP);
#undef INIT_TYPE
}
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index b66007ceac4..01d6bb1077d 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -508,14 +508,10 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags
}
return true;
case ID_LA:
- if (!test) {
- BKE_light_make_local(bmain, (Light *)id, flags);
- }
+ BLI_assert(0);
return true;
case ID_CA:
- if (!test) {
- BKE_camera_make_local(bmain, (Camera *)id, flags);
- }
+ BLI_assert(0);
return true;
case ID_SPK:
if (!test) {
@@ -523,14 +519,10 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags
}
return true;
case ID_LP:
- if (!test) {
- BKE_lightprobe_make_local(bmain, (LightProbe *)id, flags);
- }
+ BLI_assert(0);
return true;
case ID_WO:
- if (!test) {
- BKE_world_make_local(bmain, (World *)id, flags);
- }
+ BLI_assert(0);
return true;
case ID_VF:
if (!test) {
@@ -753,22 +745,22 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
BKE_lattice_copy_data(bmain, (Lattice *)*r_newid, (Lattice *)id, flag);
break;
case ID_LA:
- BKE_light_copy_data(bmain, (Light *)*r_newid, (Light *)id, flag);
+ BLI_assert(0);
break;
case ID_SPK:
BKE_speaker_copy_data(bmain, (Speaker *)*r_newid, (Speaker *)id, flag);
break;
case ID_LP:
- BKE_lightprobe_copy_data(bmain, (LightProbe *)*r_newid, (LightProbe *)id, flag);
+ BLI_assert(0);
break;
case ID_CA:
- BKE_camera_copy_data(bmain, (Camera *)*r_newid, (Camera *)id, flag);
+ BLI_assert(0);
break;
case ID_KE:
BKE_key_copy_data(bmain, (Key *)*r_newid, (Key *)id, flag);
break;
case ID_WO:
- BKE_world_copy_data(bmain, (World *)*r_newid, (World *)id, flag);
+ BLI_assert(0);
break;
case ID_TXT:
BKE_text_copy_data(bmain, (Text *)*r_newid, (Text *)id, flag);
@@ -1374,19 +1366,19 @@ void BKE_libblock_init_empty(ID *id)
BKE_lattice_init((Lattice *)id);
break;
case ID_LA:
- BKE_light_init((Light *)id);
+ BLI_assert(0);
break;
case ID_SPK:
BKE_speaker_init((Speaker *)id);
break;
case ID_LP:
- BKE_lightprobe_init((LightProbe *)id);
+ BLI_assert(0);
break;
case ID_CA:
- BKE_camera_init((Camera *)id);
+ BLI_assert(0);
break;
case ID_WO:
- BKE_world_init((World *)id);
+ BLI_assert(0);
break;
case ID_SCR:
/* Nothing to do. */
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index e311dd2ef03..7d5f5c55ead 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -167,10 +167,10 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
BKE_lattice_free((Lattice *)id);
break;
case ID_LA:
- BKE_light_free((Light *)id);
+ BLI_assert(0);
break;
case ID_CA:
- BKE_camera_free((Camera *)id);
+ BLI_assert(0);
break;
case ID_IP: /* Deprecated. */
BKE_ipo_free((Ipo *)id);
@@ -179,7 +179,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
BKE_key_free((Key *)id);
break;
case ID_WO:
- BKE_world_free((World *)id);
+ BLI_assert(0);
break;
case ID_SCR:
BKE_screen_free((bScreen *)id);
@@ -194,7 +194,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
BKE_speaker_free((Speaker *)id);
break;
case ID_LP:
- BKE_lightprobe_free((LightProbe *)id);
+ BLI_assert(0);
break;
case ID_SO:
BKE_sound_free((bSound *)id);
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index 7f8626df409..d37e0af1ce2 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -40,13 +40,17 @@
#include "BKE_animsys.h"
#include "BKE_colortools.h"
#include "BKE_icons.h"
+#include "BKE_idtype.h"
#include "BKE_light.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_node.h"
-void BKE_light_init(Light *la)
+#include "BLT_translation.h"
+
+static void light_init_data(ID *id)
{
+ Light *la = (Light *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(la, id));
MEMCPY_STRUCT_AFTER(la, DNA_struct_default_get(Light), id);
@@ -61,7 +65,7 @@ Light *BKE_light_add(Main *bmain, const char *name)
la = BKE_libblock_alloc(bmain, ID_LA, name, 0);
- BKE_light_init(la);
+ light_init_data(&la->id);
return la;
}
@@ -76,8 +80,10 @@ Light *BKE_light_add(Main *bmain, const char *name)
*
* \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
*/
-void BKE_light_copy_data(Main *bmain, Light *la_dst, const Light *la_src, const int flag)
+static void light_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag)
{
+ Light *la_dst = (Light *)id_dst;
+ const Light *la_src = (const Light *)id_src;
/* We always need allocation of our private ID data. */
const int flag_private_id_data = flag & ~LIB_ID_CREATE_NO_ALLOCATE;
@@ -129,14 +135,15 @@ Light *BKE_light_localize(Light *la)
return lan;
}
-void BKE_light_make_local(Main *bmain, Light *la, const int flags)
+static void light_make_local(Main *bmain, ID *id, const int flags)
{
- BKE_lib_id_make_local_generic(bmain, &la->id, flags);
+ BKE_lib_id_make_local_generic(bmain, id, flags);
}
-void BKE_light_free(Light *la)
+static void light_free_data(ID *id)
{
- BKE_animdata_free((ID *)la, false);
+ Light *la = (Light *)id;
+ BKE_animdata_free(&la->id, false);
BKE_curvemapping_free(la->curfalloff);
@@ -151,3 +158,19 @@ void BKE_light_free(Light *la)
BKE_icon_id_delete(&la->id);
la->id.icon_id = 0;
}
+
+IDTypeInfo IDType_ID_LA = {
+ .id_code = ID_LA,
+ .id_filter = FILTER_ID_LA,
+ .main_listbase_index = INDEX_ID_LA,
+ .struct_size = sizeof(Light),
+ .name = "Light",
+ .name_plural = "lights",
+ .translation_context = BLT_I18NCONTEXT_ID_LIGHT,
+ .flags = 0,
+
+ .init_data = light_init_data,
+ .copy_data = light_copy_data,
+ .free_data = light_free_data,
+ .make_local = light_make_local,
+};
diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c
index 55e7b90d8cf..f360edfbf54 100644
--- a/source/blender/blenkernel/intern/lightprobe.c
+++ b/source/blender/blenkernel/intern/lightprobe.c
@@ -30,12 +30,16 @@
#include "BLI_utildefines.h"
#include "BKE_animsys.h"
+#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "BKE_lightprobe.h"
#include "BKE_main.h"
-void BKE_lightprobe_init(LightProbe *probe)
+#include "BLT_translation.h"
+
+static void lightprobe_init_data(ID *id)
{
+ LightProbe *probe = (LightProbe *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(probe, id));
MEMCPY_STRUCT_AFTER(probe, DNA_struct_default_get(LightProbe), id);
@@ -71,7 +75,7 @@ void *BKE_lightprobe_add(Main *bmain, const char *name)
probe = BKE_libblock_alloc(bmain, ID_LP, name, 0);
- BKE_lightprobe_init(probe);
+ lightprobe_init_data(&probe->id);
return probe;
}
@@ -86,10 +90,10 @@ void *BKE_lightprobe_add(Main *bmain, const char *name)
*
* \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
*/
-void BKE_lightprobe_copy_data(Main *UNUSED(bmain),
- LightProbe *UNUSED(probe_dst),
- const LightProbe *UNUSED(probe_src),
- const int UNUSED(flag))
+static void lightprobe_copy_data(Main *UNUSED(bmain),
+ ID *UNUSED(id_dst),
+ const ID *UNUSED(id_src),
+ const int UNUSED(flag))
{
/* Nothing to do here. */
}
@@ -101,12 +105,28 @@ LightProbe *BKE_lightprobe_copy(Main *bmain, const LightProbe *probe)
return probe_copy;
}
-void BKE_lightprobe_make_local(Main *bmain, LightProbe *probe, const int flags)
+static void lightprobe_make_local(Main *bmain, ID *id, const int flags)
{
- BKE_lib_id_make_local_generic(bmain, &probe->id, flags);
+ BKE_lib_id_make_local_generic(bmain, id, flags);
}
-void BKE_lightprobe_free(LightProbe *probe)
+static void lightprobe_free_data(ID *id)
{
- BKE_animdata_free((ID *)probe, false);
+ BKE_animdata_free(id, false);
}
+
+IDTypeInfo IDType_ID_LP = {
+ .id_code = ID_LP,
+ .id_filter = FILTER_ID_LP,
+ .main_listbase_index = INDEX_ID_LP,
+ .struct_size = sizeof(LightProbe),
+ .name = "LightProbe",
+ .name_plural = "lightprobes",
+ .translation_context = BLT_I18NCONTEXT_ID_LIGHTPROBE,
+ .flags = 0,
+
+ .init_data = lightprobe_init_data,
+ .copy_data = lightprobe_copy_data,
+ .free_data = lightprobe_free_data,
+ .make_local = lightprobe_make_local,
+};
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index f8ba4e3085e..398e53d6cda 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -37,11 +37,14 @@
#include "BKE_animsys.h"
#include "BKE_icons.h"
+#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_world.h"
+#include "BLT_translation.h"
+
#include "DRW_engine.h"
#include "DEG_depsgraph.h"
@@ -49,11 +52,12 @@
#include "GPU_material.h"
/** Free (or release) any data used by this world (does not free the world itself). */
-void BKE_world_free(World *wrld)
+static void world_free_data(ID *id)
{
- BKE_animdata_free((ID *)wrld, false);
+ World *wrld = (World *)id;
+ BKE_animdata_free(id, false);
- DRW_drawdata_free((ID *)wrld);
+ DRW_drawdata_free(id);
/* is no lib link block, but world extension */
if (wrld->nodetree) {
@@ -68,8 +72,9 @@ void BKE_world_free(World *wrld)
BKE_previewimg_free(&wrld->preview);
}
-void BKE_world_init(World *wrld)
+static void world_init_data(ID *id)
{
+ World *wrld = (World *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(wrld, id));
MEMCPY_STRUCT_AFTER(wrld, DNA_struct_default_get(World), id);
@@ -81,7 +86,7 @@ World *BKE_world_add(Main *bmain, const char *name)
wrld = BKE_libblock_alloc(bmain, ID_WO, name, 0);
- BKE_world_init(wrld);
+ world_init_data(&wrld->id);
return wrld;
}
@@ -96,8 +101,10 @@ World *BKE_world_add(Main *bmain, const char *name)
*
* \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
*/
-void BKE_world_copy_data(Main *bmain, World *wrld_dst, const World *wrld_src, const int flag)
+static void world_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag)
{
+ World *wrld_dst = (World *)id_dst;
+ const World *wrld_src = (const World *)id_src;
/* We always need allocation of our private ID data. */
const int flag_private_id_data = flag & ~LIB_ID_CREATE_NO_ALLOCATE;
@@ -154,11 +161,27 @@ World *BKE_world_localize(World *wrld)
return wrldn;
}
-void BKE_world_make_local(Main *bmain, World *wrld, const int flags)
+static void world_make_local(Main *bmain, ID *id, const int flags)
{
- BKE_lib_id_make_local_generic(bmain, &wrld->id, flags);
+ BKE_lib_id_make_local_generic(bmain, id, flags);
}
+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 = world_make_local,
+};
+
void BKE_world_eval(struct Depsgraph *depsgraph, World *world)
{
DEG_debug_print_eval(depsgraph, __func__, world->id.name, world);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index e2841f01ab5..b6c588c8c33 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -958,23 +958,7 @@ static void preview_id_copy_free(ID *id)
IDP_FreePropertyContent_ex(properties, false);
MEM_freeN(properties);
}
- switch (GS(id->name)) {
- case ID_MA:
- BKE_material_free((Material *)id);
- break;
- case ID_TE:
- BKE_texture_free((Tex *)id);
- break;
- case ID_LA:
- BKE_light_free((Light *)id);
- break;
- case ID_WO:
- BKE_world_free((World *)id);
- break;
- default:
- BLI_assert(!"ID type preview not supported.");
- break;
- }
+ BKE_libblock_free_datablock(id, 0);
MEM_freeN(id);
}