1
1

Compare commits

...

49 Commits

Author SHA1 Message Date
e003c31ca0 cleanups 2020-03-08 12:39:19 +01:00
429e85c33a avoid some unnecessary changes 2020-03-08 12:29:24 +01:00
d2f2f732a5 add comment in ModifierTypeInfo 2020-03-08 12:24:51 +01:00
7502cdd86f improve naming 2020-03-08 12:16:33 +01:00
4e742352ec improve naming 2020-03-08 12:13:44 +01:00
f0b75491e9 avoid unnecesary changes in writefile 2020-03-08 12:09:49 +01:00
d7858eedbf improve naming 2020-03-08 12:06:31 +01:00
7a5da6a16c improve naming 2020-03-08 12:03:13 +01:00
5a90d35f79 use less nested preprocessing 2020-03-07 19:20:40 +01:00
fb29231e45 update armature modifier 2020-03-07 19:06:17 +01:00
ab673563e8 update subsurf modifier 2020-03-07 19:05:24 +01:00
bc317808d6 update explode modifier 2020-03-07 19:04:06 +01:00
5961d6565b update particle system modifier 2020-03-07 19:02:56 +01:00
acc05a1053 update surface modifier 2020-03-07 19:01:23 +01:00
dc3b6617bb update ocean modifier 2020-03-07 19:00:01 +01:00
d912bb9cce update mesh sequence cache modifier 2020-03-07 18:58:28 +01:00
23a071ee6c update dynamic paint 2020-03-07 18:56:28 +01:00
d807418a45 update warp modifier 2020-03-07 18:47:04 +01:00
9ad3a3754f update vertex weight edit modifier 2020-03-07 18:44:00 +01:00
b9a4a3ece5 improve parameter order 2020-03-07 18:37:37 +01:00
f563674d58 update laplacian deform modifier 2020-03-07 18:32:32 +01:00
0fa3a00f34 cleanup naming 2020-03-07 18:27:28 +01:00
7ed6e3a5ef simplify writing array 2020-03-07 18:23:46 +01:00
c6e61edb34 update corrective smooth modifier 2020-03-07 18:13:15 +01:00
a883e0a30e update bevel modifier 2020-03-07 18:03:50 +01:00
cfa101cf46 update surface deform modifier 2020-03-07 17:59:22 +01:00
520db97acf move meshdeform modifier writing/reading 2020-03-07 17:41:13 +01:00
6f77056dca move cloth modifier file writing/reading to MOD_cloth.c 2020-03-07 17:22:55 +01:00
0d444bd3ef simplify reading raw arrays of primitive types 2020-03-07 17:14:45 +01:00
0e52777cf0 add bloRead method to ModifierTypeInfo 2020-03-07 17:03:53 +01:00
f9e4086b04 write raw array utility 2020-03-07 16:53:35 +01:00
192091903e move hook modifier file writing into MOD_hook.c 2020-03-07 16:49:37 +01:00
681ff0c789 Add bloWrite callback to ModifierTypeInfo definitions of individual modifiers 2020-03-07 16:41:55 +01:00
081311d168 add blenloader write callback to ModifierTypeInfo 2020-03-07 16:38:00 +01:00
e41f2c1238 improve naming 2020-03-07 16:33:54 +01:00
ac7d45cc19 try different naming convention 2020-03-07 16:30:33 +01:00
eafb864bfe Merge branch 'master' into blenloader-api 2020-03-07 16:18:25 +01:00
fb13e40ce1 move curve profile writing/reading to blenkernel 2020-03-07 16:17:52 +01:00
ff86d46805 move point cache reading to blenkernel 2020-03-07 16:06:15 +01:00
ecb4c5d8a4 change parameter order 2020-03-07 13:20:33 +01:00
a0ec12a249 move pointcache file writing to blenkernel 2020-03-07 13:17:15 +01:00
c3c2ea39b2 move blenloader callback api to single file 2020-03-07 13:05:16 +01:00
ac8d26974e cleanup curve mapping reading 2020-03-07 12:58:45 +01:00
d7839734a0 utility for updating addresses 2020-03-07 12:58:32 +01:00
672372583e move curvemapping file handling to blenkernel 2020-03-07 12:52:00 +01:00
4c95dc5a1b fix api 2020-03-07 12:51:27 +01:00
7adcc0731e improve naming 2020-03-07 12:25:16 +01:00
7c08cd508a improve naming 2020-03-07 12:21:10 +01:00
a9f39fa197 initial blenloader api 2020-03-06 14:50:39 +01:00
67 changed files with 901 additions and 516 deletions

View File

