Core/Maps: fixed a floating point issue when retrieving minHeight values from GridMap
This commit is contained in:
1 parent
c926327077
commit
5a08b65cef
2 files changed
+10
-3
No files matched your search
@@ -181,8 +181,8 @@ namespace Trinity
|
||||
double x_offset = (double(x) - center_offset)/size;
|
||||
double y_offset = (double(y) - center_offset)/size;
|
||||
|
||||
int x_val = int(x_offset + CENTER_VAL + 0.5f);
|
||||
int y_val = int(y_offset + CENTER_VAL + 0.5f);
|
||||
int x_val = int(x_offset + CENTER_VAL + 0.5);
|
||||
int y_val = int(y_offset + CENTER_VAL + 0.5);
|
||||
return RET_TYPE(x_val, y_val);
|
||||
}
|
||||
|
||||
@@ -191,6 +191,13 @@ namespace Trinity
|
||||
return Compute<GridCoord, CENTER_GRID_ID>(x, y, CENTER_GRID_OFFSET, SIZE_OF_GRIDS);
|
||||
}
|
||||
|
||||
inline GridCoord ComputeGridCoordSimple(float x, float y)
|
||||
{
|
||||
int gx = (int)(CENTER_GRID_ID - x / SIZE_OF_GRIDS);
|
||||
int gy = (int)(CENTER_GRID_ID - y / SIZE_OF_GRIDS);
|
||||
return GridCoord((MAX_NUMBER_OF_GRIDS - 1) - gx, (MAX_NUMBER_OF_GRIDS - 1) - gy);
|
||||
}
|
||||
|
||||
inline CellCoord ComputeCellCoord(float x, float y)
|
||||
{
|
||||
return Compute<CellCoord, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL);
|
||||
|
||||
@@ -2271,7 +2271,7 @@ float GridMap::getMinHeight(float x, float y) const
|
||||
if (!_minHeightPlanes)
|
||||
return -500.0f;
|
||||
|
||||
GridCoord gridCoord = Trinity::ComputeGridCoord(x, y);
|
||||
GridCoord gridCoord = Trinity::ComputeGridCoordSimple(x, y);
|
||||
|
||||
int32 doubleGridX = int32(std::floor(-(x - MAP_HALFSIZE) / CENTER_GRID_OFFSET));
|
||||
int32 doubleGridY = int32(std::floor(-(y - MAP_HALFSIZE) / CENTER_GRID_OFFSET));
|
||||
|
||||
Reference in new issue
Block a user