Cleanup: decentralize .blend I/O for space types
This adds callbacks to `SpaceType` to make each editor responsible to manage their own .blend I/O, and moves relevant code from `screen.c` to the editors files. Differential Revision: D11069
This commit is contained in:
@@ -108,6 +108,23 @@ typedef struct SpaceType {
|
||||
void (*space_subtype_set)(struct ScrArea *area, int value);
|
||||
void (*space_subtype_item_extend)(struct bContext *C, EnumPropertyItem **item, int *totitem);
|
||||
|
||||
/**
|
||||
* Update pointers for all structs directly owned by this space.
|
||||
*/
|
||||
void (*blend_read_data)(struct BlendDataReader *reader, struct SpaceLink *space_link);
|
||||
|
||||
/**
|
||||
* Update pointers to other id data blocks.
|
||||
*/
|
||||
void (*blend_read_lib)(struct BlendLibReader *reader,
|
||||
struct ID *parent_id,
|
||||
struct SpaceLink *space_link);
|
||||
|
||||
/**
|
||||
* Write all structs that should be saved in a .blend file.
|
||||
*/
|
||||
void (*blend_write)(struct BlendWriter *writer, struct SpaceLink *space_link);
|
||||
|
||||
/* region type definitions */
|
||||
ListBase regiontypes;
|
||||
|
||||
|
||||
@@ -1123,59 +1123,6 @@ static void write_uilist(BlendWriter *writer, uiList *ui_list)
|
||||
}
|
||||
}
|
||||
|
||||
static void write_space_outliner(BlendWriter *writer, const SpaceOutliner *space_outliner)
|
||||
{
|
||||
BLI_mempool *ts = space_outliner->treestore;
|
||||
|
||||
if (ts) {
|
||||
const int elems = BLI_mempool_len(ts);
|
||||
/* linearize mempool to array */
|
||||
TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL;
|
||||
|
||||
if (data) {
|
||||
BLO_write_struct(writer, SpaceOutliner, space_outliner);
|
||||
|
||||
/* To store #TreeStore (instead of the mempool), two unique memory addresses are needed,
|
||||
* which can be used to identify the data on read:
|
||||
* 1) One for the #TreeStore data itself.
|
||||
* 2) One for the array of #TreeStoreElem's inside #TreeStore (#TreeStore.data).
|
||||
*
|
||||
* For 1) we just use the mempool's address (#SpaceOutliner::treestore).
|
||||
* For 2) we don't have such a direct choice. We can't just use the array's address from
|
||||
* above, since that may not be unique over all Outliners. So instead use an address relative
|
||||
* to 1).
|
||||
*/
|
||||
/* TODO the mempool could be moved to #SpaceOutliner_Runtime so that #SpaceOutliner could
|
||||
* hold the #TreeStore directly. */
|
||||
|
||||
/* Address relative to the tree-store, as noted above. */
|
||||
void *data_addr = (void *)POINTER_OFFSET(ts, sizeof(void *));
|
||||
/* There should be plenty of memory addresses within the mempool data that we can point into,
|
||||
* just double-check we don't potentially end up with a memory address that another DNA
|
||||
* struct might use. Assumes BLI_mempool uses the guarded allocator. */
|
||||
BLI_assert(MEM_allocN_len(ts) >= sizeof(void *) * 2);
|
||||
|
||||
TreeStore ts_flat = {0};
|
||||
ts_flat.usedelem = elems;
|
||||
ts_flat.totelem = elems;
|
||||
ts_flat.data = data_addr;
|
||||
|
||||
BLO_write_struct_at_address(writer, TreeStore, ts, &ts_flat);
|
||||
BLO_write_struct_array_at_address(writer, TreeStoreElem, elems, data_addr, data);
|
||||
|
||||
MEM_freeN(data);
|
||||
}
|
||||
else {
|
||||
SpaceOutliner space_outliner_flat = *space_outliner;
|
||||
space_outliner_flat.treestore = NULL;
|
||||
BLO_write_struct_at_address(writer, SpaceOutliner, space_outliner, &space_outliner_flat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BLO_write_struct(writer, SpaceOutliner, space_outliner);
|
||||
}
|
||||
}
|
||||
|
||||
static void write_panel_list(BlendWriter *writer, ListBase *lb)
|
||||
{
|
||||
LISTBASE_FOREACH (Panel *, panel, lb) {
|
||||
@@ -1208,146 +1155,9 @@ static void write_area(BlendWriter *writer, ScrArea *area)
|
||||
write_region(writer, region, sl->spacetype);
|
||||
}
|
||||
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = (View3D *)sl;
|
||||
BLO_write_struct(writer, View3D, v3d);
|
||||
|
||||
if (v3d->localvd) {
|
||||
BLO_write_struct(writer, View3D, v3d->localvd);
|
||||
}
|
||||
|
||||
BKE_screen_view3d_shading_blend_write(writer, &v3d->shading);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_GRAPH) {
|
||||
SpaceGraph *sipo = (SpaceGraph *)sl;
|
||||
ListBase tmpGhosts = sipo->runtime.ghost_curves;
|
||||
|
||||
/* temporarily disable ghost curves when saving */
|
||||
BLI_listbase_clear(&sipo->runtime.ghost_curves);
|
||||
|
||||
BLO_write_struct(writer, SpaceGraph, sl);
|
||||
if (sipo->ads) {
|
||||
BLO_write_struct(writer, bDopeSheet, sipo->ads);
|
||||
}
|
||||
|
||||
/* reenable ghost curves */
|
||||
sipo->runtime.ghost_curves = tmpGhosts;
|
||||
}
|
||||
else if (sl->spacetype == SPACE_PROPERTIES) {
|
||||
BLO_write_struct(writer, SpaceProperties, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_FILE) {
|
||||
SpaceFile *sfile = (SpaceFile *)sl;
|
||||
|
||||
BLO_write_struct(writer, SpaceFile, sl);
|
||||
if (sfile->params) {
|
||||
BLO_write_struct(writer, FileSelectParams, sfile->params);
|
||||
}
|
||||
if (sfile->asset_params) {
|
||||
BLO_write_struct(writer, FileAssetSelectParams, sfile->asset_params);
|
||||
}
|
||||
}
|
||||
else if (sl->spacetype == SPACE_SEQ) {
|
||||
BLO_write_struct(writer, SpaceSeq, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_OUTLINER) {
|
||||
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
|
||||
write_space_outliner(writer, space_outliner);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_IMAGE) {
|
||||
BLO_write_struct(writer, SpaceImage, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_TEXT) {
|
||||
BLO_write_struct(writer, SpaceText, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_SCRIPT) {
|
||||
SpaceScript *scr = (SpaceScript *)sl;
|
||||
scr->but_refs = NULL;
|
||||
BLO_write_struct(writer, SpaceScript, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_ACTION) {
|
||||
BLO_write_struct(writer, SpaceAction, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_NLA) {
|
||||
SpaceNla *snla = (SpaceNla *)sl;
|
||||
|
||||
BLO_write_struct(writer, SpaceNla, snla);
|
||||
if (snla->ads) {
|
||||
BLO_write_struct(writer, bDopeSheet, snla->ads);
|
||||
}
|
||||
}
|
||||
else if (sl->spacetype == SPACE_NODE) {
|
||||
SpaceNode *snode = (SpaceNode *)sl;
|
||||
BLO_write_struct(writer, SpaceNode, snode);
|
||||
|
||||
LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
|
||||
BLO_write_struct(writer, bNodeTreePath, path);
|
||||
}
|
||||
}
|
||||
else if (sl->spacetype == SPACE_CONSOLE) {
|
||||
SpaceConsole *con = (SpaceConsole *)sl;
|
||||
|
||||
LISTBASE_FOREACH (ConsoleLine *, cl, &con->history) {
|
||||
/* 'len_alloc' is invalid on write, set from 'len' on read */
|
||||
BLO_write_struct(writer, ConsoleLine, cl);
|
||||
BLO_write_raw(writer, (size_t)cl->len + 1, cl->line);
|
||||
}
|
||||
BLO_write_struct(writer, SpaceConsole, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_TOPBAR) {
|
||||
BLO_write_struct(writer, SpaceTopBar, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_STATUSBAR) {
|
||||
BLO_write_struct(writer, SpaceStatusBar, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_USERPREF) {
|
||||
BLO_write_struct(writer, SpaceUserPref, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_CLIP) {
|
||||
BLO_write_struct(writer, SpaceClip, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_INFO) {
|
||||
BLO_write_struct(writer, SpaceInfo, sl);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_SPREADSHEET) {
|
||||
BLO_write_struct(writer, SpaceSpreadsheet, sl);
|
||||
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
|
||||
|
||||
LISTBASE_FOREACH (SpreadsheetRowFilter *, row_filter, &sspreadsheet->row_filters) {
|
||||
BLO_write_struct(writer, SpreadsheetRowFilter, row_filter);
|
||||
BLO_write_string(writer, row_filter->value_string);
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
|
||||
BLO_write_struct(writer, SpreadsheetColumn, column);
|
||||
BLO_write_struct(writer, SpreadsheetColumnID, column->id);
|
||||
BLO_write_string(writer, column->id->name);
|
||||
/* While the display name is technically runtime data, we write it here, otherwise the row
|
||||
* filters might not now their type if their region draws before the main region.
|
||||
* This would ideally be cleared here. */
|
||||
BLO_write_string(writer, column->display_name);
|
||||
}
|
||||
LISTBASE_FOREACH (SpreadsheetContext *, context, &sspreadsheet->context_path) {
|
||||
switch (context->type) {
|
||||
case SPREADSHEET_CONTEXT_OBJECT: {
|
||||
SpreadsheetContextObject *object_context = (SpreadsheetContextObject *)context;
|
||||
BLO_write_struct(writer, SpreadsheetContextObject, object_context);
|
||||
break;
|
||||
}
|
||||
case SPREADSHEET_CONTEXT_MODIFIER: {
|
||||
SpreadsheetContextModifier *modifier_context = (SpreadsheetContextModifier *)context;
|
||||
BLO_write_struct(writer, SpreadsheetContextModifier, modifier_context);
|
||||
BLO_write_string(writer, modifier_context->modifier_name);
|
||||
break;
|
||||
}
|
||||
case SPREADSHEET_CONTEXT_NODE: {
|
||||
SpreadsheetContextNode *node_context = (SpreadsheetContextNode *)context;
|
||||
BLO_write_struct(writer, SpreadsheetContextNode, node_context);
|
||||
BLO_write_string(writer, node_context->node_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SpaceType *space_type = BKE_spacetype_from_id(sl->spacetype);
|
||||
if (space_type && space_type->blend_write) {
|
||||
space_type->blend_write(writer, sl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1523,225 +1333,9 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
|
||||
direct_link_region(reader, region, sl->spacetype);
|
||||
}
|
||||
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = (View3D *)sl;
|
||||
|
||||
memset(&v3d->runtime, 0x0, sizeof(v3d->runtime));
|
||||
|
||||
if (v3d->gpd) {
|
||||
BLO_read_data_address(reader, &v3d->gpd);
|
||||
BKE_gpencil_blend_read_data(reader, v3d->gpd);
|
||||
}
|
||||
BLO_read_data_address(reader, &v3d->localvd);
|
||||
|
||||
/* render can be quite heavy, set to solid on load */
|
||||
if (v3d->shading.type == OB_RENDER) {
|
||||
v3d->shading.type = OB_SOLID;
|
||||
}
|
||||
v3d->shading.prev_type = OB_SOLID;
|
||||
|
||||
BKE_screen_view3d_shading_blend_read_data(reader, &v3d->shading);
|
||||
|
||||
BKE_screen_view3d_do_versions_250(v3d, &sl->regionbase);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_GRAPH) {
|
||||
SpaceGraph *sipo = (SpaceGraph *)sl;
|
||||
|
||||
BLO_read_data_address(reader, &sipo->ads);
|
||||
memset(&sipo->runtime, 0x0, sizeof(sipo->runtime));
|
||||
}
|
||||
else if (sl->spacetype == SPACE_NLA) {
|
||||
SpaceNla *snla = (SpaceNla *)sl;
|
||||
|
||||
BLO_read_data_address(reader, &snla->ads);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_OUTLINER) {
|
||||
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
|
||||
|
||||
/* use #BLO_read_get_new_data_address_no_us and do not free old memory avoiding double
|
||||
* frees and use of freed memory. this could happen because of a
|
||||
* bug fixed in revision 58959 where the treestore memory address
|
||||
* was not unique */
|
||||
TreeStore *ts = BLO_read_get_new_data_address_no_us(reader, space_outliner->treestore);
|
||||
space_outliner->treestore = NULL;
|
||||
if (ts) {
|
||||
TreeStoreElem *elems = BLO_read_get_new_data_address_no_us(reader, ts->data);
|
||||
|
||||
space_outliner->treestore = BLI_mempool_create(
|
||||
sizeof(TreeStoreElem), ts->usedelem, 512, BLI_MEMPOOL_ALLOW_ITER);
|
||||
if (ts->usedelem && elems) {
|
||||
for (int i = 0; i < ts->usedelem; i++) {
|
||||
TreeStoreElem *new_elem = BLI_mempool_alloc(space_outliner->treestore);
|
||||
*new_elem = elems[i];
|
||||
}
|
||||
}
|
||||
/* we only saved what was used */
|
||||
space_outliner->storeflag |= SO_TREESTORE_CLEANUP; /* at first draw */
|
||||
}
|
||||
space_outliner->tree.first = space_outliner->tree.last = NULL;
|
||||
space_outliner->runtime = NULL;
|
||||
}
|
||||
else if (sl->spacetype == SPACE_IMAGE) {
|
||||
SpaceImage *sima = (SpaceImage *)sl;
|
||||
|
||||
sima->iuser.scene = NULL;
|
||||
sima->scopes.waveform_1 = NULL;
|
||||
sima->scopes.waveform_2 = NULL;
|
||||
sima->scopes.waveform_3 = NULL;
|
||||
sima->scopes.vecscope = NULL;
|
||||
sima->scopes.ok = 0;
|
||||
|
||||
/* WARNING: gpencil data is no longer stored directly in sima after 2.5
|
||||
* so sacrifice a few old files for now to avoid crashes with new files!
|
||||
* committed: r28002 */
|
||||
#if 0
|
||||
sima->gpd = newdataadr(fd, sima->gpd);
|
||||
if (sima->gpd) {
|
||||
BKE_gpencil_blend_read_data(fd, sima->gpd);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (sl->spacetype == SPACE_NODE) {
|
||||
SpaceNode *snode = (SpaceNode *)sl;
|
||||
|
||||
if (snode->gpd) {
|
||||
BLO_read_data_address(reader, &snode->gpd);
|
||||
BKE_gpencil_blend_read_data(reader, snode->gpd);
|
||||
}
|
||||
|
||||
BLO_read_list(reader, &snode->treepath);
|
||||
snode->edittree = NULL;
|
||||
snode->runtime = NULL;
|
||||
}
|
||||
else if (sl->spacetype == SPACE_TEXT) {
|
||||
SpaceText *st = (SpaceText *)sl;
|
||||
memset(&st->runtime, 0x0, sizeof(st->runtime));
|
||||
}
|
||||
else if (sl->spacetype == SPACE_SEQ) {
|
||||
SpaceSeq *sseq = (SpaceSeq *)sl;
|
||||
|
||||
/* grease pencil data is not a direct data and can't be linked from direct_link*
|
||||
* functions, it should be linked from lib_link* functions instead
|
||||
*
|
||||
* otherwise it'll lead to lost grease data on open because it'll likely be
|
||||
* read from file after all other users of grease pencil and newdataadr would
|
||||
* simple return NULL here (sergey)
|
||||
*/
|
||||
#if 0
|
||||
if (sseq->gpd) {
|
||||
sseq->gpd = newdataadr(fd, sseq->gpd);
|
||||
BKE_gpencil_blend_read_data(fd, sseq->gpd);
|
||||
}
|
||||
#endif
|
||||
sseq->scopes.reference_ibuf = NULL;
|
||||
sseq->scopes.zebra_ibuf = NULL;
|
||||
sseq->scopes.waveform_ibuf = NULL;
|
||||
sseq->scopes.sep_waveform_ibuf = NULL;
|
||||
sseq->scopes.vector_ibuf = NULL;
|
||||
sseq->scopes.histogram_ibuf = NULL;
|
||||
memset(&sseq->runtime, 0x0, sizeof(sseq->runtime));
|
||||
}
|
||||
else if (sl->spacetype == SPACE_PROPERTIES) {
|
||||
SpaceProperties *sbuts = (SpaceProperties *)sl;
|
||||
|
||||
sbuts->path = NULL;
|
||||
sbuts->texuser = NULL;
|
||||
sbuts->mainbo = sbuts->mainb;
|
||||
sbuts->mainbuser = sbuts->mainb;
|
||||
sbuts->runtime = NULL;
|
||||
}
|
||||
else if (sl->spacetype == SPACE_CONSOLE) {
|
||||
SpaceConsole *sconsole = (SpaceConsole *)sl;
|
||||
|
||||
BLO_read_list(reader, &sconsole->scrollback);
|
||||
BLO_read_list(reader, &sconsole->history);
|
||||
|
||||
/* Comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
|
||||
* from left to right. the right-most expression sets the result of the comma
|
||||
* expression as a whole. */
|
||||
LISTBASE_FOREACH_MUTABLE (ConsoleLine *, cl, &sconsole->history) {
|
||||
BLO_read_data_address(reader, &cl->line);
|
||||
if (cl->line) {
|
||||
/* The allocated length is not written, so reset here. */
|
||||
cl->len_alloc = cl->len + 1;
|
||||
}
|
||||
else {
|
||||
BLI_remlink(&sconsole->history, cl);
|
||||
MEM_freeN(cl);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sl->spacetype == SPACE_FILE) {
|
||||
SpaceFile *sfile = (SpaceFile *)sl;
|
||||
|
||||
/* this sort of info is probably irrelevant for reloading...
|
||||
* plus, it isn't saved to files yet!
|
||||
*/
|
||||
sfile->folders_prev = sfile->folders_next = NULL;
|
||||
BLI_listbase_clear(&sfile->folder_histories);
|
||||
sfile->files = NULL;
|
||||
sfile->layout = NULL;
|
||||
sfile->op = NULL;
|
||||
sfile->previews_timer = NULL;
|
||||
sfile->tags = 0;
|
||||
sfile->runtime = NULL;
|
||||
BLO_read_data_address(reader, &sfile->params);
|
||||
BLO_read_data_address(reader, &sfile->asset_params);
|
||||
if (sfile->params) {
|
||||
sfile->params->rename_id = NULL;
|
||||
}
|
||||
if (sfile->asset_params) {
|
||||
sfile->asset_params->base_params.rename_id = NULL;
|
||||
}
|
||||
}
|
||||
else if (sl->spacetype == SPACE_ACTION) {
|
||||
SpaceAction *saction = (SpaceAction *)sl;
|
||||
|
||||
memset(&saction->runtime, 0x0, sizeof(saction->runtime));
|
||||
}
|
||||
else if (sl->spacetype == SPACE_CLIP) {
|
||||
SpaceClip *sclip = (SpaceClip *)sl;
|
||||
|
||||
sclip->scopes.track_search = NULL;
|
||||
sclip->scopes.track_preview = NULL;
|
||||
sclip->scopes.ok = 0;
|
||||
}
|
||||
else if (sl->spacetype == SPACE_SPREADSHEET) {
|
||||
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
|
||||
|
||||
sspreadsheet->runtime = NULL;
|
||||
BLO_read_list(reader, &sspreadsheet->row_filters);
|
||||
LISTBASE_FOREACH (SpreadsheetRowFilter *, row_filter, &sspreadsheet->row_filters) {
|
||||
BLO_read_data_address(reader, &row_filter->value_string);
|
||||
}
|
||||
BLO_read_list(reader, &sspreadsheet->columns);
|
||||
LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
|
||||
BLO_read_data_address(reader, &column->id);
|
||||
BLO_read_data_address(reader, &column->id->name);
|
||||
/* While the display name is technically runtime data, it is loaded here, otherwise the row
|
||||
* filters might not now their type if their region draws before the main region.
|
||||
* This would ideally be cleared here. */
|
||||
BLO_read_data_address(reader, &column->display_name);
|
||||
}
|
||||
|
||||
BLO_read_list(reader, &sspreadsheet->context_path);
|
||||
LISTBASE_FOREACH (SpreadsheetContext *, context, &sspreadsheet->context_path) {
|
||||
switch (context->type) {
|
||||
case SPREADSHEET_CONTEXT_NODE: {
|
||||
SpreadsheetContextNode *node_context = (SpreadsheetContextNode *)context;
|
||||
BLO_read_data_address(reader, &node_context->node_name);
|
||||
break;
|
||||
}
|
||||
case SPREADSHEET_CONTEXT_MODIFIER: {
|
||||
SpreadsheetContextModifier *modifier_context = (SpreadsheetContextModifier *)context;
|
||||
BLO_read_data_address(reader, &modifier_context->modifier_name);
|
||||
break;
|
||||
}
|
||||
case SPREADSHEET_CONTEXT_OBJECT: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SpaceType *space_type = BKE_spacetype_from_id(sl->spacetype);
|
||||
if (space_type && space_type->blend_read_data) {
|
||||
space_type->blend_read_data(reader, sl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1785,185 +1379,10 @@ void BKE_screen_area_blend_read_lib(BlendLibReader *reader, ID *parent_id, ScrAr
|
||||
memset(&area->runtime, 0x0, sizeof(area->runtime));
|
||||
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
switch (sl->spacetype) {
|
||||
case SPACE_VIEW3D: {
|
||||
View3D *v3d = (View3D *)sl;
|
||||
SpaceType *space_type = BKE_spacetype_from_id(sl->spacetype);
|
||||
|
||||
BLO_read_id_address(reader, parent_id->lib, &v3d->camera);
|
||||
BLO_read_id_address(reader, parent_id->lib, &v3d->ob_center);
|
||||
|
||||
if (v3d->localvd) {
|
||||
BLO_read_id_address(reader, parent_id->lib, &v3d->localvd->camera);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPACE_GRAPH: {
|
||||
SpaceGraph *sipo = (SpaceGraph *)sl;
|
||||
bDopeSheet *ads = sipo->ads;
|
||||
|
||||
if (ads) {
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->source);
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPACE_PROPERTIES: {
|
||||
SpaceProperties *sbuts = (SpaceProperties *)sl;
|
||||
BLO_read_id_address(reader, parent_id->lib, &sbuts->pinid);
|
||||
if (sbuts->pinid == NULL) {
|
||||
sbuts->flag &= ~SB_PIN_CONTEXT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPACE_FILE: {
|
||||
SpaceFile *sfile = (SpaceFile *)sl;
|
||||
sfile->tags |= FILE_TAG_REBUILD_MAIN_FILES;
|
||||
break;
|
||||
}
|
||||
case SPACE_ACTION: {
|
||||
SpaceAction *saction = (SpaceAction *)sl;
|
||||
bDopeSheet *ads = &saction->ads;
|
||||
|
||||
if (ads) {
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->source);
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
|
||||
}
|
||||
|
||||
BLO_read_id_address(reader, parent_id->lib, &saction->action);
|
||||
break;
|
||||
}
|
||||
case SPACE_IMAGE: {
|
||||
SpaceImage *sima = (SpaceImage *)sl;
|
||||
|
||||
BLO_read_id_address(reader, parent_id->lib, &sima->image);
|
||||
BLO_read_id_address(reader, parent_id->lib, &sima->mask_info.mask);
|
||||
|
||||
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
|
||||
* so fingers crossed this works fine!
|
||||
*/
|
||||
BLO_read_id_address(reader, parent_id->lib, &sima->gpd);
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ: {
|
||||
SpaceSeq *sseq = (SpaceSeq *)sl;
|
||||
|
||||
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
|
||||
* so fingers crossed this works fine!
|
||||
*/
|
||||
BLO_read_id_address(reader, parent_id->lib, &sseq->gpd);
|
||||
break;
|
||||
}
|
||||
case SPACE_NLA: {
|
||||
SpaceNla *snla = (SpaceNla *)sl;
|
||||
bDopeSheet *ads = snla->ads;
|
||||
|
||||
if (ads) {
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->source);
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPACE_TEXT: {
|
||||
SpaceText *st = (SpaceText *)sl;
|
||||
|
||||
BLO_read_id_address(reader, parent_id->lib, &st->text);
|
||||
break;
|
||||
}
|
||||
case SPACE_SCRIPT: {
|
||||
SpaceScript *scpt = (SpaceScript *)sl;
|
||||
/*scpt->script = NULL; - 2.45 set to null, better re-run the script */
|
||||
if (scpt->script) {
|
||||
BLO_read_id_address(reader, parent_id->lib, &scpt->script);
|
||||
if (scpt->script) {
|
||||
SCRIPT_SET_NULL(scpt->script);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPACE_OUTLINER: {
|
||||
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
|
||||
|
||||
if (space_outliner->treestore) {
|
||||
TreeStoreElem *tselem;
|
||||
BLI_mempool_iter iter;
|
||||
|
||||
BLI_mempool_iternew(space_outliner->treestore, &iter);
|
||||
while ((tselem = BLI_mempool_iterstep(&iter))) {
|
||||
BLO_read_id_address(reader, NULL, &tselem->id);
|
||||
}
|
||||
/* rebuild hash table, because it depends on ids too */
|
||||
space_outliner->storeflag |= SO_TREESTORE_REBUILD;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPACE_NODE: {
|
||||
SpaceNode *snode = (SpaceNode *)sl;
|
||||
|
||||
/* node tree can be stored locally in id too, link this first */
|
||||
BLO_read_id_address(reader, parent_id->lib, &snode->id);
|
||||
BLO_read_id_address(reader, parent_id->lib, &snode->from);
|
||||
|
||||
bNodeTree *ntree = snode->id ? ntreeFromID(snode->id) : NULL;
|
||||
if (ntree) {
|
||||
snode->nodetree = ntree;
|
||||
}
|
||||
else {
|
||||
BLO_read_id_address(reader, parent_id->lib, &snode->nodetree);
|
||||
}
|
||||
|
||||
bNodeTreePath *path;
|
||||
for (path = snode->treepath.first; path; path = path->next) {
|
||||
if (path == snode->treepath.first) {
|
||||
/* first nodetree in path is same as snode->nodetree */
|
||||
path->nodetree = snode->nodetree;
|
||||
}
|
||||
else {
|
||||
BLO_read_id_address(reader, parent_id->lib, &path->nodetree);
|
||||
}
|
||||
|
||||
if (!path->nodetree) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* remaining path entries are invalid, remove */
|
||||
bNodeTreePath *path_next;
|
||||
for (; path; path = path_next) {
|
||||
path_next = path->next;
|
||||
|
||||
BLI_remlink(&snode->treepath, path);
|
||||
MEM_freeN(path);
|
||||
}
|
||||
|
||||
/* edittree is just the last in the path,
|
||||
* set this directly since the path may have been shortened above */
|
||||
if (snode->treepath.last) {
|
||||
path = snode->treepath.last;
|
||||
snode->edittree = path->nodetree;
|
||||
}
|
||||
else {
|
||||
snode->edittree = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPACE_CLIP: {
|
||||
SpaceClip *sclip = (SpaceClip *)sl;
|
||||
BLO_read_id_address(reader, parent_id->lib, &sclip->clip);
|
||||
BLO_read_id_address(reader, parent_id->lib, &sclip->mask_info.mask);
|
||||
break;
|
||||
}
|
||||
case SPACE_SPREADSHEET: {
|
||||
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
|
||||
LISTBASE_FOREACH (SpreadsheetContext *, context, &sspreadsheet->context_path) {
|
||||
if (context->type == SPREADSHEET_CONTEXT_OBJECT) {
|
||||
BLO_read_id_address(
|
||||
reader, parent_id->lib, &((SpreadsheetContextObject *)context)->object);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
if (space_type && space_type->blend_read_lib) {
|
||||
space_type->blend_read_lib(reader, parent_id, sl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ set(INC
|
||||
../include
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../depsgraph
|
||||
../../gpu
|
||||
@@ -11,6 +12,9 @@ set(INC
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -35,5 +39,5 @@ set(LIB
|
||||
|
||||
blender_add_lib(bf_editor_space_action "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_action bf_rna)
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_time_scrub_ui.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "action_intern.h" /* own include */
|
||||
|
||||
/* ******************** default callbacks for action space ***************** */
|
||||
@@ -834,6 +836,30 @@ static void action_space_subtype_item_extend(bContext *UNUSED(C),
|
||||
RNA_enum_items_add(item, totitem, rna_enum_space_action_mode_items);
|
||||
}
|
||||
|
||||
static void action_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
|
||||
{
|
||||
SpaceAction *saction = (SpaceAction *)sl;
|
||||
memset(&saction->runtime, 0x0, sizeof(saction->runtime));
|
||||
}
|
||||
|
||||
static void action_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
SpaceAction *saction = (SpaceAction *)sl;
|
||||
bDopeSheet *ads = &saction->ads;
|
||||
|
||||
if (ads) {
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->source);
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
|
||||
}
|
||||
|
||||
BLO_read_id_address(reader, parent_id->lib, &saction->action);
|
||||
}
|
||||
|
||||
static void action_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
BLO_write_struct(writer, SpaceAction, sl);
|
||||
}
|
||||
|
||||
void ED_spacetype_action(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype action");
|
||||
@@ -854,6 +880,9 @@ void ED_spacetype_action(void)
|
||||
st->space_subtype_item_extend = action_space_subtype_item_extend;
|
||||
st->space_subtype_get = action_space_subtype_get;
|
||||
st->space_subtype_set = action_space_subtype_set;
|
||||
st->blend_read_data = action_blend_read_data;
|
||||
st->blend_read_lib = action_blend_read_lib;
|
||||
st->blend_write = action_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
|
||||
|
||||
@@ -4,6 +4,7 @@ set(INC
|
||||
../include
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../gpu
|
||||
../../makesdna
|
||||
@@ -11,6 +12,9 @@ set(INC
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
../../bmesh
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -39,5 +43,5 @@ endif()
|
||||
|
||||
blender_add_lib(bf_editor_space_buttons "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_buttons bf_rna)
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "buttons_intern.h" /* own include */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -905,6 +907,31 @@ static void buttons_id_remap(ScrArea *UNUSED(area),
|
||||
}
|
||||
}
|
||||
|
||||
static void buttons_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
|
||||
{
|
||||
SpaceProperties *sbuts = (SpaceProperties *)sl;
|
||||
|
||||
sbuts->path = NULL;
|
||||
sbuts->texuser = NULL;
|
||||
sbuts->mainbo = sbuts->mainb;
|
||||
sbuts->mainbuser = sbuts->mainb;
|
||||
sbuts->runtime = NULL;
|
||||
}
|
||||
|
||||
static void buttons_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
SpaceProperties *sbuts = (SpaceProperties *)sl;
|
||||
BLO_read_id_address(reader, parent_id->lib, &sbuts->pinid);
|
||||
if (sbuts->pinid == NULL) {
|
||||
sbuts->flag &= ~SB_PIN_CONTEXT;
|
||||
}
|
||||
}
|
||||
|
||||
static void buttons_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
BLO_write_struct(writer, SpaceProperties, sl);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -928,6 +955,9 @@ void ED_spacetype_buttons(void)
|
||||
st->listener = buttons_area_listener;
|
||||
st->context = buttons_context;
|
||||
st->id_remap = buttons_id_remap;
|
||||
st->blend_read_data = buttons_blend_read_data;
|
||||
st->blend_read_lib = buttons_blend_read_lib;
|
||||
st->blend_write = buttons_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
|
||||
|
||||
@@ -6,6 +6,7 @@ set(INC
|
||||
../../blenfont
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../depsgraph
|
||||
../../gpu
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "clip_intern.h" /* own include */
|
||||
@@ -1245,6 +1247,27 @@ static void clip_id_remap(ScrArea *UNUSED(area),
|
||||
BKE_id_remapper_apply(mappings, (ID **)&sclip->mask_info.mask, ID_REMAP_APPLY_ENSURE_REAL);
|
||||
}
|
||||
|
||||
static void clip_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
|
||||
{
|
||||
SpaceClip *sclip = (SpaceClip *)sl;
|
||||
|
||||
sclip->scopes.track_search = NULL;
|
||||
sclip->scopes.track_preview = NULL;
|
||||
sclip->scopes.ok = 0;
|
||||
}
|
||||
|
||||
static void clip_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
SpaceClip *sclip = (SpaceClip *)sl;
|
||||
BLO_read_id_address(reader, parent_id->lib, &sclip->clip);
|
||||
BLO_read_id_address(reader, parent_id->lib, &sclip->mask_info.mask);
|
||||
}
|
||||
|
||||
static void clip_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
BLO_write_struct(writer, SpaceClip, sl);
|
||||
}
|
||||
|
||||
void ED_spacetype_clip(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype clip");
|
||||
@@ -1265,6 +1288,9 @@ void ED_spacetype_clip(void)
|
||||
st->dropboxes = clip_dropboxes;
|
||||
st->refresh = clip_refresh;
|
||||
st->id_remap = clip_id_remap;
|
||||
st->blend_read_data = clip_blend_read_data;
|
||||
st->blend_read_lib = clip_blend_read_lib;
|
||||
st->blend_write = clip_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype clip region");
|
||||
|
||||
@@ -5,11 +5,15 @@ set(INC
|
||||
../../blenfont
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../gpu
|
||||
../../makesdna
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
)
|
||||
|
||||
set(SRC
|
||||
@@ -31,3 +35,6 @@ endif()
|
||||
|
||||
|
||||
blender_add_lib(bf_editor_space_console "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_console bf_dna)
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "console_intern.h" /* own include */
|
||||
|
||||
/* ******************** default callbacks for console space ***************** */
|
||||
@@ -284,6 +286,41 @@ static void console_main_region_listener(const wmRegionListenerParams *params)
|
||||
}
|
||||
}
|
||||
|
||||
static void console_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
|
||||
{
|
||||
SpaceConsole *sconsole = (SpaceConsole *)sl;
|
||||
|
||||
BLO_read_list(reader, &sconsole->scrollback);
|
||||
BLO_read_list(reader, &sconsole->history);
|
||||
|
||||
/* Comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
|
||||
* from left to right. the right-most expression sets the result of the comma
|
||||
* expression as a whole. */
|
||||
LISTBASE_FOREACH_MUTABLE (ConsoleLine *, cl, &sconsole->history) {
|
||||
BLO_read_data_address(reader, &cl->line);
|
||||
if (cl->line) {
|
||||
/* The allocated length is not written, so reset here. */
|
||||
cl->len_alloc = cl->len + 1;
|
||||
}
|
||||
else {
|
||||
BLI_remlink(&sconsole->history, cl);
|
||||
MEM_freeN(cl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void console_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
SpaceConsole *con = (SpaceConsole *)sl;
|
||||
|
||||
LISTBASE_FOREACH (ConsoleLine *, cl, &con->history) {
|
||||
/* 'len_alloc' is invalid on write, set from 'len' on read */
|
||||
BLO_write_struct(writer, ConsoleLine, cl);
|
||||
BLO_write_raw(writer, (size_t)cl->len + 1, cl->line);
|
||||
}
|
||||
BLO_write_struct(writer, SpaceConsole, sl);
|
||||
}
|
||||
|
||||
void ED_spacetype_console(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype console");
|
||||
@@ -299,6 +336,8 @@ void ED_spacetype_console(void)
|
||||
st->operatortypes = console_operatortypes;
|
||||
st->keymap = console_keymap;
|
||||
st->dropboxes = console_dropboxes;
|
||||
st->blend_read_data = console_blend_read_data;
|
||||
st->blend_write = console_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype console region");
|
||||
|
||||
@@ -16,6 +16,9 @@ set(INC
|
||||
../../windowmanager
|
||||
../../../../intern/atomic
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -89,5 +92,5 @@ endif()
|
||||
|
||||
blender_add_lib(bf_editor_space_file "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_file bf_rna)
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "GPU_framebuffer.h"
|
||||
#include "file_indexer.h"
|
||||
#include "file_intern.h" /* own include */
|
||||
@@ -986,6 +988,52 @@ static void file_id_remap(ScrArea *area, SpaceLink *sl, const struct IDRemapper
|
||||
file_reset_filelist_showing_main_data(area, sfile);
|
||||
}
|
||||
|
||||
static void file_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
|
||||
{
|
||||
SpaceFile *sfile = (SpaceFile *)sl;
|
||||
|
||||
/* this sort of info is probably irrelevant for reloading...
|
||||
* plus, it isn't saved to files yet!
|
||||
*/
|
||||
sfile->folders_prev = sfile->folders_next = NULL;
|
||||
BLI_listbase_clear(&sfile->folder_histories);
|
||||
sfile->files = NULL;
|
||||
sfile->layout = NULL;
|
||||
sfile->op = NULL;
|
||||
sfile->previews_timer = NULL;
|
||||
sfile->tags = 0;
|
||||
sfile->runtime = NULL;
|
||||
BLO_read_data_address(reader, &sfile->params);
|
||||
BLO_read_data_address(reader, &sfile->asset_params);
|
||||
if (sfile->params) {
|
||||
sfile->params->rename_id = NULL;
|
||||
}
|
||||
if (sfile->asset_params) {
|
||||
sfile->asset_params->base_params.rename_id = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void file_blend_read_lib(BlendLibReader *UNUSED(reader),
|
||||
ID *UNUSED(parent_id),
|
||||
SpaceLink *sl)
|
||||
{
|
||||
SpaceFile *sfile = (SpaceFile *)sl;
|
||||
sfile->tags |= FILE_TAG_REBUILD_MAIN_FILES;
|
||||
}
|
||||
|
||||
static void file_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
SpaceFile *sfile = (SpaceFile *)sl;
|
||||
|
||||
BLO_write_struct(writer, SpaceFile, sl);
|
||||
if (sfile->params) {
|
||||
BLO_write_struct(writer, FileSelectParams, sfile->params);
|
||||
}
|
||||
if (sfile->asset_params) {
|
||||
BLO_write_struct(writer, FileAssetSelectParams, sfile->asset_params);
|
||||
}
|
||||
}
|
||||
|
||||
void ED_spacetype_file(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype file");
|
||||
@@ -1009,6 +1057,9 @@ void ED_spacetype_file(void)
|
||||
st->space_subtype_set = file_space_subtype_set;
|
||||
st->context = file_context;
|
||||
st->id_remap = file_id_remap;
|
||||
st->blend_read_data = file_blend_read_data;
|
||||
st->blend_read_lib = file_blend_read_lib;
|
||||
st->blend_write = file_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
|
||||
|
||||
@@ -4,6 +4,7 @@ set(INC
|
||||
../include
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../depsgraph
|
||||
../../gpu
|
||||
@@ -11,6 +12,9 @@ set(INC
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -50,5 +54,5 @@ endif()
|
||||
|
||||
blender_add_lib(bf_editor_space_graph "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_graph bf_rna)
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "graph_intern.h" /* own include */
|
||||
|
||||
/* ******************** default callbacks for ipo space ***************** */
|
||||
@@ -804,6 +806,42 @@ static void graph_space_subtype_item_extend(bContext *UNUSED(C),
|
||||
RNA_enum_items_add(item, totitem, rna_enum_space_graph_mode_items);
|
||||
}
|
||||
|
||||
static void graph_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
|
||||
{
|
||||
SpaceGraph *sipo = (SpaceGraph *)sl;
|
||||
|
||||
BLO_read_data_address(reader, &sipo->ads);
|
||||
memset(&sipo->runtime, 0x0, sizeof(sipo->runtime));
|
||||
}
|
||||
|
||||
static void graph_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
SpaceGraph *sipo = (SpaceGraph *)sl;
|
||||
bDopeSheet *ads = sipo->ads;
|
||||
|
||||
if (ads) {
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->source);
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
|
||||
}
|
||||
}
|
||||
|
||||
static void graph_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
SpaceGraph *sipo = (SpaceGraph *)sl;
|
||||
ListBase tmpGhosts = sipo->runtime.ghost_curves;
|
||||
|
||||
/* temporarily disable ghost curves when saving */
|
||||
BLI_listbase_clear(&sipo->runtime.ghost_curves);
|
||||
|
||||
BLO_write_struct(writer, SpaceGraph, sl);
|
||||
if (sipo->ads) {
|
||||
BLO_write_struct(writer, bDopeSheet, sipo->ads);
|
||||
}
|
||||
|
||||
/* reenable ghost curves */
|
||||
sipo->runtime.ghost_curves = tmpGhosts;
|
||||
}
|
||||
|
||||
void ED_spacetype_ipo(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype ipo");
|
||||
@@ -824,6 +862,9 @@ void ED_spacetype_ipo(void)
|
||||
st->space_subtype_item_extend = graph_space_subtype_item_extend;
|
||||
st->space_subtype_get = graph_space_subtype_get;
|
||||
st->space_subtype_set = graph_space_subtype_set;
|
||||
st->blend_read_data = graph_blend_read_data;
|
||||
st->blend_read_lib = graph_blend_read_lib;
|
||||
st->blend_write = graph_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
|
||||
|
||||
@@ -5,6 +5,7 @@ set(INC
|
||||
../../blenfont
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../bmesh
|
||||
../../depsgraph
|
||||
@@ -17,6 +18,9 @@ set(INC
|
||||
../../windowmanager
|
||||
../../../../intern/clog
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -65,5 +69,5 @@ endif()
|
||||
|
||||
blender_add_lib(bf_editor_space_image "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_image bf_rna)
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "DRW_engine.h"
|
||||
|
||||
#include "image_intern.h"
|
||||
@@ -1026,6 +1028,46 @@ static void image_space_subtype_item_extend(bContext *UNUSED(C),
|
||||
RNA_enum_items_add(item, totitem, rna_enum_space_image_mode_items);
|
||||
}
|
||||
|
||||
static void image_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
|
||||
{
|
||||
SpaceImage *sima = (SpaceImage *)sl;
|
||||
|
||||
sima->iuser.scene = NULL;
|
||||
sima->scopes.waveform_1 = NULL;
|
||||
sima->scopes.waveform_2 = NULL;
|
||||
sima->scopes.waveform_3 = NULL;
|
||||
sima->scopes.vecscope = NULL;
|
||||
sima->scopes.ok = 0;
|
||||
|
||||
/* WARNING: gpencil data is no longer stored directly in sima after 2.5
|
||||
* so sacrifice a few old files for now to avoid crashes with new files!
|
||||
* committed: r28002 */
|
||||
#if 0
|
||||
sima->gpd = newdataadr(fd, sima->gpd);
|
||||
if (sima->gpd) {
|
||||
BKE_gpencil_blend_read_data(fd, sima->gpd);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void image_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
SpaceImage *sima = (SpaceImage *)sl;
|
||||
|
||||
BLO_read_id_address(reader, parent_id->lib, &sima->image);
|
||||
BLO_read_id_address(reader, parent_id->lib, &sima->mask_info.mask);
|
||||
|
||||
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
|
||||
* so fingers crossed this works fine!
|
||||
*/
|
||||
BLO_read_id_address(reader, parent_id->lib, &sima->gpd);
|
||||
}
|
||||
|
||||
static void image_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
BLO_write_struct(writer, SpaceImage, sl);
|
||||
}
|
||||
|
||||
/**************************** spacetype *****************************/
|
||||
|
||||
void ED_spacetype_image(void)
|
||||
@@ -1051,6 +1093,9 @@ void ED_spacetype_image(void)
|
||||
st->space_subtype_item_extend = image_space_subtype_item_extend;
|
||||
st->space_subtype_get = image_space_subtype_get;
|
||||
st->space_subtype_set = image_space_subtype_set;
|
||||
st->blend_read_data = image_blend_read_data;
|
||||
st->blend_read_lib = image_blend_read_lib;
|
||||
st->blend_write = image_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
|
||||
|
||||
@@ -15,6 +15,9 @@ set(INC
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -37,5 +40,5 @@ set(LIB
|
||||
|
||||
blender_add_lib(bf_editor_space_info "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_info bf_rna)
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "info_intern.h" /* own include */
|
||||
|
||||
/* ******************** default callbacks for info space ***************** */
|
||||
@@ -248,6 +250,11 @@ static void info_header_region_message_subscribe(const wmRegionMessageSubscribeP
|
||||
WM_msg_subscribe_rna_anon_prop(mbus, ViewLayer, name, &msg_sub_value_region_tag_redraw);
|
||||
}
|
||||
|
||||
static void info_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
BLO_write_struct(writer, SpaceInfo, sl);
|
||||
}
|
||||
|
||||
void ED_spacetype_info(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype info");
|
||||
@@ -262,6 +269,7 @@ void ED_spacetype_info(void)
|
||||
st->duplicate = info_duplicate;
|
||||
st->operatortypes = info_operatortypes;
|
||||
st->keymap = info_keymap;
|
||||
st->blend_write = info_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype info region");
|
||||
|
||||
@@ -4,6 +4,7 @@ set(INC
|
||||
../include
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../depsgraph
|
||||
../../gpu
|
||||
@@ -11,6 +12,9 @@ set(INC
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -36,5 +40,5 @@ set(LIB
|
||||
|
||||
blender_add_lib(bf_editor_space_nla "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_nla bf_rna)
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "nla_intern.h" /* own include */
|
||||
|
||||
/* ******************** default callbacks for nla space ***************** */
|
||||
@@ -562,6 +564,33 @@ static void nla_id_remap(ScrArea *UNUSED(area),
|
||||
BKE_id_remapper_apply(mappings, (ID **)&snla->ads->source, ID_REMAP_APPLY_DEFAULT);
|
||||
}
|
||||
|
||||
static void nla_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
|
||||
{
|
||||
SpaceNla *snla = (SpaceNla *)sl;
|
||||
BLO_read_data_address(reader, &snla->ads);
|
||||
}
|
||||
|
||||
static void nla_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
SpaceNla *snla = (SpaceNla *)sl;
|
||||
bDopeSheet *ads = snla->ads;
|
||||
|
||||
if (ads) {
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->source);
|
||||
BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
|
||||
}
|
||||
}
|
||||
|
||||
static void nla_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
SpaceNla *snla = (SpaceNla *)sl;
|
||||
|
||||
BLO_write_struct(writer, SpaceNla, snla);
|
||||
if (snla->ads) {
|
||||
BLO_write_struct(writer, bDopeSheet, snla->ads);
|
||||
}
|
||||
}
|
||||
|
||||
void ED_spacetype_nla(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype nla");
|
||||
@@ -578,6 +607,9 @@ void ED_spacetype_nla(void)
|
||||
st->listener = nla_listener;
|
||||
st->keymap = nla_keymap;
|
||||
st->id_remap = nla_id_remap;
|
||||
st->blend_read_data = nla_blend_read_data;
|
||||
st->blend_read_lib = nla_blend_read_lib;
|
||||
st->blend_write = nla_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype nla region");
|
||||
|
||||
@@ -5,6 +5,7 @@ set(INC
|
||||
../../blenfont
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../compositor
|
||||
../../depsgraph
|
||||
@@ -18,6 +19,9 @@ set(INC
|
||||
../../render
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -80,5 +84,5 @@ endif()
|
||||
|
||||
blender_add_lib(bf_editor_space_node "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_node bf_rna)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_lib_remap.h"
|
||||
#include "BKE_node.h"
|
||||
@@ -27,6 +28,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
#include "RNA_enum_types.h"
|
||||
@@ -1011,6 +1014,81 @@ static void node_space_subtype_item_extend(bContext *C, EnumPropertyItem **item,
|
||||
}
|
||||
}
|
||||
|
||||
static void node_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
|
||||
{
|
||||
SpaceNode *snode = (SpaceNode *)sl;
|
||||
|
||||
if (snode->gpd) {
|
||||
BLO_read_data_address(reader, &snode->gpd);
|
||||
BKE_gpencil_blend_read_data(reader, snode->gpd);
|
||||
}
|
||||
|
||||
BLO_read_list(reader, &snode->treepath);
|
||||
snode->edittree = nullptr;
|
||||
snode->runtime = nullptr;
|
||||
}
|
||||
|
||||
static void node_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
SpaceNode *snode = (SpaceNode *)sl;
|
||||
|
||||
/* node tree can be stored locally in id too, link this first */
|
||||
BLO_read_id_address(reader, parent_id->lib, &snode->id);
|
||||
BLO_read_id_address(reader, parent_id->lib, &snode->from);
|
||||
|
||||
bNodeTree *ntree = snode->id ? ntreeFromID(snode->id) : nullptr;
|
||||
if (ntree) {
|
||||
snode->nodetree = ntree;
|
||||
}
|
||||
else {
|
||||
BLO_read_id_address(reader, parent_id->lib, &snode->nodetree);
|
||||
}
|
||||
|
||||
bNodeTreePath *path;
|
||||
for (path = static_cast<bNodeTreePath *>(snode->treepath.first); path; path = path->next) {
|
||||
if (path == snode->treepath.first) {
|
||||
/* first nodetree in path is same as snode->nodetree */
|
||||
path->nodetree = snode->nodetree;
|
||||
}
|
||||
else {
|
||||
BLO_read_id_address(reader, parent_id->lib, &path->nodetree);
|
||||
}
|
||||
|
||||
if (!path->nodetree) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* remaining path entries are invalid, remove */
|
||||
bNodeTreePath *path_next;
|
||||
for (; path; path = path_next) {
|
||||
path_next = path->next;
|
||||
|
||||
BLI_remlink(&snode->treepath, path);
|
||||
MEM_freeN(path);
|
||||
}
|
||||
|
||||
/* edittree is just the last in the path,
|
||||
* set this directly since the path may have been shortened above */
|
||||
if (snode->treepath.last) {
|
||||
path = static_cast<bNodeTreePath *>(snode->treepath.last);
|
||||
snode->edittree = path->nodetree;
|
||||
}
|
||||
else {
|
||||
snode->edittree = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void node_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
SpaceNode *snode = (SpaceNode *)sl;
|
||||
BLO_write_struct(writer, SpaceNode, snode);
|
||||
|
||||
LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
|
||||
BLO_write_struct(writer, bNodeTreePath, path);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blender::ed::space_node
|
||||
|
||||
void ED_spacetype_node()
|
||||
@@ -1038,6 +1116,9 @@ void ED_spacetype_node()
|
||||
st->space_subtype_item_extend = node_space_subtype_item_extend;
|
||||
st->space_subtype_get = node_space_subtype_get;
|
||||
st->space_subtype_set = node_space_subtype_set;
|
||||
st->blend_read_data = node_blend_read_data;
|
||||
st->blend_read_lib = node_blend_read_lib;
|
||||
st->blend_write = node_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_cnew<ARegionType>("spacetype node region");
|
||||
|
||||
@@ -4,6 +4,7 @@ set(INC
|
||||
../include
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../depsgraph
|
||||
../../gpu
|
||||
@@ -14,6 +15,9 @@ set(INC
|
||||
../../windowmanager
|
||||
../../../../intern/clog
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -90,5 +94,5 @@ set(LIB
|
||||
|
||||
blender_add_lib(bf_editor_space_outliner "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_outliner bf_rna)
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
* \ingroup spoutliner
|
||||
*/
|
||||
|
||||
/* Allow using deprecated functionality for .blend file I/O. */
|
||||
#define DNA_DEPRECATED_ALLOW
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
@@ -34,6 +37,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "outliner_intern.hh"
|
||||
#include "tree/tree_display.hh"
|
||||
|
||||
@@ -435,6 +440,115 @@ static void outliner_deactivate(struct ScrArea *area)
|
||||
ED_region_tag_redraw_no_rebuild(BKE_area_find_region_type(area, RGN_TYPE_WINDOW));
|
||||
}
|
||||
|
||||
static void outliner_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
|
||||
{
|
||||
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
|
||||
|
||||
/* use #BLO_read_get_new_data_address_no_us and do not free old memory avoiding double
|
||||
* frees and use of freed memory. this could happen because of a
|
||||
* bug fixed in revision 58959 where the treestore memory address
|
||||
* was not unique */
|
||||
TreeStore *ts = static_cast<TreeStore *>(
|
||||
BLO_read_get_new_data_address_no_us(reader, space_outliner->treestore));
|
||||
space_outliner->treestore = nullptr;
|
||||
if (ts) {
|
||||
TreeStoreElem *elems = static_cast<TreeStoreElem *>(
|
||||
BLO_read_get_new_data_address_no_us(reader, ts->data));
|
||||
|
||||
space_outliner->treestore = BLI_mempool_create(
|
||||
sizeof(TreeStoreElem), ts->usedelem, 512, BLI_MEMPOOL_ALLOW_ITER);
|
||||
if (ts->usedelem && elems) {
|
||||
for (int i = 0; i < ts->usedelem; i++) {
|
||||
TreeStoreElem *new_elem = static_cast<TreeStoreElem *>(
|
||||
BLI_mempool_alloc(space_outliner->treestore));
|
||||
*new_elem = elems[i];
|
||||
}
|
||||
}
|
||||
/* we only saved what was used */
|
||||
space_outliner->storeflag |= SO_TREESTORE_CLEANUP; /* at first draw */
|
||||
}
|
||||
space_outliner->tree.first = space_outliner->tree.last = nullptr;
|
||||
space_outliner->runtime = nullptr;
|
||||
}
|
||||
|
||||
static void outliner_blend_read_lib(BlendLibReader *reader, ID *UNUSED(parent_id), SpaceLink *sl)
|
||||
{
|
||||
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
|
||||
|
||||
if (space_outliner->treestore) {
|
||||
TreeStoreElem *tselem;
|
||||
BLI_mempool_iter iter;
|
||||
|
||||
BLI_mempool_iternew(space_outliner->treestore, &iter);
|
||||
while ((tselem = static_cast<TreeStoreElem *>(BLI_mempool_iterstep(&iter)))) {
|
||||
BLO_read_id_address(reader, nullptr, &tselem->id);
|
||||
}
|
||||
/* rebuild hash table, because it depends on ids too */
|
||||
space_outliner->storeflag |= SO_TREESTORE_REBUILD;
|
||||
}
|
||||
}
|
||||
|
||||
static void write_space_outliner(BlendWriter *writer, const SpaceOutliner *space_outliner)
|
||||
{
|
||||
BLI_mempool *ts = space_outliner->treestore;
|
||||
|
||||
if (ts) {
|
||||
const int elems = BLI_mempool_len(ts);
|
||||
/* linearize mempool to array */
|
||||
TreeStoreElem *data = elems ? static_cast<TreeStoreElem *>(
|
||||
BLI_mempool_as_arrayN(ts, "TreeStoreElem")) :
|
||||
nullptr;
|
||||
|
||||
if (data) {
|
||||
BLO_write_struct(writer, SpaceOutliner, space_outliner);
|
||||
|
||||
/* To store #TreeStore (instead of the mempool), two unique memory addresses are needed,
|
||||
* which can be used to identify the data on read:
|
||||
* 1) One for the #TreeStore data itself.
|
||||
* 2) One for the array of #TreeStoreElem's inside #TreeStore (#TreeStore.data).
|
||||
*
|
||||
* For 1) we just use the mempool's address (#SpaceOutliner::treestore).
|
||||
* For 2) we don't have such a direct choice. We can't just use the array's address from
|
||||
* above, since that may not be unique over all Outliners. So instead use an address relative
|
||||
* to 1).
|
||||
*/
|
||||
/* TODO the mempool could be moved to #SpaceOutliner_Runtime so that #SpaceOutliner could
|
||||
* hold the #TreeStore directly. */
|
||||
|
||||
/* Address relative to the tree-store, as noted above. */
|
||||
void *data_addr = (void *)POINTER_OFFSET(ts, sizeof(void *));
|
||||
/* There should be plenty of memory addresses within the mempool data that we can point into,
|
||||
* just double-check we don't potentially end up with a memory address that another DNA
|
||||
* struct might use. Assumes BLI_mempool uses the guarded allocator. */
|
||||
BLI_assert(MEM_allocN_len(ts) >= sizeof(void *) * 2);
|
||||
|
||||
TreeStore ts_flat = {0};
|
||||
ts_flat.usedelem = elems;
|
||||
ts_flat.totelem = elems;
|
||||
ts_flat.data = static_cast<TreeStoreElem *>(data_addr);
|
||||
|
||||
BLO_write_struct_at_address(writer, TreeStore, ts, &ts_flat);
|
||||
BLO_write_struct_array_at_address(writer, TreeStoreElem, elems, data_addr, data);
|
||||
|
||||
MEM_freeN(data);
|
||||
}
|
||||
else {
|
||||
SpaceOutliner space_outliner_flat = *space_outliner;
|
||||
space_outliner_flat.treestore = nullptr;
|
||||
BLO_write_struct_at_address(writer, SpaceOutliner, space_outliner, &space_outliner_flat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BLO_write_struct(writer, SpaceOutliner, space_outliner);
|
||||
}
|
||||
}
|
||||
|
||||
static void outliner_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
|
||||
write_space_outliner(writer, space_outliner);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::outliner
|
||||
|
||||
void ED_spacetype_outliner(void)
|
||||
@@ -457,6 +571,9 @@ void ED_spacetype_outliner(void)
|
||||
st->id_remap = outliner_id_remap;
|
||||
st->deactivate = outliner_deactivate;
|
||||
st->context = outliner_context;
|
||||
st->blend_read_data = outliner_blend_read_data;
|
||||
st->blend_read_lib = outliner_blend_read_lib;
|
||||
st->blend_write = outliner_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_cnew<ARegionType>("spacetype outliner region");
|
||||
|
||||
@@ -4,11 +4,15 @@ set(INC
|
||||
../include
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../gpu
|
||||
../../makesdna
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
)
|
||||
|
||||
|
||||
@@ -32,3 +36,6 @@ endif()
|
||||
|
||||
|
||||
blender_add_lib(bf_editor_space_script "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_script bf_dna)
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
#endif
|
||||
|
||||
@@ -146,6 +148,25 @@ static void script_main_region_listener(const wmRegionListenerParams *UNUSED(par
|
||||
#endif
|
||||
}
|
||||
|
||||
static void script_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
SpaceScript *scpt = (SpaceScript *)sl;
|
||||
/*scpt->script = NULL; - 2.45 set to null, better re-run the script */
|
||||
if (scpt->script) {
|
||||
BLO_read_id_address(reader, parent_id->lib, &scpt->script);
|
||||
if (scpt->script) {
|
||||
SCRIPT_SET_NULL(scpt->script);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void script_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
SpaceScript *scr = (SpaceScript *)sl;
|
||||
scr->but_refs = NULL;
|
||||
BLO_write_struct(writer, SpaceScript, sl);
|
||||
}
|
||||
|
||||
void ED_spacetype_script(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype script");
|
||||
@@ -160,6 +181,8 @@ void ED_spacetype_script(void)
|
||||
st->duplicate = script_duplicate;
|
||||
st->operatortypes = script_operatortypes;
|
||||
st->keymap = script_keymap;
|
||||
st->blend_read_lib = script_blend_read_lib;
|
||||
st->blend_write = script_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype script region");
|
||||
|
||||
@@ -5,6 +5,7 @@ set(INC
|
||||
../../blenfont
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../depsgraph
|
||||
../../draw
|
||||
@@ -16,6 +17,9 @@ set(INC
|
||||
../../windowmanager
|
||||
../../../../intern/atomic
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -62,5 +66,5 @@ endif()
|
||||
|
||||
blender_add_lib(bf_editor_space_sequencer "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_sequencer bf_rna)
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#include "UI_interface.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "IMB_imbuf.h"
|
||||
|
||||
/* Only for cursor drawing. */
|
||||
@@ -991,6 +993,47 @@ static void sequencer_channel_region_draw(const bContext *C, ARegion *region)
|
||||
draw_channels(C, region);
|
||||
}
|
||||
|
||||
static void sequencer_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
|
||||
{
|
||||
SpaceSeq *sseq = (SpaceSeq *)sl;
|
||||
|
||||
/* grease pencil data is not a direct data and can't be linked from direct_link*
|
||||
* functions, it should be linked from lib_link* functions instead
|
||||
*
|
||||
* otherwise it'll lead to lost grease data on open because it'll likely be
|
||||
* read from file after all other users of grease pencil and newdataadr would
|
||||
* simple return NULL here (sergey)
|
||||
*/
|
||||
#if 0
|
||||
if (sseq->gpd) {
|
||||
sseq->gpd = newdataadr(fd, sseq->gpd);
|
||||
BKE_gpencil_blend_read_data(fd, sseq->gpd);
|
||||
}
|
||||
#endif
|
||||
sseq->scopes.reference_ibuf = NULL;
|
||||
sseq->scopes.zebra_ibuf = NULL;
|
||||
sseq->scopes.waveform_ibuf = NULL;
|
||||
sseq->scopes.sep_waveform_ibuf = NULL;
|
||||
sseq->scopes.vector_ibuf = NULL;
|
||||
sseq->scopes.histogram_ibuf = NULL;
|
||||
memset(&sseq->runtime, 0x0, sizeof(sseq->runtime));
|
||||
}
|
||||
|
||||
static void sequencer_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
SpaceSeq *sseq = (SpaceSeq *)sl;
|
||||
|
||||
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
|
||||
* so fingers crossed this works fine!
|
||||
*/
|
||||
BLO_read_id_address(reader, parent_id->lib, &sseq->gpd);
|
||||
}
|
||||
|
||||
static void sequencer_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
BLO_write_struct(writer, SpaceSeq, sl);
|
||||
}
|
||||
|
||||
void ED_spacetype_sequencer(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype sequencer");
|
||||
@@ -1011,6 +1054,9 @@ void ED_spacetype_sequencer(void)
|
||||
st->refresh = sequencer_refresh;
|
||||
st->listener = sequencer_listener;
|
||||
st->id_remap = sequencer_id_remap;
|
||||
st->blend_read_data = sequencer_blend_read_data;
|
||||
st->blend_read_lib = sequencer_blend_read_lib;
|
||||
st->blend_write = sequencer_blend_write;
|
||||
|
||||
/* Create regions: */
|
||||
/* Main window. */
|
||||
|
||||
@@ -5,6 +5,7 @@ set(INC
|
||||
../../blenfont
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../bmesh
|
||||
../../depsgraph
|
||||
@@ -15,6 +16,9 @@ set(INC
|
||||
../../nodes
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -63,5 +67,5 @@ endif()
|
||||
|
||||
blender_add_lib(bf_editor_space_spreadsheet "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_spreadsheet bf_rna)
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
@@ -613,6 +615,97 @@ static void spreadsheet_right_region_listener(const wmRegionListenerParams *UNUS
|
||||
{
|
||||
}
|
||||
|
||||
static void spreadsheet_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
|
||||
{
|
||||
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
|
||||
|
||||
sspreadsheet->runtime = nullptr;
|
||||
BLO_read_list(reader, &sspreadsheet->row_filters);
|
||||
LISTBASE_FOREACH (SpreadsheetRowFilter *, row_filter, &sspreadsheet->row_filters) {
|
||||
BLO_read_data_address(reader, &row_filter->value_string);
|
||||
}
|
||||
BLO_read_list(reader, &sspreadsheet->columns);
|
||||
LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
|
||||
BLO_read_data_address(reader, &column->id);
|
||||
BLO_read_data_address(reader, &column->id->name);
|
||||
/* While the display name is technically runtime data, it is loaded here, otherwise the row
|
||||
* filters might not now their type if their region draws before the main region.
|
||||
* This would ideally be cleared here. */
|
||||
BLO_read_data_address(reader, &column->display_name);
|
||||
}
|
||||
|
||||
BLO_read_list(reader, &sspreadsheet->context_path);
|
||||
LISTBASE_FOREACH (SpreadsheetContext *, context, &sspreadsheet->context_path) {
|
||||
switch (context->type) {
|
||||
case SPREADSHEET_CONTEXT_NODE: {
|
||||
SpreadsheetContextNode *node_context = (SpreadsheetContextNode *)context;
|
||||
BLO_read_data_address(reader, &node_context->node_name);
|
||||
break;
|
||||
}
|
||||
case SPREADSHEET_CONTEXT_MODIFIER: {
|
||||
SpreadsheetContextModifier *modifier_context = (SpreadsheetContextModifier *)context;
|
||||
BLO_read_data_address(reader, &modifier_context->modifier_name);
|
||||
break;
|
||||
}
|
||||
case SPREADSHEET_CONTEXT_OBJECT: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void spreadsheet_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
|
||||
LISTBASE_FOREACH (SpreadsheetContext *, context, &sspreadsheet->context_path) {
|
||||
if (context->type == SPREADSHEET_CONTEXT_OBJECT) {
|
||||
BLO_read_id_address(reader, parent_id->lib, &((SpreadsheetContextObject *)context)->object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void spreadsheet_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
BLO_write_struct(writer, SpaceSpreadsheet, sl);
|
||||
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
|
||||
|
||||
LISTBASE_FOREACH (SpreadsheetRowFilter *, row_filter, &sspreadsheet->row_filters) {
|
||||
BLO_write_struct(writer, SpreadsheetRowFilter, row_filter);
|
||||
BLO_write_string(writer, row_filter->value_string);
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
|
||||
BLO_write_struct(writer, SpreadsheetColumn, column);
|
||||
BLO_write_struct(writer, SpreadsheetColumnID, column->id);
|
||||
BLO_write_string(writer, column->id->name);
|
||||
/* While the display name is technically runtime data, we write it here, otherwise the row
|
||||
* filters might not now their type if their region draws before the main region.
|
||||
* This would ideally be cleared here. */
|
||||
BLO_write_string(writer, column->display_name);
|
||||
}
|
||||
LISTBASE_FOREACH (SpreadsheetContext *, context, &sspreadsheet->context_path) {
|
||||
switch (context->type) {
|
||||
case SPREADSHEET_CONTEXT_OBJECT: {
|
||||
SpreadsheetContextObject *object_context = (SpreadsheetContextObject *)context;
|
||||
BLO_write_struct(writer, SpreadsheetContextObject, object_context);
|
||||
break;
|
||||
}
|
||||
case SPREADSHEET_CONTEXT_MODIFIER: {
|
||||
SpreadsheetContextModifier *modifier_context = (SpreadsheetContextModifier *)context;
|
||||
BLO_write_struct(writer, SpreadsheetContextModifier, modifier_context);
|
||||
BLO_write_string(writer, modifier_context->modifier_name);
|
||||
break;
|
||||
}
|
||||
case SPREADSHEET_CONTEXT_NODE: {
|
||||
SpreadsheetContextNode *node_context = (SpreadsheetContextNode *)context;
|
||||
BLO_write_struct(writer, SpreadsheetContextNode, node_context);
|
||||
BLO_write_string(writer, node_context->node_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ED_spacetype_spreadsheet()
|
||||
{
|
||||
SpaceType *st = MEM_cnew<SpaceType>("spacetype spreadsheet");
|
||||
@@ -628,6 +721,9 @@ void ED_spacetype_spreadsheet()
|
||||
st->operatortypes = spreadsheet_operatortypes;
|
||||
st->keymap = spreadsheet_keymap;
|
||||
st->id_remap = spreadsheet_id_remap;
|
||||
st->blend_read_data = spreadsheet_blend_read_data;
|
||||
st->blend_read_lib = spreadsheet_blend_read_lib;
|
||||
st->blend_write = spreadsheet_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_cnew<ARegionType>("spacetype spreadsheet region");
|
||||
|
||||
@@ -11,6 +11,9 @@ set(INC
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -28,5 +31,5 @@ set(LIB
|
||||
|
||||
blender_add_lib(bf_editor_space_statusbar "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_statusbar bf_rna)
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "UI_interface.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_message.h"
|
||||
#include "WM_types.h"
|
||||
@@ -130,6 +132,11 @@ static void statusbar_header_region_message_subscribe(const wmRegionMessageSubsc
|
||||
WM_msg_subscribe_rna_anon_prop(mbus, ViewLayer, name, &msg_sub_value_region_tag_redraw);
|
||||
}
|
||||
|
||||
static void statusbar_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
BLO_write_struct(writer, SpaceStatusBar, sl);
|
||||
}
|
||||
|
||||
void ED_spacetype_statusbar(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(*st), "spacetype statusbar");
|
||||
@@ -144,6 +151,7 @@ void ED_spacetype_statusbar(void)
|
||||
st->duplicate = statusbar_duplicate;
|
||||
st->operatortypes = statusbar_operatortypes;
|
||||
st->keymap = statusbar_keymap;
|
||||
st->blend_write = statusbar_blend_write;
|
||||
|
||||
/* regions: header window */
|
||||
art = MEM_callocN(sizeof(*art), "spacetype statusbar header region");
|
||||
|
||||
@@ -5,12 +5,16 @@ set(INC
|
||||
../../blenfont
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../gpu
|
||||
../../makesdna
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
)
|
||||
|
||||
|
||||
@@ -47,3 +51,6 @@ endif()
|
||||
|
||||
|
||||
blender_add_lib(bf_editor_space_text "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_text bf_dna)
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_path.h"
|
||||
|
||||
@@ -395,6 +397,23 @@ static void text_id_remap(ScrArea *UNUSED(area),
|
||||
BKE_id_remapper_apply(mappings, (ID **)&stext->text, ID_REMAP_APPLY_ENSURE_REAL);
|
||||
}
|
||||
|
||||
static void text_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
|
||||
{
|
||||
SpaceText *st = (SpaceText *)sl;
|
||||
memset(&st->runtime, 0x0, sizeof(st->runtime));
|
||||
}
|
||||
|
||||
static void text_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
SpaceText *st = (SpaceText *)sl;
|
||||
BLO_read_id_address(reader, parent_id->lib, &st->text);
|
||||
}
|
||||
|
||||
static void text_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
BLO_write_struct(writer, SpaceText, sl);
|
||||
}
|
||||
|
||||
/********************* registration ********************/
|
||||
|
||||
void ED_spacetype_text(void)
|
||||
@@ -415,6 +434,9 @@ void ED_spacetype_text(void)
|
||||
st->context = text_context;
|
||||
st->dropboxes = text_dropboxes;
|
||||
st->id_remap = text_id_remap;
|
||||
st->blend_read_data = text_blend_read_data;
|
||||
st->blend_read_lib = text_blend_read_lib;
|
||||
st->blend_write = text_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
||||
|
||||
@@ -11,6 +11,9 @@ set(INC
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
@@ -27,5 +30,5 @@ set(LIB
|
||||
blender_add_lib(bf_editor_space_topbar "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
|
||||
# RNA_prototypes.h
|
||||
# RNA_prototypes.h dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_topbar bf_rna)
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
@@ -282,6 +284,11 @@ static void undo_history_menu_register(void)
|
||||
WM_menutype_add(mt);
|
||||
}
|
||||
|
||||
static void topbar_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
BLO_write_struct(writer, SpaceTopBar, sl);
|
||||
}
|
||||
|
||||
void ED_spacetype_topbar(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype topbar");
|
||||
@@ -296,6 +303,7 @@ void ED_spacetype_topbar(void)
|
||||
st->duplicate = topbar_duplicate;
|
||||
st->operatortypes = topbar_operatortypes;
|
||||
st->keymap = topbar_keymap;
|
||||
st->blend_write = topbar_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype topbar main region");
|
||||
|
||||
@@ -4,10 +4,14 @@ set(INC
|
||||
../include
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../makesdna
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
|
||||
# dna_type_offsets.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||
)
|
||||
|
||||
set(INC_SYS
|
||||
@@ -25,3 +29,6 @@ set(LIB
|
||||
)
|
||||
|
||||
blender_add_lib(bf_editor_space_userpref "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# dna_type_offsets.h
|
||||
add_dependencies(bf_editor_space_userpref bf_dna)
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "UI_interface.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
/* ******************** default callbacks for userpref space ***************** */
|
||||
|
||||
static SpaceLink *userpref_create(const ScrArea *area, const Scene *UNUSED(scene))
|
||||
@@ -183,6 +185,11 @@ static void userpref_execute_region_listener(const wmRegionListenerParams *UNUSE
|
||||
{
|
||||
}
|
||||
|
||||
static void userpref_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
BLO_write_struct(writer, SpaceUserPref, sl);
|
||||
}
|
||||
|
||||
void ED_spacetype_userpref(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype userpref");
|
||||
@@ -197,6 +204,7 @@ void ED_spacetype_userpref(void)
|
||||
st->duplicate = userpref_duplicate;
|
||||
st->operatortypes = userpref_operatortypes;
|
||||
st->keymap = userpref_keymap;
|
||||
st->blend_write = userpref_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype userpref region");
|
||||
|
||||
@@ -5,6 +5,7 @@ set(INC
|
||||
../../blenfont
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../bmesh
|
||||
../../depsgraph
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
* \ingroup spview3d
|
||||
*/
|
||||
|
||||
/* Allow using deprecated functionality for .blend file I/O. */
|
||||
#define DNA_DEPRECATED_ALLOW
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -29,6 +32,7 @@
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_icons.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_lattice.h"
|
||||
@@ -67,6 +71,8 @@
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "BLO_read_write.h"
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
# include "BPY_extern.h"
|
||||
#endif
|
||||
@@ -1976,6 +1982,53 @@ static void view3d_id_remap(ScrArea *area, SpaceLink *slink, const struct IDRema
|
||||
}
|
||||
}
|
||||
|
||||
static void view3d_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
|
||||
{
|
||||
View3D *v3d = (View3D *)sl;
|
||||
|
||||
memset(&v3d->runtime, 0x0, sizeof(v3d->runtime));
|
||||
|
||||
if (v3d->gpd) {
|
||||
BLO_read_data_address(reader, &v3d->gpd);
|
||||
BKE_gpencil_blend_read_data(reader, v3d->gpd);
|
||||
}
|
||||
BLO_read_data_address(reader, &v3d->localvd);
|
||||
|
||||
/* render can be quite heavy, set to solid on load */
|
||||
if (v3d->shading.type == OB_RENDER) {
|
||||
v3d->shading.type = OB_SOLID;
|
||||
}
|
||||
v3d->shading.prev_type = OB_SOLID;
|
||||
|
||||
BKE_screen_view3d_shading_blend_read_data(reader, &v3d->shading);
|
||||
|
||||
BKE_screen_view3d_do_versions_250(v3d, &sl->regionbase);
|
||||
}
|
||||
|
||||
static void view3d_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
|
||||
{
|
||||
View3D *v3d = (View3D *)sl;
|
||||
|
||||
BLO_read_id_address(reader, parent_id->lib, &v3d->camera);
|
||||
BLO_read_id_address(reader, parent_id->lib, &v3d->ob_center);
|
||||
|
||||
if (v3d->localvd) {
|
||||
BLO_read_id_address(reader, parent_id->lib, &v3d->localvd->camera);
|
||||
}
|
||||
}
|
||||
|
||||
static void view3d_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||
{
|
||||
View3D *v3d = (View3D *)sl;
|
||||
BLO_write_struct(writer, View3D, v3d);
|
||||
|
||||
if (v3d->localvd) {
|
||||
BLO_write_struct(writer, View3D, v3d->localvd);
|
||||
}
|
||||
|
||||
BKE_screen_view3d_shading_blend_write(writer, &v3d->shading);
|
||||
}
|
||||
|
||||
void ED_spacetype_view3d(void)
|
||||
{
|
||||
SpaceType *st = MEM_cnew<SpaceType>("spacetype view3d");
|
||||
@@ -1997,6 +2050,9 @@ void ED_spacetype_view3d(void)
|
||||
st->gizmos = view3d_widgets;
|
||||
st->context = view3d_context;
|
||||
st->id_remap = view3d_id_remap;
|
||||
st->blend_read_data = view3d_blend_read_data;
|
||||
st->blend_read_lib = view3d_blend_read_lib;
|
||||
st->blend_write = view3d_blend_write;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_cnew<ARegionType>("spacetype view3d main region");
|
||||
|
||||
Reference in New Issue
Block a user