Skip to content

MikktspaceTangentGenerator should ignore meshes without triangles #1919

@stephengold

Description

@stephengold

The experimental tangent generator in jme3-core assumes that all meshes are composed of triangles. If you feed it a mesh whose mode is Mesh.Mode.Points or Mesh.Mode.Lines, it will usually crash with a BufferUnderflowException:

    java.nio.BufferUnderflowException
        at java.base/java.nio.Buffer.nextGetIndex(Buffer.java:699)
        at java.base/java.nio.DirectFloatBufferU.get(DirectFloatBufferU.java:324)
        at com.jme3.util.mikktspace.MikkTSpaceImpl.getPosition(MikkTSpaceImpl.java:77)
        at com.jme3.util.mikktspace.MikktspaceTangentGenerator.getPosition(MikktspaceTangentGenerator.java:719)
        at com.jme3.util.mikktspace.MikktspaceTangentGenerator.generateSharedVerticesIndexList(MikktspaceTangentGenerator.java:286)
        at com.jme3.util.mikktspace.MikktspaceTangentGenerator.genTangSpace(MikktspaceTangentGenerator.java:164)
        at com.jme3.util.mikktspace.MikktspaceTangentGenerator.genTangSpaceDefault(MikktspaceTangentGenerator.java:126)
        at com.jme3.util.mikktspace.MikktspaceTangentGenerator.generate(MikktspaceTangentGenerator.java:118)
  

A mesh composed entirely of lines or points doesn't need tangents. Since MikktspaceTangentGenerator processes models containing multiple geometries, it should quietly skip any geometries without triangles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that is supposed to work, but doesn't. More severe than a "defect".

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions