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/makesrna/intern/rna_cachefile.c
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/makesrna/intern/rna_cachefile.c')
-rw-r--r--source/blender/makesrna/intern/rna_cachefile.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_cachefile.c b/source/blender/makesrna/intern/rna_cachefile.c
index 7249ebd5feb..09fdeb15b10 100644
--- a/source/blender/makesrna/intern/rna_cachefile.c
+++ b/source/blender/makesrna/intern/rna_cachefile.c
@@ -37,6 +37,8 @@
#include "BKE_cachefile.h"
#include "BKE_depsgraph.h"
+#include "BLI_string.h"
+
#include "DEG_depsgraph.h"
#include "WM_api.h"
@@ -60,6 +62,12 @@ static void rna_CacheFile_update_handle(Main *bmain, Scene *scene, PointerRNA *p
{
CacheFile *cache_file = ptr->data;
+ if ((cache_file->flag & CACHEFILE_DIRTY) != 0) {
+ BKE_cachefile_clean(scene, cache_file);
+ BLI_freelistN(&cache_file->object_paths);
+ cache_file->flag &= ~CACHEFILE_DIRTY;
+ }
+
BKE_cachefile_reload(bmain, cache_file);
rna_CacheFile_update(bmain, scene, ptr);
@@ -71,6 +79,20 @@ static void rna_CacheFile_object_paths_begin(CollectionPropertyIterator *iter, P
rna_iterator_listbase_begin(iter, &cache_file->object_paths, NULL);
}
+static void rna_CacheFile_filename_set(PointerRNA *ptr, const char *value)
+{
+ CacheFile *cache_file = ptr->data;
+
+ if (STREQ(cache_file->filepath, value)) {
+ return;
+ }
+
+ /* Different file is opened, close all readers. */
+ cache_file->flag |= CACHEFILE_DIRTY;
+
+ BLI_strncpy(cache_file->filepath, value, sizeof(cache_file->filepath));
+}
+
#else
/* cachefile.object_paths */
@@ -103,6 +125,7 @@ static void rna_def_cachefile(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_FILE);
PropertyRNA *prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_CacheFile_filename_set");
RNA_def_property_ui_text(prop, "File Path", "Path to external displacements file");
RNA_def_property_update(prop, 0, "rna_CacheFile_update_handle");