GridLayout.WorldToCell() returned incorrect results

Looks like the grid component added the coordinates with a size/100000 when converting to cell.


Here’s the grid properties.

The position with x -0.00064 was considered as (0,0,0);

The position with x -0.000641 was considered as (-1,0,0);

I hadn’t found anything about this from document;

I didn’t write this code but from what I understand, it has to perform some rounding here at some point for stability/consistency in the conversions. Obviously floating-point does not have infinite precision.

Internally it uses “const float Grid::kGridEpsilon = 0.00001f;” so it sounds like it’s related to that.

For a rectangular grid it’s simply doing a Transform.InversTransformPoint to get the local position then local to cell on it which is where the rounding has to happen.

0.000641 is a tiny value and not a practical rendering value either.

Thank you for your response!

Understanding of this content has a significant impact on how to use grid components, such as how to store some points when organizing them according to the cells in the grid component,because a grid is composed of an infinite number of closely packed cells, rounding on any one cell will disrupt the normal behavior of some other cells,this content provides sufficient reasons for using CellInterpolated coordinates to store points’s positions instead of world coordinates. Perhaps this content should be mentioned in the document?