Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenloader/intern/writefile.c')
-rw-r--r--source/blender/blenloader/intern/writefile.c146
1 files changed, 52 insertions, 94 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index e7bca4c7e5b..552f5420e8d 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -166,6 +166,7 @@
#include "BKE_constraint.h"
#include "BKE_global.h" // for G
#include "BKE_idcode.h"
+#include "BKE_layer.h"
#include "BKE_library.h" // for set_listbasepointers
#include "BKE_library_override.h"
#include "BKE_main.h"
@@ -347,10 +348,6 @@ typedef struct {
* Will be NULL for UNDO.
*/
WriteWrap *ww;
-
-#ifdef USE_BMESH_SAVE_AS_COMPAT
- bool use_mesh_compat; /* option to save with older mesh format */
-#endif
} WriteData;
static WriteData *writedata_new(WriteWrap *ww)
@@ -1106,6 +1103,13 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
}
writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
}
+ else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_CRYPTOMATTE)) {
+ NodeCryptomatte *nc = (NodeCryptomatte *)node->storage;
+ if (nc->matte_id) {
+ writedata(wd, DATA, strlen(nc->matte_id) + 1, nc->matte_id);
+ }
+ writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
+ }
else {
writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
}
@@ -1147,7 +1151,6 @@ static void current_screen_compat(
{
wmWindowManager *wm;
wmWindow *window = NULL;
- WorkSpace *workspace;
/* find a global current screen in the first open window, to have
* a reasonable default for reading in older versions */
@@ -1171,11 +1174,10 @@ static void current_screen_compat(
window = wm->windows.first;
}
}
- workspace = (window) ? BKE_workspace_active_get(window->workspace_hook) : NULL;
*r_screen = (window) ? BKE_workspace_active_screen_get(window->workspace_hook) : NULL;
*r_scene = (window) ? window->scene : NULL;
- *r_render_layer = (window) ? BKE_workspace_view_layer_get(workspace, *r_scene) : NULL;
+ *r_render_layer = (window && *r_scene) ? BKE_view_layer_find(*r_scene, window->view_layer_name) : NULL;
}
typedef struct RenderInfo {
@@ -1816,9 +1818,13 @@ static void write_object(WriteData *wd, Object *ob)
write_motionpath(wd, ob->mpath);
writestruct(wd, DATA, PartDeflect, 1, ob->pd);
- writestruct(wd, DATA, SoftBody, 1, ob->soft);
if (ob->soft) {
- write_pointcaches(wd, &ob->soft->ptcaches);
+ /* Set deprecated pointers to prevent crashes of older Blenders */
+ ob->soft->pointcache = ob->soft->shared->pointcache;
+ ob->soft->ptcaches = ob->soft->shared->ptcaches;
+ writestruct(wd, DATA, SoftBody, 1, ob->soft);
+ writestruct(wd, DATA, SoftBody_Shared, 1, ob->soft->shared);
+ write_pointcaches(wd, &(ob->soft->shared->ptcaches));
writestruct(wd, DATA, EffectorWeights, 1, ob->soft->effector_weights);
}
@@ -2080,12 +2086,6 @@ static void write_customdata(
static void write_mesh(WriteData *wd, Mesh *mesh)
{
-#ifdef USE_BMESH_SAVE_AS_COMPAT
- const bool save_for_old_blender = wd->use_mesh_compat; /* option to save with older mesh format */
-#else
- const bool save_for_old_blender = false;
-#endif
-
CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE];
CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE];
CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE];
@@ -2094,19 +2094,17 @@ static void write_mesh(WriteData *wd, Mesh *mesh)
if (mesh->id.us > 0 || wd->use_memfile) {
/* write LibData */
- if (!save_for_old_blender) {
+ {
/* write a copy of the mesh, don't modify in place because it is
* not thread safe for threaded renders that are reading this */
Mesh *old_mesh = mesh;
Mesh copy_mesh = *mesh;
mesh = &copy_mesh;
-#ifdef USE_BMESH_SAVE_WITHOUT_MFACE
/* cache only - don't write */
mesh->mface = NULL;
mesh->totface = 0;
memset(&mesh->fdata, 0, sizeof(mesh->fdata));
-#endif /* USE_BMESH_SAVE_WITHOUT_MFACE */
/**
* Those calls:
@@ -2117,11 +2115,7 @@ static void write_mesh(WriteData *wd, Mesh *mesh)
*/
CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
-#ifndef USE_BMESH_SAVE_WITHOUT_MFACE /* Do not copy org fdata in this case!!! */
- CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff));
-#else
flayers = flayers_buff;
-#endif
CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
@@ -2146,73 +2140,6 @@ static void write_mesh(WriteData *wd, Mesh *mesh)
/* restore pointer */
mesh = old_mesh;
}
- else {
-
-#ifdef USE_BMESH_SAVE_AS_COMPAT
- /* write a copy of the mesh, don't modify in place because it is
- * not thread safe for threaded renders that are reading this */
- Mesh *old_mesh = mesh;
- Mesh copy_mesh = *mesh;
- mesh = &copy_mesh;
-
- mesh->mpoly = NULL;
- mesh->mface = NULL;
- mesh->totface = 0;
- mesh->totpoly = 0;
- mesh->totloop = 0;
- CustomData_reset(&mesh->fdata);
- CustomData_reset(&mesh->pdata);
- CustomData_reset(&mesh->ldata);
- mesh->edit_btmesh = NULL;
-
- /* now fill in polys to mfaces */
- /* XXX This breaks writing design, by using temp allocated memory, which will likely generate
- * duplicates in stored 'old' addresses.
- * This is very bad, but do not see easy way to avoid this, aside from generating those data
- * outside of save process itself.
- * Maybe we can live with this, though?
- */
- mesh->totface = BKE_mesh_mpoly_to_mface(
- &mesh->fdata, &old_mesh->ldata, &old_mesh->pdata,
- mesh->totface, old_mesh->totloop, old_mesh->totpoly);
-
- BKE_mesh_update_customdata_pointers(mesh, false);
-
- CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
- CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
- CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff));
-#if 0
- CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
- CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
-#endif
-
- writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh);
- write_iddata(wd, &mesh->id);
-
- /* direct data */
- if (mesh->adt) {
- write_animdata(wd, mesh->adt);
- }
-
- writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat);
- /* writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect); */ /* pre-bmesh NULL's */
-
- write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, -1, 0);
- /* harmless for older blender versioins but _not_ writing these keeps file size down */
-#if 0
- write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, -1, 0);
-#endif
-
- CustomData_free(&mesh->fdata, mesh->totface);
- flayers = NULL;
-
- /* restore pointer */
- mesh = old_mesh;
-#endif /* USE_BMESH_SAVE_AS_COMPAT */
- }
}
if (vlayers && vlayers != vlayers_buff) {
@@ -2476,6 +2403,36 @@ static void write_view_layer(WriteData *wd, ViewLayer *view_layer)
write_layer_collections(wd, &view_layer->layer_collections);
}
+static void write_lightcache_texture(WriteData *wd, LightCacheTexture *tex)
+{
+ if (tex->data) {
+ size_t data_size = tex->components * tex->tex_size[0] * tex->tex_size[1] * tex->tex_size[2];
+ if (tex->data_type == LIGHTCACHETEX_FLOAT) {
+ data_size *= sizeof(float);
+ }
+ else if (tex->data_type == LIGHTCACHETEX_UINT) {
+ data_size *= sizeof(unsigned int);
+ }
+ writedata(wd, DATA, data_size, tex->data);
+ }
+}
+
+static void write_lightcache(WriteData *wd, LightCache *cache)
+{
+ write_lightcache_texture(wd, &cache->grid_tx);
+ write_lightcache_texture(wd, &cache->cube_tx);
+
+ if (cache->cube_mips) {
+ writestruct(wd, DATA, LightCacheTexture, cache->mips_len, cache->cube_mips);
+ for (int i = 0; i < cache->mips_len; ++i) {
+ write_lightcache_texture(wd, &cache->cube_mips[i]);
+ }
+ }
+
+ writestruct(wd, DATA, LightGridCache, cache->grid_len, cache->grid_data);
+ writestruct(wd, DATA, LightProbeCache, cache->cube_len, cache->cube_data);
+}
+
static void write_scene(WriteData *wd, Scene *sce)
{
/* write LibData */
@@ -2676,6 +2633,12 @@ static void write_scene(WriteData *wd, Scene *sce)
write_collection_nolib(wd, sce->master_collection);
}
+ /* Eevee Lightcache */
+ if (sce->eevee.light_cache && !wd->use_memfile) {
+ writestruct(wd, DATA, LightCache, 1, sce->eevee.light_cache);
+ write_lightcache(wd, sce->eevee.light_cache);
+ }
+
/* Freed on doversion. */
BLI_assert(sce->layer_properties == NULL);
}
@@ -3642,7 +3605,6 @@ static void write_workspace(WriteData *wd, WorkSpace *workspace)
writestruct(wd, ID_WS, WorkSpace, 1, workspace);
writelist(wd, DATA, WorkSpaceLayout, layouts);
writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations);
- writelist(wd, DATA, WorkSpaceSceneRelation, &workspace->scene_layer_relations);
writelist(wd, DATA, wmOwnerID, &workspace->owner_ids);
writelist(wd, DATA, bToolRef, &workspace->tools);
for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
@@ -3799,10 +3761,6 @@ static bool write_file_handle(
wd = mywrite_begin(ww, compare, current);
-#ifdef USE_BMESH_SAVE_AS_COMPAT
- wd->use_mesh_compat = (write_flags & G_FILE_MESH_COMPAT) != 0;
-#endif
-
#ifdef USE_NODE_COMPAT_CUSTOMNODES
/* don't write compatibility data on undo */
if (!current) {