diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2020-09-30 20:07:03 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2020-10-07 11:56:48 +0300 |
commit | 449e6124b5f75f91c52d231f763868ef4ddc5f1e (patch) | |
tree | 6168df350b65ab5f016533cfaf7189f05d40ac0f /source/blender/io/alembic/intern | |
parent | b7ca2365cfc3d7b05779ab6d01e500e2938aa25e (diff) |
Fix T81330: Alembic Import ignores constant meshes with animated vertex
colors
If the mesh was constant, no check was done if there were animated
vertex colors and thus creation of a MeshSequenceCache modifier was
skipped.
Thx @sybren for feedback!
Maniphest Tasks: T81330
Differential Revision: https://developer.blender.org/D9057
Diffstat (limited to 'source/blender/io/alembic/intern')
-rw-r--r-- | source/blender/io/alembic/intern/abc_reader_mesh.cc | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc index e69c0edfec8..93e4c7b154a 100644 --- a/source/blender/io/alembic/intern/abc_reader_mesh.cc +++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc @@ -43,7 +43,10 @@ using Alembic::Abc::Int32ArraySamplePtr; using Alembic::Abc::P3fArraySamplePtr; +using Alembic::Abc::PropertyHeader; +using Alembic::AbcGeom::IC3fGeomParam; +using Alembic::AbcGeom::IC4fGeomParam; using Alembic::AbcGeom::IFaceSet; using Alembic::AbcGeom::IFaceSetSchema; using Alembic::AbcGeom::IN3fGeomParam; @@ -494,6 +497,39 @@ bool AbcMeshReader::valid() const return m_schema.valid(); } +template<class typedGeomParam> +bool is_valid_animated(const ICompoundProperty arbGeomParams, const PropertyHeader &prop_header) +{ + if (!typedGeomParam::matches(prop_header)) { + return false; + } + + typedGeomParam geom_param(arbGeomParams, prop_header.getName()); + return geom_param.valid() && !geom_param.isConstant(); +} + +bool has_animated_geom_params(const ICompoundProperty arbGeomParams) +{ + if (!arbGeomParams.valid()) { + return false; + } + + const int num_props = arbGeomParams.getNumProperties(); + for (int i = 0; i < num_props; i++) { + const PropertyHeader &prop_header = arbGeomParams.getPropertyHeader(i); + + /* These are interpreted as vertex colors later (see 'read_custom_data'). */ + if (is_valid_animated<IC3fGeomParam>(arbGeomParams, prop_header)) { + return true; + } + if (is_valid_animated<IC4fGeomParam>(arbGeomParams, prop_header)) { + return true; + } + } + + return false; +} + /* Specialisation of has_animations() as defined in abc_reader_object.h. */ template<> bool has_animations(Alembic::AbcGeom::IPolyMeshSchema &schema, ImportSettings *settings) { @@ -502,9 +538,21 @@ template<> bool has_animations(Alembic::AbcGeom::IPolyMeshSchema &schema, Import } IV2fGeomParam uvsParam = schema.getUVsParam(); + if (uvsParam.valid() && !uvsParam.isConstant()) { + return true; + } + IN3fGeomParam normalsParam = schema.getNormalsParam(); - return (uvsParam.valid() && !uvsParam.isConstant()) || - (normalsParam.valid() && !normalsParam.isConstant()); + if (normalsParam.valid() && !normalsParam.isConstant()) { + return true; + } + + ICompoundProperty arbGeomParams = schema.getArbGeomParams(); + if (has_animated_geom_params(arbGeomParams)) { + return true; + } + + return false; } void AbcMeshReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) |