Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-01-27 12:17:53 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-01-27 12:17:53 +0400
commit3062798de3a34d461578da4bd9d8d4f700f70ddb (patch)
tree3188a200d245f1796fa15456d706bc4fc5d34285 /intern/boolop
parent82300fabb9cc0d55c3044fc1cf039025bd39129a (diff)
Fixed some possible issues and access non-initialized variable in Carve BOP interface.
Discovered when was investigating some crashes caused by Carve's triangulator.
Diffstat (limited to 'intern/boolop')
-rw-r--r--intern/boolop/intern/BOP_CarveInterface.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/intern/boolop/intern/BOP_CarveInterface.cpp b/intern/boolop/intern/BOP_CarveInterface.cpp
index 274d9cac0cf..5a847ff26d4 100644
--- a/intern/boolop/intern/BOP_CarveInterface.cpp
+++ b/intern/boolop/intern/BOP_CarveInterface.cpp
@@ -150,12 +150,19 @@ static MeshSet<3> *Carve_unionIntersectingMeshes(MeshSet<3> *poly,
MeshSet<3> *right = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB);
try {
- MeshSet<3> *result = csg.compute(left, right, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE);
+ if(left->meshes.size()==0) {
+ delete left;
- delete left;
- delete right;
+ left = right;
+ }
+ else {
+ MeshSet<3> *result = csg.compute(left, right, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE);
- left = result;
+ delete left;
+ delete right;
+
+ left = result;
+ }
}
catch(carve::exception e) {
std::cerr << "CSG failed, exception " << e.str() << std::endl;
@@ -492,7 +499,7 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType,
CSG_VertexIteratorDescriptor obBVertices)
{
carve::csg::CSG::OP op;
- MeshSet<3> *left, *right, *output;
+ MeshSet<3> *left, *right, *output = NULL;
carve::csg::CSG csg;
carve::geom3d::Vector min, max;
carve::interpolate::FaceAttr<uint> oface_num;
@@ -517,6 +524,17 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType,
Carve_prepareOperands(&left, &right, oface_num);
+ if(left->meshes.size() == 0 || right->meshes.size()==0) {
+ // normally sohuldn't happen (zero-faces objects are handled by modifier itself), but
+ // unioning intersecting meshes which doesn't have consistent normals might lead to
+ // empty result which wouldn't work here
+
+ delete left;
+ delete right;
+
+ return BOP_ERROR;
+ }
+
min.x = max.x = left->vertex_storage[0].v.x;
min.y = max.y = left->vertex_storage[0].v.y;
min.z = max.z = left->vertex_storage[0].v.z;