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:
authorSybren A. Stüvel <sybren@blender.org>2019-08-16 15:52:08 +0300
committerSybren A. Stüvel <sybren@blender.org>2019-08-16 15:52:08 +0300
commitee8aad79c1590cd0e98ba67961909ebfa8f6a803 (patch)
tree3d7ec905e3a4e1ce525d7f961699983afe56cce0 /source/blender/alembic/intern/abc_mesh.cc
parentc70f975d5c3b961e0c77eba3a35c8a892f39214d (diff)
Fix T56408: Hair children recalc on every frame on Alembic mesh
This fixes the glitching hairs described in T56408, T63534, and possibly also T63534. The fix consists of returning the original mesh (i.e. as visible in edit mode) when constructing the ORCO mesh. This allows a static set of coordinates to be used when computing the child hair positions. The original mesh is only returned when it has the same topology (at least same number of vertices, loops, and polys. It's up the author of the Alembic file to ensure stable geometry when it's desired to be compatible with Blender's hair system. Reviewers: mont29, brecht Differential Revision: https://developer.blender.org/D5492
Diffstat (limited to 'source/blender/alembic/intern/abc_mesh.cc')
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc30
1 files changed, 26 insertions, 4 deletions
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 6647ca83bd6..be2793e38f7 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -1131,6 +1131,31 @@ bool AbcMeshReader::accepts_object_type(
return true;
}
+bool AbcMeshReader::topology_changed(Mesh *existing_mesh, const ISampleSelector &sample_sel)
+{
+ IPolyMeshSchema::Sample sample;
+ try {
+ sample = m_schema.getValue(sample_sel);
+ }
+ catch (Alembic::Util::Exception &ex) {
+ printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
+ m_iobject.getFullName().c_str(),
+ m_schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
+ // A similar error in read_mesh() would just return existing_mesh.
+ return false;
+ }
+
+ const P3fArraySamplePtr &positions = sample.getPositions();
+ const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices();
+ const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts();
+
+ return positions->size() != existing_mesh->totvert ||
+ face_counts->size() != existing_mesh->totpoly ||
+ face_indices->size() != existing_mesh->totloop;
+}
+
Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
const ISampleSelector &sample_sel,
int read_flag,
@@ -1162,10 +1187,7 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
ImportSettings settings;
settings.read_flag |= read_flag;
- bool topology_changed = positions->size() != existing_mesh->totvert ||
- face_counts->size() != existing_mesh->totpoly ||
- face_indices->size() != existing_mesh->totloop;
- if (topology_changed) {
+ if (topology_changed(existing_mesh, sample_sel)) {
new_mesh = BKE_mesh_new_nomain_from_template(
existing_mesh, positions->size(), 0, 0, face_indices->size(), face_counts->size());