[Bf-blender-cvs] [449e6124b5f] master: Fix T81330: Alembic Import ignores constant meshes with animated vertex colors
Philipp Oeser
noreply at git.blender.org
Wed Oct 7 11:00:39 CEST 2020
Commit: 449e6124b5f75f91c52d231f763868ef4ddc5f1e
Author: Philipp Oeser
Date: Wed Sep 30 19:07:03 2020 +0200
Branches: master
https://developer.blender.org/rB449e6124b5f75f91c52d231f763868ef4ddc5f1e
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
===================================================================
M source/blender/io/alembic/intern/abc_reader_mesh.cc
===================================================================
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)
More information about the Bf-blender-cvs
mailing list