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
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')
-rw-r--r--source/blender/makesrna/intern/rna_cachefile.c23
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c21
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c15
3 files changed, 57 insertions, 2 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");
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index db3f76f3cfc..ad037af943d 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -148,12 +148,17 @@ static EnumPropertyItem space_object_items[] = {
{0, NULL, 0, NULL, NULL}
};
+#include "DNA_cachefile_types.h"
+
#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_constraint.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
+#ifdef WITH_ALEMBIC
+# include "ABC_alembic.h"
+#endif
static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr)
{
@@ -471,6 +476,20 @@ static void rna_Constraint_objectSolver_camera_set(PointerRNA *ptr, PointerRNA v
}
}
+static void rna_Constraint_transformCache_object_path_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ bConstraint *con = (bConstraint *)ptr->data;
+ bTransformCacheConstraint *data = (bTransformCacheConstraint *)con->data;
+ Object *ob = (Object *)ptr->id.data;
+
+ data->reader = CacheReader_open_alembic_object(data->cache_file->handle,
+ data->reader,
+ ob,
+ data->object_path);
+
+ rna_Constraint_update(bmain, scene, ptr);
+}
+
#else
static EnumPropertyItem constraint_distance_items[] = {
@@ -2593,7 +2612,7 @@ static void rna_def_constraint_transform_cache(BlenderRNA *brna)
prop = RNA_def_property(srna, "object_path", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Object Path", "Path to the object in the Alembic archive used to lookup the transform matrix");
- RNA_def_property_update(prop, 0, "rna_Constraint_update");
+ RNA_def_property_update(prop, 0, "rna_Constraint_transformCache_object_path_update");
}
/* base struct for constraints */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 39f6298ca61..b30c156a88c 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1131,6 +1131,19 @@ static int rna_CorrectiveSmoothModifier_is_bind_get(PointerRNA *ptr)
return (csmd->bind_coords != NULL);
}
+static void rna_MeshSequenceCache_object_path_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)ptr->data;
+ Object *ob = (Object *)ptr->id.data;
+
+ mcmd->reader = CacheReader_open_alembic_object(mcmd->cache_file->handle,
+ mcmd->reader,
+ ob,
+ mcmd->object_path);
+
+ rna_Modifier_update(bmain, scene, ptr);
+}
+
#else
static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const char type[])
@@ -4257,7 +4270,7 @@ static void rna_def_modifier_meshseqcache(BlenderRNA *brna)
prop = RNA_def_property(srna, "object_path", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Object Path", "Path to the object in the Alembic archive used to lookup geometric data");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ RNA_def_property_update(prop, 0, "rna_MeshSequenceCache_object_path_update");
static EnumPropertyItem read_flag_items[] = {
{MOD_MESHSEQ_READ_VERT, "VERT", 0, "Vertex", ""},