@@ -37,6 +37,8 @@ struct Histogram;
struct ImBuf;
struct Scopes;
struct rctf;
struct BloWriter;
struct BloReader;
void BKE_curvemapping_set_defaults(
struct CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy);
@@ -51,6 +53,9 @@ void BKE_curvemapping_set_black_white_ex(const float black[3],
void BKE_curvemapping_set_black_white(struct CurveMapping *cumap,
const float black[3],
const float white[3]);
void BKE_curvemapping_blo_write(struct BloWriter *writer, struct CurveMapping *cumap);
void BKE_curvemapping_blo_write_content(struct BloWriter *writer, struct CurveMapping *cumap);
void BKE_curvemapping_blo_read(struct BloReader *reader, struct CurveMapping *cumap);
enum {
CURVEMAP_SLOPE_NEGATIVE = 0,

View File

@@ -30,6 +30,8 @@ extern "C" {
struct CurveProfile;
struct CurveProfilePoint;
struct BloWriter;
struct BloReader;
void BKE_curveprofile_set_defaults(struct CurveProfile *profile);
@@ -78,6 +80,9 @@ void BKE_curveprofile_evaluate_length_portion(const struct CurveProfile *profile
float *x_out,
float *y_out);
void BKE_curveprofile_blo_write(struct BloWriter *writer, const struct CurveProfile *profile);
void BKE_curveprofile_blo_read(struct BloReader *reader, struct CurveProfile *profile);
#ifdef __cplusplus
}
#endif

View File

@@ -40,6 +40,8 @@ struct ModifierData;
struct Object;
struct Scene;
struct bArmature;
struct BloWriter;
struct BloReader;
typedef enum {
/* Should not be used, only for None modifier type */
@@ -333,6 +335,21 @@ typedef struct ModifierTypeInfo {
* more like "ensure the data is freed".
*/
void (*freeRuntimeData)(void *runtime_data);
/* Is called when the modifier is written to a file. The modifier data struct itself is written
* already.
*
* This method should write any additional arrays and referenced structs that should be
* stored in the file.
*/
void (*bloWrite)(struct BloWriter *writer, const struct ModifierData *md);
/* Is called when the modifier is read from a file.
*
* It can be used to update pointers to arrays and other structs. Furthermore, fields that have
* not been written (e.g. runtime data) can be reset.
*/
void (*bloRead)(struct BloReader *reader, struct ModifierData *md);
} ModifierTypeInfo;
/* Initialize modifier's global data (type info and some common global storages). */

View File

@@ -90,6 +90,8 @@ struct RigidBodyWorld;
struct Scene;
struct SoftBody;
struct ViewLayer;
struct BloWriter;
struct BloReader;
struct OpenVDBReader;
struct OpenVDBWriter;
@@ -340,6 +342,12 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old);
/* Main cache writing call. */
int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra);
void BKE_ptcache_blo_write_list(struct BloWriter *writer, struct ListBase *ptcaches);
void BKE_ptcache_blo_read(struct BloReader *reader,
struct ListBase *ptcaches,
struct PointCache **ocache,
int force_disk);
/******************* Allocate & free ***************/
struct PointCache *BKE_ptcache_add(struct ListBase *ptcaches);
void BKE_ptcache_free_mem(struct ListBase *mem_cache);

View File

@@ -44,6 +44,8 @@
#include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
#include "BLO_callback_api.h"
/* ********************************* color curve ********************* */
/* ***************** operations on full struct ************* */
@@ -178,6 +180,30 @@ void BKE_curvemapping_set_black_white(CurveMapping *cumap,
cumap->changed_timestamp++;
}
void BKE_curvemapping_blo_write(BloWriter *writer, CurveMapping *cumap)
{
BLO_write_struct(writer, CurveMapping, cumap);
BKE_curvemapping_blo_write_content(writer, cumap);
}
void BKE_curvemapping_blo_write_content(BloWriter *writer, CurveMapping *cumap)
{
for (int i = 0; i < CM_TOT; i++) {
BLO_write_struct_array(writer, CurveMapPoint, cumap->cm[i].totpoint, cumap->cm[i].curve);
}
}
void BKE_curvemapping_blo_read(struct BloReader *reader, struct CurveMapping *cumap)
{
cumap->flag &= ~CUMA_PREMULLED;
for (int i = 0; i < CM_TOT; i++) {
BLO_read_data_address(reader, cumap->cm[i].curve);
cumap->cm[i].table = NULL;
cumap->cm[i].premultable = NULL;
}
}
/* ***************** operations on single curve ************* */
/* ********** NOTE: requires BKE_curvemapping_changed() call after ******** */

View File

@@ -41,6 +41,8 @@
#include "BKE_curve.h"
#include "BKE_fcurve.h"
#include "BLO_callback_api.h"
void BKE_curveprofile_free_data(CurveProfile *profile)
{
MEM_SAFE_FREE(profile->path);
@@ -1070,3 +1072,16 @@ void BKE_curveprofile_evaluate_length_portion(const CurveProfile *profile,
*x_out = interpf(profile->table[i].x, profile->table[i + 1].x, lerp_factor);
*y_out = interpf(profile->table[i].y, profile->table[i + 1].y, lerp_factor);
}
void BKE_curveprofile_blo_write(BloWriter *writer, const CurveProfile *profile)
{
BLO_write_struct(writer, CurveProfile, profile);
BLO_write_struct_array(writer, CurveProfilePoint, profile->path_len, profile->path);
}
void BKE_curveprofile_blo_read(BloReader *reader, CurveProfile *profile)
{
BLO_read_data_address(reader, profile->path);
profile->table = NULL;
profile->segments = NULL;
}

View File

@@ -43,6 +43,7 @@
#include "DNA_fluid_types.h"
#include "BLI_blenlib.h"
#include "BLI_endian_switch.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
@@ -67,6 +68,8 @@
#include "BKE_fluid.h"
#include "BKE_softbody.h"
#include "BLO_callback_api.h"
#include "BIK_api.h"
#ifdef WITH_BULLET
@@ -3345,6 +3348,137 @@ int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra)
* mode - PTCACHE_CLEAR_ALL,
*/
static const char *ptcache_data_struct[] = {
"", // BPHYS_DATA_INDEX
"", // BPHYS_DATA_LOCATION
"", // BPHYS_DATA_VELOCITY
"", // BPHYS_DATA_ROTATION
"", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
"", // BPHYS_DATA_SIZE:
"", // BPHYS_DATA_TIMES:
"BoidData", // case BPHYS_DATA_BOIDS:
};
static const char *ptcache_extra_struct[] = {
"",
"ParticleSpring",
};
void BKE_ptcache_blo_write_list(BloWriter *writer, ListBase *ptcaches)
{
PointCache *cache = ptcaches->first;
int i;
for (; cache; cache = cache->next) {
BLO_write_struct(writer, PointCache, cache);
if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
PTCacheMem *pm = cache->mem_cache.first;
for (; pm; pm = pm->next) {
PTCacheExtra *extra = pm->extradata.first;
BLO_write_struct(writer, PTCacheMem, pm);
for (i = 0; i < BPHYS_TOT_DATA; i++) {
if (pm->data[i] && pm->data_types & (1 << i)) {
if (ptcache_data_struct[i][0] == '\0') {
BLO_write_raw(writer, MEM_allocN_len(pm->data[i]), pm->data[i]);
}
else {
BLO_write_struct_array_by_name(
writer, ptcache_data_struct[i], pm->totpoint, pm->data[i]);
}
}
}
for (; extra; extra = extra->next) {
if (ptcache_extra_struct[extra->type][0] == '\0') {
continue;
}
BLO_write_struct(writer, PTCacheExtra, extra);
BLO_write_struct_array_by_name(
writer, ptcache_extra_struct[extra->type], extra->totdata, extra->data);
}
}
}
}
}
static void file_read_pointcache_cb(BloReader *reader, void *data)
{
PTCacheMem *pm = data;
PTCacheExtra *extra;
int i;
for (i = 0; i < BPHYS_TOT_DATA; i++) {
BLO_read_data_address(reader, pm->data[i]);
/* the cache saves non-struct data without DNA */
if (pm->data[i] && ptcache_data_struct[i][0] == '\0' &&
BLO_read_requires_endian_switch(reader)) {
/* data_size returns bytes. */
int tot = (BKE_ptcache_data_size(i) * pm->totpoint) / sizeof(int);
int *poin = pm->data[i];
BLI_endian_switch_int32_array(poin, tot);
}
}
BLO_read_list(reader, &pm->extradata, NULL);
for (extra = pm->extradata.first; extra; extra = extra->next) {
BLO_read_data_address(reader, extra->data);
}
}
static void file_read_pointcache(BloReader *reader, PointCache *cache)
{
if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
BLO_read_list(reader, &cache->mem_cache, file_read_pointcache_cb);
}
else {
BLI_listbase_clear(&cache->mem_cache);
}
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe = 0;
cache->edit = NULL;
cache->free_edit = NULL;
cache->cached_frames = NULL;
cache->cached_frames_len = 0;
}
void BKE_ptcache_blo_read(struct BloReader *reader,
struct ListBase *ptcaches,
struct PointCache **ocache,
int force_disk)
{
if (ptcaches->first) {
PointCache *cache = NULL;
BLO_read_list(reader, ptcaches, NULL);
for (cache = ptcaches->first; cache; cache = cache->next) {
file_read_pointcache(reader, cache);
if (force_disk) {
cache->flag |= PTCACHE_DISK_CACHE;
cache->step = 1;
}
}
BLO_read_data_address(reader, *ocache);
}
else if (*ocache) {
/* old "single" caches need to be linked too */
BLO_read_data_address(reader, *ocache);
file_read_pointcache(reader, *ocache);
if (force_disk) {
(*ocache)->flag |= PTCACHE_DISK_CACHE;
(*ocache)->step = 1;
}
ptcaches->first = ptcaches->last = *ocache;
}
}
/* Clears & resets */
void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
{

View File

@@ -0,0 +1,78 @@
#ifndef __BLO_CALLBACK_API_H__
#define __BLO_CALLBACK_API_H__
#include "BLI_endian_switch.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct BloWriter BloWriter;
typedef struct BloReader BloReader;
/* API for file writing.
**********************************************/
void BLO_write_raw(BloWriter *writer, int size_in_bytes, const void *data_ptr);
void BLO_write_struct_by_name(BloWriter *writer, const char *struct_name, const void *data_ptr);
void BLO_write_struct_array_by_name(BloWriter *writer,
const char *struct_name,
int array_size,
const void *data_ptr);
void BLO_write_struct_by_id(BloWriter *writer, int struct_id, const void *data_ptr);
void BLO_write_struct_array_by_id(BloWriter *writer,
int struct_id,
int array_size,
const void *data_ptr);
int BLO_get_struct_id_by_name(BloWriter *writer, const char *struct_name);
#define BLO_get_struct_id(writer, struct_name) BLO_get_struct_id_by_name(writer, #struct_name)
#define BLO_write_struct(writer, struct_name, data_ptr) \
BLO_write_struct_by_id(writer, BLO_get_struct_id(writer, struct_name), data_ptr)
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr) \
BLO_write_struct_array_by_id( \
writer, BLO_get_struct_id(writer, struct_name), array_size, data_ptr)
void BLO_write_int32_array(BloWriter *writer, int size, const int32_t *data_ptr);
void BLO_write_uint32_array(BloWriter *writer, int size, const uint32_t *data_ptr);
void BLO_write_float_array(BloWriter *writer, int size, const float *data_ptr);
void BLO_write_float3_array(BloWriter *writer, int size, const float *data_ptr);
/* API for file reading.
**********************************************/
void *BLO_read_get_new_data_address(BloReader *reader, const void *old_address);
bool BLO_read_requires_endian_switch(BloReader *reader);
#define BLO_read_data_address(reader, ptr) ptr = BLO_read_get_new_data_address(reader, ptr)
typedef void (*BloReadListFn)(BloReader *reader, void *data);
void BLO_read_list(BloReader *reader, struct ListBase *list, BloReadListFn callback);
#define BLO_read_int32_array(reader, array_size, ptr) \
BLO_read_data_address(reader, ptr); \
if (BLO_read_requires_endian_switch(reader)) { \
BLI_endian_switch_int32_array((int32_t *)ptr, array_size); \
}
#define BLO_read_uint32_array(reader, array_size, ptr) \
BLO_read_data_address(reader, ptr); \
if (BLO_read_requires_endian_switch(reader)) { \
BLI_endian_switch_uint32_array((uint32_t *)ptr, array_size); \
}
#define BLO_read_float_array(reader, array_size, ptr) \
BLO_read_data_address(reader, ptr); \
if (BLO_read_requires_endian_switch(reader)) { \
BLI_endian_switch_float_array((float *)ptr, array_size); \
}
#define BLO_read_float3_array(reader, array_size, ptr) \
BLO_read_float_array(reader, 3 * (int)(array_size), ptr)
#ifdef __cplusplus
}
#endif
#endif /* __BLO_CALLBACK_API_H__ */

