diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp | 4 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/outland/black_temple/boss_teron_gorefiend.cpp | 2 | ||||
-rw-r--r-- | src/game/Creature.cpp | 2 | ||||
-rw-r--r-- | src/game/Map.cpp | 29 | ||||
-rw-r--r-- | src/game/Map.h | 2 | ||||
-rw-r--r-- | src/game/Player.cpp | 2 | ||||
-rw-r--r-- | src/game/Spell.cpp | 2 | ||||
-rw-r--r-- | src/shared/vmap/IVMapManager.h | 3 | ||||
-rw-r--r-- | src/shared/vmap/VMapManager.cpp | 9 | ||||
-rw-r--r-- | src/shared/vmap/VMapManager.h | 4 |
10 files changed, 29 insertions, 30 deletions
diff --git a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp index 3757c753814..3550e1c956e 100644 --- a/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp +++ b/src/bindings/scripts/scripts/kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp @@ -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); diff --git a/src/bindings/scripts/scripts/outland/black_temple/boss_teron_gorefiend.cpp b/src/bindings/scripts/scripts/outland/black_temple/boss_teron_gorefiend.cpp index cd758269ffc..9d04cca9650 100644 --- a/src/bindings/scripts/scripts/outland/black_temple/boss_teron_gorefiend.cpp +++ b/src/bindings/scripts/scripts/outland/black_temple/boss_teron_gorefiend.cpp @@ -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) { diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 818e01bb396..9fcd1cd48ac 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -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; diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 8e72be7ad5e..4fe35bd889b 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -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 diff --git a/src/game/Map.h b/src/game/Map.h index 494618baa8e..a1958677807 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -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; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 8c98e1c0876..ed728429f1e 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 9aa54f9b14e..6db68f9a92c 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -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; diff --git a/src/shared/vmap/IVMapManager.h b/src/shared/vmap/IVMapManager.h index 243a15aef73..71ef5f72c6f 100644 --- a/src/shared/vmap/IVMapManager.h +++ b/src/shared/vmap/IVMapManager.h @@ -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 diff --git a/src/shared/vmap/VMapManager.cpp b/src/shared/vmap/VMapManager.cpp index a059f267f2e..655bd77abfc 100644 --- a/src/shared/vmap/VMapManager.cpp +++ b/src/shared/vmap/VMapManager.cpp @@ -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; diff --git a/src/shared/vmap/VMapManager.h b/src/shared/vmap/VMapManager.h index bfeba3cfe67..9646a377bfc 100644 --- a/src/shared/vmap/VMapManager.h +++ b/src/shared/vmap/VMapManager.h @@ -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 |