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:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2016-10-29 13:23:09 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2016-10-29 13:23:09 +0300
commit753edafcb77d9aaf07fe869372319b841dd80681 (patch)
tree676445ce05cf2a8a53ced9deedf5bcba37fd9653 /source/blender/blenkernel
parent0c13792437b3e501c06605876a0396e187c0f7da (diff)
Alembic: store a pointer to the object reader in the cache modifiers and
constraints. This avoids traversing the archive everytime object data is needed and gives an overall consistent ~2x speedup here with files containing between 136 and 500 Alembic objects. Also this somewhat nicely de- duplicates code between data creation (upon import) and data streaming (modifiers and constraints). The only worying part is what happens when a CacheFile is deleted and/or has its path changed. For now, we traverse the whole scene and for each object using the CacheFile we free the pointer and NULL-ify it (see BKE_cachefile_clean), but at some point this should be re-considered and make use of the dependency graph.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_cachefile.h2
-rw-r--r--source/blender/blenkernel/intern/cachefile.c37
-rw-r--r--source/blender/blenkernel/intern/constraint.c14
3 files changed, 51 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h
index a55cb51766c..7e1c069df9a 100644
--- a/source/blender/blenkernel/BKE_cachefile.h
+++ b/source/blender/blenkernel/BKE_cachefile.h
@@ -63,6 +63,8 @@ bool BKE_cachefile_filepath_get(
float BKE_cachefile_time_offset(struct CacheFile *cache_file, const float time, const float fps);
+void BKE_cachefile_clean(struct Scene *scene, struct CacheFile *cache_file);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index e62e652b4a6..2a2699f3a14 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -29,6 +29,8 @@
#include "DNA_anim_types.h"
#include "DNA_cachefile_types.h"
+#include "DNA_constraint_types.h"
+#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_fileops.h"
@@ -43,6 +45,7 @@
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
+#include "BKE_modifier.h"
#include "BKE_scene.h"
#ifdef WITH_ALEMBIC
@@ -196,3 +199,37 @@ float BKE_cachefile_time_offset(CacheFile *cache_file, const float time, const f
const float frame = (cache_file->override_frame ? cache_file->frame : time);
return cache_file->is_sequence ? frame : frame / fps;
}
+
+/* TODO(kevin): replace this with some depsgraph mechanism, or something similar. */
+void BKE_cachefile_clean(Scene *scene, CacheFile *cache_file)
+{
+ for (Base *base = scene->base.first; base; base = base->next) {
+ Object *ob = base->object;
+
+ ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache);
+
+ if (md) {
+ MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
+
+ if (cache_file == mcmd->cache_file) {
+ CacheReader_free(mcmd->reader);
+ mcmd->reader = NULL;
+ mcmd->object_path[0] = '\0';
+ }
+ }
+
+ for (bConstraint *con = ob->constraints.first; con; con = con->next) {
+ if (con->type != CONSTRAINT_TYPE_TRANSFORM_CACHE) {
+ continue;
+ }
+
+ bTransformCacheConstraint *data = con->data;
+
+ if (cache_file == data->cache_file) {
+ CacheReader_free(data->reader);
+ data->reader = NULL;
+ data->object_path[0] = '\0';
+ }
+ }
+ }
+}
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index c4afa58b7d3..c7750707cc4 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -4364,8 +4364,14 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
BKE_cachefile_ensure_handle(G.main, cache_file);
- ABC_get_transform(cache_file->handle, cob->ob, data->object_path,
- cob->matrix, time, cache_file->scale);
+ if (!data->reader) {
+ data->reader = CacheReader_open_alembic_object(cache_file->handle,
+ data->reader,
+ cob->ob,
+ data->object_path);
+ }
+
+ ABC_get_transform(data->reader, cob->matrix, time, cache_file->scale);
#else
UNUSED_VARS(con, cob);
#endif
@@ -4393,6 +4399,10 @@ static void transformcache_free(bConstraint *con)
if (data->cache_file) {
id_us_min(&data->cache_file->id);
}
+
+ if (data->reader) {
+ CacheReader_free(data->reader);
+ }
}
static void transformcache_new_data(void *cdata)