}
return true;
}
public static void getPlaneEquationsFromVertices(ObjectArrayList<Vector3f> vertices, ObjectArrayList<Vector4f> planeEquationsOut) {
Vector4f planeEquation = Stack.alloc(Vector4f.class);
Vector3f edge0 = Stack.alloc(Vector3f.class), edge1 = Stack.alloc(Vector3f.class);
Vector3f tmp = Stack.alloc(Vector3f.class);
int numvertices = vertices.size();
// brute force:
for (int i = 0; i < numvertices; i++) {
Vector3f N1 = vertices.getQuick(i);
for (int j = i + 1; j < numvertices; j++) {
Vector3f N2 = vertices.getQuick(j);
for (int k = j + 1; k < numvertices; k++) {
Vector3f N3 = vertices.getQuick(k);
edge0.sub(N2, N1);
edge1.sub(N3, N1);
float normalSign = 1f;
for (int ww = 0; ww < 2; ww++) {
tmp.cross(edge0, edge1);
planeEquation.x = normalSign * tmp.x;
planeEquation.y = normalSign * tmp.y;
planeEquation.z = normalSign * tmp.z;
if (VectorUtil.lengthSquared3(planeEquation) > 0.0001f) {
VectorUtil.normalize3(planeEquation);
if (notExist(planeEquation, planeEquationsOut)) {
planeEquation.w = -VectorUtil.dot3(planeEquation, N1);
// check if inside, and replace supportingVertexOut if needed
if (areVerticesBehindPlane(planeEquation, vertices, 0.01f)) {
planeEquationsOut.add(new Vector4f(planeEquation));
}
}
}
normalSign = -1f;
}