Add option for search distance to getHeight() functions and make Creature::FallGround() use VMaps properly. (Fix by Lynx3d)

This finally prevents flying creatures from falling to infinity (basically instantly diappearing) in several instances, aswell
as prevent creatures from falling inside larger solid object around the world.

--HG--
branch : trunk
This commit is contained in:
click
2010-07-27 17:29:33 +02:00
parent dbd76ef9ed
commit e5b7f6ad01
9 changed files with 14 additions and 21 deletions
+2 -2
View File
@@ -1680,7 +1680,7 @@ inline GridMap *Map::GetGrid(float x, float y)
return GridMaps[gx][gy];
}
float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const
float Map::GetHeight(float x, float y, float z, bool pUseVmaps, float maxSearchDist) const
{
// find raw .map surface under Z coordinates
float mapHeight;
@@ -1704,7 +1704,7 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const
if (vmgr->isHeightCalcEnabled())
{
// look from a bit higher pos to find the floor
vmapHeight = vmgr->getHeight(GetId(), x, y, z + 2.0f);
vmapHeight = vmgr->getHeight(GetId(), x, y, z + 2.0f, maxSearchDist);
}
else
vmapHeight = VMAP_INVALID_HEIGHT_VALUE;
+3 -1
View File
@@ -234,6 +234,8 @@ typedef UNORDERED_MAP<Creature*, CreatureMover> CreatureMoveList;
#define MAX_HEIGHT 100000.0f // can be use for find ground height at surface
#define INVALID_HEIGHT -100000.0f // for check, must be equal to VMAP_INVALID_HEIGHT, real value for unknown height is VMAP_INVALID_HEIGHT_VALUE
#define MAX_FALL_DISTANCE 250000.0f // "unlimited fall" to find VMap ground if it is available, just larger than MAX_HEIGHT - INVALID_HEIGHT
#define DEFAULT_HEIGHT_SEARCH 10.0f // default search distance to find height at nearby locations
#define MIN_UNLOAD_DELAY 1 // immediate unload
typedef std::map<uint32/*leaderDBGUID*/, CreatureGroup*> CreatureGroupHolderType;
@@ -313,7 +315,7 @@ class Map : public GridRefManager<NGridType>
// some calls like isInWater should not use vmaps due to processor power
// can return INVALID_HEIGHT if under z+2 z coord not found height
float GetHeight(float x, float y, float z, bool pCheckVMap=true) const;
float GetHeight(float x, float y, float z, bool pCheckVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const;
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data = 0) const;