Compare commits
9 Commits
temp-llvm-
...
blenloader
Author | SHA1 | Date | |
---|---|---|---|
f4937677d9 | |||
da09867c9f | |||
090947ce6c | |||
9bde79d734 | |||
64cdcf7973 | |||
ef817015d1 | |||
5240df4e0c | |||
150950e30f | |||
0316676e71 |
@@ -34,6 +34,10 @@ struct AnimData;
|
||||
struct Depsgraph;
|
||||
struct FCurve;
|
||||
struct ID;
|
||||
struct BlendWriter;
|
||||
struct BlendDataReader;
|
||||
struct BlendLibReader;
|
||||
struct BlendExpander;
|
||||
struct KS_Path;
|
||||
struct KeyingSet;
|
||||
struct ListBase;
|
||||
@@ -254,6 +258,13 @@ void BKE_animsys_update_driver_array(struct ID *id);
|
||||
|
||||
/* ************************************* */
|
||||
|
||||
void BKE_animsys_blend_write(struct BlendWriter *writer, struct AnimData *adt);
|
||||
void BKE_animsys_blend_read_data(struct BlendDataReader *reader, struct AnimData *adt);
|
||||
void BKE_animsys_blend_read_lib(struct BlendLibReader *reader,
|
||||
struct AnimData *adt,
|
||||
struct ID *id);
|
||||
void BKE_animsys_blend_expand(struct BlendExpander *expander, struct AnimData *adt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -37,6 +37,8 @@ struct Histogram;
|
||||
struct ImBuf;
|
||||
struct Scopes;
|
||||
struct rctf;
|
||||
struct BlendWriter;
|
||||
struct BlendDataReader;
|
||||
|
||||
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_blend_write(struct BlendWriter *writer, struct CurveMapping *cumap);
|
||||
void BKE_curvemapping_blend_write_content(struct BlendWriter *writer, struct CurveMapping *cumap);
|
||||
void BKE_curvemapping_blend_read_data(struct BlendDataReader *reader, struct CurveMapping *cumap);
|
||||
|
||||
enum {
|
||||
CURVEMAP_SLOPE_NEGATIVE = 0,
|
||||
|
@@ -30,6 +30,8 @@ extern "C" {
|
||||
|
||||
struct CurveProfile;
|
||||
struct CurveProfilePoint;
|
||||
struct BlendWriter;
|
||||
struct BlendDataReader;
|
||||
|
||||
void BKE_curveprofile_set_defaults(struct CurveProfile *profile);
|
||||
|
||||
@@ -78,6 +80,10 @@ void BKE_curveprofile_evaluate_length_portion(const struct CurveProfile *profile
|
||||
float *x_out,
|
||||
float *y_out);
|
||||
|
||||
void BKE_curveprofile_blend_write(struct BlendWriter *writer, const struct CurveProfile *profile);
|
||||
void BKE_curveprofile_blend_read_data(struct BlendDataReader *reader,
|
||||
struct CurveProfile *profile);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -34,6 +34,10 @@ struct FCurve;
|
||||
struct FModifier;
|
||||
|
||||
struct AnimData;
|
||||
struct BlendExpander;
|
||||
struct BlendDataReader;
|
||||
struct BlendLibReader;
|
||||
struct BlendWriter;
|
||||
struct BezTriple;
|
||||
struct PathResolvedRNA;
|
||||
struct PointerRNA;
|
||||
@@ -309,6 +313,22 @@ float fcurve_samplingcb_evalcurve(struct FCurve *fcu, void *data, float evaltime
|
||||
void fcurve_store_samples(
|
||||
struct FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb);
|
||||
|
||||
void BKE_fcurve_blend_write(struct BlendWriter *writer, struct ListBase *fcurves);
|
||||
void BKE_fcurve_blend_read_data(struct BlendDataReader *reader, struct ListBase *list);
|
||||
void BKE_fcurve_blend_read_lib(struct BlendLibReader *reader,
|
||||
struct ListBase *list,
|
||||
struct ID *id);
|
||||
void BKE_fcurve_blend_expand(struct BlendExpander *expander, struct ListBase *list);
|
||||
|
||||
void BKE_fcurve_modifiers_blend_write(struct BlendWriter *writer, struct ListBase *fmodifiers);
|
||||
void BKE_fcurve_modifiers_blend_read_data(struct BlendDataReader *reader,
|
||||
struct ListBase *list,
|
||||
struct FCurve *fcurve);
|
||||
void BKE_fcurve_modifiers_blend_read_lib(struct BlendLibReader *reader,
|
||||
struct ListBase *list,
|
||||
struct ID *id);
|
||||
void BKE_fcurve_modifiers_blend_expand(struct BlendExpander *expander, struct ListBase *list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -31,6 +31,10 @@ extern "C" {
|
||||
|
||||
struct ID;
|
||||
struct IDProperty;
|
||||
struct BlendDataReader;
|
||||
struct BlendLibReader;
|
||||
struct BlendWriter;
|
||||
struct BlendExpander;
|
||||
|
||||
typedef union IDPropertyTemplate {
|
||||
int i;
|
||||
@@ -197,6 +201,16 @@ void IDP_repr_fn(const IDProperty *prop,
|
||||
void *user_data);
|
||||
void IDP_print(const struct IDProperty *prop);
|
||||
|
||||
void IDP_BlendReadData(struct BlendDataReader *reader, struct IDProperty *prop);
|
||||
void IDP_BlendReadLib(struct BlendLibReader *reader, struct IDProperty *prop);
|
||||
void IDP_BlendExpand(struct BlendExpander *expander, struct IDProperty *prop);
|
||||
|
||||
void IDP_Group_BlendReadData(struct BlendDataReader *reader,
|
||||
struct IDProperty **prop,
|
||||
const char *caller_func_id);
|
||||
|
||||
void IDP_BlendWrite(struct BlendWriter *writer, const struct IDProperty *prop);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -34,6 +34,10 @@ extern "C" {
|
||||
|
||||
struct ID;
|
||||
struct Main;
|
||||
struct BlendWriter;
|
||||
struct BlendDataReader;
|
||||
struct BlendLibReader;
|
||||
struct BlendExpander;
|
||||
|
||||
/** IDTypeInfo.flags. */
|
||||
enum {
|
||||
@@ -60,6 +64,13 @@ typedef void (*IDTypeFreeDataFunction)(struct ID *id);
|
||||
/** \param flag: See BKE_lib_id.h's LIB_ID_MAKELOCAL_... flags. */
|
||||
typedef void (*IDTypeMakeLocalFunction)(struct Main *bmain, struct ID *id, const int flags);
|
||||
|
||||
typedef void (*IDTypeBlendWriteFunction)(struct BlendWriter *writer,
|
||||
struct ID *id,
|
||||
const void *id_address);
|
||||
typedef void (*IDTypeBlendReadDataFunction)(struct BlendDataReader *reader, struct ID *id);
|
||||
typedef void (*IDTypeBlendReadLibFunction)(struct BlendLibReader *reader, struct ID *id);
|
||||
typedef void (*IDTypeBlendExpandFunction)(struct BlendExpander *expander, struct ID *id);
|
||||
|
||||
typedef struct IDTypeInfo {
|
||||
/* ********** General IDType data. ********** */
|
||||
|
||||
@@ -121,6 +132,28 @@ typedef struct IDTypeInfo {
|
||||
* `BKE_lib_id_make_local_generic()` is enough.
|
||||
*/
|
||||
IDTypeMakeLocalFunction make_local;
|
||||
|
||||
/* ********** Blend file io callbacks ********** */
|
||||
|
||||
/**
|
||||
* Write all structs that should be saved in a .blend file.
|
||||
*/
|
||||
IDTypeBlendWriteFunction blend_write;
|
||||
|
||||
/**
|
||||
* Update pointers for all structs directly owned by this data block.
|
||||
*/
|
||||
IDTypeBlendReadDataFunction blend_read_data;
|
||||
|
||||
/**
|
||||
* Update pointers to other id data blocks.
|
||||
*/
|
||||
IDTypeBlendReadLibFunction blend_read_lib;
|
||||
|
||||
/**
|
||||
* Specify which other id data blocks should be loaded when the current one is loaded.
|
||||
*/
|
||||
IDTypeBlendExpandFunction blend_expand;
|
||||
} IDTypeInfo;
|
||||
|
||||
/* ********** Declaration of each IDTypeInfo. ********** */
|
||||
|
@@ -270,6 +270,10 @@ bool BKE_id_is_in_global_main(struct ID *id);
|
||||
void BKE_id_ordered_list(struct ListBase *ordered_lb, const struct ListBase *lb);
|
||||
void BKE_id_reorder(const struct ListBase *lb, struct ID *id, struct ID *relative, bool after);
|
||||
|
||||
/* Should probably be in another file. */
|
||||
struct BlendWriter;
|
||||
void BKE_iddata_blend_write(struct BlendWriter *writer, struct ID *id);
|
||||
|
||||
#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT))
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -40,6 +40,8 @@ struct ModifierData;
|
||||
struct Object;
|
||||
struct Scene;
|
||||
struct bArmature;
|
||||
struct BlendWriter;
|
||||
struct BlendDataReader;
|
||||
|
||||
typedef enum {
|
||||
/* Should not be used, only for None modifier type */
|
||||
@@ -348,6 +350,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 (*blendWrite)(struct BlendWriter *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 (*blendRead)(struct BlendDataReader *reader, struct ModifierData *md);
|
||||
} ModifierTypeInfo;
|
||||
|
||||
/* Initialize modifier's global data (type info and some common global storages). */
|
||||
|
@@ -35,6 +35,10 @@ struct NlaTrack;
|
||||
struct Scene;
|
||||
struct Speaker;
|
||||
struct bAction;
|
||||
struct BlendDataReader;
|
||||
struct BlendLibReader;
|
||||
struct BlendExpander;
|
||||
struct BlendWriter;
|
||||
|
||||
struct PointerRNA;
|
||||
struct PropertyRNA;
|
||||
@@ -143,6 +147,11 @@ enum eNlaTime_ConvertModes {
|
||||
|
||||
float BKE_nla_tweakedit_remap(struct AnimData *adt, float cframe, short mode);
|
||||
|
||||
void BKE_nla_blend_write(struct BlendWriter *writer, struct ListBase *nlabase);
|
||||
void BKE_nla_blend_read_data(struct BlendDataReader *reader, struct ListBase *list);
|
||||
void BKE_nla_blend_read_lib(struct BlendLibReader *reader, struct ListBase *list, struct ID *id);
|
||||
void BKE_nla_blend_expand(struct BlendExpander *expander, struct ListBase *list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -90,6 +90,9 @@ struct RigidBodyWorld;
|
||||
struct Scene;
|
||||
struct SoftBody;
|
||||
struct ViewLayer;
|
||||
struct BlendWriter;
|
||||
struct BlendDataReader;
|
||||
struct BlendLibReader;
|
||||
|
||||
struct OpenVDBReader;
|
||||
struct OpenVDBWriter;
|
||||
@@ -340,6 +343,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_blend_write_list(struct BlendWriter *writer, struct ListBase *ptcaches);
|
||||
void BKE_ptcache_blend_read(struct BlendDataReader *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);
|
||||
|
@@ -63,6 +63,8 @@
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
static CLG_LogRef LOG = {"bke.action"};
|
||||
|
||||
/* *********************** NOTE ON POSE AND ACTION **********************
|
||||
@@ -154,6 +156,102 @@ static void action_free_data(struct ID *id)
|
||||
BLI_freelistN(&action->markers);
|
||||
}
|
||||
|
||||
static void action_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
{
|
||||
bAction *action = (bAction *)id;
|
||||
if (action->id.us == 0 && !BLO_write_is_undo(writer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BLO_write_id_struct(writer, bAction, id_address, id);
|
||||
BKE_iddata_blend_write(writer, id);
|
||||
|
||||
BKE_fcurve_blend_write(writer, &action->curves);
|
||||
|
||||
BLO_write_struct_list(writer, bActionGroup, &action->groups);
|
||||
BLO_write_struct_list(writer, TimeMarker, &action->markers);
|
||||
}
|
||||
|
||||
static void action_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
{
|
||||
bAction *action = (bAction *)id;
|
||||
|
||||
BLO_read_list(reader, &action->curves, NULL);
|
||||
BLO_read_list(reader, &action->chanbase, NULL);
|
||||
BLO_read_list(reader, &action->groups, NULL);
|
||||
BLO_read_list(reader, &action->markers, NULL);
|
||||
|
||||
// XXX deprecated - old animation system <<<
|
||||
for (bActionChannel *achan = action->chanbase.first; achan; achan = achan->next) {
|
||||
BLO_read_data_address(reader, &achan->grp);
|
||||
|
||||
BLO_read_list(reader, &achan->constraintChannels, NULL);
|
||||
}
|
||||
// >>> XXX deprecated - old animation system
|
||||
|
||||
BKE_fcurve_blend_read_data(reader, &action->curves);
|
||||
|
||||
for (bActionGroup *agrp = action->groups.first; agrp; agrp = agrp->next) {
|
||||
BLO_read_data_address(reader, &agrp->channels.first);
|
||||
BLO_read_data_address(reader, &agrp->channels.last);
|
||||
}
|
||||
}
|
||||
|
||||
static void blend_read_lib_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
|
||||
{
|
||||
for (bConstraintChannel *chan = chanbase->first; chan; chan = chan->next) {
|
||||
BLO_read_id_address(reader, id->lib, &chan->ipo);
|
||||
}
|
||||
}
|
||||
|
||||
static void action_blend_read_lib(BlendLibReader *reader, ID *id)
|
||||
{
|
||||
bAction *action = (bAction *)id;
|
||||
|
||||
// XXX deprecated - old animation system <<<
|
||||
for (bActionChannel *chan = action->chanbase.first; chan; chan = chan->next) {
|
||||
BLO_read_id_address(reader, id->lib, &chan->ipo);
|
||||
blend_read_lib_constraint_channels(reader, &action->id, &chan->constraintChannels);
|
||||
}
|
||||
// >>> XXX deprecated - old animation system
|
||||
|
||||
BKE_fcurve_blend_read_lib(reader, &action->curves, id);
|
||||
|
||||
for (TimeMarker *marker = action->markers.first; marker; marker = marker->next) {
|
||||
if (marker->camera) {
|
||||
BLO_read_id_address(reader, id->lib, &marker->camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void blend_expand_constraint_channels(BlendExpander *expander, ListBase *chanbase)
|
||||
{
|
||||
for (bConstraintChannel *chan = chanbase->first; chan; chan = chan->next) {
|
||||
BLO_expand(expander, chan->ipo);
|
||||
}
|
||||
}
|
||||
|
||||
static void action_blend_expand(BlendExpander *expander, ID *id)
|
||||
{
|
||||
bAction *action = (bAction *)id;
|
||||
|
||||
// XXX deprecated - old animation system --------------
|
||||
for (bActionChannel *chan = action->chanbase.first; chan; chan = chan->next) {
|
||||
BLO_expand(expander, chan->ipo);
|
||||
blend_expand_constraint_channels(expander, &chan->constraintChannels);
|
||||
}
|
||||
// ---------------------------------------------------
|
||||
|
||||
/* F-Curves in Action */
|
||||
BKE_fcurve_blend_expand(expander, &action->curves);
|
||||
|
||||
for (TimeMarker *marker = action->markers.first; marker; marker = marker->next) {
|
||||
if (marker->camera) {
|
||||
BLO_expand(expander, marker->camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IDTypeInfo IDType_ID_AC = {
|
||||
.id_code = ID_AC,
|
||||
.id_filter = FILTER_ID_AC,
|
||||
@@ -168,6 +266,11 @@ IDTypeInfo IDType_ID_AC = {
|
||||
.copy_data = action_copy_data,
|
||||
.free_data = action_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = action_blend_write,
|
||||
.blend_read_data = action_blend_read_data,
|
||||
.blend_read_lib = action_blend_read_lib,
|
||||
.blend_expand = action_blend_expand,
|
||||
};
|
||||
|
||||
/* ***************** Library data level operations on action ************** */
|
||||
|
@@ -56,6 +56,7 @@
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_material.h"
|
||||
@@ -67,6 +68,8 @@
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "nla_private.h"
|
||||
@@ -2810,3 +2813,94 @@ void BKE_animsys_eval_driver(Depsgraph *depsgraph, ID *id, int driver_index, FCu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_animsys_blend_read_data(BlendDataReader *reader, AnimData *adt)
|
||||
{
|
||||
if (adt == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
BLO_read_list(reader, &adt->drivers, NULL);
|
||||
BKE_fcurve_blend_read_data(reader, &adt->drivers);
|
||||
adt->driver_array = NULL;
|
||||
|
||||
/* link overrides */
|
||||
// TODO...
|
||||
|
||||
/* link NLA-data */
|
||||
BLO_read_list(reader, &adt->nla_tracks, NULL);
|
||||
BKE_nla_blend_read_data(reader, &adt->nla_tracks);
|
||||
|
||||
/* relink active track/strip - even though strictly speaking this should only be used
|
||||
* if we're in 'tweaking mode', we need to be able to have this loaded back for
|
||||
* undo, but also since users may not exit tweakmode before saving (#24535)
|
||||
*/
|
||||
// TODO: it's not really nice that anyone should be able to save the file in this
|
||||
// state, but it's going to be too hard to enforce this single case...
|
||||
BLO_read_data_address(reader, &adt->act_track);
|
||||
BLO_read_data_address(reader, &adt->actstrip);
|
||||
}
|
||||
|
||||
void BKE_animsys_blend_read_lib(BlendLibReader *reader, AnimData *adt, ID *id)
|
||||
{
|
||||
if (adt == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* link action data */
|
||||
BLO_read_id_address(reader, id->lib, &adt->action);
|
||||
BLO_read_id_address(reader, id->lib, &adt->tmpact);
|
||||
|
||||
/* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */
|
||||
if ((adt->action) && (adt->action->idroot == 0)) {
|
||||
adt->action->idroot = GS(id->name);
|
||||
}
|
||||
if ((adt->tmpact) && (adt->tmpact->idroot == 0)) {
|
||||
adt->tmpact->idroot = GS(id->name);
|
||||
}
|
||||
|
||||
/* link drivers */
|
||||
BKE_fcurve_blend_read_lib(reader, &adt->drivers, id);
|
||||
|
||||
/* overrides don't have lib-link for now, so no need to do anything */
|
||||
|
||||
/* link NLA-data */
|
||||
BKE_nla_blend_read_lib(reader, &adt->nla_tracks, id);
|
||||
}
|
||||
|
||||
void BKE_animsys_blend_expand(BlendExpander *expander, AnimData *adt)
|
||||
{
|
||||
/* own action */
|
||||
BLO_expand(expander, adt->action);
|
||||
BLO_expand(expander, adt->tmpact);
|
||||
|
||||
/* drivers - assume that these F-Curves have driver data to be in this list... */
|
||||
BKE_fcurve_blend_expand(expander, &adt->drivers);
|
||||
|
||||
/* nla-data - referenced actions */
|
||||
for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
|
||||
BKE_nla_blend_expand(expander, &nlt->strips);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_animsys_blend_write(BlendWriter *writer, AnimData *adt)
|
||||
{
|
||||
/* firstly, just write the AnimData block */
|
||||
BLO_write_struct(writer, AnimData, adt);
|
||||
|
||||
/* write drivers */
|
||||
BKE_fcurve_blend_write(writer, &adt->drivers);
|
||||
|
||||
/* write overrides */
|
||||
// FIXME: are these needed?
|
||||
for (AnimOverride *aor = adt->overrides.first; aor; aor = aor->next) {
|
||||
/* overrides consist of base data + rna_path */
|
||||
BLO_write_struct(writer, AnimOverride, aor);
|
||||
BLO_write_raw(writer, strlen(aor->rna_path) + 1, aor->rna_path);
|
||||
}
|
||||
|
||||
// TODO write the remaps (if they are needed)
|
||||
|
||||
/* write NLA data */
|
||||
BKE_nla_blend_write(writer, &adt->nla_tracks);
|
||||
}
|
||||
|
@@ -164,6 +164,11 @@ IDTypeInfo IDType_ID_AR = {
|
||||
.copy_data = armature_copy_data,
|
||||
.free_data = armature_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/* **************** Generic Functions, data level *************** */
|
||||
|
@@ -174,6 +174,11 @@ IDTypeInfo IDType_ID_BR = {
|
||||
.copy_data = brush_copy_data,
|
||||
.free_data = brush_free_data,
|
||||
.make_local = brush_make_local,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
static RNG *brush_rng;
|
||||
|
@@ -97,6 +97,11 @@ IDTypeInfo IDType_ID_CF = {
|
||||
.copy_data = cache_file_copy_data,
|
||||
.free_data = cache_file_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/* TODO: make this per cache file to avoid global locks. */
|
||||
|
@@ -127,6 +127,11 @@ IDTypeInfo IDType_ID_CA = {
|
||||
.copy_data = camera_copy_data,
|
||||
.free_data = camera_free_data,
|
||||
.make_local = camera_make_local,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/******************************** Camera Usage *******************************/
|
||||
|
@@ -142,6 +142,11 @@ IDTypeInfo IDType_ID_GR = {
|
||||
.copy_data = collection_copy_data,
|
||||
.free_data = collection_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/***************************** Add Collection *******************************/
|
||||
|
@@ -44,6 +44,8 @@
|
||||
#include "IMB_colormanagement.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "BLO_read_write.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_blend_write(BlendWriter *writer, CurveMapping *cumap)
|
||||
{
|
||||
BLO_write_struct(writer, CurveMapping, cumap);
|
||||
BKE_curvemapping_blend_write_content(writer, cumap);
|
||||
}
|
||||
|
||||
void BKE_curvemapping_blend_write_content(BlendWriter *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_blend_read_data(struct BlendDataReader *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 ******** */
|
||||
|
||||
|
@@ -131,6 +131,11 @@ IDTypeInfo IDType_ID_CU = {
|
||||
.copy_data = curve_copy_data,
|
||||
.free_data = curve_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
static int cu_isectLL(const float v1[3],
|
||||
|
@@ -41,6 +41,8 @@
|
||||
#include "BKE_curveprofile.h"
|
||||
#include "BKE_fcurve.h"
|
||||
|
||||
#include "BLO_read_write.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_blend_write(BlendWriter *writer, const CurveProfile *profile)
|
||||
{
|
||||
BLO_write_struct(writer, CurveProfile, profile);
|
||||
BLO_write_struct_array(writer, CurveProfilePoint, profile->path_len, profile->path);
|
||||
}
|
||||
|
||||
void BKE_curveprofile_blend_read_data(BlendDataReader *reader, CurveProfile *profile)
|
||||
{
|
||||
BLO_read_data_address(reader, &profile->path);
|
||||
profile->table = NULL;
|
||||
profile->segments = NULL;
|
||||
}
|
||||
|
@@ -45,6 +45,8 @@
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_nla.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "CLG_log.h"
|
||||
@@ -1906,3 +1908,149 @@ float calculate_fcurve(PathResolvedRNA *anim_rna, FCurve *fcu, float evaltime)
|
||||
fcu->curval = curval; /* debug display only, not thread safe! */
|
||||
return curval;
|
||||
}
|
||||
|
||||
void BKE_fcurve_blend_read_data(BlendDataReader *reader, ListBase *list)
|
||||
{
|
||||
/* link F-Curve data to F-Curve again (non ID-libs) */
|
||||
for (FCurve *fcu = list->first; fcu; fcu = fcu->next) {
|
||||
/* curve data */
|
||||
BLO_read_data_address(reader, &fcu->bezt);
|
||||
BLO_read_data_address(reader, &fcu->fpt);
|
||||
|
||||
/* rna path */
|
||||
BLO_read_data_address(reader, &fcu->rna_path);
|
||||
|
||||
/* group */
|
||||
BLO_read_data_address(reader, &fcu->grp);
|
||||
|
||||
/* clear disabled flag - allows disabled drivers to be tried again ([#32155]),
|
||||
* but also means that another method for "reviving disabled F-Curves" exists
|
||||
*/
|
||||
fcu->flag &= ~FCURVE_DISABLED;
|
||||
|
||||
/* driver */
|
||||
BLO_read_data_address(reader, &fcu->driver);
|
||||
if (fcu->driver) {
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
|
||||
/* Compiled expression data will need to be regenerated
|
||||
* (old pointer may still be set here). */
|
||||
driver->expr_comp = NULL;
|
||||
driver->expr_simple = NULL;
|
||||
|
||||
/* give the driver a fresh chance - the operating environment may be different now
|
||||
* (addons, etc. may be different) so the driver namespace may be sane now [#32155]
|
||||
*/
|
||||
driver->flag &= ~DRIVER_FLAG_INVALID;
|
||||
|
||||
/* relink variables, targets and their paths */
|
||||
BLO_read_list(reader, &driver->variables, NULL);
|
||||
LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
|
||||
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
|
||||
/* only relink the targets being used */
|
||||
if (tarIndex < dvar->num_targets) {
|
||||
BLO_read_data_address(reader, &dtar->rna_path);
|
||||
}
|
||||
else {
|
||||
dtar->rna_path = NULL;
|
||||
}
|
||||
}
|
||||
DRIVER_TARGETS_LOOPER_END;
|
||||
}
|
||||
}
|
||||
|
||||
/* modifiers */
|
||||
BLO_read_list(reader, &fcu->modifiers, NULL);
|
||||
BKE_fcurve_modifiers_blend_read_data(reader, &fcu->modifiers, fcu);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_fcurve_blend_read_lib(BlendLibReader *reader, ListBase *list, ID *id)
|
||||
{
|
||||
if (list == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (FCurve *fcu = list->first; fcu; fcu = fcu->next) {
|
||||
if (fcu->driver) {
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
|
||||
for (DriverVar *dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
||||
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
|
||||
/* only relink if still used */
|
||||
if (tarIndex < dvar->num_targets) {
|
||||
BLO_read_id_address(reader, id->lib, &dtar->id);
|
||||
}
|
||||
else {
|
||||
dtar->id = NULL;
|
||||
}
|
||||
}
|
||||
DRIVER_TARGETS_LOOPER_END;
|
||||
}
|
||||
}
|
||||
|
||||
BKE_fcurve_modifiers_blend_read_lib(reader, &fcu->modifiers, id);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_fcurve_blend_expand(BlendExpander *expander, ListBase *list)
|
||||
{
|
||||
for (FCurve *fcu = list->first; fcu; fcu = fcu->next) {
|
||||
/* Driver targets if there is a driver */
|
||||
if (fcu->driver) {
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
DriverVar *dvar;
|
||||
|
||||
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
||||
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
|
||||
// TODO: only expand those that are going to get used?
|
||||
BLO_expand(expander, dtar->id);
|
||||
}
|
||||
DRIVER_TARGETS_LOOPER_END;
|
||||
}
|
||||
}
|
||||
|
||||
/* F-Curve Modifiers */
|
||||
BKE_fcurve_modifiers_blend_expand(expander, &fcu->modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_fcurve_blend_write(struct BlendWriter *writer, struct ListBase *fcurves)
|
||||
{
|
||||
BLO_write_struct_list(writer, FCurve, fcurves);
|
||||
|
||||
for (FCurve *fcu = fcurves->first; fcu; fcu = fcu->next) {
|
||||
/* curve data */
|
||||
if (fcu->bezt) {
|
||||
BLO_write_struct_array(writer, BezTriple, fcu->totvert, fcu->bezt);
|
||||
}
|
||||
if (fcu->fpt) {
|
||||
BLO_write_struct_array(writer, FPoint, fcu->totvert, fcu->fpt);
|
||||
}
|
||||
|
||||
if (fcu->rna_path) {
|
||||
BLO_write_raw(writer, strlen(fcu->rna_path) + 1, fcu->rna_path);
|
||||
}
|
||||
|
||||
/* driver data */
|
||||
if (fcu->driver) {
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
|
||||
BLO_write_struct(writer, ChannelDriver, driver);
|
||||
|
||||
/* variables */
|
||||
BLO_write_struct_list(writer, DriverVar, &driver->variables);
|
||||
for (DriverVar *dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
||||
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
|
||||
if (dtar->rna_path) {
|
||||
BLO_write_raw(writer, strlen(dtar->rna_path) + 1, dtar->rna_path);
|
||||
}
|
||||
}
|
||||
DRIVER_TARGETS_LOOPER_END;
|
||||
}
|
||||
}
|
||||
|
||||
/* write F-Modifiers */
|
||||
BKE_fcurve_modifiers_blend_write(writer, &fcu->modifiers);
|
||||
}
|
||||
}
|
||||
|
@@ -44,6 +44,8 @@
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_idprop.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
static CLG_LogRef LOG = {"bke.fmodifier"};
|
||||
|
||||
/* ******************************** F-Modifiers ********************************* */
|
||||
@@ -1561,3 +1563,107 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end)
|
||||
/* restore driver */
|
||||
fcu->driver = driver;
|
||||
}
|
||||
|
||||
void BKE_fcurve_modifiers_blend_read_data(BlendDataReader *reader, ListBase *list, FCurve *fcurve)
|
||||
{
|
||||
for (FModifier *fcm = list->first; fcm; fcm = fcm->next) {
|
||||
/* relink general data */
|
||||
BLO_read_data_address(reader, &fcm->data);
|
||||
fcm->curve = fcurve;
|
||||
|
||||
/* do relinking of data for specific types */
|
||||
switch (fcm->type) {
|
||||
case FMODIFIER_TYPE_GENERATOR: {
|
||||
FMod_Generator *data = (FMod_Generator *)fcm->data;
|
||||
BLO_read_float_array(reader, data->arraysize, &data->coefficients);
|
||||
break;
|
||||
}
|
||||
case FMODIFIER_TYPE_ENVELOPE: {
|
||||
FMod_Envelope *data = (FMod_Envelope *)fcm->data;
|
||||
BLO_read_data_address(reader, &data->data);
|
||||
break;
|
||||
}
|
||||
case FMODIFIER_TYPE_PYTHON: {
|
||||
FMod_Python *data = (FMod_Python *)fcm->data;
|
||||
BLO_read_data_address(reader, &data->prop);
|
||||
IDP_Group_BlendReadData(reader, &data->prop, __func__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_fcurve_modifiers_blend_read_lib(BlendLibReader *reader, ListBase *list, ID *id)
|
||||
{
|
||||
for (FModifier *fcm = list->first; fcm; fcm = fcm->next) {
|
||||
switch (fcm->type) {
|
||||
case FMODIFIER_TYPE_PYTHON: {
|
||||
FMod_Python *data = (FMod_Python *)fcm->data;
|
||||
BLO_read_id_address(reader, id->lib, &data->script);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_fcurve_modifiers_blend_expand(BlendExpander *expander, ListBase *list)
|
||||
{
|
||||
LISTBASE_FOREACH (FModifier *, fcm, list) {
|
||||
switch (fcm->type) {
|
||||
case FMODIFIER_TYPE_PYTHON: {
|
||||
FMod_Python *data = (FMod_Python *)fcm->data;
|
||||
BLO_expand(expander, data->script);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_fcurve_modifiers_blend_write(BlendWriter *writer, ListBase *fmodifiers)
|
||||
{
|
||||
/* Write all modifiers first (for faster reloading) */
|
||||
BLO_write_struct_list(writer, FModifier, fmodifiers);
|
||||
|
||||
/* Modifiers */
|
||||
for (FModifier *fcm = fmodifiers->first; fcm; fcm = fcm->next) {
|
||||
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
|
||||
/* Write the specific data */
|
||||
if (fmi && fcm->data) {
|
||||
/* firstly, just write the plain fmi->data struct */
|
||||
BLO_write_struct_by_name(writer, fmi->structName, fcm->data);
|
||||
|
||||
/* do any modifier specific stuff */
|
||||
switch (fcm->type) {
|
||||
case FMODIFIER_TYPE_GENERATOR: {
|
||||
FMod_Generator *data = fcm->data;
|
||||
|
||||
/* write coefficients array */
|
||||
if (data->coefficients) {
|
||||
BLO_write_raw(writer, sizeof(float) * data->arraysize, data->coefficients);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case FMODIFIER_TYPE_ENVELOPE: {
|
||||
FMod_Envelope *data = fcm->data;
|
||||
|
||||
/* write envelope data */
|
||||
if (data->data) {
|
||||
BLO_write_struct_array(writer, FCM_EvenlopeData, data->totvert, data->data);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case FMODIFIER_TYPE_PYTHON: {
|
||||
FMod_Python *data = fcm->data;
|
||||
|
||||
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
||||
* of library blocks that implement this.*/
|
||||
IDP_BlendWrite(writer, data->prop);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -134,6 +134,11 @@ IDTypeInfo IDType_ID_VF = {
|
||||
.copy_data = vfont_copy_data,
|
||||
.free_data = vfont_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/***************************** VFont *******************************/
|
||||
|
@@ -111,6 +111,11 @@ IDTypeInfo IDType_ID_GD = {
|
||||
.copy_data = greasepencil_copy_data,
|
||||
.free_data = greasepencil_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/* ************************************************** */
|
||||
|
@@ -173,6 +173,11 @@ IDTypeInfo IDType_ID_HA = {
|
||||
.copy_data = hair_copy_data,
|
||||
.free_data = hair_free_data,
|
||||
.make_local = hair_make_local,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
BoundBox *BKE_hair_boundbox_get(Object *ob)
|
||||
|
@@ -31,9 +31,12 @@
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_lib_id.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
@@ -1172,3 +1175,269 @@ void IDP_foreach_property(IDProperty *id_property_root,
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
static void idp_read_array(BlendDataReader *reader, IDProperty *prop)
|
||||
{
|
||||
/* Since we didn't save the extra buffer, set totallen to len. */
|
||||
prop->totallen = prop->len;
|
||||
|
||||
if (prop->subtype == IDP_GROUP) {
|
||||
BLO_read_pointer_array(reader, &prop->data.pointer);
|
||||
IDProperty **array = prop->data.pointer;
|
||||
|
||||
for (int i = 0; i < prop->len; i++) {
|
||||
IDP_BlendReadData(reader, array[i]);
|
||||
}
|
||||
}
|
||||
else if (prop->subtype == IDP_DOUBLE) {
|
||||
BLO_read_double_array(reader, prop->len, (double **)&prop->data.pointer);
|
||||
}
|
||||
else if (prop->subtype == IDP_FLOAT) {
|
||||
BLO_read_float_array(reader, prop->len, (float **)&prop->data.pointer);
|
||||
}
|
||||
else if (prop->subtype == IDP_INT) {
|
||||
BLO_read_int32_array(reader, prop->len, (int32_t **)&prop->data.pointer);
|
||||
}
|
||||
else {
|
||||
BLI_assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
static void idp_read_string(BlendDataReader *reader, IDProperty *prop)
|
||||
{
|
||||
/* Since we didn't save the extra string buffer, set totallen to len. */
|
||||
prop->totallen = prop->len;
|
||||
BLO_read_data_address(reader, &prop->data.pointer);
|
||||
}
|
||||
|
||||
static void idp_read_group(BlendDataReader *reader, IDProperty *prop)
|
||||
{
|
||||
BLO_read_list(reader, &prop->data.group, NULL);
|
||||
|
||||
/* Link child properties now. */
|
||||
LISTBASE_FOREACH (IDProperty *, sub_prop, &prop->data.group) {
|
||||
IDP_BlendReadData(reader, sub_prop);
|
||||
}
|
||||
}
|
||||
|
||||
static void idp_read_idp_array(BlendDataReader *reader, IDProperty *prop)
|
||||
{
|
||||
/* Since we didn't save the extra buffer, set totallen to len. */
|
||||
prop->totallen = prop->len;
|
||||
BLO_read_pointer_array(reader, &prop->data.pointer);
|
||||
|
||||
IDProperty *array = (IDProperty *)prop->data.pointer;
|
||||
|
||||
/* Note, idp-arrays didn't exist in 2.4x, so the pointer will be cleared.
|
||||
* There is not really anything we can do to correct this, at least don't crash. */
|
||||
if (array == NULL) {
|
||||
prop->len = 0;
|
||||
prop->totallen = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < prop->len; i++) {
|
||||
IDP_BlendReadData(reader, &array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void idp_read_double(BlendDataReader *reader, IDProperty *prop)
|
||||
{
|
||||
/* Workaround for doubles.
|
||||
* They are stored in the same field as `int val, val2` in the IDPropertyData struct,
|
||||
* they have to deal with endianness specifically.
|
||||
*
|
||||
* In theory, val and val2 would've already been swapped
|
||||
* if switch_endian is true, so we have to first unswap
|
||||
* them then re-swap them as a single 64-bit entity. */
|
||||
if (BLO_read_requires_endian_switch(reader)) {
|
||||
BLI_endian_switch_int32(&prop->data.val);
|
||||
BLI_endian_switch_int32(&prop->data.val2);
|
||||
BLI_endian_switch_int64((int64_t *)&prop->data.val);
|
||||
}
|
||||
}
|
||||
|
||||
void IDP_BlendReadData(BlendDataReader *reader, IDProperty *prop)
|
||||
{
|
||||
switch (prop->type) {
|
||||
case IDP_GROUP:
|
||||
idp_read_group(reader, prop);
|
||||
break;
|
||||
case IDP_STRING:
|
||||
idp_read_string(reader, prop);
|
||||
break;
|
||||
case IDP_ARRAY:
|
||||
idp_read_array(reader, prop);
|
||||
break;
|
||||
case IDP_IDPARRAY:
|
||||
idp_read_idp_array(reader, prop);
|
||||
break;
|
||||
case IDP_DOUBLE:
|
||||
idp_read_double(reader, prop);
|
||||
break;
|
||||
case IDP_INT:
|
||||
case IDP_FLOAT:
|
||||
case IDP_ID:
|
||||
break; /* Nothing special to do here. */
|
||||
default: {
|
||||
/* Unknown IDP type, nuke it (we cannot handle unknown types everywhere in code,
|
||||
* IDP are way too polymorphic to do it safely. */
|
||||
printf(
|
||||
"%s: found unknown IDProperty type %d, reset to Integer one !\n", __func__, prop->type);
|
||||
/* Note: we do not attempt to free unknown prop, we have no way to know how to do that! */
|
||||
prop->type = IDP_INT;
|
||||
prop->subtype = 0;
|
||||
IDP_Int(prop) = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IDP_BlendReadLib(BlendLibReader *reader, IDProperty *prop)
|
||||
{
|
||||
if (prop == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (prop->type) {
|
||||
case IDP_ID: /* PointerProperty */
|
||||
{
|
||||
ID *new_address = BLO_read_get_new_id_address(reader, NULL, (ID *)prop->data.pointer);
|
||||
if (IDP_Id(prop) && !new_address && G.debug) {
|
||||
printf("Error while loading \"%s\". Data not found in file!\n", prop->name);
|
||||
}
|
||||
prop->data.pointer = new_address;
|
||||
break;
|
||||
}
|
||||
case IDP_IDPARRAY: /* CollectionProperty */
|
||||
{
|
||||
IDProperty *idp_array = IDP_IDPArray(prop);
|
||||
for (int i = 0; i < prop->len; i++) {
|
||||
IDP_BlendReadLib(reader, &idp_array[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDP_GROUP: /* PointerProperty */
|
||||
{
|
||||
LISTBASE_FOREACH (IDProperty *, sub_prop, &prop->data.group) {
|
||||
IDP_BlendReadLib(reader, sub_prop);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break; /* Nothing to do for other IDProps. */
|
||||
}
|
||||
}
|
||||
|
||||
void IDP_BlendExpand(BlendExpander *expander, IDProperty *prop)
|
||||
{
|
||||
if (!prop) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (prop->type) {
|
||||
case IDP_ID:
|
||||
BLO_expand(expander, IDP_Id(prop));
|
||||
break;
|
||||
case IDP_IDPARRAY: {
|
||||
IDProperty *idp_array = IDP_IDPArray(prop);
|
||||
for (int i = 0; i < prop->len; i++) {
|
||||
IDP_BlendExpand(expander, &idp_array[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDP_GROUP:
|
||||
for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) {
|
||||
IDP_BlendExpand(expander, loop);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void IDP_Group_BlendReadData(struct BlendDataReader *reader,
|
||||
struct IDProperty **prop,
|
||||
const char *caller_func_id)
|
||||
{
|
||||
if (prop == NULL || *prop == NULL) {
|
||||
return;
|
||||
}
|
||||
if ((*prop)->type == IDP_GROUP) {
|
||||
IDP_BlendReadData(reader, *prop);
|
||||
}
|
||||
else {
|
||||
/* corrupt file! */
|
||||
printf("%s: found non group data, freeing type %d!\n", caller_func_id, (*prop)->type);
|
||||
/* don't risk id, data's likely corrupt. */
|
||||
// IDP_FreePropertyContent(*prop);
|
||||
*prop = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void idp_write_group(BlendWriter *writer, const IDProperty *prop)
|
||||
{
|
||||
LISTBASE_FOREACH (const IDProperty *, sub_prop, &prop->data.group) {
|
||||
IDP_BlendWrite(writer, sub_prop);
|
||||
}
|
||||
}
|
||||
|
||||
static void idp_write_string(BlendWriter *writer, const IDProperty *prop)
|
||||
{
|
||||
/* Remember to set totallen to len in the linking code. */
|
||||
BLO_write_raw(writer, prop->len, prop->data.pointer);
|
||||
}
|
||||
|
||||
static void idp_write_array(BlendWriter *writer, const IDProperty *prop)
|
||||
{
|
||||
if (prop->data.pointer == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Remember to set totallen to len in the linking code. */
|
||||
BLO_write_raw(writer, (int)MEM_allocN_len(prop->data.pointer), prop->data.pointer);
|
||||
|
||||
if (prop->subtype == IDP_GROUP) {
|
||||
IDProperty **array = prop->data.pointer;
|
||||
|
||||
for (int i = 0; i < prop->len; i++) {
|
||||
IDP_BlendWrite(writer, array[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void idp_write_only_data(BlendWriter *writer, const IDProperty *prop);
|
||||
|
||||
static void idp_write_idp_array(BlendWriter *writer, const IDProperty *prop)
|
||||
{
|
||||
/* Remember to set totallen to len in the linking code. */
|
||||
if (prop->data.pointer) {
|
||||
const IDProperty *array = prop->data.pointer;
|
||||
BLO_write_struct_array(writer, IDProperty, prop->len, array);
|
||||
|
||||
for (int i = 0; i < prop->len; i++) {
|
||||
idp_write_only_data(writer, &array[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void idp_write_only_data(BlendWriter *writer, const IDProperty *prop)
|
||||
{
|
||||
switch (prop->type) {
|
||||
case IDP_GROUP:
|
||||
idp_write_group(writer, prop);
|
||||
break;
|
||||
case IDP_STRING:
|
||||
idp_write_string(writer, prop);
|
||||
break;
|
||||
case IDP_ARRAY:
|
||||
idp_write_array(writer, prop);
|
||||
break;
|
||||
case IDP_IDPARRAY:
|
||||
idp_write_idp_array(writer, prop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void IDP_BlendWrite(BlendWriter *writer, const IDProperty *prop)
|
||||
{
|
||||
BLO_write_struct(writer, IDProperty, prop);
|
||||
idp_write_only_data(writer, prop);
|
||||
}
|
||||
|
@@ -199,6 +199,11 @@ IDTypeInfo IDType_ID_IM = {
|
||||
.copy_data = image_copy_data,
|
||||
.free_data = image_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/* prototypes */
|
||||
|
@@ -123,6 +123,11 @@ IDTypeInfo IDType_ID_IP = {
|
||||
.copy_data = NULL,
|
||||
.free_data = ipo_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/* *************************************************** */
|
||||
|
@@ -43,6 +43,7 @@
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_customdata.h"
|
||||
#include "BKE_deform.h"
|
||||
@@ -55,8 +56,15 @@
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_scene.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
/* old defines from DNA_ipo_types.h for data-type, stored in DNA - don't modify! */
|
||||
#define IPO_FLOAT 4
|
||||
#define IPO_BEZTRIPLE 100
|
||||
#define IPO_BPOINT 101
|
||||
|
||||
static void shapekey_copy_data(Main *UNUSED(bmain),
|
||||
ID *id_dst,
|
||||
const ID *id_src,
|
||||
@@ -91,6 +99,94 @@ static void shapekey_free_data(ID *id)
|
||||
}
|
||||
}
|
||||
|
||||
static void shapekey_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
{
|
||||
Key *key = (Key *)id;
|
||||
if (key->id.us == 0 && !BLO_write_is_undo(writer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Key, id_address, id);
|
||||
BKE_iddata_blend_write(writer, id);
|
||||
|
||||
if (key->adt) {
|
||||
BKE_animsys_blend_write(writer, key->adt);
|
||||
}
|
||||
|
||||
/* direct data */
|
||||
for (KeyBlock *kb = key->block.first; kb; kb = kb->next) {
|
||||
BLO_write_struct(writer, KeyBlock, kb);
|
||||
if (kb->data) {
|
||||
BLO_write_raw(writer, kb->totelem * key->elemsize, kb->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void switch_endian_keyblock(Key *key, KeyBlock *kb)
|
||||
{
|
||||
int elemsize, a, b;
|
||||
char *data;
|
||||
|
||||
elemsize = key->elemsize;
|
||||
data = kb->data;
|
||||
|
||||
for (a = 0; a < kb->totelem; a++) {
|
||||
const char *cp = key->elemstr;
|
||||
char *poin = data;
|
||||
|
||||
while (cp[0]) { /* cp[0] == amount */
|
||||
switch (cp[1]) { /* cp[1] = type */
|
||||
case IPO_FLOAT:
|
||||
case IPO_BPOINT:
|
||||
case IPO_BEZTRIPLE:
|
||||
b = cp[0];
|
||||
BLI_endian_switch_float_array((float *)poin, b);
|
||||
poin += sizeof(float) * b;
|
||||
break;
|
||||
}
|
||||
|
||||
cp += 2;
|
||||
}
|
||||
data += elemsize;
|
||||
}
|
||||
}
|
||||
|
||||
static void shapekey_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
{
|
||||
Key *key = (Key *)id;
|
||||
|
||||
BLO_read_list(reader, &key->block, NULL);
|
||||
|
||||
BLO_read_data_address(reader, &key->adt);
|
||||
BKE_animsys_blend_read_data(reader, key->adt);
|
||||
|
||||
BLO_read_data_address(reader, &key->refkey);
|
||||
|
||||
for (KeyBlock *kb = key->block.first; kb; kb = kb->next) {
|
||||
BLO_read_data_address(reader, &kb->data);
|
||||
|
||||
if (BLO_read_requires_endian_switch(reader)) {
|
||||
switch_endian_keyblock(key, kb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void shapekey_blend_read_lib(BlendLibReader *reader, ID *id)
|
||||
{
|
||||
Key *key = (Key *)id;
|
||||
BLI_assert((key->id.tag & LIB_TAG_EXTERN) == 0);
|
||||
|
||||
BLO_read_id_address(reader, id->lib, &key->ipo); // XXX deprecated - old animation system
|
||||
BLO_read_id_address(reader, id->lib, &key->from);
|
||||
}
|
||||
|
||||
static void shapekey_blend_expand(BlendExpander *expander, ID *id)
|
||||
{
|
||||
Key *key = (Key *)id;
|
||||
BLO_expand(expander, key->ipo); // XXX deprecated - old animation system
|
||||
}
|
||||
|
||||
IDTypeInfo IDType_ID_KE = {
|
||||
.id_code = ID_KE,
|
||||
.id_filter = 0,
|
||||
@@ -105,17 +201,17 @@ IDTypeInfo IDType_ID_KE = {
|
||||
.copy_data = shapekey_copy_data,
|
||||
.free_data = shapekey_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = shapekey_blend_write,
|
||||
.blend_read_data = shapekey_blend_read_data,
|
||||
.blend_read_lib = shapekey_blend_read_lib,
|
||||
.blend_expand = shapekey_blend_expand,
|
||||
};
|
||||
|
||||
#define KEY_MODE_DUMMY 0 /* use where mode isn't checked for */
|
||||
#define KEY_MODE_BPOINT 1
|
||||
#define KEY_MODE_BEZTRIPLE 2
|
||||
|
||||
/* old defines from DNA_ipo_types.h for data-type, stored in DNA - don't modify! */
|
||||
#define IPO_FLOAT 4
|
||||
#define IPO_BEZTRIPLE 100
|
||||
#define IPO_BPOINT 101
|
||||
|
||||
/* Internal use only. */
|
||||
typedef struct WeightsArrayCache {
|
||||
int num_defgroup_weights;
|
||||
|
@@ -135,6 +135,11 @@ IDTypeInfo IDType_ID_LT = {
|
||||
.copy_data = lattice_copy_data,
|
||||
.free_data = lattice_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
int BKE_lattice_index_from_uvw(Lattice *lt, const int u, const int v, const int w)
|
||||
|
@@ -74,6 +74,8 @@
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "atomic_ops.h"
|
||||
|
||||
//#define DEBUG_TIME
|
||||
@@ -99,6 +101,11 @@ IDTypeInfo IDType_ID_LINK_PLACEHOLDER = {
|
||||
.copy_data = NULL,
|
||||
.free_data = NULL,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/* GS reads the memory pointed at in a specific ordering.
|
||||
@@ -2242,3 +2249,28 @@ void BKE_id_reorder(const ListBase *lb, ID *id, ID *relative, bool after)
|
||||
*id_order = relative_order - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_iddata_blend_write(BlendWriter *writer, ID *id)
|
||||
{
|
||||
/* ID_WM's id->properties are considered runtime only, and never written in .blend file. */
|
||||
if (id->properties && !ELEM(GS(id->name), ID_WM)) {
|
||||
IDP_BlendWrite(writer, id->properties);
|
||||
}
|
||||
|
||||
if (id->override_library) {
|
||||
BLO_write_struct(writer, IDOverrideLibrary, id->override_library);
|
||||
|
||||
BLO_write_struct_list(writer, IDOverrideLibraryProperty, &id->override_library->properties);
|
||||
for (IDOverrideLibraryProperty *op = id->override_library->properties.first; op;
|
||||
op = op->next) {
|
||||
BLO_write_string(writer, op->rna_path);
|
||||
|
||||
BLO_write_struct_list(writer, IDOverrideLibraryPropertyOperation, &op->operations);
|
||||
for (IDOverrideLibraryPropertyOperation *opop = op->operations.first; opop;
|
||||
opop = opop->next) {
|
||||
BLO_write_string(writer, opop->subitem_reference_name);
|
||||
BLO_write_string(writer, opop->subitem_local_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -67,6 +67,11 @@ IDTypeInfo IDType_ID_LI = {
|
||||
.copy_data = NULL,
|
||||
.free_data = library_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
|
||||
|
@@ -121,6 +121,11 @@ IDTypeInfo IDType_ID_LA = {
|
||||
.copy_data = light_copy_data,
|
||||
.free_data = light_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
Light *BKE_light_add(Main *bmain, const char *name)
|
||||
|
@@ -123,4 +123,9 @@ IDTypeInfo IDType_ID_LP = {
|
||||
.copy_data = lightprobe_copy_data,
|
||||
.free_data = NULL,
|
||||
.make_local = lightprobe_make_local,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
@@ -158,6 +158,11 @@ IDTypeInfo IDType_ID_LS = {
|
||||
.copy_data = linestyle_copy_data,
|
||||
.free_data = linestyle_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
static const char *modifier_name[LS_MODIFIER_NUM] = {
|
||||
|
@@ -93,6 +93,11 @@ IDTypeInfo IDType_ID_MSK = {
|
||||
.copy_data = mask_copy_data,
|
||||
.free_data = mask_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
static struct {
|
||||
|
@@ -157,6 +157,11 @@ IDTypeInfo IDType_ID_MA = {
|
||||
.copy_data = material_copy_data,
|
||||
.free_data = material_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
void BKE_gpencil_material_attr_init(Material *ma)
|
||||
|
@@ -115,6 +115,11 @@ IDTypeInfo IDType_ID_MB = {
|
||||
.copy_data = metaball_copy_data,
|
||||
.free_data = metaball_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/* Functions */
|
||||
|
@@ -156,6 +156,11 @@ IDTypeInfo IDType_ID_ME = {
|
||||
.copy_data = mesh_copy_data,
|
||||
.free_data = mesh_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@@ -120,6 +120,11 @@ IDTypeInfo IDType_ID_MC = {
|
||||
.copy_data = movie_clip_copy_data,
|
||||
.free_data = movie_clip_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/*********************** movieclip buffer loaders *************************/
|
||||
|
@@ -53,6 +53,8 @@
|
||||
#include "BKE_nla.h"
|
||||
#include "BKE_sound.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "nla_private.h"
|
||||
|
||||
@@ -2174,3 +2176,103 @@ void BKE_nla_tweakmode_exit(AnimData *adt)
|
||||
adt->actstrip = NULL;
|
||||
adt->flag &= ~ADT_NLA_EDIT_ON;
|
||||
}
|
||||
|
||||
static void nla_strips_blend_read_data(BlendDataReader *reader, ListBase *list)
|
||||
{
|
||||
for (NlaStrip *strip = list->first; strip; strip = strip->next) {
|
||||
/* strip's child strips */
|
||||
BLO_read_list(reader, &strip->strips, NULL);
|
||||
nla_strips_blend_read_data(reader, &strip->strips);
|
||||
|
||||
/* strip's F-Curves */
|
||||
BLO_read_list(reader, &strip->fcurves, NULL);
|
||||
BKE_fcurve_blend_read_data(reader, &strip->fcurves);
|
||||
|
||||
/* strip's F-Modifiers */
|
||||
BLO_read_list(reader, &strip->modifiers, NULL);
|
||||
BKE_fcurve_modifiers_blend_read_data(reader, &strip->modifiers, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_nla_blend_read_data(BlendDataReader *reader, ListBase *list)
|
||||
{
|
||||
for (NlaTrack *nlt = list->first; nlt; nlt = nlt->next) {
|
||||
/* relink list of strips */
|
||||
BLO_read_list(reader, &nlt->strips, NULL);
|
||||
|
||||
/* relink strip data */
|
||||
nla_strips_blend_read_data(reader, &nlt->strips);
|
||||
}
|
||||
}
|
||||
|
||||
static void nla_strips_blend_read_lib(BlendLibReader *reader, ListBase *list, ID *id)
|
||||
{
|
||||
for (NlaStrip *strip = list->first; strip; strip = strip->next) {
|
||||
/* check strip's children */
|
||||
nla_strips_blend_read_lib(reader, &strip->strips, id);
|
||||
|
||||
/* check strip's F-Curves */
|
||||
BKE_fcurve_blend_read_lib(reader, &strip->fcurves, id);
|
||||
|
||||
/* reassign the counted-reference to action */
|
||||
BLO_read_id_address(reader, id->lib, &strip->act);
|
||||
|
||||
/* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */
|
||||
if ((strip->act) && (strip->act->idroot == 0)) {
|
||||
strip->act->idroot = GS(id->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_nla_blend_read_lib(BlendLibReader *reader, ListBase *list, ID *id)
|
||||
{
|
||||
/* we only care about the NLA strips inside the tracks */
|
||||
for (NlaTrack *nlt = list->first; nlt; nlt = nlt->next) {
|
||||
nla_strips_blend_read_lib(reader, &nlt->strips, id);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_nla_blend_expand(struct BlendExpander *expander, struct ListBase *list)
|
||||
{
|
||||
for (NlaStrip *strip = list->first; strip; strip = strip->next) {
|
||||
/* check child strips */
|
||||
BKE_nla_blend_expand(expander, &strip->strips);
|
||||
|
||||
/* check F-Curves */
|
||||
BKE_fcurve_blend_expand(expander, &strip->fcurves);
|
||||
|
||||
/* check F-Modifiers */
|
||||
BKE_fcurve_modifiers_blend_expand(expander, &strip->modifiers);
|
||||
|
||||
/* relink referenced action */
|
||||
BLO_expand(expander, strip->act);
|
||||
}
|
||||
}
|
||||
|
||||
static void write_nlastrips(BlendWriter *writer, ListBase *strips)
|
||||
{
|
||||
BLO_write_struct_list(writer, NlaStrip, strips);
|
||||
|
||||
for (NlaStrip *strip = strips->first; strip; strip = strip->next) {
|
||||
/* write the strip's F-Curves and modifiers */
|
||||
BKE_fcurve_blend_write(writer, &strip->fcurves);
|
||||
BKE_fcurve_modifiers_blend_write(writer, &strip->modifiers);
|
||||
|
||||
/* write the strip's children */
|
||||
write_nlastrips(writer, &strip->strips);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_nla_blend_write(BlendWriter *writer, ListBase *nlabase)
|
||||
{
|
||||
NlaTrack *nlt;
|
||||
|
||||
/* write all the tracks */
|
||||
for (nlt = nlabase->first; nlt; nlt = nlt->next) {
|
||||
/* write the track first */
|
||||
BLO_write_struct(writer, NlaTrack, nlt);
|
||||
|
||||
/* write the track's strips */
|
||||
write_nlastrips(writer, &nlt->strips);
|
||||
}
|
||||
}
|
||||
|
@@ -267,6 +267,11 @@ IDTypeInfo IDType_ID_NT = {
|
||||
.copy_data = ntree_copy_data,
|
||||
.free_data = ntree_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType *ntype)
|
||||
|
@@ -392,6 +392,11 @@ IDTypeInfo IDType_ID_OB = {
|
||||
.copy_data = object_copy_data,
|
||||
.free_data = object_free_data,
|
||||
.make_local = object_make_local,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
void BKE_object_workob_clear(Object *workob)
|
||||
|
@@ -116,6 +116,11 @@ IDTypeInfo IDType_ID_PAL = {
|
||||
.copy_data = palette_copy_data,
|
||||
.free_data = palette_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
static void paint_curve_copy_data(Main *UNUSED(bmain),
|
||||
@@ -153,6 +158,11 @@ IDTypeInfo IDType_ID_PC = {
|
||||
.copy_data = paint_curve_copy_data,
|
||||
.free_data = paint_curve_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
const char PAINT_CURSOR_SCULPT[3] = {255, 100, 100};
|
||||
|
@@ -160,6 +160,11 @@ IDTypeInfo IDType_ID_PA = {
|
||||
.copy_data = particle_settings_copy_data,
|
||||
.free_data = particle_settings_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
unsigned int PSYS_FRAND_SEED_OFFSET[PSYS_FRAND_COUNT];
|
||||
|
@@ -43,6 +43,7 @@
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_endian_switch.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_utildefines.h"
|
||||
@@ -66,6 +67,8 @@
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_softbody.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "BIK_api.h"
|
||||
|
||||
#ifdef WITH_BULLET
|
||||
@@ -3344,6 +3347,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_blend_write_list(BlendWriter *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(BlendDataReader *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(BlendDataReader *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_blend_read(struct BlendDataReader *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)
|
||||
{
|
||||
|
@@ -140,6 +140,11 @@ IDTypeInfo IDType_ID_PT = {
|
||||
.copy_data = pointcloud_copy_data,
|
||||
.free_data = pointcloud_free_data,
|
||||
.make_local = pointcloud_make_local,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
BoundBox *BKE_pointcloud_boundbox_get(Object *ob)
|
||||
|
@@ -426,6 +426,11 @@ IDTypeInfo IDType_ID_SCE = {
|
||||
/* For now default `BKE_lib_id_make_local_generic()` should work, may need more work though to
|
||||
* support all possible corner cases. */
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE";
|
||||
|
@@ -86,6 +86,11 @@ IDTypeInfo IDType_ID_SCR = {
|
||||
.copy_data = NULL,
|
||||
.free_data = screen_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/* ************ Spacetype/regiontype handling ************** */
|
||||
|
@@ -127,6 +127,11 @@ IDTypeInfo IDType_ID_SO = {
|
||||
.copy_data = sound_copy_data,
|
||||
.free_data = sound_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
#ifdef WITH_AUDASPACE
|
||||
|
@@ -56,6 +56,11 @@ IDTypeInfo IDType_ID_SPK = {
|
||||
.copy_data = NULL,
|
||||
.free_data = NULL,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
void *BKE_speaker_add(Main *bmain, const char *name)
|
||||
|
@@ -206,6 +206,11 @@ IDTypeInfo IDType_ID_TXT = {
|
||||
.copy_data = text_copy_data,
|
||||
.free_data = text_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/***/
|
||||
|
@@ -137,6 +137,11 @@ IDTypeInfo IDType_ID_TE = {
|
||||
.copy_data = texture_copy_data,
|
||||
.free_data = texture_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/* ****************** Mapping ******************* */
|
||||
|
@@ -520,6 +520,11 @@ IDTypeInfo IDType_ID_VO = {
|
||||
/* copy_data */ volume_copy_data,
|
||||
/* free_data */ volume_free_data,
|
||||
/* make_local */ volume_make_local,
|
||||
|
||||
/* blend_write */ NULL,
|
||||
/* blend_read_data */ NULL,
|
||||
/* blend_read_lib */ NULL,
|
||||
/* blend_expand */ NULL,
|
||||
};
|
||||
|
||||
/* Sequence */
|
||||
|
@@ -79,6 +79,11 @@ IDTypeInfo IDType_ID_WS = {
|
||||
.copy_data = NULL,
|
||||
.free_data = workspace_free_data,
|
||||
.make_local = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
/** \name Internal Utils
|
||||
|
@@ -178,6 +178,11 @@ IDTypeInfo IDType_ID_WO = {
|
||||
.copy_data = world_copy_data,
|
||||
.free_data = world_free_data,
|
||||
.make_local = world_make_local,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_expand = NULL,
|
||||
};
|
||||
|
||||
void BKE_world_eval(struct Depsgraph *depsgraph, World *world)
|
||||
|
209
source/blender/blenloader/BLO_read_write.h
Normal file
209
source/blender/blenloader/BLO_read_write.h
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup blenloader
|
||||
*
|
||||
* This file contains an API that allows different parts of Blender to define what data is stored
|
||||
* in .blend files.
|
||||
*
|
||||
* Four callbacks have to be provided to fully implement .blend I/O for a piece of data. One of
|
||||
* those is related to file writing and three for file reading. Reading requires multiple
|
||||
* callbacks, due to the way linking between files works.
|
||||
*
|
||||
* Brief description of the individual callbacks:
|
||||
* - Blend Write: Define which structs and memory buffers are saved.
|
||||
* - Blend Read Data: Loads structs and memory buffers from file and updates pointers them.
|
||||
* - Blend Read Lib: Updates pointers to ID data blocks.
|
||||
* - Blend Expand: Defines which other data blocks should be loaded (possibly from other files).
|
||||
*
|
||||
* Each of these callbacks uses a different API functions.
|
||||
*
|
||||
* Some parts of Blender, e.g. modifiers, don't require you to implement all four callbacks.
|
||||
* Instead only the first two are necessary. The other two are handled by general ID management. In
|
||||
* the future, we might want to get rid of those two callbacks entirely, but for now they are
|
||||
* necessary.
|
||||
*/
|
||||
|
||||
#ifndef __BLO_READ_WRITE_H__
|
||||
#define __BLO_READ_WRITE_H__
|
||||
|
||||
#include "BLI_endian_switch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct BlendWriter BlendWriter;
|
||||
typedef struct BlendDataReader BlendDataReader;
|
||||
typedef struct BlendLibReader BlendLibReader;
|
||||
typedef struct BlendExpander BlendExpander;
|
||||
|
||||
/* Blend Write API
|
||||
* ===============
|
||||
*
|
||||
* Most functions fall into one of two categories. Either they write a DNA struct or a raw memory
|
||||
* buffer to the .blend file.
|
||||
*
|
||||
* It is safe to pass NULL as data_ptr. In this case nothing will be stored.
|
||||
*
|
||||
* DNA Struct Writing
|
||||
* ------------------
|
||||
*
|
||||
* Functions dealing with DNA structs begin with BLO_write_struct_*.
|
||||
*
|
||||
* DNA struct types can be identified in different ways:
|
||||
* - Run-time Name: The name is provided as const char *.
|
||||
* - Compile-time Name: The name is provided at compile time. This can be more efficient. Note
|
||||
* that this optimization is not implemented currently.
|
||||
* - Struct ID: Every DNA struct type has an integer ID that can be queried with
|
||||
* BLO_get_struct_id_by_name. Providing this ID can be a useful optimization when many structs
|
||||
* of the same type are stored AND if those structs are not in a continuous array.
|
||||
*
|
||||
* Often only a single instance of a struct is written at once. However, sometimes it is necessary
|
||||
* to write arrays or linked lists. Separate functions for that are provided as well.
|
||||
*
|
||||
* There is a special macro for writing id structs: BLO_write_id_struct. Those are handled
|
||||
* differently from other structs.
|
||||
*
|
||||
* Raw Data Writing
|
||||
* ----------------
|
||||
*
|
||||
* At the core there is BLO_write_raw, which can write arbitrary memory buffers to the file. The
|
||||
* code that reads this data might have to correct its byte-order. For the common cases there are
|
||||
* convenience functions that write and read arrays of simple types such as int32. Those will
|
||||
* correct endianness automatically.
|
||||
*/
|
||||
|
||||
/* Mapping between names and ids. */
|
||||
int BLO_get_struct_id_by_name(BlendWriter *writer, const char *struct_name);
|
||||
#define BLO_get_struct_id(writer, struct_name) BLO_get_struct_id_by_name(writer, #struct_name)
|
||||
|
||||
/* Write single struct. */
|
||||
void BLO_write_struct_by_name(BlendWriter *writer, const char *struct_name, const void *data_ptr);
|
||||
void BLO_write_struct_by_id(BlendWriter *writer, int struct_id, const void *data_ptr);
|
||||
#define BLO_write_struct(writer, struct_name, data_ptr) \
|
||||
BLO_write_struct_by_id(writer, BLO_get_struct_id(writer, struct_name), data_ptr)
|
||||
|
||||
/* Write struct array. */
|
||||
void BLO_write_struct_array_by_name(BlendWriter *writer,
|
||||
const char *struct_name,
|
||||
int array_size,
|
||||
const void *data_ptr);
|
||||
void BLO_write_struct_array_by_id(BlendWriter *writer,
|
||||
int struct_id,
|
||||
int array_size,
|
||||
const void *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)
|
||||
|
||||
/* Write struct list. */
|
||||
void BLO_write_struct_list_by_name(BlendWriter *writer,
|
||||
const char *struct_name,
|
||||
struct ListBase *list);
|
||||
void BLO_write_struct_list_by_id(BlendWriter *writer, int struct_id, struct ListBase *list);
|
||||
#define BLO_write_struct_list(writer, struct_name, list_ptr) \
|
||||
BLO_write_struct_list_by_id(writer, BLO_get_struct_id(writer, struct_name), list_ptr)
|
||||
|
||||
/* Write id struct. */
|
||||
void blo_write_id_struct(BlendWriter *writer,
|
||||
int struct_id,
|
||||
const void *id_address,
|
||||
const struct ID *id);
|
||||
#define BLO_write_id_struct(writer, struct_name, id_address, id) \
|
||||
blo_write_id_struct(writer, BLO_get_struct_id(writer, struct_name), id_address, id)
|
||||
|
||||
/* Write raw data. */
|
||||
void BLO_write_raw(BlendWriter *writer, int size_in_bytes, const void *data_ptr);
|
||||
void BLO_write_int32_array(BlendWriter *writer, int size, const int32_t *data_ptr);
|
||||
void BLO_write_uint32_array(BlendWriter *writer, int size, const uint32_t *data_ptr);
|
||||
void BLO_write_float_array(BlendWriter *writer, int size, const float *data_ptr);
|
||||
void BLO_write_float3_array(BlendWriter *writer, int size, const float *data_ptr);
|
||||
void BLO_write_string(BlendWriter *writer, const char *data_ptr);
|
||||
|
||||
/* Misc. */
|
||||
bool BLO_write_is_undo(BlendWriter *writer);
|
||||
|
||||
/* Blend Read Data API
|
||||
* ===================
|
||||
*
|
||||
* Generally, for every BLO_write_* call there should be a corresponding BLO_read_* call.
|
||||
*
|
||||
* Most BLO_read_* functions get a pointer to a pointer as argument. That allows the function to
|
||||
* update the pointer to its new value.
|
||||
*
|
||||
* When the given pointer points to a memory buffer that was not stored in the file, the pointer is
|
||||
* updated to be NULL. When it was pointing to NULL before, it will stay that way.
|
||||
*
|
||||
* Examples of matching calls:
|
||||
* BLO_write_struct(writer, ClothSimSettings, clmd->sim_parms);
|
||||
* BLO_read_data_address(reader, &clmd->sim_parms);
|
||||
*
|
||||
* BLO_write_struct_list(writer, TimeMarker, &action->markers);
|
||||
* BLO_read_list(reader, &action->markers, NULL);
|
||||
*
|
||||
* BLO_write_int32_array(writer, hmd->totindex, hmd->indexar);
|
||||
* BLO_read_int32_array(reader, hmd->totindex, &hmd->indexar);
|
||||
*/
|
||||
|
||||
void *BLO_read_get_new_data_address(BlendDataReader *reader, const void *old_address);
|
||||
|
||||
#define BLO_read_data_address(reader, ptr_p) \
|
||||
*(ptr_p) = BLO_read_get_new_data_address((reader), *(ptr_p))
|
||||
|
||||
typedef void (*BlendReadListFn)(BlendDataReader *reader, void *data);
|
||||
void BLO_read_list(BlendDataReader *reader, struct ListBase *list, BlendReadListFn callback);
|
||||
|
||||
/* Update data pointers and correct byte-order if necessary. */
|
||||
void BLO_read_int32_array(BlendDataReader *reader, int array_size, int32_t **ptr_p);
|
||||
void BLO_read_uint32_array(BlendDataReader *reader, int array_size, uint32_t **ptr_p);
|
||||
void BLO_read_float_array(BlendDataReader *reader, int array_size, float **ptr_p);
|
||||
void BLO_read_float3_array(BlendDataReader *reader, int array_size, float **ptr_p);
|
||||
void BLO_read_double_array(BlendDataReader *reader, int array_size, double **ptr_p);
|
||||
void BLO_read_pointer_array(BlendDataReader *reader, void **ptr_p);
|
||||
|
||||
/* Misc. */
|
||||
bool BLO_read_requires_endian_switch(BlendDataReader *reader);
|
||||
|
||||
/* Blend Read Lib API
|
||||
* ===================
|
||||
*
|
||||
* This API does almost the same as the Blend Read Data API. However, now only pointers to ID data
|
||||
* blocks are updated.
|
||||
*/
|
||||
|
||||
ID *BLO_read_get_new_id_address(BlendLibReader *reader, struct Library *lib, struct ID *id);
|
||||
|
||||
#define BLO_read_id_address(reader, lib, id_ptr_p) \
|
||||
*(id_ptr_p) = (void *)BLO_read_get_new_id_address((reader), (lib), (ID *)*(id_ptr_p))
|
||||
|
||||
/* Blend Expand API
|
||||
* ===================
|
||||
*
|
||||
* BLO_expand has to be called for every data block that should be loaded. If the data block is in
|
||||
* a separate .blend file, it will be pulled from there.
|
||||
*/
|
||||
|
||||
void BLO_expand_id(BlendExpander *expander, struct ID *id);
|
||||
|
||||
#define BLO_expand(expander, id) BLO_expand_id(expander, (struct ID *)id)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BLO_READ_WRITE_H__ */
|
@@ -63,6 +63,7 @@ set(SRC
|
||||
|
||||
BLO_blend_defs.h
|
||||
BLO_blend_validate.h
|
||||
BLO_read_write.h
|
||||
BLO_readfile.h
|
||||
BLO_undofile.h
|
||||
BLO_writefile.h
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -151,20 +151,25 @@
|
||||
#include "MEM_guardedalloc.h" // MEM_freeN
|
||||
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_animsys.h"
|
||||
#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_fcurve_driver.h"
|
||||
#include "BKE_global.h" // for G
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_lib_override.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_nla.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_pointcache.h"
|
||||
@@ -176,6 +181,7 @@
|
||||
|
||||
#include "BLO_blend_defs.h"
|
||||
#include "BLO_blend_validate.h"
|
||||
#include "BLO_read_write.h"
|
||||
#include "BLO_readfile.h"
|
||||
#include "BLO_undofile.h"
|
||||
#include "BLO_writefile.h"
|
||||
@@ -387,6 +393,10 @@ static void writedata_free(WriteData *wd)
|
||||
MEM_freeN(wd);
|
||||
}
|
||||
|
||||
typedef struct BlendWriter {
|
||||
WriteData *wd;
|
||||
} BlendWriter;
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -634,79 +644,10 @@ static void writelist_id(WriteData *wd, int filecode, const char *structname, co
|
||||
* These functions are used by blender's .blend system for file saving/loading.
|
||||
* \{ */
|
||||
|
||||
void IDP_WriteProperty_OnlyData(const IDProperty *prop, void *wd);
|
||||
void IDP_WriteProperty(const IDProperty *prop, void *wd);
|
||||
|
||||
static void IDP_WriteArray(const IDProperty *prop, void *wd)
|
||||
static void IDP_WriteProperty(const IDProperty *prop, void *wd)
|
||||
{
|
||||
/*REMEMBER to set totalen to len in the linking code!!*/
|
||||
if (prop->data.pointer) {
|
||||
writedata(wd, DATA, MEM_allocN_len(prop->data.pointer), prop->data.pointer);
|
||||
|
||||
if (prop->subtype == IDP_GROUP) {
|
||||
IDProperty **array = prop->data.pointer;
|
||||
int a;
|
||||
|
||||
for (a = 0; a < prop->len; a++) {
|
||||
IDP_WriteProperty(array[a], wd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void IDP_WriteIDPArray(const IDProperty *prop, void *wd)
|
||||
{
|
||||
/*REMEMBER to set totalen to len in the linking code!!*/
|
||||
if (prop->data.pointer) {
|
||||
const IDProperty *array = prop->data.pointer;
|
||||
int a;
|
||||
|
||||
writestruct(wd, DATA, IDProperty, prop->len, array);
|
||||
|
||||
for (a = 0; a < prop->len; a++) {
|
||||
IDP_WriteProperty_OnlyData(&array[a], wd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void IDP_WriteString(const IDProperty *prop, void *wd)
|
||||
{
|
||||
/*REMEMBER to set totalen to len in the linking code!!*/
|
||||
writedata(wd, DATA, prop->len, prop->data.pointer);
|
||||
}
|
||||
|
||||
static void IDP_WriteGroup(const IDProperty *prop, void *wd)
|
||||
{
|
||||
IDProperty *loop;
|
||||
|
||||
for (loop = prop->data.group.first; loop; loop = loop->next) {
|
||||
IDP_WriteProperty(loop, wd);
|
||||
}
|
||||
}
|
||||
|
||||
/* Functions to read/write ID Properties */
|
||||
void IDP_WriteProperty_OnlyData(const IDProperty *prop, void *wd)
|
||||
{
|
||||
switch (prop->type) {
|
||||
case IDP_GROUP:
|
||||
IDP_WriteGroup(prop, wd);
|
||||
break;
|
||||
case IDP_STRING:
|
||||
IDP_WriteString(prop, wd);
|
||||
break;
|
||||
case IDP_ARRAY:
|
||||
IDP_WriteArray(prop, wd);
|
||||
break;
|
||||
case IDP_IDPARRAY:
|
||||
IDP_WriteIDPArray(prop, wd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void IDP_WriteProperty(const IDProperty *prop, void *wd)
|
||||
{
|
||||
writestruct(wd, DATA, IDProperty, 1, prop);
|
||||
IDP_WriteProperty_OnlyData(prop, wd);
|
||||
BlendWriter writer = {wd};
|
||||
IDP_BlendWrite(&writer, prop);
|
||||
}
|
||||
|
||||
static void write_iddata(WriteData *wd, ID *id)
|
||||
@@ -761,118 +702,6 @@ static void write_previews(WriteData *wd, const PreviewImage *prv_orig)
|
||||
}
|
||||
}
|
||||
|
||||
static void write_fmodifiers(WriteData *wd, ListBase *fmodifiers)
|
||||
{
|
||||
FModifier *fcm;
|
||||
|
||||
/* Write all modifiers first (for faster reloading) */
|
||||
writelist(wd, DATA, FModifier, fmodifiers);
|
||||
|
||||
/* Modifiers */
|
||||
for (fcm = fmodifiers->first; fcm; fcm = fcm->next) {
|
||||
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
||||
|
||||
/* Write the specific data */
|
||||
if (fmi && fcm->data) {
|
||||
/* firstly, just write the plain fmi->data struct */
|
||||
writestruct_id(wd, DATA, fmi->structName, 1, fcm->data);
|
||||
|
||||
/* do any modifier specific stuff */
|
||||
switch (fcm->type) {
|
||||
case FMODIFIER_TYPE_GENERATOR: {
|
||||
FMod_Generator *data = fcm->data;
|
||||
|
||||
/* write coefficients array */
|
||||
if (data->coefficients) {
|
||||
writedata(wd, DATA, sizeof(float) * (data->arraysize), data->coefficients);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case FMODIFIER_TYPE_ENVELOPE: {
|
||||
FMod_Envelope *data = fcm->data;
|
||||
|
||||
/* write envelope data */
|
||||
if (data->data) {
|
||||
writestruct(wd, DATA, FCM_EnvelopeData, data->totvert, data->data);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case FMODIFIER_TYPE_PYTHON: {
|
||||
FMod_Python *data = fcm->data;
|
||||
|
||||
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
||||
* of library blocks that implement this.*/
|
||||
IDP_WriteProperty(data->prop, wd);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_fcurves(WriteData *wd, ListBase *fcurves)
|
||||
{
|
||||
FCurve *fcu;
|
||||
|
||||
writelist(wd, DATA, FCurve, fcurves);
|
||||
for (fcu = fcurves->first; fcu; fcu = fcu->next) {
|
||||
/* curve data */
|
||||
if (fcu->bezt) {
|
||||
writestruct(wd, DATA, BezTriple, fcu->totvert, fcu->bezt);
|
||||
}
|
||||
if (fcu->fpt) {
|
||||
writestruct(wd, DATA, FPoint, fcu->totvert, fcu->fpt);
|
||||
}
|
||||
|
||||
if (fcu->rna_path) {
|
||||
writedata(wd, DATA, strlen(fcu->rna_path) + 1, fcu->rna_path);
|
||||
}
|
||||
|
||||
/* driver data */
|
||||
if (fcu->driver) {
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
DriverVar *dvar;
|
||||
|
||||
writestruct(wd, DATA, ChannelDriver, 1, driver);
|
||||
|
||||
/* variables */
|
||||
writelist(wd, DATA, DriverVar, &driver->variables);
|
||||
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
||||
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
|
||||
if (dtar->rna_path) {
|
||||
writedata(wd, DATA, strlen(dtar->rna_path) + 1, dtar->rna_path);
|
||||
}
|
||||
}
|
||||
DRIVER_TARGETS_LOOPER_END;
|
||||
}
|
||||
}
|
||||
|
||||
/* write F-Modifiers */
|
||||
write_fmodifiers(wd, &fcu->modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
static void write_action(WriteData *wd, bAction *act, const void *id_address)
|
||||
{
|
||||
if (act->id.us > 0 || wd->use_memfile) {
|
||||
writestruct_at_address(wd, ID_AC, bAction, 1, id_address, act);
|
||||
write_iddata(wd, &act->id);
|
||||
|
||||
write_fcurves(wd, &act->curves);
|
||||
|
||||
LISTBASE_FOREACH (bActionGroup *, grp, &act->groups) {
|
||||
writestruct(wd, DATA, bActionGroup, 1, grp);
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
|
||||
writestruct(wd, DATA, TimeMarker, 1, marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_keyingsets(WriteData *wd, ListBase *list)
|
||||
{
|
||||
KeyingSet *ks;
|
||||
@@ -894,77 +723,22 @@ static void write_keyingsets(WriteData *wd, ListBase *list)
|
||||
}
|
||||
}
|
||||
|
||||
static void write_nlastrips(WriteData *wd, ListBase *strips)
|
||||
{
|
||||
NlaStrip *strip;
|
||||
|
||||
writelist(wd, DATA, NlaStrip, strips);
|
||||
for (strip = strips->first; strip; strip = strip->next) {
|
||||
/* write the strip's F-Curves and modifiers */
|
||||
write_fcurves(wd, &strip->fcurves);
|
||||
write_fmodifiers(wd, &strip->modifiers);
|
||||
|
||||
/* write the strip's children */
|
||||
write_nlastrips(wd, &strip->strips);
|
||||
}
|
||||
}
|
||||
|
||||
static void write_nladata(WriteData *wd, ListBase *nlabase)
|
||||
{
|
||||
NlaTrack *nlt;
|
||||
|
||||
/* write all the tracks */
|
||||
for (nlt = nlabase->first; nlt; nlt = nlt->next) {
|
||||
/* write the track first */
|
||||
writestruct(wd, DATA, NlaTrack, 1, nlt);
|
||||
|
||||
/* write the track's strips */
|
||||
write_nlastrips(wd, &nlt->strips);
|
||||
}
|
||||
}
|
||||
|
||||
static void write_animdata(WriteData *wd, AnimData *adt)
|
||||
{
|
||||
AnimOverride *aor;
|
||||
|
||||
/* firstly, just write the AnimData block */
|
||||
writestruct(wd, DATA, AnimData, 1, adt);
|
||||
|
||||
/* write drivers */
|
||||
write_fcurves(wd, &adt->drivers);
|
||||
|
||||
/* write overrides */
|
||||
// FIXME: are these needed?
|
||||
for (aor = adt->overrides.first; aor; aor = aor->next) {
|
||||
/* overrides consist of base data + rna_path */
|
||||
writestruct(wd, DATA, AnimOverride, 1, aor);
|
||||
writedata(wd, DATA, strlen(aor->rna_path) + 1, aor->rna_path);
|
||||
}
|
||||
|
||||
// TODO write the remaps (if they are needed)
|
||||
|
||||
/* write NLA data */
|
||||
write_nladata(wd, &adt->nla_tracks);
|
||||
BlendWriter writer = {wd};
|
||||
BKE_animsys_blend_write(&writer, 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);
|
||||
}
|
||||
BlendWriter writer = {wd};
|
||||
BKE_curvemapping_blend_write_content(&writer, 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);
|
||||
BlendWriter writer = {wd};
|
||||
BKE_curvemapping_blend_write(&writer, cumap);
|
||||
}
|
||||
|
||||
static void write_node_socket_default_value(WriteData *wd, bNodeSocket *sock)
|
||||
@@ -1342,60 +1116,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, const void *id_address)
|
||||
{
|
||||
if (part->id.us > 0 || wd->use_memfile) {
|
||||
@@ -1500,7 +1220,8 @@ static void write_particlesystems(WriteData *wd, ListBase *particles)
|
||||
writestruct(wd, DATA, ClothCollSettings, 1, psys->clmd->coll_parms);
|
||||
}
|
||||
|
||||
write_pointcaches(wd, &psys->ptcaches);
|
||||
BlendWriter writer = {wd};
|
||||
BKE_ptcache_blend_write_list(&writer, &psys->ptcaches);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1653,38 +1374,27 @@ 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->blendWrite != NULL) {
|
||||
BlendWriter writer = {wd};
|
||||
mti->blendWrite(&writer, 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]));
|
||||
BlendWriter writer = {wd};
|
||||
BKE_ptcache_blend_write_list(&writer, &(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_blend_write_list(&writer, &(mmd->domain->ptcaches[1]));
|
||||
|
||||
if (mmd->domain->coba) {
|
||||
writestruct(wd, DATA, ColorBand, 1, mmd->domain->coba);
|
||||
@@ -1709,30 +1419,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
|
||||
@@ -1744,79 +1430,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1945,7 +1558,8 @@ static void write_object(WriteData *wd, Object *ob, const void *id_address)
|
||||
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));
|
||||
BlendWriter writer = {wd};
|
||||
BKE_ptcache_blend_write_list(&writer, &(ob->soft->shared->ptcaches));
|
||||
writestruct(wd, DATA, EffectorWeights, 1, ob->soft->effector_weights);
|
||||
}
|
||||
|
||||
@@ -1993,27 +1607,6 @@ static void write_vfont(WriteData *wd, VFont *vf, const void *id_address)
|
||||
}
|
||||
}
|
||||
|
||||
static void write_key(WriteData *wd, Key *key, const void *id_address)
|
||||
{
|
||||
if (key->id.us > 0 || wd->use_memfile) {
|
||||
/* write LibData */
|
||||
writestruct_at_address(wd, ID_KE, Key, 1, id_address, key);
|
||||
write_iddata(wd, &key->id);
|
||||
|
||||
if (key->adt) {
|
||||
write_animdata(wd, key->adt);
|
||||
}
|
||||
|
||||
/* direct data */
|
||||
LISTBASE_FOREACH (KeyBlock *, kb, &key->block) {
|
||||
writestruct(wd, DATA, KeyBlock, 1, kb);
|
||||
if (kb->data) {
|
||||
writedata(wd, DATA, kb->totelem * key->elemsize, kb->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_camera(WriteData *wd, Camera *cam, const void *id_address)
|
||||
{
|
||||
if (cam->id.us > 0 || wd->use_memfile) {
|
||||
@@ -2653,7 +2246,8 @@ static void write_scene(WriteData *wd, Scene *sce, const void *id_address)
|
||||
}
|
||||
/* Write the curve profile to the file. */
|
||||
if (tos->custom_bevel_profile_preset) {
|
||||
write_CurveProfile(wd, tos->custom_bevel_profile_preset);
|
||||
BlendWriter writer = {wd};
|
||||
BKE_curveprofile_blend_write(&writer, tos->custom_bevel_profile_preset);
|
||||
}
|
||||
|
||||
write_paint(wd, &tos->imapaint.paint);
|
||||
@@ -2792,7 +2386,8 @@ static void write_scene(WriteData *wd, Scene *sce, const void *id_address)
|
||||
|
||||
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));
|
||||
BlendWriter writer = {wd};
|
||||
BKE_ptcache_blend_write_list(&writer, &(sce->rigidbody_world->shared->ptcaches));
|
||||
}
|
||||
|
||||
write_previews(wd, sce->preview);
|
||||
@@ -4121,6 +3716,12 @@ static bool write_file_handle(Main *mainvar,
|
||||
|
||||
((ID *)id_buffer)->tag = 0;
|
||||
|
||||
const IDTypeInfo *type_info = BKE_idtype_get_info_from_id(id);
|
||||
if (type_info->blend_write != NULL) {
|
||||
BlendWriter writer = {wd};
|
||||
type_info->blend_write(&writer, (ID *)id_buffer, id);
|
||||
}
|
||||
|
||||
switch ((ID_Type)GS(id->name)) {
|
||||
case ID_WM:
|
||||
write_windowmanager(wd, (wmWindowManager *)id_buffer, id);
|
||||
@@ -4161,9 +3762,6 @@ static bool write_file_handle(Main *mainvar,
|
||||
case ID_VF:
|
||||
write_vfont(wd, (VFont *)id_buffer, id);
|
||||
break;
|
||||
case ID_KE:
|
||||
write_key(wd, (Key *)id_buffer, id);
|
||||
break;
|
||||
case ID_WO:
|
||||
write_world(wd, (World *)id_buffer, id);
|
||||
break;
|
||||
@@ -4185,9 +3783,6 @@ static bool write_file_handle(Main *mainvar,
|
||||
case ID_AR:
|
||||
write_armature(wd, (bArmature *)id_buffer, id);
|
||||
break;
|
||||
case ID_AC:
|
||||
write_action(wd, (bAction *)id_buffer, id);
|
||||
break;
|
||||
case ID_OB:
|
||||
write_object(wd, (Object *)id_buffer, id);
|
||||
break;
|
||||
@@ -4240,6 +3835,10 @@ static bool write_file_handle(Main *mainvar,
|
||||
/* Do nothing, handled below - and should never be reached. */
|
||||
BLI_assert(0);
|
||||
break;
|
||||
case ID_KE:
|
||||
case ID_AC:
|
||||
/* Do nothing, handled in callback. */
|
||||
break;
|
||||
case ID_IP:
|
||||
/* Do nothing, deprecated. */
|
||||
break;
|
||||
@@ -4472,4 +4071,98 @@ bool BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int w
|
||||
return (err == 0);
|
||||
}
|
||||
|
||||
void BLO_write_raw(BlendWriter *writer, int size_in_bytes, const void *data_ptr)
|
||||
{
|
||||
writedata(writer->wd, DATA, size_in_bytes, data_ptr);
|
||||
}
|
||||
|
||||
void BLO_write_struct_by_name(BlendWriter *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(BlendWriter *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(BlendWriter *writer, int struct_id, const void *data_ptr)
|
||||
{
|
||||
writestruct_nr(writer->wd, DATA, struct_id, 1, data_ptr);
|
||||
}
|
||||
|
||||
void BLO_write_struct_array_by_id(BlendWriter *writer,
|
||||
int struct_id,
|
||||
int array_size,
|
||||
const void *data_ptr)
|
||||
{
|
||||
writestruct_nr(writer->wd, DATA, struct_id, array_size, data_ptr);
|
||||
}
|
||||
|
||||
void BLO_write_struct_list_by_id(BlendWriter *writer, int struct_id, ListBase *list)
|
||||
{
|
||||
writelist_nr(writer->wd, DATA, struct_id, list);
|
||||
}
|
||||
|
||||
void BLO_write_struct_list_by_name(BlendWriter *writer, const char *struct_name, ListBase *list)
|
||||
{
|
||||
BLO_write_struct_list_by_id(writer, BLO_get_struct_id_by_name(writer, struct_name), list);
|
||||
}
|
||||
|
||||
void blo_write_id_struct(BlendWriter *writer, int struct_id, const void *id_address, const ID *id)
|
||||
{
|
||||
writestruct_at_address_nr(writer->wd, GS(id->name), struct_id, 1, id_address, id);
|
||||
}
|
||||
|
||||
int BLO_get_struct_id_by_name(BlendWriter *writer, const char *struct_name)
|
||||
{
|
||||
int struct_id = DNA_struct_find_nr(writer->wd->sdna, struct_name);
|
||||
BLI_assert(struct_id >= 0);
|
||||
return struct_id;
|
||||
}
|
||||
|
||||
void BLO_write_int32_array(BlendWriter *writer, int size, const int32_t *data_ptr)
|
||||
{
|
||||
BLO_write_raw(writer, sizeof(int32_t) * size, data_ptr);
|
||||
}
|
||||
|
||||
void BLO_write_uint32_array(BlendWriter *writer, int size, const uint32_t *data_ptr)
|
||||
{
|
||||
BLO_write_raw(writer, sizeof(uint32_t) * size, data_ptr);
|
||||
}
|
||||
|
||||
void BLO_write_float_array(BlendWriter *writer, int size, const float *data_ptr)
|
||||
{
|
||||
BLO_write_raw(writer, sizeof(float) * size, data_ptr);
|
||||
}
|
||||
|
||||
void BLO_write_float3_array(BlendWriter *writer, int size, const float *data_ptr)
|
||||
{
|
||||
BLO_write_raw(writer, sizeof(float) * 3 * size, data_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a null terminated string.
|
||||
*/
|
||||
void BLO_write_string(BlendWriter *writer, const char *str)
|
||||
{
|
||||
if (str != NULL) {
|
||||
BLO_write_raw(writer, strlen(str) + 1, str);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sometimes different data is written depending on whether the file is saved to disk or used for
|
||||
* undo. This function returns true when the current file-writing is done for undo.
|
||||
*/
|
||||
bool BLO_write_is_undo(BlendWriter *writer)
|
||||
{
|
||||
return writer->wd->use_memfile;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@@ -24,6 +24,7 @@ set(INC
|
||||
../blenfont
|
||||
../blenkernel
|
||||
../blenlib
|
||||
../blenloader
|
||||
../bmesh
|
||||
../depsgraph
|
||||
../makesdna
|
||||
|
@@ -45,6 +45,8 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLO_read_write.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 blendRead(BlendDataReader *UNUSED(reader), ModifierData *md)
|
||||
{
|
||||
ArmatureModifierData *amd = (ArmatureModifierData *)md;
|
||||
amd->prevCos = NULL;
|
||||
}
|
||||
|
||||
static void deformVerts(ModifierData *md,
|
||||
const ModifierEvalContext *ctx,
|
||||
Mesh *mesh,
|
||||
@@ -269,4 +277,6 @@ ModifierTypeInfo modifierType_Armature = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -853,4 +853,6 @@ ModifierTypeInfo modifierType_Array = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -45,6 +45,8 @@
|
||||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "BLO_read_write.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 blendWrite(BlendWriter *writer, const ModifierData *md)
|
||||
{
|
||||
BevelModifierData *bmd = (BevelModifierData *)md;
|
||||
if (bmd->custom_profile) {
|
||||
BKE_curveprofile_blend_write(writer, bmd->custom_profile);
|
||||
}
|
||||
}
|
||||
|
||||
static void blendRead(BlendDataReader *reader, ModifierData *md)
|
||||
{
|
||||
BevelModifierData *bmd = (BevelModifierData *)md;
|
||||
BLO_read_data_address(reader, &bmd->custom_profile);
|
||||
if (bmd->custom_profile) {
|
||||
BKE_curveprofile_blend_read_data(reader, bmd->custom_profile);
|
||||
}
|
||||
}
|
||||
|
||||
ModifierTypeInfo modifierType_Bevel = {
|
||||
/* name */ "Bevel",
|
||||
/* structName */ "BevelModifierData",
|
||||
@@ -290,4 +309,6 @@ ModifierTypeInfo modifierType_Bevel = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ blendWrite,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -375,4 +375,6 @@ ModifierTypeInfo modifierType_Boolean = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -304,4 +304,6 @@ ModifierTypeInfo modifierType_Build = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -548,4 +548,6 @@ ModifierTypeInfo modifierType_Cast = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -48,6 +48,8 @@
|
||||
#include "DEG_depsgraph_physics.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "MOD_util.h"
|
||||
|
||||
static void initData(ModifierData *md)
|
||||
@@ -253,6 +255,45 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u
|
||||
}
|
||||
}
|
||||
|
||||
static void blendWrite(BlendWriter *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_blend_write_list(writer, &clmd->ptcaches);
|
||||
}
|
||||
|
||||
static void blendRead(BlendDataReader *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_blend_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",
|
||||
@@ -283,4 +324,6 @@ ModifierTypeInfo modifierType_Cloth = {
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ blendWrite,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -270,4 +270,6 @@ ModifierTypeInfo modifierType_Collision = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -46,6 +46,8 @@
|
||||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
// #define DEBUG_TIME
|
||||
|
||||
#include "PIL_time.h"
|
||||
@@ -115,6 +117,28 @@ static void requiredDataMask(Object *UNUSED(ob),
|
||||
}
|
||||
}
|
||||
|
||||
static void blendWrite(BlendWriter *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 blendRead(BlendDataReader *reader, ModifierData *md)
|
||||
{
|
||||
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
|
||||
|
||||
if (csmd->bind_coords) {
|
||||
BLO_read_float3_array(reader, (int)csmd->bind_coords_num, (float **)&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,
|
||||
@@ -792,4 +816,6 @@ ModifierTypeInfo modifierType_CorrectiveSmooth = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ blendWrite,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -179,4 +179,6 @@ ModifierTypeInfo modifierType_Curve = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -264,4 +264,6 @@ ModifierTypeInfo modifierType_DataTransfer = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -244,4 +244,6 @@ ModifierTypeInfo modifierType_Decimate = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -443,4 +443,6 @@ ModifierTypeInfo modifierType_Displace = {
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ foreachTexLink,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -30,16 +30,20 @@
|
||||
#include "DNA_scene_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_read_write.h"
|
||||
|
||||
#include "MOD_modifiertypes.h"
|
||||
|
||||
static void initData(ModifierData *md)
|
||||
@@ -113,6 +117,66 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
||||
return mesh;
|
||||
}
|
||||
|
||||
static void blendWrite(BlendWriter *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_blend_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 blendRead(BlendDataReader *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_blend_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 bool is_brush_cb(Object *UNUSED(ob), ModifierData *md)
|
||||
{
|
||||
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
|
||||
@@ -203,4 +267,6 @@ ModifierTypeInfo modifierType_DynamicPaint = {
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ foreachTexLink,
|
||||
/* freeRuntimeData */ freeRuntimeData,
|
||||
/* blendWrite */ blendWrite,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -158,4 +158,6 @@ ModifierTypeInfo modifierType_EdgeSplit = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -45,6 +45,8 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "MOD_modifiertypes.h"
|
||||
|
||||
static void initData(ModifierData *md)
|
||||
@@ -86,6 +88,12 @@ static void requiredDataMask(Object *UNUSED(ob),
|
||||
}
|
||||
}
|
||||
|
||||
static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md)
|
||||
{
|
||||
ExplodeModifierData *psmd = (ExplodeModifierData *)md;
|
||||
psmd->facepa = NULL;
|
||||
}
|
||||
|
||||
static void createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *psmd, Mesh *mesh)
|
||||
{
|
||||
ParticleSystem *psys = psmd->psys;
|
||||
@@ -1202,4 +1210,6 @@ ModifierTypeInfo modifierType_Explode = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -223,4 +223,6 @@ ModifierTypeInfo modifierType_Fluid = {
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -44,6 +44,8 @@
|
||||
|
||||
#include "MOD_util.h"
|
||||
|
||||
#include "BLO_read_write.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 blendWrite(BlendWriter *writer, const ModifierData *md)
|
||||
{
|
||||
HookModifierData *hmd = (HookModifierData *)md;
|
||||
|
||||
BLO_write_int32_array(writer, hmd->totindex, hmd->indexar);
|
||||
if (hmd->curfalloff) {
|
||||
BKE_curvemapping_blend_write(writer, hmd->curfalloff);
|
||||
}
|
||||
}
|
||||
|
||||
static void blendRead(BlendDataReader *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_blend_read_data(reader, hmd->curfalloff);
|
||||
}
|
||||
}
|
||||
|
||||
struct HookData_cb {
|
||||
float (*vertexCos)[3];
|
||||
|
||||
@@ -417,4 +440,6 @@ ModifierTypeInfo modifierType_Hook = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ blendWrite,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -43,6 +43,8 @@
|
||||
|
||||
#include "eigen_capi.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
enum {
|
||||
LAPDEFORM_SYSTEM_NOT_CHANGE = 0,
|
||||
LAPDEFORM_SYSTEM_IS_DIFFERENT,
|
||||
@@ -757,6 +759,21 @@ static void requiredDataMask(Object *UNUSED(ob),
|
||||
}
|
||||
}
|
||||
|
||||
static void blendWrite(BlendWriter *writer, const ModifierData *md)
|
||||
{
|
||||
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
|
||||
|
||||
BLO_write_float3_array(writer, lmd->total_verts, lmd->vertexco);
|
||||
}
|
||||
|
||||
static void blendRead(BlendDataReader *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,
|
||||
@@ -830,4 +847,6 @@ ModifierTypeInfo modifierType_LaplacianDeform = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ blendWrite,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -596,4 +596,6 @@ ModifierTypeInfo modifierType_LaplacianSmooth = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -162,4 +162,6 @@ ModifierTypeInfo modifierType_Lattice = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -417,4 +417,6 @@ ModifierTypeInfo modifierType_Mask = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -317,4 +317,6 @@ ModifierTypeInfo modifierType_MeshCache = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -45,6 +45,8 @@
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "MOD_util.h"
|
||||
|
||||
#ifdef __SSE2__
|
||||
@@ -165,6 +167,36 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
||||
DEG_add_modifier_to_transform_relation(ctx->node, "Mesh Deform Modifier");
|
||||
}
|
||||
|
||||
static void blendWrite(BlendWriter *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 blendRead(BlendDataReader *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;
|
||||
@@ -583,4 +615,6 @@ ModifierTypeInfo modifierType_MeshDeform = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ blendWrite,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -37,6 +37,8 @@
|
||||
#include "DEG_depsgraph_build.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "MOD_modifiertypes.h"
|
||||
|
||||
#ifdef WITH_ALEMBIC
|
||||
@@ -184,6 +186,13 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
||||
}
|
||||
}
|
||||
|
||||
static void blendRead(BlendDataReader *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",
|
||||
@@ -213,4 +222,6 @@ ModifierTypeInfo modifierType_MeshSequenceCache = {
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -146,4 +146,6 @@ ModifierTypeInfo modifierType_Mirror = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -302,4 +302,6 @@ ModifierTypeInfo modifierType_Multires = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ freeRuntimeData,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -67,4 +67,6 @@ ModifierTypeInfo modifierType_None = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -719,4 +719,6 @@ ModifierTypeInfo modifierType_NormalEdit = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -41,6 +41,8 @@
|
||||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "MOD_modifiertypes.h"
|
||||
|
||||
#ifdef WITH_OCEANSIM
|
||||
@@ -183,6 +185,13 @@ static bool dependsOnNormals(ModifierData *md)
|
||||
return (omd->geometry_mode != MOD_OCEAN_GEOM_GENERATE);
|
||||
}
|
||||
|
||||
static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md)
|
||||
{
|
||||
OceanModifierData *omd = (OceanModifierData *)md;
|
||||
omd->oceancache = NULL;
|
||||
omd->ocean = NULL;
|
||||
}
|
||||
|
||||
#ifdef WITH_OCEANSIM
|
||||
|
||||
typedef struct GenerateOceanGeometryData {
|
||||
@@ -525,4 +534,6 @@ ModifierTypeInfo modifierType_Ocean = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -576,4 +576,6 @@ ModifierTypeInfo modifierType_ParticleInstance = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -36,6 +36,8 @@
|
||||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "BLO_read_write.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 blendRead(BlendDataReader *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,
|
||||
@@ -280,4 +293,6 @@ ModifierTypeInfo modifierType_ParticleSystem = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ blendRead,
|
||||
};
|
||||
|
@@ -248,4 +248,6 @@ ModifierTypeInfo modifierType_Remesh = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -1187,4 +1187,6 @@ ModifierTypeInfo modifierType_Screw = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -147,4 +147,6 @@ ModifierTypeInfo modifierType_ShapeKey = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -229,4 +229,6 @@ ModifierTypeInfo modifierType_Shrinkwrap = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -479,4 +479,6 @@ ModifierTypeInfo modifierType_SimpleDeform = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -1956,4 +1956,6 @@ ModifierTypeInfo modifierType_Skin = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
@@ -253,4 +253,6 @@ ModifierTypeInfo modifierType_Smooth = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
};
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user