From 449e6124b5f75f91c52d231f763868ef4ddc5f1e Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 30 Sep 2020 19:07:03 +0200 Subject: 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 --- .../blender/io/alembic/intern/abc_reader_mesh.cc | 52 +++++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'source/blender') 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 +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(arbGeomParams, prop_header)) { + return true; + } + if (is_valid_animated(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) -- cgit v1.2.3