[Bf-blender-cvs] [deeb09a] alembic_pointcache: Sanity checks for Alembic archive validity to avoid crashes when trying an invalid file operation (e.g. overwriting files).
Lukas Tönne
noreply at git.blender.org
Tue Feb 17 13:40:42 CET 2015
Commit: deeb09a5cbc340a314f4f3d5ed680745d2064a20
Author: Lukas Tönne
Date: Tue Feb 17 13:40:00 2015 +0100
Branches: alembic_pointcache
https://developer.blender.org/rBdeeb09a5cbc340a314f4f3d5ed680745d2064a20
Sanity checks for Alembic archive validity to avoid crashes when trying
an invalid file operation (e.g. overwriting files).
===================================================================
M source/blender/pointcache/alembic/abc_cloth.cpp
M source/blender/pointcache/alembic/abc_dynamicpaint.cpp
M source/blender/pointcache/alembic/abc_mesh.cpp
M source/blender/pointcache/alembic/abc_particles.cpp
M source/blender/pointcache/alembic/abc_rigidbody.cpp
M source/blender/pointcache/alembic/abc_smoke.cpp
M source/blender/pointcache/alembic/abc_softbody.cpp
===================================================================
diff --git a/source/blender/pointcache/alembic/abc_cloth.cpp b/source/blender/pointcache/alembic/abc_cloth.cpp
index e3f3951..67fd42e 100644
--- a/source/blender/pointcache/alembic/abc_cloth.cpp
+++ b/source/blender/pointcache/alembic/abc_cloth.cpp
@@ -43,14 +43,16 @@ AbcClothWriter::AbcClothWriter(Scene *scene, Object *ob, ClothModifierData *clmd
{
set_error_handler(new ModifierErrorHandler(&clmd->modifier));
- OObject root = m_archive.archive.getTop();
- m_points = OPoints(root, m_clmd->modifier.name, m_archive.frame_sampling_index());
-
- OPointsSchema &schema = m_points.getSchema();
- OCompoundProperty geom_params = schema.getArbGeomParams();
-
- m_param_velocities = OV3fGeomParam(geom_params, "velocities", false, kVaryingScope, 1, 0);
- m_param_goal_positions = OP3fGeomParam(geom_params, "goal_positions", false, kVaryingScope, 1, 0);
+ if (m_archive.archive) {
+ OObject root = m_archive.archive.getTop();
+ m_points = OPoints(root, m_clmd->modifier.name, m_archive.frame_sampling_index());
+
+ OPointsSchema &schema = m_points.getSchema();
+ OCompoundProperty geom_params = schema.getArbGeomParams();
+
+ m_param_velocities = OV3fGeomParam(geom_params, "velocities", false, kVaryingScope, 1, 0);
+ m_param_goal_positions = OP3fGeomParam(geom_params, "goal_positions", false, kVaryingScope, 1, 0);
+ }
}
AbcClothWriter::~AbcClothWriter()
@@ -87,6 +89,9 @@ static P3fArraySample create_sample_goal_positions(Cloth *cloth, std::vector<V3f
void AbcClothWriter::write_sample()
{
+ if (!m_archive.archive)
+ return;
+
Cloth *cloth = m_clmd->clothObject;
if (!cloth)
return;
diff --git a/source/blender/pointcache/alembic/abc_dynamicpaint.cpp b/source/blender/pointcache/alembic/abc_dynamicpaint.cpp
index aa9d928..49ae62b 100644
--- a/source/blender/pointcache/alembic/abc_dynamicpaint.cpp
+++ b/source/blender/pointcache/alembic/abc_dynamicpaint.cpp
@@ -36,6 +36,8 @@ AbcDynamicPaintWriter::AbcDynamicPaintWriter(Scene *scene, Object *ob, DynamicPa
DynamicPaintWriter(scene, ob, surface, &m_archive),
m_archive(scene, &ob->id, surface->pointcache, m_error_handler)
{
+ if (m_archive.archive) {
+ }
}
AbcDynamicPaintWriter::~AbcDynamicPaintWriter()
@@ -44,6 +46,8 @@ AbcDynamicPaintWriter::~AbcDynamicPaintWriter()
void AbcDynamicPaintWriter::write_sample()
{
+ if (!m_archive.archive)
+ return;
}
diff --git a/source/blender/pointcache/alembic/abc_mesh.cpp b/source/blender/pointcache/alembic/abc_mesh.cpp
index 78587e2..8183087 100644
--- a/source/blender/pointcache/alembic/abc_mesh.cpp
+++ b/source/blender/pointcache/alembic/abc_mesh.cpp
@@ -50,18 +50,20 @@ AbcPointCacheWriter::AbcPointCacheWriter(Scene *scene, Object *ob, PointCacheMod
{
set_error_handler(new ModifierErrorHandler(&pcmd->modifier));
- OObject root = m_archive.archive.getTop();
- m_mesh = OPolyMesh(root, m_pcmd->modifier.name, m_archive.frame_sampling_index());
-
- OPolyMeshSchema &schema = m_mesh.getSchema();
- OCompoundProperty geom_props = schema.getArbGeomParams();
- OCompoundProperty user_props = schema.getUserProperties();
-
- m_param_smooth = OBoolGeomParam(geom_props, "smooth", false, kUniformScope, 1, 0);
- m_prop_edges = OInt32ArrayProperty(user_props, "edges", 0);
- m_prop_edges_index = OInt32ArrayProperty(user_props, "edges_index", 0);
- m_param_poly_normals = ON3fGeomParam(geom_props, "poly_normals", false, kUniformScope, 1, 0);
- m_param_vertex_normals = ON3fGeomParam(geom_props, "vertex_normals", false, kVertexScope, 1, 0);
+ if (m_archive.archive) {
+ OObject root = m_archive.archive.getTop();
+ m_mesh = OPolyMesh(root, m_pcmd->modifier.name, m_archive.frame_sampling_index());
+
+ OPolyMeshSchema &schema = m_mesh.getSchema();
+ OCompoundProperty geom_props = schema.getArbGeomParams();
+ OCompoundProperty user_props = schema.getUserProperties();
+
+ m_param_smooth = OBoolGeomParam(geom_props, "smooth", false, kUniformScope, 1, 0);
+ m_prop_edges = OInt32ArrayProperty(user_props, "edges", 0);
+ m_prop_edges_index = OInt32ArrayProperty(user_props, "edges_index", 0);
+ m_param_poly_normals = ON3fGeomParam(geom_props, "poly_normals", false, kUniformScope, 1, 0);
+ m_param_vertex_normals = ON3fGeomParam(geom_props, "vertex_normals", false, kVertexScope, 1, 0);
+ }
}
AbcPointCacheWriter::~AbcPointCacheWriter()
@@ -233,6 +235,9 @@ static N3fArraySample create_sample_vertex_normals(DerivedMesh *dm, std::vector<
void AbcPointCacheWriter::write_sample()
{
+ if (!m_archive.archive)
+ return;
+
DerivedMesh *output_dm = m_pcmd->output_dm;
if (!output_dm)
return;
diff --git a/source/blender/pointcache/alembic/abc_particles.cpp b/source/blender/pointcache/alembic/abc_particles.cpp
index 6952d5f..a647864 100644
--- a/source/blender/pointcache/alembic/abc_particles.cpp
+++ b/source/blender/pointcache/alembic/abc_particles.cpp
@@ -41,8 +41,10 @@ AbcParticlesWriter::AbcParticlesWriter(Scene *scene, Object *ob, ParticleSystem
ParticlesWriter(scene, ob, psys, &m_archive),
m_archive(scene, &ob->id, psys->pointcache, m_error_handler)
{
- OObject root = m_archive.archive.getTop();
- m_points = OPoints(root, m_psys->name, m_archive.frame_sampling_index());
+ if (m_archive.archive) {
+ OObject root = m_archive.archive.getTop();
+ m_points = OPoints(root, m_psys->name, m_archive.frame_sampling_index());
+ }
}
AbcParticlesWriter::~AbcParticlesWriter()
@@ -51,6 +53,9 @@ AbcParticlesWriter::~AbcParticlesWriter()
void AbcParticlesWriter::write_sample()
{
+ if (!m_archive.archive)
+ return;
+
OPointsSchema &schema = m_points.getSchema();
int totpart = m_psys->totpart;
@@ -128,10 +133,12 @@ AbcParticlePathsWriter::AbcParticlePathsWriter(Scene *scene, Object *ob, Particl
m_archive(NULL)
{
#if 0
- OObject root = m_archive.archive.getTop();
- /* XXX non-escaped string construction here ... */
- m_parent_curves = OCurves(root, std::string(m_psys->name) + "__parent_paths", m_archive.frame_sampling_index());
- m_child_curves = OCurves(root, std::string(m_psys->name) + "__child_paths", m_archive.frame_sampling_index());
+ if (m_archive->archive) {
+ OObject root = m_archive.archive.getTop();
+ /* XXX non-escaped string construction here ... */
+ m_parent_curves = OCurves(root, std::string(m_psys->name) + "__parent_paths", m_archive.frame_sampling_index());
+ m_child_curves = OCurves(root, std::string(m_psys->name) + "__child_paths", m_archive.frame_sampling_index());
+ }
#endif
}
@@ -291,6 +298,8 @@ static OFloatGeomParam::Sample paths_create_sample_times(ParticleCacheKey **path
void AbcParticlePathsWriter::write_sample()
{
+ if (!m_archive->archive)
+ return;
if (!(*m_pathcache))
return;
diff --git a/source/blender/pointcache/alembic/abc_rigidbody.cpp b/source/blender/pointcache/alembic/abc_rigidbody.cpp
index 2cc4c24..8f9f711 100644
--- a/source/blender/pointcache/alembic/abc_rigidbody.cpp
+++ b/source/blender/pointcache/alembic/abc_rigidbody.cpp
@@ -36,6 +36,8 @@ AbcRigidBodyWriter::AbcRigidBodyWriter(Scene *scene, RigidBodyWorld *rbw) :
RigidBodyWriter(scene, rbw, &m_archive),
m_archive(scene, &scene->id, rbw->pointcache, m_error_handler)
{
+ if (m_archive.archive) {
+ }
}
AbcRigidBodyWriter::~AbcRigidBodyWriter()
@@ -44,6 +46,8 @@ AbcRigidBodyWriter::~AbcRigidBodyWriter()
void AbcRigidBodyWriter::write_sample()
{
+ if (!m_archive.archive)
+ return;
}
diff --git a/source/blender/pointcache/alembic/abc_smoke.cpp b/source/blender/pointcache/alembic/abc_smoke.cpp
index af0f491..c03f18b 100644
--- a/source/blender/pointcache/alembic/abc_smoke.cpp
+++ b/source/blender/pointcache/alembic/abc_smoke.cpp
@@ -36,8 +36,10 @@ AbcSmokeWriter::AbcSmokeWriter(Scene *scene, Object *ob, SmokeDomainSettings *do
SmokeWriter(scene, ob, domain, &m_archive),
m_archive(scene, &ob->id, domain->point_cache[0], m_error_handler)
{
- OObject root = m_archive.archive.getTop();
-// m_points = OPoints(root, m_psys->name, m_archive.frame_sampling_index());
+ if (m_archive.archive) {
+// OObject root = m_archive.archive.getTop();
+// m_points = OPoints(root, m_psys->name, m_archive.frame_sampling_index());
+ }
}
AbcSmokeWriter::~AbcSmokeWriter()
@@ -46,6 +48,8 @@ AbcSmokeWriter::~AbcSmokeWriter()
void AbcSmokeWriter::write_sample()
{
+ if (!m_archive.archive)
+ return;
}
diff --git a/source/blender/pointcache/alembic/abc_softbody.cpp b/source/blender/pointcache/alembic/abc_softbody.cpp
index 138f62f..f824206 100644
--- a/source/blender/pointcache/alembic/abc_softbody.cpp
+++ b/source/blender/pointcache/alembic/abc_softbody.cpp
@@ -36,8 +36,10 @@ AbcSoftBodyWriter::AbcSoftBodyWriter(Scene *scene, Object *ob, SoftBody *softbod
SoftBodyWriter(scene, ob, softbody, &m_archive),
m_archive(scene, &ob->id, softbody->pointcache, m_error_handler)
{
- OObject root = m_archive.archive.getTop();
-// m_points = OPoints(root, m_psys->name, m_archive.frame_sampling_index());
+ if (m_archive.archive) {
+// OObject root = m_archive.archive.getTop();
+// m_points = OPoints(root, m_psys->name, m_archive.frame_sampling_index());
+ }
}
AbcSoftBodyWriter::~AbcSoftBodyWriter()
@@ -46,6 +48,8 @@ AbcSoftBodyWriter::~AbcSoftBodyWriter()
void AbcSoftBodyWriter::write_sample()
{
+ if (!m_archive.archive)
+ return;
}
More information about the Bf-blender-cvs
mailing list