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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-04-04 16:07:37 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-01 17:02:27 +0300
commit89826e0a0d8ac55881569e021c487ac5541c6612 (patch)
treec80797e8c804d43fc84a8e91396a8a86cf3a79b7 /source/blender/modifiers
parenta72a831570822190f782e6bbecfd57b45dc2e872 (diff)
Alembic: integrate cache file into the dependency graph
* The cache file datablock is now evaluated as part of the dependency graph, creating/freeing the Alembic file handle matching the current frame. Modifiers and constraints depend on this evaluation. * Cache file handles and readers now only exist on COW datablocks, never the original ones. * Object data paths are flushed back to the original for the user interface. * The cache file keeps a list of all readers associated with its handle, and automatically frees them when the handle is freed. This kind of sharing of data across datablocks is weak but we have no better mechanism for it. Fix T62720: Alembic sequences not working and crashing Differential Revision: https://developer.blender.org/D4774
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index 7710082150b..760830ffb24 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -18,6 +18,11 @@
* \ingroup modifiers
*/
+#include <string.h>
+
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+
#include "DNA_cachefile_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -47,6 +52,9 @@ static void initData(ModifierData *md)
mcmd->cache_file = NULL;
mcmd->object_path[0] = '\0';
mcmd->read_flag = MOD_MESHSEQ_READ_ALL;
+
+ mcmd->reader = NULL;
+ mcmd->reader_object_path[0] = '\0';
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
@@ -59,6 +67,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
modifier_copyData_generic(md, target, flag);
tmcmd->reader = NULL;
+ tmcmd->reader_object_path[0] = '\0';
}
static void freeData(ModifierData *md)
@@ -66,10 +75,8 @@ static void freeData(ModifierData *md)
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
if (mcmd->reader) {
-#ifdef WITH_ALEMBIC
- CacheReader_free(mcmd->reader);
-#endif
- mcmd->reader = NULL;
+ mcmd->reader_object_path[0] = '\0';
+ BKE_cachefile_reader_free(mcmd->cache_file, &mcmd->reader);
}
}
@@ -93,17 +100,14 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
Mesh *org_mesh = mesh;
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
+ CacheFile *cache_file = mcmd->cache_file;
const float frame = DEG_get_ctime(ctx->depsgraph);
- const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
+ const float time = BKE_cachefile_time_offset(cache_file, frame, FPS);
const char *err_str = NULL;
- CacheFile *cache_file = (CacheFile *)DEG_get_original_id(&mcmd->cache_file->id);
-
- BKE_cachefile_ensure_handle(G.main, cache_file);
-
- if (!mcmd->reader) {
- mcmd->reader = CacheReader_open_alembic_object(
- cache_file->handle, NULL, ctx->object, mcmd->object_path);
+ if (!mcmd->reader || !STREQ(mcmd->reader_object_path, mcmd->object_path)) {
+ STRNCPY(mcmd->reader_object_path, mcmd->object_path);
+ BKE_cachefile_reader_open(cache_file, &mcmd->reader, ctx->object, mcmd->object_path);
if (!mcmd->reader) {
modifier_setError(md, "Could not create Alembic reader for file %s", cache_file->filepath);
return mesh;