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

Fix index computation in Gu::HeightField::computeCellCoordinates from PxF32 to PxU32 #574

Open
wants to merge 1 commit into
base: 4.1
Choose a base branch
from

Conversation

Nodli
Copy link

@Nodli Nodli commented Jun 27, 2022

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.

@Nodli Nodli changed the title Fix index computation from PxF32 to PxU32 Fix index computation in Gu::HeightField::computeCellCoordinates from PxF32 to PxU32 Jun 27, 2022
@Nodli
Copy link
Author

Nodli commented Jun 27, 2022

@kstorey-nvidia
Copy link

Thanks for reporting this. The fix looks good. Looking into the origins of this bug, it seems it stems from trying to avoid a performance penalty converting floats to ints on Xbox 360.

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 this pull request may close these issues.

2 participants