View File

@@ -62,6 +62,7 @@ set(SRC
BLO_blend_defs.h
BLO_blend_validate.h
BLO_callback_api.h
BLO_readfile.h
BLO_undofile.h
BLO_writefile.h

View File

@@ -112,6 +112,7 @@
#include "BKE_colortools.h"
#include "BKE_constraint.h"
#include "BKE_curve.h"
#include "BKE_curveprofile.h"
#include "BKE_effect.h"
#include "BKE_fcurve.h"
#include "BKE_fluid.h"
@@ -154,6 +155,7 @@
#include "BLO_blend_validate.h"
#include "BLO_readfile.h"
#include "BLO_undofile.h"
#include "BLO_callback_api.h"
#include "RE_engine.h"
@@ -702,6 +704,16 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
/** \name File Parsing
* \{ */
static BloReader *wrap_reader(FileData *fd)
{
return (BloReader *)fd;
}
static FileData *unwrap_reader(BloReader *reader)
{
return (FileData *)reader;
}
static void switch_endian_bh4(BHead4 *bhead)
{
/* the ID_.. codes */
@@ -2725,29 +2737,7 @@ static void direct_link_id(FileData *fd, ID *id)
/* cuma itself has been read! */
static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap)
{
int a;
/* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
cumap->flag &= ~CUMA_PREMULLED;
for (a = 0; a < CM_TOT; a++) {
cumap->cm[a].curve = newdataadr(fd, cumap->cm[a].curve);
cumap->cm[a].table = NULL;
cumap->cm[a].premultable = NULL;
}
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Read CurveProfile
* \{ */
static void direct_link_curveprofile(FileData *fd, CurveProfile *profile)
{
profile->path = newdataadr(fd, profile->path);
profile->table = NULL;
profile->segments = NULL;
BKE_curvemapping_blo_read(wrap_reader(fd), cumap);
}
/** \} */
@@ -4345,90 +4335,12 @@ static void direct_link_material(FileData *fd, Material *ma)
/** \name Read ID: Particle Settings
* \{ */
/* update this also to writefile.c */
static const char *ptcache_data_struct[] = {
"", // BPHYS_DATA_INDEX
"", // BPHYS_DATA_LOCATION
"", // BPHYS_DATA_VELOCITY
"", // BPHYS_DATA_ROTATION
"", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
"", // BPHYS_DATA_SIZE:
"", // BPHYS_DATA_TIMES:
"BoidData", // case BPHYS_DATA_BOIDS:
};
static void direct_link_pointcache_cb(FileData *fd, void *data)
{
PTCacheMem *pm = data;
PTCacheExtra *extra;
int i;
for (i = 0; i < BPHYS_TOT_DATA; i++) {
pm->data[i] = newdataadr(fd, pm->data[i]);
/* the cache saves non-struct data without DNA */
if (pm->data[i] && ptcache_data_struct[i][0] == '\0' && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
/* data_size returns bytes. */
int tot = (BKE_ptcache_data_size(i) * pm->totpoint) / sizeof(int);
int *poin = pm->data[i];
BLI_endian_switch_int32_array(poin, tot);
}
}
link_list(fd, &pm->extradata);
for (extra = pm->extradata.first; extra; extra = extra->next) {
extra->data = newdataadr(fd, extra->data);
}
}
static void direct_link_pointcache(FileData *fd, PointCache *cache)
{
if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
link_list_ex(fd, &cache->mem_cache, direct_link_pointcache_cb);
}
else {
BLI_listbase_clear(&cache->mem_cache);
}
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe = 0;
cache->edit = NULL;
cache->free_edit = NULL;
cache->cached_frames = NULL;
cache->cached_frames_len = 0;
}
static void direct_link_pointcache_list(FileData *fd,
ListBase *ptcaches,
PointCache **ocache,
int force_disk)
{
if (ptcaches->first) {
PointCache *cache = NULL;
link_list(fd, ptcaches);
for (cache = ptcaches->first; cache; cache = cache->next) {
direct_link_pointcache(fd, cache);
if (force_disk) {
cache->flag |= PTCACHE_DISK_CACHE;
cache->step = 1;
}
}
*ocache = newdataadr(fd, *ocache);
}
else if (*ocache) {
/* old "single" caches need to be linked too */
*ocache = newdataadr(fd, *ocache);
direct_link_pointcache(fd, *ocache);
if (force_disk) {
(*ocache)->flag |= PTCACHE_DISK_CACHE;
(*ocache)->step = 1;
}
ptcaches->first = ptcaches->last = *ocache;
}
BKE_ptcache_blo_read(wrap_reader(fd), ptcaches, ocache, force_disk);
}
static void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd)
@@ -5383,49 +5295,16 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb, Object *ob)
is_allocated = true;
}
/* if modifiers disappear, or for upward compatibility */
if (NULL == modifierType_getInfo(md->type)) {
const ModifierTypeInfo *mdi = modifierType_getInfo(md->type);
if (mdi == NULL) {
md->type = eModifierType_None;
}
if (is_allocated) {
/* All the fields has been properly allocated. */
}
else if (md->type == eModifierType_Subsurf) {
SubsurfModifierData *smd = (SubsurfModifierData *)md;
smd->emCache = smd->mCache = NULL;
}
else if (md->type == eModifierType_Armature) {
ArmatureModifierData *amd = (ArmatureModifierData *)md;
amd->prevCos = NULL;
}
else if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
clmd->clothObject = NULL;
clmd->hairdata = NULL;
clmd->sim_parms = newdataadr(fd, clmd->sim_parms);
clmd->coll_parms = newdataadr(fd, clmd->coll_parms);
direct_link_pointcache_list(fd, &clmd->ptcaches, &clmd->point_cache, 0);
if (clmd->sim_parms) {
if (clmd->sim_parms->presets > 10) {
clmd->sim_parms->presets = 0;
}
clmd->sim_parms->reset = 0;
clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights);
if (!clmd->sim_parms->effector_weights) {
clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL);
}
}
clmd->solver_result = NULL;
else if (mdi && mdi->bloRead) {
mdi->bloRead(wrap_reader(fd), md);
}
else if (md->type == eModifierType_Fluid) {
@@ -5506,37 +5385,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb, Object *ob)
}
}
}
else if (md->type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if (pmd->canvas) {
pmd->canvas = newdataadr(fd, pmd->canvas);
pmd->canvas->pmd = pmd;
pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
if (pmd->canvas->surfaces.first) {
DynamicPaintSurface *surface;
link_list(fd, &pmd->canvas->surfaces);
for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
surface->canvas = pmd->canvas;
surface->data = NULL;
direct_link_pointcache_list(fd, &(surface->ptcaches), &(surface->pointcache), 1);
if (!(surface->effector_weights = newdataadr(fd, surface->effector_weights))) {
surface->effector_weights = BKE_effector_add_weights(NULL);
}
}
}
}
if (pmd->brush) {
pmd->brush = newdataadr(fd, pmd->brush);
pmd->brush->pmd = pmd;
pmd->brush->psys = newdataadr(fd, pmd->brush->psys);
pmd->brush->paint_ramp = newdataadr(fd, pmd->brush->paint_ramp);
pmd->brush->vel_ramp = newdataadr(fd, pmd->brush->vel_ramp);
}
}
else if (md->type == eModifierType_Collision) {
CollisionModifierData *collmd = (CollisionModifierData *)md;
#if 0
@@ -5563,166 +5411,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb, Object *ob)
collmd->bvhtree = NULL;
collmd->tri = NULL;
}
else if (md->type == eModifierType_Surface) {
SurfaceModifierData *surmd = (SurfaceModifierData *)md;
surmd->mesh = NULL;
surmd->bvhtree = NULL;
surmd->x = NULL;
surmd->v = NULL;
surmd->numverts = 0;
}
else if (md->type == eModifierType_Hook) {
HookModifierData *hmd = (HookModifierData *)md;
hmd->indexar = newdataadr(fd, hmd->indexar);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
BLI_endian_switch_int32_array(hmd->indexar, hmd->totindex);
}
hmd->curfalloff = newdataadr(fd, hmd->curfalloff);
if (hmd->curfalloff) {
direct_link_curvemapping(fd, hmd->curfalloff);
}
}
else if (md->type == eModifierType_ParticleSystem) {
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
psmd->mesh_final = NULL;
psmd->mesh_original = NULL;
psmd->psys = newdataadr(fd, psmd->psys);
psmd->flag &= ~eParticleSystemFlag_psys_updated;
psmd->flag |= eParticleSystemFlag_file_loaded;
}
else if (md->type == eModifierType_Explode) {
ExplodeModifierData *psmd = (ExplodeModifierData *)md;
psmd->facepa = NULL;
}
else if (md->type == eModifierType_MeshDeform) {
MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
mmd->bindinfluences = newdataadr(fd, mmd->bindinfluences);
mmd->bindoffsets = newdataadr(fd, mmd->bindoffsets);
mmd->bindcagecos = newdataadr(fd, mmd->bindcagecos);
mmd->dyngrid = newdataadr(fd, mmd->dyngrid);
mmd->dyninfluences = newdataadr(fd, mmd->dyninfluences);
mmd->dynverts = newdataadr(fd, mmd->dynverts);
mmd->bindweights = newdataadr(fd, mmd->bindweights);
mmd->bindcos = newdataadr(fd, mmd->bindcos);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
if (mmd->bindoffsets) {
BLI_endian_switch_int32_array(mmd->bindoffsets, mmd->totvert + 1);
}
if (mmd->bindcagecos) {
BLI_endian_switch_float_array(mmd->bindcagecos, mmd->totcagevert * 3);
}
if (mmd->dynverts) {
BLI_endian_switch_int32_array(mmd->dynverts, mmd->totvert);
}
if (mmd->bindweights) {
BLI_endian_switch_float_array(mmd->bindweights, mmd->totvert);
}
if (mmd->bindcos) {
BLI_endian_switch_float_array(mmd->bindcos, mmd->totcagevert * 3);
}
}
}
else if (md->type == eModifierType_Ocean) {
OceanModifierData *omd = (OceanModifierData *)md;
omd->oceancache = NULL;
omd->ocean = NULL;
}
else if (md->type == eModifierType_Warp) {
WarpModifierData *tmd = (WarpModifierData *)md;
tmd->curfalloff = newdataadr(fd, tmd->curfalloff);
if (tmd->curfalloff) {
direct_link_curvemapping(fd, tmd->curfalloff);
}
}
else if (md->type == eModifierType_WeightVGEdit) {
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
wmd->cmap_curve = newdataadr(fd, wmd->cmap_curve);
if (wmd->cmap_curve) {
direct_link_curvemapping(fd, wmd->cmap_curve);
}
}
else if (md->type == eModifierType_LaplacianDeform) {
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
lmd->vertexco = newdataadr(fd, lmd->vertexco);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
BLI_endian_switch_float_array(lmd->vertexco, lmd->total_verts * 3);
}
lmd->cache_system = NULL;
}
else if (md->type == eModifierType_CorrectiveSmooth) {
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
if (csmd->bind_coords) {
csmd->bind_coords = newdataadr(fd, csmd->bind_coords);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
BLI_endian_switch_float_array((float *)csmd->bind_coords, csmd->bind_coords_num * 3);
}
}
/* runtime only */
csmd->delta_cache.deltas = NULL;
csmd->delta_cache.totverts = 0;
}
else if (md->type == eModifierType_MeshSequenceCache) {
MeshSeqCacheModifierData *msmcd = (MeshSeqCacheModifierData *)md;
msmcd->reader = NULL;
msmcd->reader_object_path[0] = '\0';
}
else if (md->type == eModifierType_SurfaceDeform) {
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
smd->verts = newdataadr(fd, smd->verts);
if (smd->verts) {
for (int i = 0; i < smd->numverts; i++) {
smd->verts[i].binds = newdataadr(fd, smd->verts[i].binds);
if (smd->verts[i].binds) {
for (int j = 0; j < smd->verts[i].numbinds; j++) {
smd->verts[i].binds[j].vert_inds = newdataadr(fd, smd->verts[i].binds[j].vert_inds);
smd->verts[i].binds[j].vert_weights = newdataadr(
fd, smd->verts[i].binds[j].vert_weights);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
if (smd->verts[i].binds[j].vert_inds) {
BLI_endian_switch_uint32_array(smd->verts[i].binds[j].vert_inds,
smd->verts[i].binds[j].numverts);
}
if (smd->verts[i].binds[j].vert_weights) {
if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI) {
BLI_endian_switch_float_array(smd->verts[i].binds[j].vert_weights, 3);
}
else {
BLI_endian_switch_float_array(smd->verts[i].binds[j].vert_weights,
smd->verts[i].binds[j].numverts);
}
}
}
}
}
}
}
}
else if (md->type == eModifierType_Bevel) {
BevelModifierData *bmd = (BevelModifierData *)md;
bmd->custom_profile = newdataadr(fd, bmd->custom_profile);
if (bmd->custom_profile) {
direct_link_curveprofile(fd, bmd->custom_profile);
}
}
}
}
@@ -6647,7 +6335,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
sce->toolsettings->custom_bevel_profile_preset = newdataadr(
fd, sce->toolsettings->custom_bevel_profile_preset);
if (sce->toolsettings->custom_bevel_profile_preset) {
direct_link_curveprofile(fd, sce->toolsettings->custom_bevel_profile_preset);
BKE_curveprofile_blo_read(wrap_reader(fd), sce->toolsettings->custom_bevel_profile_preset);
}
}
@@ -11879,4 +11567,19 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
BKE_main_free(main_newid);
}
void *BLO_read_get_new_data_address(BloReader *reader, const void *old_address)
{
return newdataadr(unwrap_reader(reader), old_address);
}
bool BLO_read_requires_endian_switch(BloReader *reader)
{
return (unwrap_reader(reader)->flags & FD_FLAGS_SWITCH_ENDIAN) != 0;
}
void BLO_read_list(BloReader *reader, struct ListBase *list, BloReadListFn callback)
{
link_list_ex(unwrap_reader(reader), list, (link_list_cb)callback);
}
/** \} */

