From b8c6c1fdf0cf466354b3b7a92380b06307c991e8 Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Tue, 6 Jun 2006 17:43:57 +0000 Subject: ===Tools=== Bug "fix" for #3932, and possibly for #3799. Booleans can get into an endless loop (at least until memory runs out); through triangulation somehow a face is repeatedly added to the list of faces to triangulate. This patch checks the face list for duplicates prior to a list add and aborts if a dup is found. The real issue is why the triangulation is creating the face in the first place, but that will take a more thorough (and longer) examination of the code. If I can fix that issue that prior to the 2.42 release, then this code can be removed. --- intern/boolop/intern/BOP_Triangulator.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'intern') diff --git a/intern/boolop/intern/BOP_Triangulator.cpp b/intern/boolop/intern/BOP_Triangulator.cpp index fa604d44f2d..0ac637ee28d 100644 --- a/intern/boolop/intern/BOP_Triangulator.cpp +++ b/intern/boolop/intern/BOP_Triangulator.cpp @@ -393,6 +393,32 @@ void BOP_triangulateF(BOP_Mesh* mesh, BOP_Faces* faces, BOP_Face* face, */ void BOP_addFace(BOP_Mesh* mesh, BOP_Faces* faces, BOP_Face* face, BOP_TAG tag) { + BOP_Index av1 = face->getVertex(0); + BOP_Index av2 = face->getVertex(1); + BOP_Index av3 = face->getVertex(2); + + /* + * Before adding a new face to the face list, be sure it's not + * already there. Duplicate faces have been found to cause at + * least two instances of infinite loops. + * When someone has more time to look into this issue, it's possible + * this code may be removed again. + */ + for(unsigned int idxFace=0;idxFacesize();idxFace++) { + BOP_Face *faceA = (*faces)[idxFace]; + BOP_Index bv1 = faceA->getVertex(0); + BOP_Index bv2 = faceA->getVertex(1); + BOP_Index bv3 = faceA->getVertex(2); + + if( ( av1==bv1 && av2==bv2 && av3==bv3 ) || + ( av1==bv1 && av2==bv3 && av3==bv2 ) || + ( av1==bv2 && av2==bv1 && av3==bv3 ) || + ( av1==bv2 && av2==bv3 && av3==bv1 ) || + ( av1==bv3 && av2==bv2 && av3==bv1 ) || + ( av1==bv3 && av2==bv1 && av3==bv3 ) ) + return; + } + face->setTAG(tag); faces->push_back(face); mesh->addFace(face); -- cgit v1.2.3