diff options
| author | silver1ce <none@none> | 2010-01-06 12:15:02 +0200 |
|---|---|---|
| committer | silver1ce <none@none> | 2010-01-06 12:15:02 +0200 |
| commit | f82d5cb3fcef169cf7a62f83935fa6d6b105589d (patch) | |
| tree | 690e156be323518c0c2ad5372f01684097b5e2f7 /src/shared/vmap | |
| parent | 4a0af0314ee066f37ecb2a7fb8096ae8180dc966 (diff) | |
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
Diffstat (limited to 'src/shared/vmap')
| -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 |
3 files changed, 8 insertions, 8 deletions
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 |
