[Bf-blender-cvs] [f0cdc1f] alembic_basic_io: Cleanup: use has_animations.

Kévin Dietrich noreply at git.blender.org
Thu Jul 14 14:43:21 CEST 2016


Commit: f0cdc1f6a43fcd61be534dfad0f6321c15973b97
Author: Kévin Dietrich
Date:   Thu Jul 14 14:01:02 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rBf0cdc1f6a43fcd61be534dfad0f6321c15973b97

Cleanup: use has_animations.

===================================================================

M	source/blender/alembic/intern/abc_curves.cc
M	source/blender/alembic/intern/abc_mesh.cc
M	source/blender/alembic/intern/abc_object.cc
M	source/blender/alembic/intern/abc_object.h
M	source/blender/alembic/intern/abc_points.cc
M	source/blender/alembic/intern/abc_util.h

===================================================================

diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc
index c17c279..63933c2 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -208,8 +208,8 @@ void AbcCurveReader::readObjectData(Main *bmain, Scene *scene, float time)
 
 	read_curve_sample(cu, m_curves_schema, time);
 
-	if (m_settings->is_sequence || !m_curves_schema.isConstant()) {
-		addDefaultModifier();
+	if (has_animations(m_curves_schema, m_settings)) {
+		addCacheModifier();
 	}
 }
 
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index a73ce7a..f6e6a95 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -964,41 +964,6 @@ ABC_INLINE void read_normals_params(AbcMeshData &abc_data,
 	}
 }
 
-template <typename Schema>
-static bool has_animations(Schema &schema, ImportSettings *settings)
-{
-	if (settings->is_sequence) {
-		return true;
-	}
-
-	if (!schema.isConstant()) {
-		return true;
-	}
-
-	const ICompoundProperty &arb_geom_params = schema.getArbGeomParams();
-
-	if (!arb_geom_params.valid()) {
-		return false;
-	}
-
-	const size_t num_props = arb_geom_params.getNumProperties();
-
-	for (size_t i = 0; i < num_props; ++i) {
-		const Alembic::Abc::PropertyHeader &propHeader = arb_geom_params.getPropertyHeader(i);
-
-		/* Check for animated UVs. */
-		if (IV2fGeomParam::matches(propHeader) && Alembic::AbcGeom::isUV(propHeader)) {
-			IV2fGeomParam uv_geom_param(arb_geom_params, propHeader.getName());
-
-			if (!uv_geom_param.isConstant()) {
-				return true;
-			}
-		}
-	}
-
-	return false;
-}
-
 /* ************************************************************************** */
 
 AbcMeshReader::AbcMeshReader(const IObject &object, ImportSettings &settings, bool is_subd)
@@ -1043,7 +1008,7 @@ void AbcMeshReader::readObjectData(Main *bmain, Scene *scene, float time)
 	readFaceSetsSample(bmain, mesh, 0, sample_sel);
 
 	if (has_animations(m_schema, m_settings)) {
-		addDefaultModifier();
+		addCacheModifier();
 	}
 }
 
@@ -1191,7 +1156,7 @@ void AbcSubDReader::readObjectData(Main *bmain, Scene *scene, float time)
 	BKE_mesh_validate(mesh, false, false);
 
 	if (has_animations(m_schema, m_settings)) {
-		addDefaultModifier();
+		addCacheModifier();
 	}
 }
 
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index bf92172..24f699b 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -214,7 +214,7 @@ void AbcObjectReader::readObjectMatrix(const float time)
 	}
 }
 
-void AbcObjectReader::addDefaultModifier() const
+void AbcObjectReader::addCacheModifier() const
 {
 	ModifierData *md = modifier_new(eModifierType_MeshSequenceCache);
 	BLI_addtail(&m_object->modifiers, md);
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index ac2fbf8..0c2e08d 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -94,6 +94,20 @@ struct ImportSettings {
 	CacheFile *cache_file;
 };
 
+template <typename Schema>
+static bool has_animations(Schema &schema, ImportSettings *settings)
+{
+	if (settings->is_sequence) {
+		return true;
+	}
+
+	if (!schema.isConstant()) {
+		return true;
+	}
+
+	return false;
+}
+
 /* ************************************************************************** */
 
 using Alembic::AbcCoreAbstract::chrono_t;
@@ -126,7 +140,7 @@ public:
 
 	void readObjectMatrix(const float time);
 
-	void addDefaultModifier() const;
+	void addCacheModifier() const;
 
 	chrono_t minTime() const;
 	chrono_t maxTime() const;
diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc
index ca58bd8..f86f5ef 100644
--- a/source/blender/alembic/intern/abc_points.cc
+++ b/source/blender/alembic/intern/abc_points.cc
@@ -178,7 +178,7 @@ void AbcPointsReader::readObjectData(Main *bmain, Scene *scene, float time)
 	m_object = BKE_object_add(bmain, scene, OB_MESH, m_object_name.c_str());
 	m_object->data = mesh;
 
-	if (m_settings->is_sequence || !m_schema.isConstant()) {
-		addDefaultModifier();
+	if (has_animations(m_schema, m_settings)) {
+		addCacheModifier();
 	}
 }
diff --git a/source/blender/alembic/intern/abc_util.h b/source/blender/alembic/intern/abc_util.h
index b2ab046..0409f28 100644
--- a/source/blender/alembic/intern/abc_util.h
+++ b/source/blender/alembic/intern/abc_util.h
@@ -25,8 +25,16 @@
 #include <Alembic/Abc/All.h>
 #include <Alembic/AbcGeom/All.h>
 
+#ifdef _MSC_VER
+#  define ABC_INLINE static __forceinline
+#else
+#  define ABC_INLINE static inline
+#endif
+
 using Alembic::Abc::chrono_t;
 
+class ImportSettings;
+
 struct ID;
 struct Object;
 
@@ -76,12 +84,6 @@ bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string
 
 /* ************************** */
 
-#ifdef _MSC_VER
-#  define ABC_INLINE static __forceinline
-#else
-#  define ABC_INLINE static inline
-#endif
-
 /* TODO(kevin): for now keeping these transformations hardcoded to make sure
  * everything works properly, and also because Alembic is almost exclusively
  * used in Y-up software, but eventually they'll be set by the user in the UI




More information about the Bf-blender-cvs mailing list