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/alembic/intern/abc_points.cc
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/alembic/intern/abc_points.cc')
-rw-r--r--source/blender/alembic/intern/abc_points.cc32
1 files changed, 26 insertions, 6 deletions
diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc
index 03014547416..c16da621c77 100644
--- a/source/blender/alembic/intern/abc_points.cc
+++ b/source/blender/alembic/intern/abc_points.cc
@@ -32,6 +32,7 @@ extern "C" {
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
+#include "BKE_cdderivedmesh.h"
#include "BKE_lattice.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
@@ -154,14 +155,14 @@ void AbcPointsReader::readObjectData(Main *bmain, float time)
{
Mesh *mesh = BKE_mesh_add(bmain, m_data_name.c_str());
- const ISampleSelector sample_sel(time);
- m_sample = m_schema.getValue(sample_sel);
+ DerivedMesh *dm = CDDM_from_mesh(mesh);
+ DerivedMesh *ndm = this->read_derivedmesh(dm, time, 0);
- const P3fArraySamplePtr &positions = m_sample.getPositions();
- utils::mesh_add_verts(mesh, positions->size());
+ if (ndm != dm) {
+ dm->release(dm);
+ }
- CDStreamConfig config = create_config(mesh);
- read_points_sample(m_schema, sample_sel, config, time);
+ DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true);
if (m_settings->validate_meshes) {
BKE_mesh_validate(mesh, false, false);
@@ -197,3 +198,22 @@ void read_points_sample(const IPointsSchema &schema,
read_mverts(config.mvert, positions, vnormals);
}
+
+DerivedMesh *AbcPointsReader::read_derivedmesh(DerivedMesh *dm, const float time, int /*read_flag*/)
+{
+ ISampleSelector sample_sel(time);
+ const IPointsSchema::Sample sample = m_schema.getValue(sample_sel);
+
+ const P3fArraySamplePtr &positions = sample.getPositions();
+
+ DerivedMesh *new_dm = NULL;
+
+ if (dm->getNumVerts(dm) != positions->size()) {
+ new_dm = CDDM_new(positions->size(), 0, 0, 0, 0);
+ }
+
+ CDStreamConfig config = get_config(new_dm ? new_dm : dm);
+ read_points_sample(m_schema, sample_sel, config, time);
+
+ return new_dm ? new_dm : dm;
+}