Blender  V3.3
lightprobe.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright Blender Foundation. All rights reserved. */
3 
8 #include <string.h>
9 
10 #include "DNA_collection_types.h"
11 #include "DNA_defaults.h"
12 #include "DNA_lightprobe_types.h"
13 #include "DNA_object_types.h"
14 
15 #include "BLI_utildefines.h"
16 
17 #include "BKE_anim_data.h"
18 #include "BKE_idtype.h"
19 #include "BKE_lib_id.h"
20 #include "BKE_lib_query.h"
21 #include "BKE_lightprobe.h"
22 #include "BKE_main.h"
23 
24 #include "BLT_translation.h"
25 
26 #include "BLO_read_write.h"
27 
28 static void lightprobe_init_data(ID *id)
29 {
30  LightProbe *probe = (LightProbe *)id;
32 
34 }
35 
37 {
38  LightProbe *probe = (LightProbe *)id;
39 
42 }
43 
44 static void lightprobe_blend_write(BlendWriter *writer, ID *id, const void *id_address)
45 {
46  LightProbe *prb = (LightProbe *)id;
47 
48  /* write LibData */
49  BLO_write_id_struct(writer, LightProbe, id_address, &prb->id);
50  BKE_id_blend_write(writer, &prb->id);
51 
52  if (prb->adt) {
53  BKE_animdata_blend_write(writer, prb->adt);
54  }
55 }
56 
58 {
59  LightProbe *prb = (LightProbe *)id;
60  BLO_read_data_address(reader, &prb->adt);
61  BKE_animdata_blend_read_data(reader, prb->adt);
62 }
63 
64 static void lightprobe_blend_read_lib(BlendLibReader *reader, ID *id)
65 {
66  LightProbe *prb = (LightProbe *)id;
67  BLO_read_id_address(reader, prb->id.lib, &prb->visibility_grp);
68 }
69 
71  .id_code = ID_LP,
72  .id_filter = FILTER_ID_LP,
73  .main_listbase_index = INDEX_ID_LP,
74  .struct_size = sizeof(LightProbe),
75  .name = "LightProbe",
76  .name_plural = "lightprobes",
77  .translation_context = BLT_I18NCONTEXT_ID_LIGHTPROBE,
79  .asset_type_info = NULL,
80 
82  .copy_data = NULL,
83  .free_data = NULL,
84  .make_local = NULL,
85  .foreach_id = lightprobe_foreach_id,
86  .foreach_cache = NULL,
87  .foreach_path = NULL,
88  .owner_get = NULL,
89 
90  .blend_write = lightprobe_blend_write,
91  .blend_read_data = lightprobe_blend_read_data,
92  .blend_read_lib = lightprobe_blend_read_lib,
93  .blend_read_expand = NULL,
94 
95  .blend_read_undo_preserve = NULL,
96 
97  .lib_override_apply_post = NULL,
98 };
99 
100 void BKE_lightprobe_type_set(LightProbe *probe, const short lightprobe_type)
101 {
102  probe->type = lightprobe_type;
103 
104  switch (probe->type) {
106  probe->distinf = 0.3f;
107  probe->falloff = 1.0f;
108  probe->clipsta = 0.01f;
109  break;
111  probe->distinf = 0.1f;
112  probe->falloff = 0.5f;
113  probe->clipsta = 0.001f;
114  break;
117  break;
118  default:
119  BLI_assert_msg(0, "LightProbe type not configured.");
120  break;
121  }
122 }
123 
124 void *BKE_lightprobe_add(Main *bmain, const char *name)
125 {
126  LightProbe *probe;
127 
128  probe = BKE_id_new(bmain, ID_LP, name);
129 
130  return probe;
131 }
void BKE_animdata_blend_read_data(struct BlendDataReader *reader, struct AnimData *adt)
Definition: anim_data.c:1443
void BKE_animdata_blend_write(struct BlendWriter *writer, struct AnimData *adt)
Definition: anim_data.c:1421
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
Definition: BKE_idtype.h:39
void BKE_id_blend_write(struct BlendWriter *writer, struct ID *id)
Definition: lib_id.c:2008
void * BKE_id_new(struct Main *bmain, short type, const char *name)
Definition: lib_id.c:1159
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(_data, _id_super, _cb_flag)
@ IDWALK_CB_USER
Definition: BKE_lib_query.h:73
@ IDWALK_CB_NOP
Definition: BKE_lib_query.h:33
General operations for probes.
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define BLO_read_data_address(reader, ptr_p)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_read_id_address(reader, lib, id_ptr_p)
#define BLT_I18NCONTEXT_ID_LIGHTPROBE
@ INDEX_ID_LP
Definition: DNA_ID.h:1036
#define FILTER_ID_LP
Definition: DNA_ID.h:929
@ ID_LP
Definition: DNA_ID_enums.h:80
Object groups, one object can be in many groups at once.
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:29
@ LIGHTPROBE_SHAPE_ELIPSOID
struct LightProbe LightProbe
@ LIGHTPROBE_TYPE_CUBE
@ LIGHTPROBE_TYPE_PLANAR
@ LIGHTPROBE_TYPE_GRID
Object is a sort of wrapper for general info.
static void init_data(ModifierData *md)
static void lightprobe_blend_read_lib(BlendLibReader *reader, ID *id)
Definition: lightprobe.c:64
static void lightprobe_blend_read_data(BlendDataReader *reader, ID *id)
Definition: lightprobe.c:57
void BKE_lightprobe_type_set(LightProbe *probe, const short lightprobe_type)
Definition: lightprobe.c:100
static void lightprobe_init_data(ID *id)
Definition: lightprobe.c:28
static void lightprobe_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition: lightprobe.c:44
IDTypeInfo IDType_ID_LP
Definition: lightprobe.c:70
void * BKE_lightprobe_add(Main *bmain, const char *name)
Definition: lightprobe.c:124
static void lightprobe_foreach_id(ID *id, LibraryForeachIDData *data)
Definition: lightprobe.c:36
short id_code
Definition: BKE_idtype.h:114
Definition: DNA_ID.h:368
struct Library * lib
Definition: DNA_ID.h:372
struct AnimData * adt
struct Collection * visibility_grp
struct Image * image
Definition: BKE_main.h:121