void BspConverter::getVerticesFromPlaneEquations(const std::vector<SimdVector3>& planeEquations , std::vector<SimdVector3>& verticesOut ) { const int numbrushes = planeEquations.size(); // brute force: for (int i=0;i<numbrushes;i++) { const SimdVector3& N1 = planeEquations[i]; for (int j=i+1;j<numbrushes;j++) { const SimdVector3& N2 = planeEquations[j]; for (int k=j+1;k<numbrushes;k++) { const SimdVector3& N3 = planeEquations[k]; SimdVector3 n2n3; n2n3 = N2.cross(N3); SimdVector3 n3n1; n3n1 = N3.cross(N1); SimdVector3 n1n2; n1n2 = N1.cross(N2); if ( ( n2n3.length2() > 0.0001f ) && ( n3n1.length2() > 0.0001f ) && ( n1n2.length2() > 0.0001f ) ) { //point P out of 3 plane equations: // d1 ( N2 * N3 ) + d2 ( N3 * N1 ) + d3 ( N1 * N2 ) //P = ------------------------------------------------------------------------- // N1 . ( N2 * N3 ) float quotient = (N1.dot(n2n3)); if (SimdFabs(quotient) > 0.000001f) { quotient = -1.f / quotient; n2n3 *= N1[3]; n3n1 *= N2[3]; n1n2 *= N3[3]; SimdVector3 potentialVertex = n2n3; potentialVertex += n3n1; potentialVertex += n1n2; potentialVertex *= quotient; //check if inside, and replace supportingVertexOut if needed if (isInside(planeEquations,potentialVertex,0.1f)) { verticesOut.push_back(potentialVertex); } } } } } } }
inline bool TestFuzzyZero(SimdScalar x) { return SimdFabs(x) < 0.0001f; }