View File

@@ -150,8 +150,10 @@
#include "BKE_blender_version.h"
#include "BKE_bpath.h"
#include "BKE_collection.h"
#include "BKE_colortools.h"
#include "BKE_constraint.h"
#include "BKE_curve.h"
#include "BKE_curveprofile.h"
#include "BKE_fcurve.h"
#include "BKE_global.h" // for G
#include "BKE_gpencil_modifier.h"
@@ -173,6 +175,7 @@
#include "BLO_readfile.h"
#include "BLO_undofile.h"
#include "BLO_writefile.h"
#include "BLO_callback_api.h"
#include "readfile.h"
@@ -381,6 +384,16 @@ static void writedata_free(WriteData *wd)
MEM_freeN(wd);
}
static BloWriter *wrap_writer(WriteData *wd)
{
return (BloWriter *)wd;
}
static WriteData *unwrap_writer(BloWriter *writer)
{
return (WriteData *)writer;
}
/** \} */
/* -------------------------------------------------------------------- */
@@ -945,22 +958,12 @@ static void write_animdata(WriteData *wd, AnimData *adt)
static void write_curvemapping_curves(WriteData *wd, CurveMapping *cumap)
{
for (int a = 0; a < CM_TOT; a++) {
writestruct(wd, DATA, CurveMapPoint, cumap->cm[a].totpoint, cumap->cm[a].curve);
}
BKE_curvemapping_blo_write_content(wrap_writer(wd), cumap);
}
static void write_curvemapping(WriteData *wd, CurveMapping *cumap)
{
writestruct(wd, DATA, CurveMapping, 1, cumap);
write_curvemapping_curves(wd, cumap);
}
static void write_CurveProfile(WriteData *wd, CurveProfile *profile)
{
writestruct(wd, DATA, CurveProfile, 1, profile);
writestruct(wd, DATA, CurveProfilePoint, profile->path_len, profile->path);
BKE_curvemapping_blo_write(wrap_writer(wd), cumap);
}
static void write_node_socket_default_value(WriteData *wd, bNodeSocket *sock)
@@ -1329,60 +1332,6 @@ static void write_boid_state(WriteData *wd, BoidState *state)
#endif
}
/* update this also to readfile.c */
static const char *ptcache_data_struct[] = {
"", // BPHYS_DATA_INDEX
"", // BPHYS_DATA_LOCATION
"", // BPHYS_DATA_VELOCITY
"", // BPHYS_DATA_ROTATION
"", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
"", // BPHYS_DATA_SIZE:
"", // BPHYS_DATA_TIMES:
"BoidData", // case BPHYS_DATA_BOIDS:
};
static const char *ptcache_extra_struct[] = {
"",
"ParticleSpring",
};
static void write_pointcaches(WriteData *wd, ListBase *ptcaches)
{
PointCache *cache = ptcaches->first;
int i;
for (; cache; cache = cache->next) {
writestruct(wd, DATA, PointCache, 1, cache);
if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
PTCacheMem *pm = cache->mem_cache.first;
for (; pm; pm = pm->next) {
PTCacheExtra *extra = pm->extradata.first;
writestruct(wd, DATA, PTCacheMem, 1, pm);
for (i = 0; i < BPHYS_TOT_DATA; i++) {
if (pm->data[i] && pm->data_types & (1 << i)) {
if (ptcache_data_struct[i][0] == '\0') {
writedata(wd, DATA, MEM_allocN_len(pm->data[i]), pm->data[i]);
}
else {
writestruct_id(wd, DATA, ptcache_data_struct[i], pm->totpoint, pm->data[i]);
}
}
}
for (; extra; extra = extra->next) {
if (ptcache_extra_struct[extra->type][0] == '\0') {
continue;
}
writestruct(wd, DATA, PTCacheExtra, 1, extra);
writestruct_id(wd, DATA, ptcache_extra_struct[extra->type], extra->totdata, extra->data);
}
}
}
}
}
static void write_particlesettings(WriteData *wd, ParticleSettings *part)
{
if (part->id.us > 0 || wd->use_memfile) {
@@ -1487,7 +1436,7 @@ static void write_particlesystems(WriteData *wd, ListBase *particles)
writestruct(wd, DATA, ClothCollSettings, 1, psys->clmd->coll_parms);
}
write_pointcaches(wd, &psys->ptcaches);
BKE_ptcache_blo_write_list(wrap_writer(wd), &psys->ptcaches);
}
}
@@ -1640,38 +1589,25 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
writestruct_id(wd, DATA, mti->structName, 1, md);
if (md->type == eModifierType_Hook) {
HookModifierData *hmd = (HookModifierData *)md;
if (hmd->curfalloff) {
write_curvemapping(wd, hmd->curfalloff);
}
writedata(wd, DATA, sizeof(int) * hmd->totindex, hmd->indexar);
if (mti->bloWrite != NULL) {
mti->bloWrite(wrap_writer(wd), md);
}
else if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
writestruct(wd, DATA, ClothSimSettings, 1, clmd->sim_parms);
writestruct(wd, DATA, ClothCollSettings, 1, clmd->coll_parms);
writestruct(wd, DATA, EffectorWeights, 1, clmd->sim_parms->effector_weights);
write_pointcaches(wd, &clmd->ptcaches);
}
else if (md->type == eModifierType_Fluid) {
if (md->type == eModifierType_Fluid) {
FluidModifierData *mmd = (FluidModifierData *)md;
if (mmd->type & MOD_FLUID_TYPE_DOMAIN) {
writestruct(wd, DATA, FluidDomainSettings, 1, mmd->domain);
if (mmd->domain) {
write_pointcaches(wd, &(mmd->domain->ptcaches[0]));
BKE_ptcache_blo_write_list(wrap_writer(wd), &(mmd->domain->ptcaches[0]));
/* create fake pointcache so that old blender versions can read it */
mmd->domain->point_cache[1] = BKE_ptcache_add(&mmd->domain->ptcaches[1]);
mmd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE | PTCACHE_FAKE_SMOKE;
mmd->domain->point_cache[1]->step = 1;
write_pointcaches(wd, &(mmd->domain->ptcaches[1]));
BKE_ptcache_blo_write_list(wrap_writer(wd), &(mmd->domain->ptcaches[1]));
if (mmd->domain->coba) {
writestruct(wd, DATA, ColorBand, 1, mmd->domain->coba);
@@ -1696,30 +1632,6 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
writestruct(wd, DATA, FluidsimSettings, 1, fluidmd->fss);
}
else if (md->type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if (pmd->canvas) {
DynamicPaintSurface *surface;
writestruct(wd, DATA, DynamicPaintCanvasSettings, 1, pmd->canvas);
/* write surfaces */
for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
writestruct(wd, DATA, DynamicPaintSurface, 1, surface);
}
/* write caches and effector weights */
for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
write_pointcaches(wd, &(surface->ptcaches));
writestruct(wd, DATA, EffectorWeights, 1, surface->effector_weights);
}
}
if (pmd->brush) {
writestruct(wd, DATA, DynamicPaintBrushSettings, 1, pmd->brush);
writestruct(wd, DATA, ColorBand, 1, pmd->brush->paint_ramp);
writestruct(wd, DATA, ColorBand, 1, pmd->brush->vel_ramp);
}
}
else if (md->type == eModifierType_Collision) {
#if 0
@@ -1731,79 +1643,6 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
writestruct(wd, DATA, MFace, collmd->numfaces, collmd->mfaces);
#endif
}
else if (md->type == eModifierType_MeshDeform) {
MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
int size = mmd->dyngridsize;
writestruct(wd, DATA, MDefInfluence, mmd->totinfluence, mmd->bindinfluences);
writedata(wd, DATA, sizeof(int) * (mmd->totvert + 1), mmd->bindoffsets);
writedata(wd, DATA, sizeof(float) * 3 * mmd->totcagevert, mmd->bindcagecos);
writestruct(wd, DATA, MDefCell, size * size * size, mmd->dyngrid);
writestruct(wd, DATA, MDefInfluence, mmd->totinfluence, mmd->dyninfluences);
writedata(wd, DATA, sizeof(int) * mmd->totvert, mmd->dynverts);
}
else if (md->type == eModifierType_Warp) {
WarpModifierData *tmd = (WarpModifierData *)md;
if (tmd->curfalloff) {
write_curvemapping(wd, tmd->curfalloff);
}
}
else if (md->type == eModifierType_WeightVGEdit) {
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
if (wmd->cmap_curve) {
write_curvemapping(wd, wmd->cmap_curve);
}
}
else if (md->type == eModifierType_LaplacianDeform) {
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
writedata(wd, DATA, sizeof(float) * lmd->total_verts * 3, lmd->vertexco);
}
else if (md->type == eModifierType_CorrectiveSmooth) {
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
if (csmd->bind_coords) {
writedata(wd, DATA, sizeof(float[3]) * csmd->bind_coords_num, csmd->bind_coords);
}
}
else if (md->type == eModifierType_SurfaceDeform) {
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
writestruct(wd, DATA, SDefVert, smd->numverts, smd->verts);
if (smd->verts) {
for (int i = 0; i < smd->numverts; i++) {
writestruct(wd, DATA, SDefBind, smd->verts[i].numbinds, smd->verts[i].binds);
if (smd->verts[i].binds) {
for (int j = 0; j < smd->verts[i].numbinds; j++) {
writedata(wd,
DATA,
sizeof(int) * smd->verts[i].binds[j].numverts,
smd->verts[i].binds[j].vert_inds);
if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI) {
writedata(wd, DATA, sizeof(float) * 3, smd->verts[i].binds[j].vert_weights);
}
else {
writedata(wd,
DATA,
sizeof(float) * smd->verts[i].binds[j].numverts,
smd->verts[i].binds[j].vert_weights);
}
}
}
}
}
}
else if (md->type == eModifierType_Bevel) {
BevelModifierData *bmd = (BevelModifierData *)md;
if (bmd->custom_profile) {
write_CurveProfile(wd, bmd->custom_profile);
}
}
}
}
@@ -1895,7 +1734,7 @@ static void write_object(WriteData *wd, Object *ob)
ob->soft->ptcaches = ob->soft->shared->ptcaches;
writestruct(wd, DATA, SoftBody, 1, ob->soft);
writestruct(wd, DATA, SoftBody_Shared, 1, ob->soft->shared);
write_pointcaches(wd, &(ob->soft->shared->ptcaches));
BKE_ptcache_blo_write_list(wrap_writer(wd), &(ob->soft->shared->ptcaches));
writestruct(wd, DATA, EffectorWeights, 1, ob->soft->effector_weights);
}
@@ -2560,7 +2399,7 @@ static void write_scene(WriteData *wd, Scene *sce)
}
/* Write the curve profile to the file. */
if (tos->custom_bevel_profile_preset) {
write_CurveProfile(wd, tos->custom_bevel_profile_preset);
BKE_curveprofile_blo_write(wrap_writer(wd), tos->custom_bevel_profile_preset);
}
write_paint(wd, &tos->imapaint.paint);
@@ -2699,7 +2538,7 @@ static void write_scene(WriteData *wd, Scene *sce)
writestruct(wd, DATA, RigidBodyWorld_Shared, 1, sce->rigidbody_world->shared);
writestruct(wd, DATA, EffectorWeights, 1, sce->rigidbody_world->effector_weights);
write_pointcaches(wd, &(sce->rigidbody_world->shared->ptcaches));
BKE_ptcache_blo_write_list(wrap_writer(wd), &(sce->rigidbody_world->shared->ptcaches));
}
write_previews(wd, sce->preview);
@@ -4173,4 +4012,64 @@ bool BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int w
return (err == 0);
}
void BLO_write_raw(BloWriter *writer, int size_in_bytes, const void *data_ptr)
{
writedata(unwrap_writer(writer), DATA, size_in_bytes, data_ptr);
}
void BLO_write_struct_by_name(BloWriter *writer, const char *struct_name, const void *data_ptr)
{
int struct_id = BLO_get_struct_id_by_name(writer, struct_name);
BLO_write_struct_by_id(writer, struct_id, data_ptr);
}
void BLO_write_struct_array_by_name(BloWriter *writer,
const char *struct_name,
int array_size,
const void *data_ptr)
{
int struct_id = BLO_get_struct_id_by_name(writer, struct_name);
BLO_write_struct_array_by_id(writer, struct_id, array_size, data_ptr);
}
void BLO_write_struct_by_id(BloWriter *writer, int struct_id, const void *data_ptr)
{
writestruct_nr(unwrap_writer(writer), DATA, struct_id, 1, data_ptr);
}
void BLO_write_struct_array_by_id(BloWriter *writer,
int struct_id,
int array_size,
const void *data_ptr)
{
writestruct_nr(unwrap_writer(writer), DATA, struct_id, array_size, data_ptr);
}
int BLO_get_struct_id_by_name(BloWriter *writer, const char *struct_name)
{
int struct_id = DNA_struct_find_nr(unwrap_writer(writer)->sdna, struct_name);
BLI_assert(struct_id >= 0);
return struct_id;
}
void BLO_write_int32_array(BloWriter *writer, int size, const int32_t *data_ptr)
{
BLO_write_raw(writer, sizeof(int32_t) * size, data_ptr);
}
void BLO_write_uint32_array(BloWriter *writer, int size, const uint32_t *data_ptr)
{
BLO_write_raw(writer, sizeof(uint32_t) * size, data_ptr);
}
void BLO_write_float_array(BloWriter *writer, int size, const float *data_ptr)
{
BLO_write_raw(writer, sizeof(float) * size, data_ptr);
}
void BLO_write_float3_array(BloWriter *writer, int size, const float *data_ptr)
{
BLO_write_raw(writer, sizeof(float) * 3 * size, data_ptr);
}
/** \} */

