Core/Maps: restored a hack in gridmap liquid status code to solve precision issues (#29544)

Port From (https://github.com/TrinityCore/TrinityCore/commit/bfb9fd8a2c777651c99568ba9c6a2d4a3a468955)
This commit is contained in:
hondacrx
2024-02-05 13:37:54 -05:00
parent 3deec204bf
commit 34457719bc
+4 -2
View File
@@ -513,6 +513,8 @@ namespace Game.Maps
return _liquidMap[cx_int * _liquidWidth + cy_int]; return _liquidMap[cx_int * _liquidWidth + cy_int];
} }
static float GROUND_LEVEL_OFFSET_HACK = 0.02f; // due to floating point precision issues, we have to resort to a small hack to fix inconsistencies in liquids
// Get water state on map // Get water state on map
public ZLiquidStatus GetLiquidStatus(float x, float y, float z, LiquidHeaderTypeFlags? reqLiquidType, LiquidData data, float collisionHeight) public ZLiquidStatus GetLiquidStatus(float x, float y, float z, LiquidHeaderTypeFlags? reqLiquidType, LiquidData data, float collisionHeight)
{ {
@@ -577,11 +579,11 @@ namespace Game.Maps
// Get water level // Get water level
float liquid_level = _liquidMap != null ? _liquidMap[lx_int * _liquidWidth + ly_int] : _liquidLevel; float liquid_level = _liquidMap != null ? _liquidMap[lx_int * _liquidWidth + ly_int] : _liquidLevel;
// Get ground level (sub 0.2 for fix some errors) // Get ground level (sub 0.02 for fix some errors)
float ground_level = GetHeight(x, y); float ground_level = GetHeight(x, y);
// Check water level and ground level // Check water level and ground level
if (liquid_level < ground_level || z < ground_level) if (liquid_level < (ground_level - GROUND_LEVEL_OFFSET_HACK) || z < (ground_level - GROUND_LEVEL_OFFSET_HACK))
return ZLiquidStatus.NoWater; return ZLiquidStatus.NoWater;
// All ok in water . store data // All ok in water . store data