[Bf-blender-cvs] [3a38ba6] alembic: Check for empty schemas more consistently before trying to read.

Lukas Tönne noreply at git.blender.org
Thu Apr 9 15:36:23 CEST 2015


Commit: 3a38ba68c686de4f775a60cac24083c266ba737a
Author: Lukas Tönne
Date:   Thu Apr 9 15:35:04 2015 +0200
Branches: alembic
https://developer.blender.org/rB3a38ba68c686de4f775a60cac24083c266ba737a

Check for empty schemas more consistently before trying to read.

Reading from an empty object in Alembic will throw an exception, which
is not easily handled yet. So rather avoid annoying crashes the clumsy
way for now.

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

M	source/blender/pointcache/alembic/abc_cloth.cpp
M	source/blender/pointcache/alembic/abc_mesh.cpp
M	source/blender/pointcache/alembic/abc_particles.cpp

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

diff --git a/source/blender/pointcache/alembic/abc_cloth.cpp b/source/blender/pointcache/alembic/abc_cloth.cpp
index 37aad53..d6ca2bb 100644
--- a/source/blender/pointcache/alembic/abc_cloth.cpp
+++ b/source/blender/pointcache/alembic/abc_cloth.cpp
@@ -201,6 +201,8 @@ PTCReadSampleResult AbcClothReader::read_sample(float frame)
 		return PTC_READ_SAMPLE_INVALID;
 	
 	IPointsSchema &schema = m_points.getSchema();
+	if (schema.getNumSamples() == 0)
+		return PTC_READ_SAMPLE_INVALID;
 	TimeSamplingPtr ts = schema.getTimeSampling();
 	
 	ISampleSelector ss = abc_archive()->get_frame_sample_selector(frame);
diff --git a/source/blender/pointcache/alembic/abc_mesh.cpp b/source/blender/pointcache/alembic/abc_mesh.cpp
index e6570fc..aa6a0c6a 100644
--- a/source/blender/pointcache/alembic/abc_mesh.cpp
+++ b/source/blender/pointcache/alembic/abc_mesh.cpp
@@ -512,7 +512,7 @@ PTCReadSampleResult AbcDerivedMeshReader::read_sample(float frame)
 		return PTC_READ_SAMPLE_INVALID;
 	
 	IPolyMeshSchema &schema = m_mesh.getSchema();
-	if (!schema.valid() || schema.getPositionsProperty().getNumSamples() == 0)
+	if (schema.getNumSamples() == 0)
 		return PTC_READ_SAMPLE_INVALID;
 	ICompoundProperty user_props = schema.getUserProperties();
 	
diff --git a/source/blender/pointcache/alembic/abc_particles.cpp b/source/blender/pointcache/alembic/abc_particles.cpp
index 167635a..cfd0f26 100644
--- a/source/blender/pointcache/alembic/abc_particles.cpp
+++ b/source/blender/pointcache/alembic/abc_particles.cpp
@@ -112,6 +112,8 @@ PTCReadSampleResult AbcParticlesReader::read_sample(float frame)
 		return PTC_READ_SAMPLE_INVALID;
 	
 	IPointsSchema &schema = m_points.getSchema();
+	if (schema.getNumSamples() == 0)
+		return PTC_READ_SAMPLE_INVALID;
 	
 	IPointsSchema::Sample sample;
 	schema.get(sample, ss);
@@ -610,6 +612,8 @@ PTCReadSampleResult AbcStrandsChildrenReader::read_sample(float frame)
 		return PTC_READ_SAMPLE_INVALID;
 	
 	ICurvesSchema &schema = m_curves.getSchema();
+	if (schema.getNumSamples() == 0)
+		return PTC_READ_SAMPLE_INVALID;
 	
 	ICurvesSchema::Sample sample;
 	schema.get(sample, ss);
@@ -716,6 +720,8 @@ PTCReadSampleResult AbcStrandsReader::read_sample(float frame)
 		return PTC_READ_SAMPLE_INVALID;
 	
 	ICurvesSchema &schema = m_curves.getSchema();
+	if (schema.getNumSamples() == 0)
+		return PTC_READ_SAMPLE_INVALID;
 	
 	ICurvesSchema::Sample sample;
 	schema.get(sample, ss);
@@ -1047,7 +1053,7 @@ PTCReadSampleResult AbcParticlePathcacheReader::read_sample(float frame)
 	ISampleSelector ss = abc_archive()->get_frame_sample_selector(frame);
 	
 	ICurvesSchema &schema = m_curves.getSchema();
-	if (!schema.valid() || schema.getPositionsProperty().getNumSamples() == 0)
+	if (schema.getNumSamples() == 0)
 		return PTC_READ_SAMPLE_INVALID;
 	
 	ICurvesSchema::Sample sample;




More information about the Bf-blender-cvs mailing list