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

Precision issue in index computation in Gu::HeightField::computeCellCoordinates (PxReal to PxU32) #52

Closed
Nodli opened this issue Nov 30, 2022 · 2 comments
Assignees

Comments

@Nodli
Copy link

Nodli commented Nov 30, 2022

Library and Version

PhysX v5.1.0
Release 104.0

Issue

Hi,

There is a precision issue in the computation of the vertex index in Gu::HeightField::computeCellCoordinates.

const PxU32 vertexIndex = PxU32(PxU32(x) * (mData.nbColumns) + PxU32(z));

mData.nbColumns is of type PxReal so the index computation is done in PxReal and only then cast to PxU32. This leads to problems when x, z and nbColumns have large values (~4k x 4k).
A suggested fix is to either use mData.columns like the line below or cast mData.nbColumns directly using PxU32(mData.nbColumns).

A pull request for the same issue was submitted for PhysX 4.1 ( NVIDIAGameWorks/PhysX#574 ) but the modifications that were applied for PhysX 5.1 (the final cast to PxU32) do not fix the problem.

@Nodli Nodli changed the title Precision issue in index computation in Gu::HeightField::computeCellCoordinates (PxF32 to PxU32) Precision issue in index computation in Gu::HeightField::computeCellCoordinates (PxReal to PxU32) Nov 30, 2022
@PierreTerdiman
Copy link

I changed these float members back to integers, so the issue should be fixed for good now. Should appear in a future release.

@Nodli
Copy link
Author

Nodli commented Dec 8, 2022

Thank you, i'm closing this issue.

@Nodli Nodli closed this as completed Dec 8, 2022
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

No branches or pull requests

2 participants