View File

@@ -24,6 +24,7 @@ set(INC
../blenfont
../blenkernel
../blenlib
../blenloader
../bmesh
../depsgraph
../makesdna

View File

@@ -45,6 +45,8 @@
#include "MEM_guardedalloc.h"
#include "BLO_callback_api.h"
#include "MOD_util.h"
static void initData(ModifierData *md)
@@ -124,6 +126,12 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_modifier_to_transform_relation(ctx->node, "Armature Modifier");
}
static void bloRead(BloReader *UNUSED(reader), ModifierData *md)
{
ArmatureModifierData *amd = (ArmatureModifierData *)md;
amd->prevCos = NULL;
}
static void deformVerts(ModifierData *md,
const ModifierEvalContext *ctx,
Mesh *mesh,
@@ -266,4 +274,6 @@ ModifierTypeInfo modifierType_Armature = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ bloRead,
};

View File

@@ -820,4 +820,6 @@ ModifierTypeInfo modifierType_Array = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -45,6 +45,8 @@
#include "DEG_depsgraph_query.h"
#include "BLO_callback_api.h"
static void initData(ModifierData *md)
{
BevelModifierData *bmd = (BevelModifierData *)md;
@@ -263,6 +265,23 @@ static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED
return (bmd->value == 0.0f);
}
static void bloWrite(BloWriter *writer, const ModifierData *md)
{
BevelModifierData *bmd = (BevelModifierData *)md;
if (bmd->custom_profile) {
BKE_curveprofile_blo_write(writer, bmd->custom_profile);
}
}
static void bloRead(BloReader *reader, ModifierData *md)
{
BevelModifierData *bmd = (BevelModifierData *)md;
BLO_read_data_address(reader, bmd->custom_profile);
if (bmd->custom_profile) {
BKE_curveprofile_blo_read(reader, bmd->custom_profile);
}
}
ModifierTypeInfo modifierType_Bevel = {
/* name */ "Bevel",
/* structName */ "BevelModifierData",
@@ -287,4 +306,6 @@ ModifierTypeInfo modifierType_Bevel = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ bloWrite,
/* bloRead */ bloRead,
};

