Revision: 43741
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43741
Author:   nazgul
Date:     2012-01-27 08:17:53 +0000 (Fri, 27 Jan 2012)
Log Message:
-----------
Fixed some possible issues and access non-initialized variable in Carve BOP 
interface.

Discovered when was investigating some crashes caused by Carve's triangulator.

Modified Paths:
--------------
    trunk/blender/intern/boolop/intern/BOP_CarveInterface.cpp

Modified: trunk/blender/intern/boolop/intern/BOP_CarveInterface.cpp
===================================================================
--- trunk/blender/intern/boolop/intern/BOP_CarveInterface.cpp   2012-01-27 
08:15:30 UTC (rev 43740)
+++ trunk/blender/intern/boolop/intern/BOP_CarveInterface.cpp   2012-01-27 
08:17:53 UTC (rev 43741)
@@ -150,12 +150,19 @@
                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 @@
                                         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 @@
 
        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;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to