Refactor: move keyingset .blend I/O to blenkernel
Ref T76372
This commit is contained in:
@@ -46,6 +46,10 @@ struct Scene;
|
||||
struct bAction;
|
||||
struct bActionGroup;
|
||||
struct bContext;
|
||||
struct BlendWriter;
|
||||
struct BlendDataReader;
|
||||
struct BlendLibReader;
|
||||
struct BlendExpander;
|
||||
|
||||
/* Container for data required to do FCurve and Driver evaluation. */
|
||||
typedef struct AnimationEvalContext {
|
||||
@@ -101,6 +105,13 @@ void BKE_keyingset_free(struct KeyingSet *ks);
|
||||
/* Free all the KeyingSets in the given list */
|
||||
void BKE_keyingsets_free(struct ListBase *list);
|
||||
|
||||
void BKE_keyingsets_blend_write(struct BlendWriter *writer, struct ListBase *list);
|
||||
void BKE_keyingsets_blend_read_data(struct BlendDataReader *reader, struct ListBase *list);
|
||||
void BKE_keyingsets_blend_read_lib(struct BlendLibReader *reader,
|
||||
struct ID *id,
|
||||
struct ListBase *list);
|
||||
void BKE_keyingsets_blend_read_expand(struct BlendExpander *expander, struct ListBase *list);
|
||||
|
||||
/* ************************************* */
|
||||
/* Path Fixing API */
|
||||
|
||||
|
||||
@@ -69,6 +69,8 @@
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "nla_private.h"
|
||||
|
||||
#include "atomic_ops.h"
|
||||
@@ -308,6 +310,55 @@ void BKE_keyingsets_free(ListBase *list)
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_keyingsets_blend_write(BlendWriter *writer, ListBase *list)
|
||||
{
|
||||
LISTBASE_FOREACH (KeyingSet *, ks, list) {
|
||||
/* KeyingSet */
|
||||
BLO_write_struct(writer, KeyingSet, ks);
|
||||
|
||||
/* Paths */
|
||||
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
|
||||
/* Path */
|
||||
BLO_write_struct(writer, KS_Path, ksp);
|
||||
|
||||
if (ksp->rna_path) {
|
||||
BLO_write_string(writer, ksp->rna_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_keyingsets_blend_read_data(BlendDataReader *reader, ListBase *list)
|
||||
{
|
||||
LISTBASE_FOREACH (KeyingSet *, ks, list) {
|
||||
/* paths */
|
||||
BLO_read_list(reader, &ks->paths);
|
||||
|
||||
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
|
||||
/* rna path */
|
||||
BLO_read_data_address(reader, &ksp->rna_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_keyingsets_blend_read_lib(BlendLibReader *reader, ID *id, ListBase *list)
|
||||
{
|
||||
LISTBASE_FOREACH (KeyingSet *, ks, list) {
|
||||
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
|
||||
BLO_read_id_address(reader, id->lib, &ksp->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_keyingsets_blend_read_expand(BlendExpander *expander, ListBase *list)
|
||||
{
|
||||
LISTBASE_FOREACH (KeyingSet *, ks, list) {
|
||||
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
|
||||
BLO_expand(expander, ksp->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ***************************************** */
|
||||
/* Evaluation Data-Setting Backend */
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_anim_data.h"
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_armature.h"
|
||||
#include "BKE_brush.h"
|
||||
#include "BKE_collection.h"
|
||||
@@ -2687,37 +2688,6 @@ static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBas
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Read: Keyingsets
|
||||
* \{ */
|
||||
|
||||
static void lib_link_keyingsets(BlendLibReader *reader, ID *id, ListBase *list)
|
||||
{
|
||||
/* here, we're only interested in the ID pointer stored in some of the paths */
|
||||
LISTBASE_FOREACH (KeyingSet *, ks, list) {
|
||||
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
|
||||
BLO_read_id_address(reader, id->lib, &ksp->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTE: this assumes that BLO_read_list has already been called on the list */
|
||||
static void direct_link_keyingsets(BlendDataReader *reader, ListBase *list)
|
||||
{
|
||||
/* link KeyingSet data to KeyingSet again (non ID-libs) */
|
||||
LISTBASE_FOREACH (KeyingSet *, ks, list) {
|
||||
/* paths */
|
||||
BLO_read_list(reader, &ks->paths);
|
||||
|
||||
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
|
||||
/* rna path */
|
||||
BLO_read_data_address(reader, &ksp->rna_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Read ID: CacheFiles
|
||||
* \{ */
|
||||
@@ -5257,7 +5227,7 @@ static bool scene_validate_setscene__liblink(Scene *sce, const int totscene)
|
||||
|
||||
static void lib_link_scene(BlendLibReader *reader, Scene *sce)
|
||||
{
|
||||
lib_link_keyingsets(reader, &sce->id, &sce->keyingsets);
|
||||
BKE_keyingsets_blend_read_lib(reader, &sce->id, &sce->keyingsets);
|
||||
|
||||
BLO_read_id_address(reader, sce->id.lib, &sce->camera);
|
||||
BLO_read_id_address(reader, sce->id.lib, &sce->world);
|
||||
@@ -5536,7 +5506,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
|
||||
BKE_animdata_blend_read_data(reader, sce->adt);
|
||||
|
||||
BLO_read_list(reader, &sce->keyingsets);
|
||||
direct_link_keyingsets(reader, &sce->keyingsets);
|
||||
BKE_keyingsets_blend_read_data(reader, &sce->keyingsets);
|
||||
|
||||
BLO_read_data_address(reader, &sce->basact);
|
||||
|
||||
@@ -9416,16 +9386,6 @@ static void expand_id(BlendExpander *expander, ID *id)
|
||||
expand_id_embedded_id(expander, id);
|
||||
}
|
||||
|
||||
static void expand_keyingsets(BlendExpander *expander, ListBase *list)
|
||||
{
|
||||
/* expand the ID-pointers in KeyingSets's paths */
|
||||
LISTBASE_FOREACH (KeyingSet *, ks, list) {
|
||||
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
|
||||
BLO_expand(expander, ksp->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void expand_particlesettings(BlendExpander *expander, ParticleSettings *part)
|
||||
{
|
||||
BLO_expand(expander, part->instance_object);
|
||||
@@ -9783,7 +9743,7 @@ static void expand_scene(BlendExpander *expander, Scene *sce)
|
||||
BLO_expand(expander, sce->camera);
|
||||
BLO_expand(expander, sce->world);
|
||||
|
||||
expand_keyingsets(expander, &sce->keyingsets);
|
||||
BKE_keyingsets_blend_read_expand(expander, &sce->keyingsets);
|
||||
|
||||
if (sce->set) {
|
||||
BLO_expand(expander, sce->set);
|
||||
|
||||
@@ -153,6 +153,7 @@
|
||||
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_anim_data.h"
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_armature.h"
|
||||
#include "BKE_blender_version.h"
|
||||
#include "BKE_bpath.h"
|
||||
@@ -660,24 +661,6 @@ 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.
|
||||
* \{ */
|
||||
|
||||
static void write_keyingsets(BlendWriter *writer, ListBase *list)
|
||||
{
|
||||
LISTBASE_FOREACH (KeyingSet *, ks, list) {
|
||||
/* KeyingSet */
|
||||
BLO_write_struct(writer, KeyingSet, ks);
|
||||
|
||||
/* Paths */
|
||||
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
|
||||
/* Path */
|
||||
BLO_write_struct(writer, KS_Path, ksp);
|
||||
|
||||
if (ksp->rna_path) {
|
||||
BLO_write_string(writer, ksp->rna_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *sock)
|
||||
{
|
||||
if (sock->default_value == NULL) {
|
||||
@@ -2018,7 +2001,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address)
|
||||
if (sce->adt) {
|
||||
BKE_animdata_blend_write(writer, sce->adt);
|
||||
}
|
||||
write_keyingsets(writer, &sce->keyingsets);
|
||||
BKE_keyingsets_blend_write(writer, &sce->keyingsets);
|
||||
|
||||
/* direct data */
|
||||
ToolSettings *tos = sce->toolsettings;
|
||||
|
||||
Reference in New Issue
Block a user