View File

@@ -372,4 +372,6 @@ ModifierTypeInfo modifierType_Boolean = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -301,4 +301,6 @@ ModifierTypeInfo modifierType_Build = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -535,4 +535,6 @@ ModifierTypeInfo modifierType_Cast = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -48,6 +48,8 @@
#include "DEG_depsgraph_physics.h"
#include "DEG_depsgraph_query.h"
#include "BLO_callback_api.h"
#include "MOD_util.h"
static void initData(ModifierData *md)
@@ -249,6 +251,45 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u
}
}
static void bloWrite(BloWriter *writer, const ModifierData *md)
{
ClothModifierData *clmd = (ClothModifierData *)md;
BLO_write_struct(writer, ClothSimSettings, clmd->sim_parms);
BLO_write_struct(writer, ClothCollSettings, clmd->coll_parms);
BLO_write_struct(writer, EffectorWeights, clmd->sim_parms->effector_weights);
BKE_ptcache_blo_write_list(writer, &clmd->ptcaches);
}
static void bloRead(BloReader *reader, ModifierData *md)
{
ClothModifierData *clmd = (ClothModifierData *)md;
clmd->clothObject = NULL;
clmd->hairdata = NULL;
BLO_read_data_address(reader, clmd->sim_parms);
BLO_read_data_address(reader, clmd->coll_parms);
BKE_ptcache_blo_read(reader, &clmd->ptcaches, &clmd->point_cache, 0);
if (clmd->sim_parms) {
if (clmd->sim_parms->presets > 10) {
clmd->sim_parms->presets = 0;
}
clmd->sim_parms->reset = 0;
BLO_read_data_address(reader, clmd->sim_parms->effector_weights);
if (clmd->sim_parms->effector_weights == NULL) {
clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL);
}
}
clmd->solver_result = NULL;
}
ModifierTypeInfo modifierType_Cloth = {
/* name */ "Cloth",
/* structName */ "ClothModifierData",
@@ -276,4 +317,6 @@ ModifierTypeInfo modifierType_Cloth = {
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ bloWrite,
/* bloRead */ bloRead,
};

View File

@@ -267,4 +267,6 @@ ModifierTypeInfo modifierType_Collision = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -46,6 +46,8 @@
#include "DEG_depsgraph_query.h"
#include "BLO_callback_api.h"
// #define DEBUG_TIME
#include "PIL_time.h"
@@ -114,6 +116,28 @@ static void requiredDataMask(Object *UNUSED(ob),
}
}
static void bloWrite(BloWriter *writer, const ModifierData *md)
{
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
if (csmd->bind_coords) {
BLO_write_float3_array(writer, (int)csmd->bind_coords_num, (float *)csmd->bind_coords);
}
}
static void bloRead(BloReader *reader, ModifierData *md)
{
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
if (csmd->bind_coords) {
BLO_read_float3_array(reader, csmd->bind_coords_num, csmd->bind_coords);
}
/* runtime only */
csmd->delta_cache.deltas = NULL;
csmd->delta_cache.totverts = 0;
}
/* check individual weights for changes and cache values */
static void mesh_get_weights(MDeformVert *dvert,
const int defgrp_index,
@@ -788,4 +812,6 @@ ModifierTypeInfo modifierType_CorrectiveSmooth = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ bloWrite,
/* bloRead */ bloRead,
};

View File

@@ -176,4 +176,6 @@ ModifierTypeInfo modifierType_Curve = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -262,4 +262,6 @@ ModifierTypeInfo modifierType_DataTransfer = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -241,4 +241,6 @@ ModifierTypeInfo modifierType_Decimate = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -431,4 +431,6 @@ ModifierTypeInfo modifierType_Displace = {
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -29,16 +29,20 @@
#include "DNA_mesh_types.h"
#include "BKE_dynamicpaint.h"
#include "BKE_effect.h"
#include "BKE_layer.h"
#include "BKE_lib_query.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_pointcache.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_physics.h"
#include "DEG_depsgraph_query.h"
#include "BLO_callback_api.h"
#include "MOD_modifiertypes.h"
static void initData(ModifierData *md)
@@ -100,6 +104,66 @@ static void requiredDataMask(Object *UNUSED(ob),
}
}
static void bloWrite(BloWriter *writer, const ModifierData *md)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if (pmd->canvas) {
DynamicPaintSurface *surface;
BLO_write_struct(writer, DynamicPaintCanvasSettings, pmd->canvas);
/* write surfaces */
for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
BLO_write_struct(writer, DynamicPaintSurface, surface);
}
/* write caches and effector weights */
for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
BKE_ptcache_blo_write_list(writer, &(surface->ptcaches));
BLO_write_struct(writer, EffectorWeights, surface->effector_weights);
}
}
if (pmd->brush) {
BLO_write_struct(writer, DynamicPaintBrushSettings, pmd->brush);
BLO_write_struct(writer, ColorBand, pmd->brush->paint_ramp);
BLO_write_struct(writer, ColorBand, pmd->brush->vel_ramp);
}
}
static void bloRead(BloReader *reader, ModifierData *md)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if (pmd->canvas) {
BLO_read_data_address(reader, pmd->canvas);
pmd->canvas->pmd = pmd;
pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
if (pmd->canvas->surfaces.first) {
DynamicPaintSurface *surface;
BLO_read_list(reader, &pmd->canvas->surfaces, NULL);
for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
surface->canvas = pmd->canvas;
surface->data = NULL;
BKE_ptcache_blo_read(reader, &(surface->ptcaches), &(surface->pointcache), 1);
BLO_read_data_address(reader, surface->effector_weights);
if (surface->effector_weights == NULL) {
surface->effector_weights = BKE_effector_add_weights(NULL);
}
}
}
}
if (pmd->brush) {
BLO_read_data_address(reader, pmd->brush);
pmd->brush->pmd = pmd;
BLO_read_data_address(reader, pmd->brush->psys);
BLO_read_data_address(reader, pmd->brush->paint_ramp);
BLO_read_data_address(reader, pmd->brush->vel_ramp);
}
}
static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
@@ -200,4 +264,6 @@ ModifierTypeInfo modifierType_DynamicPaint = {
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
/* freeRuntimeData */ freeRuntimeData,
/* bloWrite */ bloWrite,
/* bloRead */ bloRead,
};

