Fix index computation in Gu::HeightField::computeCellCoordinates from PxF32 to PxU32 #574
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The vertex index in Gu::HeightField::computeCellCoordinates is computed in 32-bit floating point and the lack of precision causes indexing errors. Indexing errors of 1 start appearing on GuHeightField with a size between 4000x4000 and 5000x5000.
For example a GuHeighField with 8193 columns can see x = 5720 and z = 7826 which means vertexIndex should be 5720*8193+7826 = 46871786 but the floating point representation only allows 46871784 or 46871788 as values.
Wrong indexing causes issues when trying to compute normals or determine the orientation of the tesselation of a GuHeightField.