Alembic import: don't crash Blender when reading invalid samples
This commit is contained in:
parent
5852c66125
commit
9a873d0ab2
|
@ -256,9 +256,21 @@ void AbcCurveReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele
|
|||
|
||||
/* ************************************************************************** */
|
||||
|
||||
void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSelector &sample_sel)
|
||||
void AbcCurveReader::read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSelector &sample_sel)
|
||||
{
|
||||
ICurvesSchema::Sample smp = schema.getValue(sample_sel);
|
||||
ICurvesSchema::Sample smp;
|
||||
try {
|
||||
smp = schema.getValue(sample_sel);
|
||||
}
|
||||
catch(Alembic::Util::Exception &ex) {
|
||||
printf("Alembic: error reading curve sample for '%s/%s' at time %f: %s\n",
|
||||
m_iobject.getFullName().c_str(),
|
||||
schema.getName().c_str(),
|
||||
sample_sel.getRequestedTime(),
|
||||
ex.what());
|
||||
return;
|
||||
}
|
||||
|
||||
const Int32ArraySamplePtr num_vertices = smp.getCurvesNumVertices();
|
||||
const P3fArraySamplePtr positions = smp.getPositions();
|
||||
const FloatArraySamplePtr weights = smp.getPositionWeights();
|
||||
|
@ -404,12 +416,25 @@ void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSele
|
|||
* object directly and create a new Mesh from that. Also we might need to
|
||||
* create new or delete existing NURBS in the curve.
|
||||
*/
|
||||
Mesh *AbcCurveReader::read_mesh(Mesh * /*existing_mesh*/,
|
||||
Mesh *AbcCurveReader::read_mesh(Mesh *existing_mesh,
|
||||
const ISampleSelector &sample_sel,
|
||||
int /*read_flag*/,
|
||||
const char ** /*err_str*/)
|
||||
const char **err_str)
|
||||
{
|
||||
const ICurvesSchema::Sample sample = m_curves_schema.getValue(sample_sel);
|
||||
ICurvesSchema::Sample sample;
|
||||
|
||||
try {
|
||||
sample = m_curves_schema.getValue(sample_sel);
|
||||
}
|
||||
catch(Alembic::Util::Exception &ex) {
|
||||
*err_str = "Error reading curve sample; more detail on the console";
|
||||
printf("Alembic: error reading curve sample for '%s/%s' at time %f: %s\n",
|
||||
m_iobject.getFullName().c_str(),
|
||||
m_curves_schema.getName().c_str(),
|
||||
sample_sel.getRequestedTime(),
|
||||
ex.what());
|
||||
return existing_mesh;
|
||||
}
|
||||
|
||||
const P3fArraySamplePtr &positions = sample.getPositions();
|
||||
const Int32ArraySamplePtr num_vertices = sample.getCurvesNumVertices();
|
||||
|
|
|
@ -62,12 +62,13 @@ public:
|
|||
const Alembic::Abc::ISampleSelector &sample_sel,
|
||||
int read_flag,
|
||||
const char **err_str);
|
||||
|
||||
void read_curve_sample(Curve *cu,
|
||||
const Alembic::AbcGeom::ICurvesSchema &schema,
|
||||
const Alembic::Abc::ISampleSelector &sample_selector);
|
||||
|
||||
};
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
void read_curve_sample(Curve *cu,
|
||||
const Alembic::AbcGeom::ICurvesSchema &schema,
|
||||
const Alembic::Abc::ISampleSelector &sample_selector);
|
||||
|
||||
#endif /* __ABC_CURVES_H__ */
|
||||
|
|
|
@ -1062,7 +1062,19 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
|
|||
int read_flag,
|
||||
const char **err_str)
|
||||
{
|
||||
const IPolyMeshSchema::Sample sample = m_schema.getValue(sample_sel);
|
||||
IPolyMeshSchema::Sample sample;
|
||||
try {
|
||||
sample = m_schema.getValue(sample_sel);
|
||||
}
|
||||
catch(Alembic::Util::Exception &ex) {
|
||||
*err_str = "Error reading mesh sample; more detail on the console";
|
||||
printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
|
||||
m_iobject.getFullName().c_str(),
|
||||
m_schema.getName().c_str(),
|
||||
sample_sel.getRequestedTime(),
|
||||
ex.what());
|
||||
return existing_mesh;
|
||||
}
|
||||
|
||||
const P3fArraySamplePtr &positions = sample.getPositions();
|
||||
const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices();
|
||||
|
@ -1300,7 +1312,19 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
|
|||
Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
|
||||
BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true);
|
||||
|
||||
const ISubDSchema::Sample sample = m_schema.getValue(sample_sel);
|
||||
ISubDSchema::Sample sample;
|
||||
try {
|
||||
sample = m_schema.getValue(sample_sel);
|
||||
}
|
||||
catch(Alembic::Util::Exception &ex) {
|
||||
printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
|
||||
m_iobject.getFullName().c_str(),
|
||||
m_schema.getName().c_str(),
|
||||
sample_sel.getRequestedTime(),
|
||||
ex.what());
|
||||
return;
|
||||
}
|
||||
|
||||
Int32ArraySamplePtr indices = sample.getCreaseIndices();
|
||||
Alembic::Abc::FloatArraySamplePtr sharpnesses = sample.getCreaseSharpnesses();
|
||||
|
||||
|
@ -1335,7 +1359,19 @@ Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh,
|
|||
int read_flag,
|
||||
const char **err_str)
|
||||
{
|
||||
const ISubDSchema::Sample sample = m_schema.getValue(sample_sel);
|
||||
ISubDSchema::Sample sample;
|
||||
try {
|
||||
sample = m_schema.getValue(sample_sel);
|
||||
}
|
||||
catch(Alembic::Util::Exception &ex) {
|
||||
*err_str = "Error reading mesh sample; more detail on the console";
|
||||
printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
|
||||
m_iobject.getFullName().c_str(),
|
||||
m_schema.getName().c_str(),
|
||||
sample_sel.getRequestedTime(),
|
||||
ex.what());
|
||||
return existing_mesh;
|
||||
}
|
||||
|
||||
const P3fArraySamplePtr &positions = sample.getPositions();
|
||||
const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices();
|
||||
|
|
|
@ -253,7 +253,19 @@ void AbcNurbsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele
|
|||
nu->resolv = cu->resolv;
|
||||
|
||||
const INuPatchSchema &schema = it->first;
|
||||
const INuPatchSchema::Sample smp = schema.getValue(sample_sel);
|
||||
INuPatchSchema::Sample smp;
|
||||
try {
|
||||
smp = schema.getValue(sample_sel);
|
||||
}
|
||||
catch(Alembic::Util::Exception &ex) {
|
||||
printf("Alembic: error reading nurbs sample for '%s/%s' at time %f: %s\n",
|
||||
m_iobject.getFullName().c_str(),
|
||||
schema.getName().c_str(),
|
||||
sample_sel.getRequestedTime(),
|
||||
ex.what());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
nu->orderu = smp.getUOrder() - 1;
|
||||
nu->orderv = smp.getVOrder() - 1;
|
||||
|
|
|
@ -215,9 +215,21 @@ void read_points_sample(const IPointsSchema &schema,
|
|||
struct Mesh *AbcPointsReader::read_mesh(struct Mesh *existing_mesh,
|
||||
const ISampleSelector &sample_sel,
|
||||
int /*read_flag*/,
|
||||
const char ** /*err_str*/)
|
||||
const char **err_str)
|
||||
{
|
||||
const IPointsSchema::Sample sample = m_schema.getValue(sample_sel);
|
||||
IPointsSchema::Sample sample;
|
||||
try {
|
||||
sample = m_schema.getValue(sample_sel);
|
||||
}
|
||||
catch(Alembic::Util::Exception &ex) {
|
||||
*err_str = "Error reading points sample; more detail on the console";
|
||||
printf("Alembic: error reading points sample for '%s/%s' at time %f: %s\n",
|
||||
m_iobject.getFullName().c_str(),
|
||||
m_schema.getName().c_str(),
|
||||
sample_sel.getRequestedTime(),
|
||||
ex.what());
|
||||
return existing_mesh;
|
||||
}
|
||||
|
||||
const P3fArraySamplePtr &positions = sample.getPositions();
|
||||
|
||||
|
|
Loading…
Reference in New Issue