Skip to content

Commit

Permalink
Fixed MikktSpaceTangentGenerator that was not replacing existing Tang…
Browse files Browse the repository at this point in the history
…ent buffers on the mesh. That could cause crashes when the old tangent buffer did not have the same amount of components
  • Loading branch information
Nehon committed Dec 30, 2016
1 parent 8d818a2 commit bf2369a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Expand Up @@ -21,13 +21,10 @@ public class MikkTSpaceImpl implements MikkTSpaceContext {

public MikkTSpaceImpl(Mesh mesh) {
this.mesh = mesh;
VertexBuffer tangentBuffer = mesh.getBuffer(VertexBuffer.Type.Tangent);
if(tangentBuffer == null){
FloatBuffer fb = BufferUtils.createFloatBuffer(mesh.getVertexCount() * 4);
mesh.setBuffer(VertexBuffer.Type.Tangent, 4, fb);
}

//TODO ensure the Tangent buffer exists, else create one.
//replacing any existing tangent buffer, if you came here you want them new.
mesh.clearBuffer(VertexBuffer.Type.Tangent);
FloatBuffer fb = BufferUtils.createFloatBuffer(mesh.getVertexCount() * 4);
mesh.setBuffer(VertexBuffer.Type.Tangent, 4, fb);
}

@Override
Expand Down
Expand Up @@ -512,7 +512,7 @@ static void MergeVertsSlow(int piTriList_in_and_out[], final MikkTSpaceContext m
}
}

//TODO Nehon : Not used...seemsit's used in the original version if the structure to store the data in the regular method failed...
//TODO Nehon : Not used...seems it's used in the original version if the structure to store the data in the regular method failed...
static void generateSharedVerticesIndexListSlow(int piTriList_in_and_out[], final MikkTSpaceContext mikkTSpace, final int iNrTrianglesIn) {
int iNumUniqueVerts = 0;
for (int t = 0; t < iNrTrianglesIn; t++) {
Expand Down

0 comments on commit bf2369a

Please sign in to comment.