[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11134] trunk/blender/intern/boolop/intern : Tools:
Ken Hughes
khughes at pacific.edu
Sat Jun 30 23:32:25 CEST 2007
Revision: 11134
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11134
Author: khughes
Date: 2007-06-30 23:32:24 +0200 (Sat, 30 Jun 2007)
Log Message:
-----------
Tools:
------
Bugfix #6847: Previous fix for "spikes" when using booleans caused creation
of faces with only two unique vertices ("eekadoodles"). This patch cleans up
the test for triangles with near-colinear vertices so PHANTOM faces can be
used again, and also adds a hack for now which removes any eekadoodle faces.
I haven't figured out yet exactly how the faces are being created; if I can
do so and fix it the hack will be removed.
Modified Paths:
--------------
trunk/blender/intern/boolop/intern/BOP_Face2Face.cpp
trunk/blender/intern/boolop/intern/BOP_MathUtils.cpp
trunk/blender/intern/boolop/intern/BOP_Merge.cpp
Modified: trunk/blender/intern/boolop/intern/BOP_Face2Face.cpp
===================================================================
--- trunk/blender/intern/boolop/intern/BOP_Face2Face.cpp 2007-06-30 05:58:30 UTC (rev 11133)
+++ trunk/blender/intern/boolop/intern/BOP_Face2Face.cpp 2007-06-30 21:32:24 UTC (rev 11134)
@@ -1,4 +1,7 @@
/**
+ *
+ * $Id$
+ *
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -23,7 +26,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): Marc Freixas, Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -427,17 +430,11 @@
// v2 ~= v3
mesh->replaceVertexIndex(v2,v3);
} else {
-#if 0
- /*
- * for now, don't just remove "co-linear" faces; some of these faces
- * being removed are real and cause other things to break
- */
// all differents
if (BOP_collinear(vertex1,vertex2,vertex3)) {
// collinear triangle
face->setTAG(PHANTOM);
}
-#endif
}
}
}
Modified: trunk/blender/intern/boolop/intern/BOP_MathUtils.cpp
===================================================================
--- trunk/blender/intern/boolop/intern/BOP_MathUtils.cpp 2007-06-30 05:58:30 UTC (rev 11133)
+++ trunk/blender/intern/boolop/intern/BOP_MathUtils.cpp 2007-06-30 21:32:24 UTC (rev 11134)
@@ -1,4 +1,7 @@
/**
+ *
+ * $Id$
+ *
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -23,7 +26,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): Marc Freixas, Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -115,7 +118,12 @@
{
MT_Vector3 v1 = p2 - p1;
MT_Vector3 v2 = p3 - p2;
-
+
+ /* normalize vectors before taking their cross product, so its length
+ * has some actual meaning */
+ v1.normalize();
+ v2.normalize();
+
MT_Vector3 w = v1.cross(v2);
return (BOP_comp(w.x(),0.0) == 0) && (BOP_comp(w.y(),0.0) == 0) && (BOP_comp(w.z(),0.0) == 0);
Modified: trunk/blender/intern/boolop/intern/BOP_Merge.cpp
===================================================================
--- trunk/blender/intern/boolop/intern/BOP_Merge.cpp 2007-06-30 05:58:30 UTC (rev 11133)
+++ trunk/blender/intern/boolop/intern/BOP_Merge.cpp 2007-06-30 21:32:24 UTC (rev 11134)
@@ -1,4 +1,7 @@
/**
+ *
+ * $Id$
+ *
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -23,7 +26,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): Marc Freixas, Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -57,6 +60,32 @@
// Merge faces
mergeFaces();
+ /*
+ * HACK: somehow triangular faces are being created with two vertices the
+ * same. If it's happening in BOP_Mesh::replaceVertexIndex() we should
+ * be catching it, so either it's not happening there or we aren't
+ * catching it (duh). Until we figure this out, this hack cleans things.
+ *
+ * Test for any invalid faces: if any two vertices are the same of a
+ * triangle, the face is broken. Further, I don't believe it's possible
+ * to have any quads at this point, so if we find one send a message
+ * to stdout.
+ */
+
+ BOP_Faces faces = m_mesh->getFaces();
+ const BOP_IT_Faces ifacesIEnd = (faces.end());
+ for(BOP_IT_Faces faceI=faces.begin();faceI!=ifacesIEnd;faceI++) {
+ if ((*faceI)->getTAG() != BROKEN ) {
+ BOP_Index i1 = (*faceI)->getVertex(0);
+ BOP_Index i2 = (*faceI)->getVertex(1);
+ BOP_Index i3 = (*faceI)->getVertex(2);
+ if ( (*faceI)->size() == 4)
+ cout << "BOP_Merge::mergeFaces found a quad: this is an error" << endl;
+ if (i1 == i2 || i2 == i3 || i3 == i1 )
+ (*faceI)->setTAG(BROKEN);
+ }
+ }
+
do {
// Add quads ...
cont = createQuads();
@@ -592,6 +621,7 @@
// Get mesh faces
BOP_Faces faces = m_mesh->getFaces();
+
// Merge mesh triangles
const BOP_IT_Faces facesIEnd = (faces.end()-1);
More information about the Bf-blender-cvs
mailing list