Bugfix: fixed an error that caused bad faces triangulation in some

cases.
experimental
jmekaelthas 9 years ago
parent 696b19467f
commit 84a38d1363
  1. 30
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/Face.java

@ -335,17 +335,23 @@ public class Face implements Comparator<Integer> {
return "Face " + indexes; return "Face " + indexes;
} }
/** /**
* The method finds the closest vertex to the one specified by <b>index</b>. * The method finds the closest vertex to the one specified by <b>index</b>.
* If the vertexToIgnore is positive than it will be ignored in the result. * If the vertexToIgnore is positive than it will be ignored in the result.
* The closes vertex must be able to create an edge that is fully contained within the face and does not cross * The closest vertex must be able to create an edge that is fully contained
* any other edges. * within the face and does not cross any other edges. Also if the
* @param index * vertexToIgnore is not negative then the condition that the edge between
* the index of the vertex that needs to have found the nearest neighbour * the found index and the one to ignore is inside the face must also be
* @param indexToIgnore * met.
* the index to ignore in the result (pass -1 if none is to be ignored) *
* @return the index of the closest vertex to the given one * @param index
*/ * the index of the vertex that needs to have found the nearest
* neighbour
* @param indexToIgnore
* the index to ignore in the result (pass -1 if none is to be
* ignored)
* @return the index of the closest vertex to the given one
*/
private int findClosestVertex(int index, int indexToIgnore) { private int findClosestVertex(int index, int indexToIgnore) {
int result = -1; int result = -1;
List<Vector3f> vertices = temporalMesh.getVertices(); List<Vector3f> vertices = temporalMesh.getVertices();
@ -355,7 +361,7 @@ public class Face implements Comparator<Integer> {
if (i != index && i != indexToIgnore) { if (i != index && i != indexToIgnore) {
Vector3f v2 = vertices.get(i); Vector3f v2 = vertices.get(i);
float d = v2.distance(v1); float d = v2.distance(v1);
if (d < distance && this.contains(new Edge(index, i, 0, true, temporalMesh))) { if (d < distance && this.contains(new Edge(index, i, 0, true, temporalMesh)) && (indexToIgnore < 0 || this.contains(new Edge(indexToIgnore, i, 0, true, temporalMesh)))) {
result = i; result = i;
distance = d; distance = d;
} }

Loading…
Cancel
Save