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
This commit is contained in:
Philipp Oeser 2020-09-30 19:07:03 +02:00
parent b7ca2365cf
commit 449e6124b5
Notes: blender-bot 2023-02-14 05:41:57 +01:00
Referenced by issue #81330, Alembic Import does not apply `MeshSequenceCache` to all animated Meshes
1 changed files with 50 additions and 2 deletions

View File

@ -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)