Refactor: move Lattice .blend I/O to IDTypeInfo callbacks
This commit is contained in:
parent
8815996418
commit
7b2fe4c9ec
Notes:
blender-bot
2023-02-13 21:22:31 +01:00
Referenced by issue #80193, Sequencer crash on float images when OCIO GLSL shader can't be used
|
@ -35,6 +35,9 @@
|
|||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
/* Allow using deprecated functionality for .blend file I/O. */
|
||||
#define DNA_DEPRECATED_ALLOW
|
||||
|
||||
#include "DNA_curve_types.h"
|
||||
#include "DNA_defaults.h"
|
||||
#include "DNA_key_types.h"
|
||||
|
@ -43,7 +46,9 @@
|
|||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_anim_data.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_displist.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_lattice.h"
|
||||
|
@ -53,10 +58,10 @@
|
|||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
|
||||
#include "BKE_deform.h"
|
||||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
static void lattice_init_data(ID *id)
|
||||
{
|
||||
Lattice *lattice = (Lattice *)id;
|
||||
|
@ -124,6 +129,59 @@ static void lattice_foreach_id(ID *id, LibraryForeachIDData *data)
|
|||
BKE_LIB_FOREACHID_PROCESS(data, lattice->key, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
{
|
||||
Lattice *lt = (Lattice *)id;
|
||||
if (lt->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
|
||||
lt->editlatt = NULL;
|
||||
lt->batch_cache = NULL;
|
||||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Lattice, id_address, <->id);
|
||||
BKE_id_blend_write(writer, <->id);
|
||||
|
||||
/* write animdata */
|
||||
if (lt->adt) {
|
||||
BKE_animdata_blend_write(writer, lt->adt);
|
||||
}
|
||||
|
||||
/* direct data */
|
||||
BLO_write_struct_array(writer, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, lt->def);
|
||||
|
||||
BKE_defvert_blend_write(writer, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
|
||||
}
|
||||
}
|
||||
|
||||
static void lattice_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
{
|
||||
Lattice *lt = (Lattice *)id;
|
||||
BLO_read_data_address(reader, <->def);
|
||||
|
||||
BLO_read_data_address(reader, <->dvert);
|
||||
BKE_defvert_blend_read(reader, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
|
||||
|
||||
lt->editlatt = NULL;
|
||||
lt->batch_cache = NULL;
|
||||
|
||||
BLO_read_data_address(reader, <->adt);
|
||||
BKE_animdata_blend_read_data(reader, lt->adt);
|
||||
}
|
||||
|
||||
static void lattice_blend_read_lib(BlendLibReader *reader, ID *id)
|
||||
{
|
||||
Lattice *lt = (Lattice *)id;
|
||||
BLO_read_id_address(reader, lt->id.lib, <->ipo); // XXX deprecated - old animation system
|
||||
BLO_read_id_address(reader, lt->id.lib, <->key);
|
||||
}
|
||||
|
||||
static void lattice_blend_read_expand(BlendExpander *expander, ID *id)
|
||||
{
|
||||
Lattice *lt = (Lattice *)id;
|
||||
BLO_expand(expander, lt->ipo); // XXX deprecated - old animation system
|
||||
BLO_expand(expander, lt->key);
|
||||
}
|
||||
|
||||
IDTypeInfo IDType_ID_LT = {
|
||||
.id_code = ID_LT,
|
||||
.id_filter = FILTER_ID_LT,
|
||||
|
@ -141,10 +199,10 @@ IDTypeInfo IDType_ID_LT = {
|
|||
.foreach_id = lattice_foreach_id,
|
||||
.foreach_cache = NULL,
|
||||
|
||||
.blend_write = NULL,
|
||||
.blend_read_data = NULL,
|
||||
.blend_read_lib = NULL,
|
||||
.blend_read_expand = NULL,
|
||||
.blend_write = lattice_blend_write,
|
||||
.blend_read_data = lattice_blend_read_data,
|
||||
.blend_read_lib = lattice_blend_read_lib,
|
||||
.blend_read_expand = lattice_blend_read_expand,
|
||||
};
|
||||
|
||||
int BKE_lattice_index_from_uvw(Lattice *lt, const int u, const int v, const int w)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
/* allow using deprecated functionality for .blend file I/O */
|
||||
/* Allow using deprecated functionality for .blend file I/O. */
|
||||
#define DNA_DEPRECATED_ALLOW
|
||||
|
||||
#include "DNA_defaults.h"
|
||||
|
|
|
@ -4111,32 +4111,6 @@ static void direct_link_particlesystems(BlendDataReader *reader, ListBase *parti
|
|||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Read ID: Lattice
|
||||
* \{ */
|
||||
|
||||
static void lib_link_latt(BlendLibReader *reader, Lattice *lt)
|
||||
{
|
||||
BLO_read_id_address(reader, lt->id.lib, <->ipo); // XXX deprecated - old animation system
|
||||
BLO_read_id_address(reader, lt->id.lib, <->key);
|
||||
}
|
||||
|
||||
static void direct_link_latt(BlendDataReader *reader, Lattice *lt)
|
||||
{
|
||||
BLO_read_data_address(reader, <->def);
|
||||
|
||||
BLO_read_data_address(reader, <->dvert);
|
||||
BKE_defvert_blend_read(reader, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
|
||||
|
||||
lt->editlatt = NULL;
|
||||
lt->batch_cache = NULL;
|
||||
|
||||
BLO_read_data_address(reader, <->adt);
|
||||
BKE_animdata_blend_read_data(reader, lt->adt);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Read ID: Object
|
||||
* \{ */
|
||||
|
@ -8079,9 +8053,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
|
|||
case ID_KE:
|
||||
direct_link_key(&reader, (Key *)id);
|
||||
break;
|
||||
case ID_LT:
|
||||
direct_link_latt(&reader, (Lattice *)id);
|
||||
break;
|
||||
case ID_WO:
|
||||
direct_link_world(&reader, (World *)id);
|
||||
break;
|
||||
|
@ -8155,6 +8126,7 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
|
|||
direct_link_simulation(&reader, (Simulation *)id);
|
||||
break;
|
||||
case ID_ME:
|
||||
case ID_LT:
|
||||
/* Do nothing. Handled by IDTypeInfo callback. */
|
||||
break;
|
||||
}
|
||||
|
@ -8820,9 +8792,6 @@ static void lib_link_all(FileData *fd, Main *bmain)
|
|||
case ID_LA:
|
||||
lib_link_light(&reader, (Light *)id);
|
||||
break;
|
||||
case ID_LT:
|
||||
lib_link_latt(&reader, (Lattice *)id);
|
||||
break;
|
||||
case ID_MB:
|
||||
lib_link_mball(&reader, (MetaBall *)id);
|
||||
break;
|
||||
|
@ -8883,6 +8852,7 @@ static void lib_link_all(FileData *fd, Main *bmain)
|
|||
lib_link_library(&reader, (Library *)id); /* Only init users. */
|
||||
break;
|
||||
case ID_ME:
|
||||
case ID_LT:
|
||||
/* Do nothing. Handled by IDTypeInfo callback. */
|
||||
break;
|
||||
}
|
||||
|
@ -9699,12 +9669,6 @@ static void expand_light(BlendExpander *expander, Light *la)
|
|||
BLO_expand(expander, la->ipo); // XXX deprecated - old animation system
|
||||
}
|
||||
|
||||
static void expand_lattice(BlendExpander *expander, Lattice *lt)
|
||||
{
|
||||
BLO_expand(expander, lt->ipo); // XXX deprecated - old animation system
|
||||
BLO_expand(expander, lt->key);
|
||||
}
|
||||
|
||||
static void expand_world(BlendExpander *expander, World *wrld)
|
||||
{
|
||||
BLO_expand(expander, wrld->ipo); // XXX deprecated - old animation system
|
||||
|
@ -10185,9 +10149,6 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
|
|||
case ID_WO:
|
||||
expand_world(&expander, (World *)id);
|
||||
break;
|
||||
case ID_LT:
|
||||
expand_lattice(&expander, (Lattice *)id);
|
||||
break;
|
||||
case ID_LA:
|
||||
expand_light(&expander, (Light *)id);
|
||||
break;
|
||||
|
|
|
@ -1758,29 +1758,6 @@ static void write_curve(BlendWriter *writer, Curve *cu, const void *id_address)
|
|||
}
|
||||
}
|
||||
|
||||
static void write_lattice(BlendWriter *writer, Lattice *lt, const void *id_address)
|
||||
{
|
||||
if (lt->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
|
||||
lt->editlatt = NULL;
|
||||
lt->batch_cache = NULL;
|
||||
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Lattice, id_address, <->id);
|
||||
BKE_id_blend_write(writer, <->id);
|
||||
|
||||
/* write animdata */
|
||||
if (lt->adt) {
|
||||
BKE_animdata_blend_write(writer, lt->adt);
|
||||
}
|
||||
|
||||
/* direct data */
|
||||
BLO_write_struct_array(writer, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, lt->def);
|
||||
|
||||
BKE_defvert_blend_write(writer, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
|
||||
}
|
||||
}
|
||||
|
||||
static void write_image(BlendWriter *writer, Image *ima, const void *id_address)
|
||||
{
|
||||
if (ima->id.us > 0 || BLO_write_is_undo(writer)) {
|
||||
|
@ -3684,9 +3661,6 @@ static bool write_file_handle(Main *mainvar,
|
|||
case ID_LA:
|
||||
write_light(&writer, (Light *)id_buffer, id);
|
||||
break;
|
||||
case ID_LT:
|
||||
write_lattice(&writer, (Lattice *)id_buffer, id);
|
||||
break;
|
||||
case ID_VF:
|
||||
write_vfont(&writer, (VFont *)id_buffer, id);
|
||||
break;
|
||||
|
@ -3763,6 +3737,7 @@ static bool write_file_handle(Main *mainvar,
|
|||
write_simulation(&writer, (Simulation *)id_buffer, id);
|
||||
break;
|
||||
case ID_ME:
|
||||
case ID_LT:
|
||||
/* Do nothing, handled in IDTypeInfo callback. */
|
||||
break;
|
||||
case ID_LI:
|
||||
|
|
Loading…
Reference in New Issue