Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong calculation with faceVertexCount? #135

Open
SamuelReithmeir opened this issue Aug 26, 2024 · 0 comments · May be fixed by #136
Open

Wrong calculation with faceVertexCount? #135

SamuelReithmeir opened this issue Aug 26, 2024 · 0 comments · May be fixed by #136

Comments

@SamuelReithmeir
Copy link

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.

@SamuelReithmeir SamuelReithmeir linked a pull request Aug 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@SamuelReithmeir and others