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:
authorJacques Lucke <jacques@blender.org>2020-09-10 17:13:18 +0300
committerJacques Lucke <jacques@blender.org>2020-09-10 17:13:18 +0300
commit94c533ac35d4ad5d944c214d4809011b61be4a94 (patch)
treeea8fdf7808c6e1b96c85dfb4b633d122b6d99a03 /source/blender/blenkernel/intern/light.c
parentede094f9b207209fbd8e1d52160189ef1ed0a8c1 (diff)
Refactor: move Light .blend I/O to IDTypeInfo callbacks
Diffstat (limited to 'source/blender/blenkernel/intern/light.c')
-rw-r--r--source/blender/blenkernel/intern/light.c67
1 files changed, 63 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index 976fa010057..1ce079b006e 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -25,6 +25,9 @@
#include "MEM_guardedalloc.h"
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#include "DNA_anim_types.h"
#include "DNA_defaults.h"
#include "DNA_light_types.h"
@@ -37,6 +40,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BKE_anim_data.h"
#include "BKE_colortools.h"
#include "BKE_icons.h"
#include "BKE_idtype.h"
@@ -50,6 +54,8 @@
#include "DEG_depsgraph.h"
+#include "BLO_read_write.h"
+
static void light_init_data(ID *id)
{
Light *la = (Light *)id;
@@ -119,6 +125,59 @@ static void light_foreach_id(ID *id, LibraryForeachIDData *data)
}
}
+static void light_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ Light *la = (Light *)id;
+ if (la->id.us > 0 || BLO_write_is_undo(writer)) {
+ /* write LibData */
+ BLO_write_id_struct(writer, Light, id_address, &la->id);
+ BKE_id_blend_write(writer, &la->id);
+
+ if (la->adt) {
+ BKE_animdata_blend_write(writer, la->adt);
+ }
+
+ if (la->curfalloff) {
+ BKE_curvemapping_blend_write(writer, la->curfalloff);
+ }
+
+ /* Node-tree is integral part of lights, no libdata. */
+ if (la->nodetree) {
+ BLO_write_struct(writer, bNodeTree, la->nodetree);
+ ntreeBlendWrite(writer, la->nodetree);
+ }
+
+ BKE_previewimg_blend_write(writer, la->preview);
+ }
+}
+
+static void light_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ Light *la = (Light *)id;
+ BLO_read_data_address(reader, &la->adt);
+ BKE_animdata_blend_read_data(reader, la->adt);
+
+ BLO_read_data_address(reader, &la->curfalloff);
+ if (la->curfalloff) {
+ BKE_curvemapping_blend_read(reader, la->curfalloff);
+ }
+
+ BLO_read_data_address(reader, &la->preview);
+ BKE_previewimg_blend_read(reader, la->preview);
+}
+
+static void light_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+ Light *la = (Light *)id;
+ BLO_read_id_address(reader, la->id.lib, &la->ipo); // XXX deprecated - old animation system
+}
+
+static void light_blend_read_expand(BlendExpander *expander, ID *id)
+{
+ Light *la = (Light *)id;
+ BLO_expand(expander, la->ipo); // XXX deprecated - old animation system
+}
+
IDTypeInfo IDType_ID_LA = {
.id_code = ID_LA,
.id_filter = FILTER_ID_LA,
@@ -136,10 +195,10 @@ IDTypeInfo IDType_ID_LA = {
.foreach_id = light_foreach_id,
.foreach_cache = NULL,
- .blend_write = NULL,
- .blend_read_data = NULL,
- .blend_read_lib = NULL,
- .blend_read_expand = NULL,
+ .blend_write = light_blend_write,
+ .blend_read_data = light_blend_read_data,
+ .blend_read_lib = light_blend_read_lib,
+ .blend_read_expand = light_blend_read_expand,
};
Light *BKE_light_add(Main *bmain, const char *name)