Jump to content

Bug in GaiaWorldManager.NUtoPTI

Recommended Posts

The method NUtoPTI in GaiaWorldManager can generate a rounding error bug when you are working on terrains far from the origin.  I have a large open world. I was working on terrain tiles located around 3000,6000.  I was getting an error because NUtoPTI was generating a negative number on X, which is invalid for the terrain index it was calculating.  The error occurred in the constructor method, on line 221:
 m_physicalTerrainArray[(int)positionPTI.x, (int)positionPTI.z] = terrain;

The method NUtoPTI  uses Mathf.Floor which will return a -1 if the calculated value is slightly below zero, due to rounding.  Of course, the method could also calculate the wrong index for other terrains, with indexes other than 0,0.  


positionNU.x = Mathf.Floor(positionNU.x + m_NUZeroOffset.x);


positionNU.x = 16f

m_NUZeroOffset.x = 16f

after: positionNU.x = 2.6E-7, due to float imprecision issues when calculating the position or offset.


I fixed this, albeit crudely, by changing the calculation to: positionNU.x = Mathf.Floor(positionNU.x + m_NUZeroOffset.x + 0.01f);


Could you please address this bug in a future release?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

  • Create New...