fixed the bug that GetVmapHeight returns incorrect height on terrains(flying units fall below map etc)
also unlocked max ray lenght for getHeight, by default it's 10 yards --HG-- branch : trunk
This commit is contained in:
@@ -1126,7 +1126,7 @@ struct mob_frost_wyrmAI : public hyjal_trashAI
|
||||
|
||||
float x,y,z;
|
||||
m_creature->GetPosition(x,y,z);
|
||||
z = m_creature->GetMap()->GetVmapHeight(x, y, z, true);
|
||||
z = m_creature->GetMap()->GetVmapHeight(x, y, z);
|
||||
m_creature->GetMotionMaster()->MovePoint(0,x,y,z);
|
||||
m_creature->GetMap()->CreatureRelocation(m_creature, x,y,z,0);
|
||||
}
|
||||
@@ -1238,7 +1238,7 @@ struct mob_gargoyleAI : public hyjal_trashAI
|
||||
{
|
||||
float x,y,z;
|
||||
m_creature->GetPosition(x,y,z);
|
||||
z = m_creature->GetMap()->GetVmapHeight(x, y, z, true);
|
||||
z = m_creature->GetMap()->GetVmapHeight(x, y, z);
|
||||
m_creature->GetMotionMaster()->MovePoint(0,x,y,z);
|
||||
m_creature->GetMap()->CreatureRelocation(m_creature, x,y,z,0);
|
||||
hyjal_trashAI::JustDied(victim);
|
||||
|
||||
@@ -399,7 +399,7 @@ struct TRINITY_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI
|
||||
float X = CalculateRandomLocation(pTarget->GetPositionX(), 20);
|
||||
float Y = CalculateRandomLocation(pTarget->GetPositionY(), 20);
|
||||
float Z = pTarget->GetPositionZ();
|
||||
Z = m_creature->GetMap()->GetVmapHeight(X, Y, Z, true);
|
||||
Z = m_creature->GetMap()->GetVmapHeight(X, Y, Z);
|
||||
Creature* DoomBlossom = m_creature->SummonCreature(CREATURE_DOOM_BLOSSOM, X, Y, Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 20000);
|
||||
if (DoomBlossom)
|
||||
{
|
||||
|
||||
@@ -1477,7 +1477,7 @@ bool Creature::FallGround()
|
||||
|
||||
float x, y, z;
|
||||
GetPosition(x, y, z);
|
||||
float ground_Z = GetMap()->GetVmapHeight(x, y, z, true);
|
||||
float ground_Z = GetMap()->GetVmapHeight(x, y, z);
|
||||
if (fabs(ground_Z - z) < 0.1f)
|
||||
return false;
|
||||
|
||||
|
||||
+14
-15
@@ -1994,24 +1994,23 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const
|
||||
}
|
||||
}
|
||||
|
||||
float Map::GetVmapHeight(float x, float y, float z, bool useMaps) const
|
||||
float Map::GetVmapHeight(float x, float y, float z) const
|
||||
{
|
||||
float mapHeight;
|
||||
float vmapHeight;
|
||||
if (useMaps)
|
||||
{
|
||||
mapHeight = GetHeight(x, y, z, false);
|
||||
if (fabs(mapHeight - z) < 0.1)
|
||||
return mapHeight;
|
||||
}
|
||||
else
|
||||
mapHeight = INVALID_HEIGHT;
|
||||
|
||||
mapHeight = GetHeight(x, y, z, false);
|
||||
if (fabs(mapHeight - z) < 0.1)
|
||||
return mapHeight;
|
||||
|
||||
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
|
||||
if (vmgr->isLineOfSightCalcEnabled())
|
||||
bool result = vmgr->getObjectHitPos(GetId(), x, y, z + 2.0f, x, y, mapHeight, x, y, vmapHeight, 0);
|
||||
else
|
||||
return INVALID_HEIGHT;
|
||||
return vmapHeight;
|
||||
if (!vmgr->isLineOfSightCalcEnabled())
|
||||
return mapHeight;
|
||||
|
||||
float vmapHeight = vmgr->getHeight(GetId(), x, y, z + 2.0f, z + 2.0f - mapHeight);
|
||||
if (vmapHeight > VMAP_INVALID_HEIGHT_VALUE)
|
||||
return vmapHeight;
|
||||
|
||||
return mapHeight;
|
||||
}
|
||||
|
||||
uint16 Map::GetAreaFlag(float x, float y, float z) const
|
||||
|
||||
+1
-1
@@ -333,7 +333,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
|
||||
// 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 GetVmapHeight(float x, float y, float z, bool useMaps) const;
|
||||
float GetVmapHeight(float x, float y, float z) const;
|
||||
bool IsInWater(float x, float y, float z, float min_depth = 2.0f) const;
|
||||
|
||||
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data = 0) const;
|
||||
|
||||
+1
-1
@@ -4476,7 +4476,7 @@ bool Player::FallGround(uint8 FallMode)
|
||||
|
||||
float x, y, z;
|
||||
GetPosition(x, y, z);
|
||||
float ground_Z = GetMap()->GetVmapHeight(x, y, z, true);
|
||||
float ground_Z = GetMap()->GetVmapHeight(x, y, z);
|
||||
float z_diff = 0.0f;
|
||||
if ((z_diff = fabs(ground_Z - z)) < 0.1f)
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -5177,7 +5177,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
{
|
||||
float x, y, z;
|
||||
m_caster->GetPosition(x, y, z);
|
||||
float ground_Z = m_caster->GetMap()->GetVmapHeight(x, y, z, true);
|
||||
float ground_Z = m_caster->GetMap()->GetVmapHeight(x, y, z);
|
||||
if (fabs(ground_Z - z) < 0.1f)
|
||||
return SPELL_FAILED_DONT_REPORT;
|
||||
break;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define _IVMAPMANAGER_H
|
||||
|
||||
#include<string>
|
||||
#include "VMapDefinitions.h"
|
||||
|
||||
//===========================================================
|
||||
|
||||
@@ -62,7 +63,7 @@ namespace VMAP
|
||||
virtual void unloadMap(unsigned int pMapId) = 0;
|
||||
|
||||
virtual bool isInLineOfSight(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2) = 0;
|
||||
virtual float getHeight(unsigned int pMapId, float x, float y, float z) = 0;
|
||||
virtual float getHeight(unsigned int pMapId, float x, float y, float z, float ray_lenght = MAX_CAN_FALL_DISTANCE) = 0;
|
||||
/**
|
||||
test if we hit an object. return true if we hit one. rx,ry,rz will hold the hit position or the dest position, if no intersection was found
|
||||
return a position, that is pReduceDist closer to the origin
|
||||
|
||||
@@ -450,14 +450,14 @@ namespace VMAP
|
||||
*/
|
||||
|
||||
//int gGetHeightCounter = 0;
|
||||
float VMapManager::getHeight(unsigned int pMapId, float x, float y, float z)
|
||||
float VMapManager::getHeight(unsigned int pMapId, float x, float y, float z, float ray_lenght)
|
||||
{
|
||||
float height = VMAP_INVALID_HEIGHT_VALUE; //no height
|
||||
if(isHeightCalcEnabled() && iInstanceMapTrees.containsKey(pMapId))
|
||||
{
|
||||
Vector3 pos = convertPositionToInternalRep(x,y,z);
|
||||
MapTree* mapTree = iInstanceMapTrees.get(pMapId);
|
||||
height = mapTree->getHeight(pos);
|
||||
height = mapTree->getHeight(pos, ray_lenght);
|
||||
if(!(height < inf()))
|
||||
{
|
||||
height = VMAP_INVALID_HEIGHT_VALUE; //no height
|
||||
@@ -633,13 +633,12 @@ namespace VMAP
|
||||
|
||||
//=========================================================
|
||||
|
||||
float MapTree::getHeight(const Vector3& pPos)
|
||||
float MapTree::getHeight(const Vector3& pPos, float ray_lenght)
|
||||
{
|
||||
float height = inf();
|
||||
Vector3 dir = Vector3(0,-1,0);
|
||||
Ray ray = Ray::fromOriginAndDirection(pPos, dir); // direction with length of 1
|
||||
float maxDist = VMapDefinitions::getMaxCanFallDistance();
|
||||
float dist = getIntersectionTime(ray, maxDist, false);
|
||||
float dist = getIntersectionTime(ray, ray_lenght, false);
|
||||
if(dist < inf())
|
||||
{
|
||||
height = (pPos + dir * dist).y;
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace VMAP
|
||||
|
||||
bool isInLineOfSight(const G3D::Vector3& pos1, const G3D::Vector3& pos2);
|
||||
bool getObjectHitPos(const G3D::Vector3& pos1, const G3D::Vector3& pos2, G3D::Vector3& pResultHitPos, float pModifyDist);
|
||||
float getHeight(const G3D::Vector3& pPos);
|
||||
float getHeight(const G3D::Vector3& pPos, float ray_lenght);
|
||||
|
||||
bool PrepareTree();
|
||||
bool loadMap(const std::string& pDirFileName, unsigned int pMapTileIdent);
|
||||
@@ -165,7 +165,7 @@ namespace VMAP
|
||||
fill the hit pos and return true, if an object was hit
|
||||
*/
|
||||
bool getObjectHitPos(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float pModifyDist);
|
||||
float getHeight(unsigned int pMapId, float x, float y, float z);
|
||||
float getHeight(unsigned int pMapId, float x, float y, float z, float ray_lenght);
|
||||
|
||||
bool processCommand(char *pCommand); // for debug and extensions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user