Skip to content

Wrong calculation with faceVertexCount? #135

Description

@SamuelReithmeir

I just stumbled over a problem with FaceVertexCount, i get an invalid memory access.
A sample would be:
face0: 3 vertices
face1: 4 vertices
face2: 5 vertices
this results in a total IndexCount of 12

when adding that mesh declaration i get a invalid memory access (i use XAtlas in c# using swig).
After looking at the code i found this code:

polygon[i] = DecodeIndex(meshDecl.indexFormat, meshDecl.indexData, meshDecl.indexOffset, face * faceVertexCount + i);

According to my understanding face * faceVertexCount + i seems to be a logic error. To explain:
This seems to calculate the offset/beginning of the indices of this face and add i. But the problem is that it assumes that all faces before also have the same faceVertexCount, which destroys the entire purpose of having faceVertexCount be an array in the first place.

Please correct me if i misunderstand the logik here, but i will provide a PR, which will change the logic here to a variable which will sum up the previous faceVertexCounts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions