diff --git a/engine/src/core/com/jme3/util/TangentBinormalGenerator.java b/engine/src/core/com/jme3/util/TangentBinormalGenerator.java index 36d2e4a8c..e982e9665 100644 --- a/engine/src/core/com/jme3/util/TangentBinormalGenerator.java +++ b/engine/src/core/com/jme3/util/TangentBinormalGenerator.java @@ -179,7 +179,7 @@ public class TangentBinormalGenerator { mesh.getMode() + " is not supported."); } - processTriangleData(mesh, vertices, approxTangents); + processTriangleData(mesh, vertices, approxTangents,splitMirrored); //if the mesh has a bind pose, we need to generate the bind pose for the tangent buffer if (mesh.getBuffer(Type.BindPosePosition) != null) { @@ -597,7 +597,7 @@ public class TangentBinormalGenerator { (FastMath.abs(u.y - v.y) < tolerance); } - private static ArrayList linkVertices(Mesh mesh) { + private static ArrayList linkVertices(Mesh mesh, boolean splitMirrored) { ArrayList vertexMap = new ArrayList(); FloatBuffer vertexBuffer = mesh.getFloatBuffer(Type.Position); @@ -618,19 +618,20 @@ public class TangentBinormalGenerator { boolean found = false; //Nehon 07/07/2013 //Removed this part, joining splitted vertice to compute tangent space makes no sense to me - //separate vertice should have separate tangent space -// for (int j = 0; j < vertexMap.size(); j++) { -// VertexInfo vertexInfo = vertexMap.get(j); -// if (approxEqual(vertexInfo.position, position) && -// approxEqual(vertexInfo.normal, normal) && -// approxEqual(vertexInfo.texCoord, texCoord)) -// { -// vertexInfo.indices.add(i); -// found = true; -// break; -// } -// } - + //separate vertice should have separate tangent space + if(!splitMirrored){ + for (int j = 0; j < vertexMap.size(); j++) { + VertexInfo vertexInfo = vertexMap.get(j); + if (approxEqual(vertexInfo.position, position) && + approxEqual(vertexInfo.normal, normal) && + approxEqual(vertexInfo.texCoord, texCoord)) + { + vertexInfo.indices.add(i); + found = true; + break; + } + } + } if (!found) { VertexInfo vertexInfo = new VertexInfo(position.clone(), normal.clone(), texCoord.clone()); vertexInfo.indices.add(i); @@ -642,8 +643,8 @@ public class TangentBinormalGenerator { } private static void processTriangleData(Mesh mesh, List vertices, - boolean approxTangent) { - ArrayList vertexMap = linkVertices(mesh); + boolean approxTangent, boolean splitMirrored) { + ArrayList vertexMap = linkVertices(mesh,splitMirrored); FloatBuffer tangents = BufferUtils.createFloatBuffer(vertices.size() * 4);