View File

@@ -155,4 +155,6 @@ ModifierTypeInfo modifierType_EdgeSplit = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -45,6 +45,8 @@
#include "MEM_guardedalloc.h"
#include "BLO_callback_api.h"
#include "MOD_modifiertypes.h"
static void initData(ModifierData *md)
@@ -86,6 +88,12 @@ static void requiredDataMask(Object *UNUSED(ob),
}
}
static void bloRead(BloReader *UNUSED(reader), ModifierData *md)
{
ExplodeModifierData *psmd = (ExplodeModifierData *)md;
psmd->facepa = NULL;
}
static void createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *psmd, Mesh *mesh)
{
ParticleSystem *psys = psmd->psys;
@@ -1199,4 +1207,6 @@ ModifierTypeInfo modifierType_Explode = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ bloRead,
};

View File

@@ -220,4 +220,6 @@ ModifierTypeInfo modifierType_Fluid = {
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -44,6 +44,8 @@
#include "MOD_util.h"
#include "BLO_callback_api.h"
static void initData(ModifierData *md)
{
HookModifierData *hmd = (HookModifierData *)md;
@@ -123,6 +125,27 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_modifier_to_transform_relation(ctx->node, "Hook Modifier");
}
static void bloWrite(BloWriter *writer, const ModifierData *md)
{
HookModifierData *hmd = (HookModifierData *)md;
BLO_write_int32_array(writer, hmd->totindex, hmd->indexar);
if (hmd->curfalloff) {
BKE_curvemapping_blo_write(writer, hmd->curfalloff);
}
}
static void bloRead(BloReader *reader, ModifierData *md)
{
HookModifierData *hmd = (HookModifierData *)md;
BLO_read_int32_array(reader, hmd->totindex, hmd->indexar);
BLO_read_data_address(reader, hmd->curfalloff);
if (hmd->curfalloff) {
BKE_curvemapping_blo_read(reader, hmd->curfalloff);
}
}
struct HookData_cb {
float (*vertexCos)[3];
@@ -414,4 +437,6 @@ ModifierTypeInfo modifierType_Hook = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ bloWrite,
/* bloRead */ bloRead,
};

View File

@@ -43,6 +43,8 @@
#include "eigen_capi.h"
#include "BLO_callback_api.h"
enum {
LAPDEFORM_SYSTEM_NOT_CHANGE = 0,
LAPDEFORM_SYSTEM_IS_DIFFERENT,
@@ -757,6 +759,21 @@ static void requiredDataMask(Object *UNUSED(ob),
}
}
static void bloWrite(BloWriter *writer, const ModifierData *md)
{
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
BLO_write_float3_array(writer, lmd->total_verts, lmd->vertexco);
}
static void bloRead(BloReader *reader, ModifierData *md)
{
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
BLO_read_float3_array(reader, lmd->total_verts, lmd->vertexco);
lmd->cache_system = NULL;
}
static void deformVerts(ModifierData *md,
const ModifierEvalContext *ctx,
Mesh *mesh,
@@ -827,4 +844,6 @@ ModifierTypeInfo modifierType_LaplacianDeform = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ bloWrite,
/* bloRead */ bloRead,
};

View File

@@ -593,4 +593,6 @@ ModifierTypeInfo modifierType_LaplacianSmooth = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -159,4 +159,6 @@ ModifierTypeInfo modifierType_Lattice = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -414,4 +414,6 @@ ModifierTypeInfo modifierType_Mask = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -314,4 +314,6 @@ ModifierTypeInfo modifierType_MeshCache = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -45,6 +45,8 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "BLO_callback_api.h"
#include "MOD_util.h"
#ifdef __SSE2__
@@ -163,6 +165,36 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
static void bloWrite(BloWriter *writer, const ModifierData *md)
{
MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
int size = mmd->dyngridsize;
BLO_write_struct_array(writer, MDefInfluence, mmd->totinfluence, mmd->bindinfluences);
BLO_write_int32_array(writer, mmd->totvert + 1, mmd->bindoffsets);
BLO_write_float3_array(writer, mmd->totcagevert, mmd->bindcagecos);
BLO_write_struct_array(writer, MDefCell, size * size * size, mmd->dyngrid);
BLO_write_struct_array(writer, MDefInfluence, mmd->totinfluence, mmd->dyninfluences);
BLO_write_int32_array(writer, mmd->totvert, mmd->dynverts);
}
static void bloRead(BloReader *reader, ModifierData *md)
{
MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
BLO_read_data_address(reader, mmd->bindinfluences);
BLO_read_int32_array(reader, mmd->totvert + 1, mmd->bindoffsets);
BLO_read_float3_array(reader, mmd->totcagevert, mmd->bindcagecos);
BLO_read_data_address(reader, mmd->dyngrid);
BLO_read_data_address(reader, mmd->dyninfluences);
BLO_read_int32_array(reader, mmd->totvert, mmd->dynverts);
BLO_read_float_array(reader, mmd->totvert, mmd->bindweights);
BLO_read_float3_array(reader, mmd->totcagevert, mmd->bindcos);
}
static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3], float vec[3])
{
MDefCell *cell;
@@ -578,4 +610,6 @@ ModifierTypeInfo modifierType_MeshDeform = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ bloWrite,
/* bloRead */ bloRead,
};

View File

@@ -37,6 +37,8 @@
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "BLO_callback_api.h"
#include "MOD_modifiertypes.h"
#ifdef WITH_ALEMBIC
@@ -184,6 +186,13 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
static void bloRead(BloReader *UNUSED(reader), ModifierData *md)
{
MeshSeqCacheModifierData *msmcd = (MeshSeqCacheModifierData *)md;
msmcd->reader = NULL;
msmcd->reader_object_path[0] = '\0';
}
ModifierTypeInfo modifierType_MeshSequenceCache = {
/* name */ "Mesh Sequence Cache",
/* structName */ "MeshSeqCacheModifierData",
@@ -210,4 +219,6 @@ ModifierTypeInfo modifierType_MeshSequenceCache = {
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ bloRead,
};

View File

@@ -143,4 +143,6 @@ ModifierTypeInfo modifierType_Mirror = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -291,4 +291,6 @@ ModifierTypeInfo modifierType_Multires = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ freeRuntimeData,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -64,4 +64,6 @@ ModifierTypeInfo modifierType_None = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -716,4 +716,6 @@ ModifierTypeInfo modifierType_NormalEdit = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -41,6 +41,8 @@
#include "DEG_depsgraph_query.h"
#include "BLO_callback_api.h"
#include "MOD_modifiertypes.h"
#ifdef WITH_OCEANSIM
@@ -179,6 +181,13 @@ static bool dependsOnNormals(ModifierData *md)
return (omd->geometry_mode != MOD_OCEAN_GEOM_GENERATE);
}
static void bloRead(BloReader *UNUSED(reader), ModifierData *md)
{
OceanModifierData *omd = (OceanModifierData *)md;
omd->oceancache = NULL;
omd->ocean = NULL;
}
#ifdef WITH_OCEANSIM
typedef struct GenerateOceanGeometryData {
@@ -518,4 +527,6 @@ ModifierTypeInfo modifierType_Ocean = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ bloRead,
};

View File

