Refactor: move Mesh .blend I/O to IDTypeInfo callbacks
I'm also adding `BKE_id_blend_write`, so that it can be accessed outside of `readfile.c`.
This commit is contained in:
parent
5db5ac611a
commit
8815996418
|
@ -59,6 +59,8 @@ struct Main;
|
|||
struct PointerRNA;
|
||||
struct PropertyRNA;
|
||||
struct bContext;
|
||||
struct BlendWriter;
|
||||
struct BlendDataReader;
|
||||
|
||||
size_t BKE_libblock_get_alloc_info(short type, const char **name);
|
||||
void *BKE_libblock_alloc_notest(short type) ATTR_WARN_UNUSED_RESULT;
|
||||
|
@ -285,6 +287,8 @@ 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);
|
||||
|
||||
void BKE_id_blend_write(struct BlendWriter *writer, struct ID *id);
|
||||
|
||||
#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT))
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "atomic_ops.h"
|
||||
|
||||
//#define DEBUG_TIME
|
||||
|
@ -2326,3 +2328,30 @@ void BKE_id_reorder(const ListBase *lb, ID *id, ID *relative, bool after)
|
|||
*id_order = relative_order - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_id_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);
|
||||
LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &id->override_library->properties) {
|
||||
BLO_write_string(writer, op->rna_path);
|
||||
|
||||
BLO_write_struct_list(writer, IDOverrideLibraryPropertyOperation, &op->operations);
|
||||
LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) {
|
||||
if (opop->subitem_reference_name) {
|
||||
BLO_write_string(writer, opop->subitem_reference_name);
|
||||
}
|
||||
if (opop->subitem_local_name) {
|
||||
BLO_write_string(writer, opop->subitem_local_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
/* allow using deprecated functionality for .blend file I/O */
|
||||
#define DNA_DEPRECATED_ALLOW
|
||||
|
||||
#include "DNA_defaults.h"
|
||||
#include "DNA_key_types.h"
|
||||
#include "DNA_material_types.h"
|
||||
|
@ -32,6 +35,7 @@
|
|||
|
||||
#include "BLI_bitmap.h"
|
||||
#include "BLI_edgehash.h"
|
||||
#include "BLI_endian_switch.h"
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_hash.h"
|
||||
#include "BLI_linklist.h"
|
||||
|
@ -43,6 +47,7 @@
|
|||
#include "BLT_translation.h"
|
||||
|
||||
#include "BKE_anim_data.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_editmesh.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idtype.h"
|
||||
|
@ -63,6 +68,8 @@
|
|||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
static void mesh_clear_geometry(Mesh *mesh);
|
||||
static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata);
|
||||
|
||||
|
@ -163,6 +170,158 @@ static void mesh_foreach_id(ID *id, LibraryForeachIDData *data)
|
|||
}
|
||||
}
|
||||
|
||||
static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
{
|
||||
Mesh *mesh = (Mesh *)id;
|
||||
if (mesh->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* cache only - don't write */
|
||||
mesh->mface = NULL;
|
||||
mesh->totface = 0;
|
||||
memset(&mesh->fdata, 0, sizeof(mesh->fdata));
|
||||
memset(&mesh->runtime, 0, sizeof(mesh->runtime));
|
||||
|
||||
BLO_write_id_struct(writer, Mesh, id_address, &mesh->id);
|
||||
BKE_id_blend_write(writer, &mesh->id);
|
||||
|
||||
/* direct data */
|
||||
if (mesh->adt) {
|
||||
BKE_animdata_blend_write(writer, mesh->adt);
|
||||
}
|
||||
|
||||
BLO_write_pointer_array(writer, mesh->totcol, mesh->mat);
|
||||
BLO_write_raw(writer, sizeof(MSelect) * mesh->totselect, mesh->mselect);
|
||||
|
||||
CustomData_blend_write(writer, &mesh->vdata, mesh->totvert, CD_MASK_MESH.vmask, &mesh->id);
|
||||
CustomData_blend_write(writer, &mesh->edata, mesh->totedge, CD_MASK_MESH.emask, &mesh->id);
|
||||
/* fdata is really a dummy - written so slots align */
|
||||
CustomData_blend_write(writer, &mesh->fdata, mesh->totface, CD_MASK_MESH.fmask, &mesh->id);
|
||||
CustomData_blend_write(writer, &mesh->ldata, mesh->totloop, CD_MASK_MESH.lmask, &mesh->id);
|
||||
CustomData_blend_write(writer, &mesh->pdata, mesh->totpoly, CD_MASK_MESH.pmask, &mesh->id);
|
||||
}
|
||||
}
|
||||
|
||||
static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
{
|
||||
Mesh *mesh = (Mesh *)id;
|
||||
BLO_read_pointer_array(reader, (void **)&mesh->mat);
|
||||
|
||||
BLO_read_data_address(reader, &mesh->mvert);
|
||||
BLO_read_data_address(reader, &mesh->medge);
|
||||
BLO_read_data_address(reader, &mesh->mface);
|
||||
BLO_read_data_address(reader, &mesh->mloop);
|
||||
BLO_read_data_address(reader, &mesh->mpoly);
|
||||
BLO_read_data_address(reader, &mesh->tface);
|
||||
BLO_read_data_address(reader, &mesh->mtface);
|
||||
BLO_read_data_address(reader, &mesh->mcol);
|
||||
BLO_read_data_address(reader, &mesh->dvert);
|
||||
BLO_read_data_address(reader, &mesh->mloopcol);
|
||||
BLO_read_data_address(reader, &mesh->mloopuv);
|
||||
BLO_read_data_address(reader, &mesh->mselect);
|
||||
|
||||
/* animdata */
|
||||
BLO_read_data_address(reader, &mesh->adt);
|
||||
BKE_animdata_blend_read_data(reader, mesh->adt);
|
||||
|
||||
/* Normally BKE_defvert_blend_read should be called in CustomData_blend_read,
|
||||
* but for backwards compatibility in do_versions to work we do it here. */
|
||||
BKE_defvert_blend_read(reader, mesh->totvert, mesh->dvert);
|
||||
|
||||
CustomData_blend_read(reader, &mesh->vdata, mesh->totvert);
|
||||
CustomData_blend_read(reader, &mesh->edata, mesh->totedge);
|
||||
CustomData_blend_read(reader, &mesh->fdata, mesh->totface);
|
||||
CustomData_blend_read(reader, &mesh->ldata, mesh->totloop);
|
||||
CustomData_blend_read(reader, &mesh->pdata, mesh->totpoly);
|
||||
|
||||
mesh->texflag &= ~ME_AUTOSPACE_EVALUATED;
|
||||
mesh->edit_mesh = NULL;
|
||||
BKE_mesh_runtime_reset(mesh);
|
||||
|
||||
/* happens with old files */
|
||||
if (mesh->mselect == NULL) {
|
||||
mesh->totselect = 0;
|
||||
}
|
||||
|
||||
/* Multires data */
|
||||
BLO_read_data_address(reader, &mesh->mr);
|
||||
if (mesh->mr) {
|
||||
BLO_read_list(reader, &mesh->mr->levels);
|
||||
MultiresLevel *lvl = mesh->mr->levels.first;
|
||||
|
||||
CustomData_blend_read(reader, &mesh->mr->vdata, lvl->totvert);
|
||||
BKE_defvert_blend_read(
|
||||
reader, lvl->totvert, CustomData_get(&mesh->mr->vdata, 0, CD_MDEFORMVERT));
|
||||
CustomData_blend_read(reader, &mesh->mr->fdata, lvl->totface);
|
||||
|
||||
BLO_read_data_address(reader, &mesh->mr->edge_flags);
|
||||
BLO_read_data_address(reader, &mesh->mr->edge_creases);
|
||||
|
||||
BLO_read_data_address(reader, &mesh->mr->verts);
|
||||
|
||||
/* If mesh has the same number of vertices as the
|
||||
* highest multires level, load the current mesh verts
|
||||
* into multires and discard the old data. Needed
|
||||
* because some saved files either do not have a verts
|
||||
* array, or the verts array contains out-of-date
|
||||
* data. */
|
||||
if (mesh->totvert == ((MultiresLevel *)mesh->mr->levels.last)->totvert) {
|
||||
if (mesh->mr->verts) {
|
||||
MEM_freeN(mesh->mr->verts);
|
||||
}
|
||||
mesh->mr->verts = MEM_dupallocN(mesh->mvert);
|
||||
}
|
||||
|
||||
for (; lvl; lvl = lvl->next) {
|
||||
BLO_read_data_address(reader, &lvl->verts);
|
||||
BLO_read_data_address(reader, &lvl->faces);
|
||||
BLO_read_data_address(reader, &lvl->edges);
|
||||
BLO_read_data_address(reader, &lvl->colfaces);
|
||||
}
|
||||
}
|
||||
|
||||
/* if multires is present but has no valid vertex data,
|
||||
* there's no way to recover it; silently remove multires */
|
||||
if (mesh->mr && !mesh->mr->verts) {
|
||||
multires_free(mesh->mr);
|
||||
mesh->mr = NULL;
|
||||
}
|
||||
|
||||
if ((BLO_read_requires_endian_switch(reader)) && mesh->tface) {
|
||||
TFace *tf = mesh->tface;
|
||||
for (int i = 0; i < mesh->totface; i++, tf++) {
|
||||
BLI_endian_switch_uint32_array(tf->col, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mesh_blend_read_lib(BlendLibReader *reader, ID *id)
|
||||
{
|
||||
Mesh *me = (Mesh *)id;
|
||||
/* this check added for python created meshes */
|
||||
if (me->mat) {
|
||||
for (int i = 0; i < me->totcol; i++) {
|
||||
BLO_read_id_address(reader, me->id.lib, &me->mat[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
me->totcol = 0;
|
||||
}
|
||||
|
||||
BLO_read_id_address(reader, me->id.lib, &me->ipo); // XXX: deprecated: old anim sys
|
||||
BLO_read_id_address(reader, me->id.lib, &me->key);
|
||||
BLO_read_id_address(reader, me->id.lib, &me->texcomesh);
|
||||
}
|
||||
|
||||
static void mesh_read_expand(BlendExpander *expander, ID *id)
|
||||
{
|
||||
Mesh *me = (Mesh *)id;
|
||||
for (int a = 0; a < me->totcol; a++) {
|
||||
BLO_expand(expander, me->mat[a]);
|
||||
}
|
||||
|
||||
BLO_expand(expander, me->key);
|
||||
BLO_expand(expander, me->texcomesh);
|
||||
}
|
||||
|
||||
IDTypeInfo IDType_ID_ME = {
|
||||
.id_code = ID_ME,
|
||||
.id_filter = FILTER_ID_ME,
|
||||
|
@ -180,10 +339,10 @@ IDTypeInfo IDType_ID_ME = {
|
|||
.foreach_id = mesh_foreach_id,
|
||||
.foreach_cache = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_read_expand = NULL,
|
||||
.blend_write = mesh_blend_write,
|
||||
.blend_read_data = mesh_blend_read_data,
|
||||
.blend_read_lib = mesh_blend_read_lib,
|
||||
.blend_read_expand = mesh_read_expand,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
|
@ -4109,115 +4109,6 @@ static void direct_link_particlesystems(BlendDataReader *reader, ListBase *parti
|
|||
/** \name Read ID: Mesh
|
||||
* \{ */
|
||||
|
||||
static void lib_link_mesh(BlendLibReader *reader, Mesh *me)
|
||||
{
|
||||
/* this check added for python created meshes */
|
||||
if (me->mat) {
|
||||
for (int i = 0; i < me->totcol; i++) {
|
||||
BLO_read_id_address(reader, me->id.lib, &me->mat[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
me->totcol = 0;
|
||||
}
|
||||
|
||||
BLO_read_id_address(reader, me->id.lib, &me->ipo); // XXX: deprecated: old anim sys
|
||||
BLO_read_id_address(reader, me->id.lib, &me->key);
|
||||
BLO_read_id_address(reader, me->id.lib, &me->texcomesh);
|
||||
}
|
||||
|
||||
static void direct_link_mesh(BlendDataReader *reader, Mesh *mesh)
|
||||
{
|
||||
BLO_read_pointer_array(reader, (void **)&mesh->mat);
|
||||
|
||||
BLO_read_data_address(reader, &mesh->mvert);
|
||||
BLO_read_data_address(reader, &mesh->medge);
|
||||
BLO_read_data_address(reader, &mesh->mface);
|
||||
BLO_read_data_address(reader, &mesh->mloop);
|
||||
BLO_read_data_address(reader, &mesh->mpoly);
|
||||
BLO_read_data_address(reader, &mesh->tface);
|
||||
BLO_read_data_address(reader, &mesh->mtface);
|
||||
BLO_read_data_address(reader, &mesh->mcol);
|
||||
BLO_read_data_address(reader, &mesh->dvert);
|
||||
BLO_read_data_address(reader, &mesh->mloopcol);
|
||||
BLO_read_data_address(reader, &mesh->mloopuv);
|
||||
BLO_read_data_address(reader, &mesh->mselect);
|
||||
|
||||
/* animdata */
|
||||
BLO_read_data_address(reader, &mesh->adt);
|
||||
BKE_animdata_blend_read_data(reader, mesh->adt);
|
||||
|
||||
/* Normally BKE_defvert_blend_read should be called in CustomData_blend_read,
|
||||
* but for backwards compatibility in do_versions to work we do it here. */
|
||||
BKE_defvert_blend_read(reader, mesh->totvert, mesh->dvert);
|
||||
|
||||
CustomData_blend_read(reader, &mesh->vdata, mesh->totvert);
|
||||
CustomData_blend_read(reader, &mesh->edata, mesh->totedge);
|
||||
CustomData_blend_read(reader, &mesh->fdata, mesh->totface);
|
||||
CustomData_blend_read(reader, &mesh->ldata, mesh->totloop);
|
||||
CustomData_blend_read(reader, &mesh->pdata, mesh->totpoly);
|
||||
|
||||
mesh->texflag &= ~ME_AUTOSPACE_EVALUATED;
|
||||
mesh->edit_mesh = NULL;
|
||||
BKE_mesh_runtime_reset(mesh);
|
||||
|
||||
/* happens with old files */
|
||||
if (mesh->mselect == NULL) {
|
||||
mesh->totselect = 0;
|
||||
}
|
||||
|
||||
/* Multires data */
|
||||
BLO_read_data_address(reader, &mesh->mr);
|
||||
if (mesh->mr) {
|
||||
BLO_read_list(reader, &mesh->mr->levels);
|
||||
MultiresLevel *lvl = mesh->mr->levels.first;
|
||||
|
||||
CustomData_blend_read(reader, &mesh->mr->vdata, lvl->totvert);
|
||||
BKE_defvert_blend_read(
|
||||
reader, lvl->totvert, CustomData_get(&mesh->mr->vdata, 0, CD_MDEFORMVERT));
|
||||
CustomData_blend_read(reader, &mesh->mr->fdata, lvl->totface);
|
||||
|
||||
BLO_read_data_address(reader, &mesh->mr->edge_flags);
|
||||
BLO_read_data_address(reader, &mesh->mr->edge_creases);
|
||||
|
||||
BLO_read_data_address(reader, &mesh->mr->verts);
|
||||
|
||||
/* If mesh has the same number of vertices as the
|
||||
* highest multires level, load the current mesh verts
|
||||
* into multires and discard the old data. Needed
|
||||
* because some saved files either do not have a verts
|
||||
* array, or the verts array contains out-of-date
|
||||
* data. */
|
||||
if (mesh->totvert == ((MultiresLevel *)mesh->mr->levels.last)->totvert) {
|
||||
if (mesh->mr->verts) {
|
||||
MEM_freeN(mesh->mr->verts);
|
||||
}
|
||||
mesh->mr->verts = MEM_dupallocN(mesh->mvert);
|
||||
}
|
||||
|
||||
for (; lvl; lvl = lvl->next) {
|
||||
BLO_read_data_address(reader, &lvl->verts);
|
||||
BLO_read_data_address(reader, &lvl->faces);
|
||||
BLO_read_data_address(reader, &lvl->edges);
|
||||
BLO_read_data_address(reader, &lvl->colfaces);
|
||||
}
|
||||
}
|
||||
|
||||
/* if multires is present but has no valid vertex data,
|
||||
* there's no way to recover it; silently remove multires */
|
||||
if (mesh->mr && !mesh->mr->verts) {
|
||||
multires_free(mesh->mr);
|
||||
mesh->mr = NULL;
|
||||
}
|
||||
|
||||
if ((BLO_read_requires_endian_switch(reader)) && mesh->tface) {
|
||||
TFace *tf = mesh->tface;
|
||||
for (int i = 0; i < mesh->totface; i++, tf++) {
|
||||
BLI_endian_switch_uint32_array(tf->col, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -8158,9 +8049,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
|
|||
case ID_OB:
|
||||
direct_link_object(&reader, (Object *)id);
|
||||
break;
|
||||
case ID_ME:
|
||||
direct_link_mesh(&reader, (Mesh *)id);
|
||||
break;
|
||||
case ID_CU:
|
||||
direct_link_curve(&reader, (Curve *)id);
|
||||
break;
|
||||
|
@ -8266,6 +8154,9 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
|
|||
case ID_SIM:
|
||||
direct_link_simulation(&reader, (Simulation *)id);
|
||||
break;
|
||||
case ID_ME:
|
||||
/* Do nothing. Handled by IDTypeInfo callback. */
|
||||
break;
|
||||
}
|
||||
|
||||
/* try to restore (when undoing) or clear ID's cache pointers. */
|
||||
|
@ -8938,9 +8829,6 @@ static void lib_link_all(FileData *fd, Main *bmain)
|
|||
case ID_CU:
|
||||
lib_link_curve(&reader, (Curve *)id);
|
||||
break;
|
||||
case ID_ME:
|
||||
lib_link_mesh(&reader, (Mesh *)id);
|
||||
break;
|
||||
case ID_CF:
|
||||
lib_link_cachefiles(&reader, (CacheFile *)id);
|
||||
break;
|
||||
|
@ -8994,6 +8882,9 @@ static void lib_link_all(FileData *fd, Main *bmain)
|
|||
case ID_LI:
|
||||
lib_link_library(&reader, (Library *)id); /* Only init users. */
|
||||
break;
|
||||
case ID_ME:
|
||||
/* Do nothing. Handled by IDTypeInfo callback. */
|
||||
break;
|
||||
}
|
||||
|
||||
id->tag &= ~LIB_TAG_NEED_LINK;
|
||||
|
@ -9843,16 +9734,6 @@ static void expand_curve(BlendExpander *expander, Curve *cu)
|
|||
BLO_expand(expander, cu->textoncurve);
|
||||
}
|
||||
|
||||
static void expand_mesh(BlendExpander *expander, Mesh *me)
|
||||
{
|
||||
for (int a = 0; a < me->totcol; a++) {
|
||||
BLO_expand(expander, me->mat[a]);
|
||||
}
|
||||
|
||||
BLO_expand(expander, me->key);
|
||||
BLO_expand(expander, me->texcomesh);
|
||||
}
|
||||
|
||||
/* callback function used to expand constraint ID-links */
|
||||
static void expand_constraint_cb(bConstraint *UNUSED(con),
|
||||
ID **idpoin,
|
||||
|
@ -10286,9 +10167,6 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
|
|||
case ID_OB:
|
||||
expand_object(&expander, (Object *)id);
|
||||
break;
|
||||
case ID_ME:
|
||||
expand_mesh(&expander, (Mesh *)id);
|
||||
break;
|
||||
case ID_CU:
|
||||
expand_curve(&expander, (Curve *)id);
|
||||
break;
|
||||
|
|
|
@ -659,33 +659,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_iddata(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);
|
||||
LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &id->override_library->properties) {
|
||||
BLO_write_string(writer, op->rna_path);
|
||||
|
||||
BLO_write_struct_list(writer, IDOverrideLibraryPropertyOperation, &op->operations);
|
||||
LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) {
|
||||
if (opop->subitem_reference_name) {
|
||||
BLO_write_string(writer, opop->subitem_reference_name);
|
||||
}
|
||||
if (opop->subitem_local_name) {
|
||||
BLO_write_string(writer, opop->subitem_local_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_previews(BlendWriter *writer, const PreviewImage *prv_orig)
|
||||
{
|
||||
/* Note we write previews also for undo steps. It takes up some memory,
|
||||
|
@ -714,7 +687,7 @@ static void write_action(BlendWriter *writer, bAction *act, const void *id_addre
|
|||
{
|
||||
if (act->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
BLO_write_id_struct(writer, bAction, id_address, &act->id);
|
||||
write_iddata(writer, &act->id);
|
||||
BKE_id_blend_write(writer, &act->id);
|
||||
|
||||
BKE_fcurve_blend_write(writer, &act->curves);
|
||||
|
||||
|
@ -1172,7 +1145,7 @@ static void write_particlesettings(BlendWriter *writer,
|
|||
if (part->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, ParticleSettings, id_address, &part->id);
|
||||
write_iddata(writer, &part->id);
|
||||
BKE_id_blend_write(writer, &part->id);
|
||||
|
||||
if (part->adt) {
|
||||
BKE_animdata_blend_write(writer, part->adt);
|
||||
|
@ -1594,7 +1567,7 @@ static void write_object(BlendWriter *writer, Object *ob, const void *id_address
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Object, id_address, &ob->id);
|
||||
write_iddata(writer, &ob->id);
|
||||
BKE_id_blend_write(writer, &ob->id);
|
||||
|
||||
if (ob->adt) {
|
||||
BKE_animdata_blend_write(writer, ob->adt);
|
||||
|
@ -1662,7 +1635,7 @@ static void write_vfont(BlendWriter *writer, VFont *vf, const void *id_address)
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, VFont, id_address, &vf->id);
|
||||
write_iddata(writer, &vf->id);
|
||||
BKE_id_blend_write(writer, &vf->id);
|
||||
|
||||
/* direct data */
|
||||
if (vf->packedfile) {
|
||||
|
@ -1678,7 +1651,7 @@ static void write_key(BlendWriter *writer, Key *key, const void *id_address)
|
|||
if (key->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Key, id_address, &key->id);
|
||||
write_iddata(writer, &key->id);
|
||||
BKE_id_blend_write(writer, &key->id);
|
||||
|
||||
if (key->adt) {
|
||||
BKE_animdata_blend_write(writer, key->adt);
|
||||
|
@ -1699,7 +1672,7 @@ static void write_camera(BlendWriter *writer, Camera *cam, const void *id_addres
|
|||
if (cam->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Camera, id_address, &cam->id);
|
||||
write_iddata(writer, &cam->id);
|
||||
BKE_id_blend_write(writer, &cam->id);
|
||||
|
||||
if (cam->adt) {
|
||||
BKE_animdata_blend_write(writer, cam->adt);
|
||||
|
@ -1724,7 +1697,7 @@ static void write_mball(BlendWriter *writer, MetaBall *mb, const void *id_addres
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, MetaBall, id_address, &mb->id);
|
||||
write_iddata(writer, &mb->id);
|
||||
BKE_id_blend_write(writer, &mb->id);
|
||||
|
||||
/* direct data */
|
||||
BLO_write_pointer_array(writer, mb->totcol, mb->mat);
|
||||
|
@ -1748,7 +1721,7 @@ static void write_curve(BlendWriter *writer, Curve *cu, const void *id_address)
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Curve, id_address, &cu->id);
|
||||
write_iddata(writer, &cu->id);
|
||||
BKE_id_blend_write(writer, &cu->id);
|
||||
|
||||
/* direct data */
|
||||
BLO_write_pointer_array(writer, cu->totcol, cu->mat);
|
||||
|
@ -1785,35 +1758,6 @@ static void write_curve(BlendWriter *writer, Curve *cu, const void *id_address)
|
|||
}
|
||||
}
|
||||
|
||||
static void write_mesh(BlendWriter *writer, Mesh *mesh, const void *id_address)
|
||||
{
|
||||
if (mesh->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* cache only - don't write */
|
||||
mesh->mface = NULL;
|
||||
mesh->totface = 0;
|
||||
memset(&mesh->fdata, 0, sizeof(mesh->fdata));
|
||||
memset(&mesh->runtime, 0, sizeof(mesh->runtime));
|
||||
|
||||
BLO_write_id_struct(writer, Mesh, id_address, &mesh->id);
|
||||
write_iddata(writer, &mesh->id);
|
||||
|
||||
/* direct data */
|
||||
if (mesh->adt) {
|
||||
BKE_animdata_blend_write(writer, mesh->adt);
|
||||
}
|
||||
|
||||
BLO_write_pointer_array(writer, mesh->totcol, mesh->mat);
|
||||
BLO_write_raw(writer, sizeof(MSelect) * mesh->totselect, mesh->mselect);
|
||||
|
||||
CustomData_blend_write(writer, &mesh->vdata, mesh->totvert, CD_MASK_MESH.vmask, &mesh->id);
|
||||
CustomData_blend_write(writer, &mesh->edata, mesh->totedge, CD_MASK_MESH.emask, &mesh->id);
|
||||
/* fdata is really a dummy - written so slots align */
|
||||
CustomData_blend_write(writer, &mesh->fdata, mesh->totface, CD_MASK_MESH.fmask, &mesh->id);
|
||||
CustomData_blend_write(writer, &mesh->ldata, mesh->totloop, CD_MASK_MESH.lmask, &mesh->id);
|
||||
CustomData_blend_write(writer, &mesh->pdata, mesh->totpoly, CD_MASK_MESH.pmask, &mesh->id);
|
||||
}
|
||||
}
|
||||
|
||||
static void write_lattice(BlendWriter *writer, Lattice *lt, const void *id_address)
|
||||
{
|
||||
if (lt->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
|
@ -1823,7 +1767,7 @@ static void write_lattice(BlendWriter *writer, Lattice *lt, const void *id_addre
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Lattice, id_address, <->id);
|
||||
write_iddata(writer, <->id);
|
||||
BKE_id_blend_write(writer, <->id);
|
||||
|
||||
/* write animdata */
|
||||
if (lt->adt) {
|
||||
|
@ -1851,7 +1795,7 @@ static void write_image(BlendWriter *writer, Image *ima, const void *id_address)
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Image, id_address, &ima->id);
|
||||
write_iddata(writer, &ima->id);
|
||||
BKE_id_blend_write(writer, &ima->id);
|
||||
|
||||
for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
|
||||
BLO_write_struct(writer, ImagePackedFile, imapf);
|
||||
|
@ -1882,7 +1826,7 @@ static void write_texture(BlendWriter *writer, Tex *tex, const void *id_address)
|
|||
if (tex->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Tex, id_address, &tex->id);
|
||||
write_iddata(writer, &tex->id);
|
||||
BKE_id_blend_write(writer, &tex->id);
|
||||
|
||||
if (tex->adt) {
|
||||
BKE_animdata_blend_write(writer, tex->adt);
|
||||
|
@ -1912,7 +1856,7 @@ static void write_material(BlendWriter *writer, Material *ma, const void *id_add
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Material, id_address, &ma->id);
|
||||
write_iddata(writer, &ma->id);
|
||||
BKE_id_blend_write(writer, &ma->id);
|
||||
|
||||
if (ma->adt) {
|
||||
BKE_animdata_blend_write(writer, ma->adt);
|
||||
|
@ -1941,7 +1885,7 @@ static void write_world(BlendWriter *writer, World *wrld, const void *id_address
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, World, id_address, &wrld->id);
|
||||
write_iddata(writer, &wrld->id);
|
||||
BKE_id_blend_write(writer, &wrld->id);
|
||||
|
||||
if (wrld->adt) {
|
||||
BKE_animdata_blend_write(writer, wrld->adt);
|
||||
|
@ -1962,7 +1906,7 @@ static void write_light(BlendWriter *writer, Light *la, const void *id_address)
|
|||
if (la->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Light, id_address, &la->id);
|
||||
write_iddata(writer, &la->id);
|
||||
BKE_id_blend_write(writer, &la->id);
|
||||
|
||||
if (la->adt) {
|
||||
BKE_animdata_blend_write(writer, la->adt);
|
||||
|
@ -2007,7 +1951,7 @@ static void write_collection(BlendWriter *writer, Collection *collection, const
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Collection, id_address, &collection->id);
|
||||
write_iddata(writer, &collection->id);
|
||||
BKE_id_blend_write(writer, &collection->id);
|
||||
|
||||
write_collection_nolib(writer, collection);
|
||||
}
|
||||
|
@ -2133,7 +2077,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address)
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Scene, id_address, &sce->id);
|
||||
write_iddata(writer, &sce->id);
|
||||
BKE_id_blend_write(writer, &sce->id);
|
||||
|
||||
if (sce->adt) {
|
||||
BKE_animdata_blend_write(writer, sce->adt);
|
||||
|
@ -2367,7 +2311,7 @@ static void write_gpencil(BlendWriter *writer, bGPdata *gpd, const void *id_addr
|
|||
|
||||
/* write gpd data block to file */
|
||||
BLO_write_id_struct(writer, bGPdata, id_address, &gpd->id);
|
||||
write_iddata(writer, &gpd->id);
|
||||
BKE_id_blend_write(writer, &gpd->id);
|
||||
|
||||
if (gpd->adt) {
|
||||
BKE_animdata_blend_write(writer, gpd->adt);
|
||||
|
@ -2641,7 +2585,7 @@ static void write_area_map(BlendWriter *writer, ScrAreaMap *area_map)
|
|||
static void write_windowmanager(BlendWriter *writer, wmWindowManager *wm, const void *id_address)
|
||||
{
|
||||
BLO_write_id_struct(writer, wmWindowManager, id_address, &wm->id);
|
||||
write_iddata(writer, &wm->id);
|
||||
BKE_id_blend_write(writer, &wm->id);
|
||||
write_wm_xr_data(writer, &wm->xr);
|
||||
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
|
@ -2676,7 +2620,7 @@ static void write_screen(BlendWriter *writer, bScreen *screen, const void *id_ad
|
|||
/* write LibData */
|
||||
/* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
|
||||
writestruct_at_address(writer->wd, ID_SCRN, bScreen, 1, id_address, screen);
|
||||
write_iddata(writer, &screen->id);
|
||||
BKE_id_blend_write(writer, &screen->id);
|
||||
|
||||
write_previews(writer, screen->preview);
|
||||
|
||||
|
@ -2716,7 +2660,7 @@ static void write_armature(BlendWriter *writer, bArmature *arm, const void *id_a
|
|||
arm->act_edbone = NULL;
|
||||
|
||||
BLO_write_id_struct(writer, bArmature, id_address, &arm->id);
|
||||
write_iddata(writer, &arm->id);
|
||||
BKE_id_blend_write(writer, &arm->id);
|
||||
|
||||
if (arm->adt) {
|
||||
BKE_animdata_blend_write(writer, arm->adt);
|
||||
|
@ -2741,7 +2685,7 @@ static void write_text(BlendWriter *writer, Text *text, const void *id_address)
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Text, id_address, &text->id);
|
||||
write_iddata(writer, &text->id);
|
||||
BKE_id_blend_write(writer, &text->id);
|
||||
|
||||
if (text->filepath) {
|
||||
BLO_write_string(writer, text->filepath);
|
||||
|
@ -2764,7 +2708,7 @@ static void write_speaker(BlendWriter *writer, Speaker *spk, const void *id_addr
|
|||
if (spk->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Speaker, id_address, &spk->id);
|
||||
write_iddata(writer, &spk->id);
|
||||
BKE_id_blend_write(writer, &spk->id);
|
||||
|
||||
if (spk->adt) {
|
||||
BKE_animdata_blend_write(writer, spk->adt);
|
||||
|
@ -2783,7 +2727,7 @@ static void write_sound(BlendWriter *writer, bSound *sound, const void *id_addre
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, bSound, id_address, &sound->id);
|
||||
write_iddata(writer, &sound->id);
|
||||
BKE_id_blend_write(writer, &sound->id);
|
||||
|
||||
if (sound->packedfile) {
|
||||
PackedFile *pf = sound->packedfile;
|
||||
|
@ -2798,7 +2742,7 @@ static void write_probe(BlendWriter *writer, LightProbe *prb, const void *id_add
|
|||
if (prb->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, LightProbe, id_address, &prb->id);
|
||||
write_iddata(writer, &prb->id);
|
||||
BKE_id_blend_write(writer, &prb->id);
|
||||
|
||||
if (prb->adt) {
|
||||
BKE_animdata_blend_write(writer, prb->adt);
|
||||
|
@ -2820,7 +2764,7 @@ static void write_nodetree(BlendWriter *writer, bNodeTree *ntree, const void *id
|
|||
BLO_write_id_struct(writer, bNodeTree, id_address, &ntree->id);
|
||||
/* Note that trees directly used by other IDs (materials etc.) are not 'real' ID, they cannot
|
||||
* be linked, etc., so we write actual id data here only, for 'real' ID trees. */
|
||||
write_iddata(writer, &ntree->id);
|
||||
BKE_id_blend_write(writer, &ntree->id);
|
||||
|
||||
write_nodetree_nolib(writer, ntree);
|
||||
}
|
||||
|
@ -2830,7 +2774,7 @@ static void write_brush(BlendWriter *writer, Brush *brush, const void *id_addres
|
|||
{
|
||||
if (brush->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
BLO_write_id_struct(writer, Brush, id_address, &brush->id);
|
||||
write_iddata(writer, &brush->id);
|
||||
BKE_id_blend_write(writer, &brush->id);
|
||||
|
||||
if (brush->curve) {
|
||||
BKE_curvemapping_blend_write(writer, brush->curve);
|
||||
|
@ -2878,7 +2822,7 @@ static void write_palette(BlendWriter *writer, Palette *palette, const void *id_
|
|||
if (palette->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
PaletteColor *color;
|
||||
BLO_write_id_struct(writer, Palette, id_address, &palette->id);
|
||||
write_iddata(writer, &palette->id);
|
||||
BKE_id_blend_write(writer, &palette->id);
|
||||
|
||||
for (color = palette->colors.first; color; color = color->next) {
|
||||
BLO_write_struct(writer, PaletteColor, color);
|
||||
|
@ -2890,7 +2834,7 @@ static void write_paintcurve(BlendWriter *writer, PaintCurve *pc, const void *id
|
|||
{
|
||||
if (pc->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
BLO_write_id_struct(writer, PaintCurve, id_address, &pc->id);
|
||||
write_iddata(writer, &pc->id);
|
||||
BKE_id_blend_write(writer, &pc->id);
|
||||
|
||||
BLO_write_struct_array(writer, PaintCurvePoint, pc->tot_points, pc->points);
|
||||
}
|
||||
|
@ -2946,7 +2890,7 @@ static void write_movieclip(BlendWriter *writer, MovieClip *clip, const void *id
|
|||
MovieTrackingObject *object;
|
||||
|
||||
BLO_write_id_struct(writer, MovieClip, id_address, &clip->id);
|
||||
write_iddata(writer, &clip->id);
|
||||
BKE_id_blend_write(writer, &clip->id);
|
||||
|
||||
if (clip->adt) {
|
||||
BKE_animdata_blend_write(writer, clip->adt);
|
||||
|
@ -2975,7 +2919,7 @@ static void write_mask(BlendWriter *writer, Mask *mask, const void *id_address)
|
|||
MaskLayer *masklay;
|
||||
|
||||
BLO_write_id_struct(writer, Mask, id_address, &mask->id);
|
||||
write_iddata(writer, &mask->id);
|
||||
BKE_id_blend_write(writer, &mask->id);
|
||||
|
||||
if (mask->adt) {
|
||||
BKE_animdata_blend_write(writer, mask->adt);
|
||||
|
@ -3285,7 +3229,7 @@ static void write_linestyle(BlendWriter *writer,
|
|||
{
|
||||
if (linestyle->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
BLO_write_id_struct(writer, FreestyleLineStyle, id_address, &linestyle->id);
|
||||
write_iddata(writer, &linestyle->id);
|
||||
BKE_id_blend_write(writer, &linestyle->id);
|
||||
|
||||
if (linestyle->adt) {
|
||||
BKE_animdata_blend_write(writer, linestyle->adt);
|
||||
|
@ -3327,7 +3271,7 @@ static void write_cachefile(BlendWriter *writer, CacheFile *cache_file, const vo
|
|||
static void write_workspace(BlendWriter *writer, WorkSpace *workspace, const void *id_address)
|
||||
{
|
||||
BLO_write_id_struct(writer, WorkSpace, id_address, &workspace->id);
|
||||
write_iddata(writer, &workspace->id);
|
||||
BKE_id_blend_write(writer, &workspace->id);
|
||||
BLO_write_struct_list(writer, WorkSpaceLayout, &workspace->layouts);
|
||||
BLO_write_struct_list(writer, WorkSpaceDataRelation, &workspace->hook_layout_relations);
|
||||
BLO_write_struct_list(writer, wmOwnerID, &workspace->owner_ids);
|
||||
|
@ -3344,7 +3288,7 @@ static void write_hair(BlendWriter *writer, Hair *hair, const void *id_address)
|
|||
if (hair->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* Write LibData */
|
||||
BLO_write_id_struct(writer, Hair, id_address, &hair->id);
|
||||
write_iddata(writer, &hair->id);
|
||||
BKE_id_blend_write(writer, &hair->id);
|
||||
|
||||
/* Direct data */
|
||||
CustomData_blend_write(writer, &hair->pdata, hair->totpoint, CD_MASK_ALL, &hair->id);
|
||||
|
@ -3365,7 +3309,7 @@ static void write_pointcloud(BlendWriter *writer, PointCloud *pointcloud, const
|
|||
|
||||
/* Write LibData */
|
||||
BLO_write_id_struct(writer, PointCloud, id_address, &pointcloud->id);
|
||||
write_iddata(writer, &pointcloud->id);
|
||||
BKE_id_blend_write(writer, &pointcloud->id);
|
||||
|
||||
/* Direct data */
|
||||
CustomData_blend_write(
|
||||
|
@ -3390,7 +3334,7 @@ static void write_volume(BlendWriter *writer, Volume *volume, const void *id_add
|
|||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Volume, id_address, &volume->id);
|
||||
write_iddata(writer, &volume->id);
|
||||
BKE_id_blend_write(writer, &volume->id);
|
||||
|
||||
/* direct data */
|
||||
BLO_write_pointer_array(writer, volume->totcol, volume->mat);
|
||||
|
@ -3410,7 +3354,7 @@ static void write_simulation(BlendWriter *writer, Simulation *simulation, const
|
|||
{
|
||||
if (simulation->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
BLO_write_id_struct(writer, Simulation, id_address, &simulation->id);
|
||||
write_iddata(writer, &simulation->id);
|
||||
BKE_id_blend_write(writer, &simulation->id);
|
||||
|
||||
if (simulation->adt) {
|
||||
BKE_animdata_blend_write(writer, simulation->adt);
|
||||
|
@ -3490,7 +3434,7 @@ static void write_libraries(WriteData *wd, Main *main)
|
|||
|
||||
BlendWriter writer = {wd};
|
||||
writestruct(wd, ID_LI, Library, 1, main->curlib);
|
||||
write_iddata(&writer, &main->curlib->id);
|
||||
BKE_id_blend_write(&writer, &main->curlib->id);
|
||||
|
||||
if (main->curlib->packedfile) {
|
||||
PackedFile *pf = main->curlib->packedfile;
|
||||
|
@ -3782,9 +3726,6 @@ static bool write_file_handle(Main *mainvar,
|
|||
case ID_TE:
|
||||
write_texture(&writer, (Tex *)id_buffer, id);
|
||||
break;
|
||||
case ID_ME:
|
||||
write_mesh(&writer, (Mesh *)id_buffer, id);
|
||||
break;
|
||||
case ID_PA:
|
||||
write_particlesettings(&writer, (ParticleSettings *)id_buffer, id);
|
||||
break;
|
||||
|
@ -3821,6 +3762,9 @@ static bool write_file_handle(Main *mainvar,
|
|||
case ID_SIM:
|
||||
write_simulation(&writer, (Simulation *)id_buffer, id);
|
||||
break;
|
||||
case ID_ME:
|
||||
/* Do nothing, handled in IDTypeInfo callback. */
|
||||
break;
|
||||
case ID_LI:
|
||||
/* Do nothing, handled below - and should never be reached. */
|
||||
BLI_assert(0);
|
||||
|
|
Loading…
Reference in New Issue