@@ -573,4 +573,6 @@ ModifierTypeInfo modifierType_ParticleInstance = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -36,6 +36,8 @@
#include "DEG_depsgraph_query.h"
#include "BLO_callback_api.h"
#include "MOD_util.h"
static void initData(ModifierData *md)
@@ -90,6 +92,17 @@ static void requiredDataMask(Object *UNUSED(ob),
psys_emitter_customdata_mask(psmd->psys, r_cddata_masks);
}
static void bloRead(BloReader *reader, ModifierData *md)
{
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
psmd->mesh_final = NULL;
psmd->mesh_original = NULL;
BLO_read_data_address(reader, psmd->psys);
psmd->flag &= ~eParticleSystemFlag_psys_updated;
psmd->flag |= eParticleSystemFlag_file_loaded;
}
/* saves the current emitter state for a particle system and calculates particles */
static void deformVerts(ModifierData *md,
const ModifierEvalContext *ctx,
@@ -277,4 +290,6 @@ ModifierTypeInfo modifierType_ParticleSystem = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ bloRead,
};

View File

@@ -228,4 +228,6 @@ ModifierTypeInfo modifierType_Remesh = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -1187,4 +1187,6 @@ ModifierTypeInfo modifierType_Screw = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -144,4 +144,6 @@ ModifierTypeInfo modifierType_ShapeKey = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -221,4 +221,6 @@ ModifierTypeInfo modifierType_Shrinkwrap = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -476,4 +476,6 @@ ModifierTypeInfo modifierType_SimpleDeform = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -1953,4 +1953,6 @@ ModifierTypeInfo modifierType_Skin = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -250,4 +250,6 @@ ModifierTypeInfo modifierType_Smooth = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -98,4 +98,6 @@ ModifierTypeInfo modifierType_Softbody = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -108,4 +108,6 @@ ModifierTypeInfo modifierType_Solidify = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -41,6 +41,8 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "BLO_callback_api.h"
#include "MOD_modifiertypes.h"
#include "intern/CCGSubSurf.h"
@@ -108,6 +110,12 @@ static bool isDisabled(const Scene *scene, ModifierData *md, bool useRenderParam
return get_render_subsurf_level(&scene->r, levels, useRenderParams != 0) == 0;
}
static void bloRead(BloReader *UNUSED(reader), ModifierData *md)
{
SubsurfModifierData *smd = (SubsurfModifierData *)md;
smd->emCache = smd->mCache = NULL;
}
static int subdiv_levels_for_modifier_get(const SubsurfModifierData *smd,
const ModifierEvalContext *ctx)
{
@@ -302,4 +310,6 @@ ModifierTypeInfo modifierType_Subsurf = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ freeRuntimeData,
/* bloWrite */ NULL,
/* bloRead */ bloRead,
};

View File

@@ -42,6 +42,8 @@
#include "MEM_guardedalloc.h"
#include "BLO_callback_api.h"
static void initData(ModifierData *md)
{
SurfaceModifierData *surmd = (SurfaceModifierData *)md;
@@ -90,6 +92,17 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
static void bloRead(BloReader *UNUSED(reader), ModifierData *md)
{
SurfaceModifierData *surmd = (SurfaceModifierData *)md;
surmd->mesh = NULL;
surmd->bvhtree = NULL;
surmd->x = NULL;
surmd->v = NULL;
surmd->numverts = 0;
}
static void deformVerts(ModifierData *md,
const ModifierEvalContext *ctx,
Mesh *mesh,
@@ -209,4 +222,6 @@ ModifierTypeInfo modifierType_Surface = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ bloRead,
};

View File

@@ -41,6 +41,8 @@
#include "MEM_guardedalloc.h"
#include "BLO_callback_api.h"
#include "MOD_util.h"
typedef struct SDefAdjacency {
@@ -203,6 +205,58 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
static void bloWrite(BloWriter *writer, const ModifierData *md)
{
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
BLO_write_struct_array(writer, SDefVert, smd->numverts, smd->verts);
if (smd->verts) {
for (int i = 0; i < smd->numverts; i++) {
BLO_write_struct_array(writer, SDefBind, smd->verts[i].numbinds, smd->verts[i].binds);
if (smd->verts[i].binds) {
for (int j = 0; j < smd->verts[i].numbinds; j++) {
SDefBind *bind = &smd->verts[i].binds[j];
BLO_write_uint32_array(writer, (int)bind->numverts, bind->vert_inds);
if (ELEM(bind->mode, MOD_SDEF_MODE_CENTROID, MOD_SDEF_MODE_LOOPTRI)) {
BLO_write_float3_array(writer, 1, bind->vert_weights);
}
else {
BLO_write_float_array(writer, (int)bind->numverts, bind->vert_weights);
}
}
}
}
}
}
static void bloRead(BloReader *reader, ModifierData *md)
{
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
BLO_read_data_address(reader, smd->verts);
if (smd->verts) {
for (int i = 0; i < smd->numverts; i++) {
BLO_read_data_address(reader, smd->verts[i].binds);
if (smd->verts[i].binds) {
for (int j = 0; j < smd->verts[i].numbinds; j++) {
SDefBind *bind = &smd->verts[i].binds[j];
BLO_read_uint32_array(reader, bind->numverts, bind->vert_inds);
if (ELEM(bind->mode, MOD_SDEF_MODE_CENTROID, MOD_SDEF_MODE_LOOPTRI)) {
BLO_read_float3_array(reader, 1, bind->vert_weights);
}
else {
BLO_read_float_array(reader, bind->numverts, bind->vert_weights);
}
}
}
}
}
}
static void freeAdjacencyMap(SDefAdjacencyArray *const vert_edges,
SDefAdjacency *const adj_ref,
SDefEdgePolys *const edge_polys)
@@ -1315,4 +1369,6 @@ ModifierTypeInfo modifierType_SurfaceDeform = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ bloWrite,
/* bloRead */ bloRead,
};

View File

@@ -142,4 +142,6 @@ ModifierTypeInfo modifierType_Triangulate = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -340,4 +340,6 @@ ModifierTypeInfo modifierType_UVProject = {
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -284,4 +284,6 @@ ModifierTypeInfo modifierType_UVWarp = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -44,6 +44,8 @@
#include "RE_shader_ext.h"
#include "BLO_callback_api.h"
#include "MOD_util.h"
static void initData(ModifierData *md)
@@ -153,6 +155,24 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
static void bloWrite(BloWriter *writer, const ModifierData *md)
{
WarpModifierData *tmd = (WarpModifierData *)md;
if (tmd->curfalloff) {
BKE_curvemapping_blo_write(writer, tmd->curfalloff);
}
}
static void bloRead(BloReader *reader, ModifierData *md)
{
WarpModifierData *tmd = (WarpModifierData *)md;
BLO_read_data_address(reader, tmd->curfalloff);
if (tmd->curfalloff) {
BKE_curvemapping_blo_read(reader, tmd->curfalloff);
}
}
static void warpModifier_do(WarpModifierData *wmd,
const ModifierEvalContext *ctx,
Mesh *mesh,
@@ -383,4 +403,6 @@ ModifierTypeInfo modifierType_Warp = {
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
/* freeRuntimeData */ NULL,
/* bloWrite */ bloWrite,
/* bloRead */ bloRead,
};

View File

@@ -376,4 +376,6 @@ ModifierTypeInfo modifierType_Wave = {
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -727,4 +727,6 @@ ModifierTypeInfo modifierType_WeightedNormal = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -47,6 +47,8 @@
#include "MOD_weightvg_util.h"
#include "MOD_modifiertypes.h"
#include "BLO_callback_api.h"
/**************************************
* Modifiers functions. *
**************************************/
@@ -156,6 +158,25 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
return (wmd->defgrp_name[0] == '\0');
}
static void bloWrite(BloWriter *writer, const ModifierData *md)
{
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
if (wmd->cmap_curve) {
BKE_curvemapping_blo_write(writer, wmd->cmap_curve);
}
}
static void bloRead(BloReader *reader, ModifierData *md)
{
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
BLO_read_data_address(reader, wmd->cmap_curve);
if (wmd->cmap_curve) {
BKE_curvemapping_blo_read(reader, wmd->cmap_curve);
}
}
static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
{
BLI_assert(mesh != NULL);
@@ -318,4 +339,6 @@ ModifierTypeInfo modifierType_WeightVGEdit = {
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
/* freeRuntimeData */ NULL,
/* bloWrite */ bloWrite,
/* bloRead */ bloRead,
};

View File

@@ -449,4 +449,6 @@ ModifierTypeInfo modifierType_WeightVGMix = {
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -632,4 +632,6 @@ ModifierTypeInfo modifierType_WeightVGProximity = {
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};

View File

@@ -1930,6 +1930,8 @@ ModifierTypeInfo modifierType_Weld = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};
/** \} */

View File

@@ -132,4 +132,6 @@ ModifierTypeInfo modifierType_Wireframe = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* bloWrite */ NULL,
/* bloRead */ NULL,
};