aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Collision/DynamicTree.cpp13
-rw-r--r--src/common/Collision/DynamicTree.h1
-rw-r--r--src/common/Collision/Management/IVMapManager.h3
-rw-r--r--src/common/Collision/Management/VMapManager2.cpp19
-rw-r--r--src/common/Collision/Management/VMapManager2.h1
-rw-r--r--src/common/Collision/Maps/MapTree.cpp13
-rw-r--r--src/common/Collision/Maps/MapTree.h1
7 files changed, 51 insertions, 0 deletions
diff --git a/src/common/Collision/DynamicTree.cpp b/src/common/Collision/DynamicTree.cpp
index 96378ef9c0d..a69d54c7f9a 100644
--- a/src/common/Collision/DynamicTree.cpp
+++ b/src/common/Collision/DynamicTree.cpp
@@ -254,3 +254,16 @@ float DynamicMapTree::getHeight(float x, float y, float z, float maxSearchDist,
else
return -G3D::finf();
}
+
+float DynamicMapTree::getCeil(float x, float y, float z, float maxSearchDist, uint32 phasemask) const
+{
+ G3D::Vector3 v(x, y, z);
+ G3D::Ray r(v, G3D::Vector3(0, 0, 1));
+ DynamicTreeIntersectionCallback callback(phasemask);
+ impl->intersectZAllignedRay(r, callback, maxSearchDist);
+
+ if (callback.didHit())
+ return v.z + maxSearchDist;
+
+ return G3D::finf();
+}
diff --git a/src/common/Collision/DynamicTree.h b/src/common/Collision/DynamicTree.h
index 9b7d5f15e20..aa7a4bb3d2a 100644
--- a/src/common/Collision/DynamicTree.h
+++ b/src/common/Collision/DynamicTree.h
@@ -51,6 +51,7 @@ public:
float pModifyDist) const;
float getHeight(float x, float y, float z, float maxSearchDist, uint32 phasemask) const;
+ float getCeil(float x, float y, float z, float maxSearchDist, uint32 phasemask) const;
void insert(GameObjectModel const&);
void remove(GameObjectModel const&);
diff --git a/src/common/Collision/Management/IVMapManager.h b/src/common/Collision/Management/IVMapManager.h
index e9aae51a025..7fa9ddb12e3 100644
--- a/src/common/Collision/Management/IVMapManager.h
+++ b/src/common/Collision/Management/IVMapManager.h
@@ -49,6 +49,8 @@ namespace VMAP
#define VMAP_INVALID_HEIGHT -100000.0f // for check
#define VMAP_INVALID_HEIGHT_VALUE -200000.0f // real assigned value in unknown height case
+ #define VMAP_INVALID_CEIL_VALUE 200000.0f
+ #define VMAP_INVALID_CEIL 100000.0f
struct AreaAndLiquidData
{
@@ -92,6 +94,7 @@ namespace VMAP
virtual bool isInLineOfSight(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, ModelIgnoreFlags ignoreFlags) = 0;
virtual float getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist) = 0;
+ virtual float getCeil(unsigned int /*pMapId*/, float /*x*/, float /*y*/, float /*z*/, float /*maxSearchDist*/) { return VMAP_INVALID_CEIL_VALUE; }
/**
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/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp
index 5b9cb34874b..922d68140d3 100644
--- a/src/common/Collision/Management/VMapManager2.cpp
+++ b/src/common/Collision/Management/VMapManager2.cpp
@@ -234,6 +234,25 @@ namespace VMAP
return VMAP_INVALID_HEIGHT_VALUE;
}
+ float VMapManager2::getCeil(unsigned int mapId, float x, float y, float z, float maxSearchDist)
+ {
+ if (isHeightCalcEnabled() && !IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_HEIGHT))
+ {
+ InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId);
+ if (instanceTree != iInstanceMapTrees.end())
+ {
+ Vector3 pos = convertPositionToInternalRep(x, y, z);
+ float height = instanceTree->second->getCeil(pos, maxSearchDist);
+ if (!(height < G3D::finf()))
+ return height = VMAP_INVALID_CEIL_VALUE; // No height
+
+ return height;
+ }
+ }
+
+ return VMAP_INVALID_CEIL_VALUE;
+ }
+
bool VMapManager2::getAreaInfo(unsigned int mapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const
{
if (!IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_AREAFLAG))
diff --git a/src/common/Collision/Management/VMapManager2.h b/src/common/Collision/Management/VMapManager2.h
index 831383ac555..b50348b8928 100644
--- a/src/common/Collision/Management/VMapManager2.h
+++ b/src/common/Collision/Management/VMapManager2.h
@@ -113,6 +113,7 @@ namespace VMAP
*/
bool getObjectHitPos(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float modifyDist) override;
float getHeight(unsigned int mapId, float x, float y, float z, float maxSearchDist) override;
+ float getCeil(unsigned int mapId, float x, float y, float z, float maxSearchDist) override;
bool processCommand(char* /*command*/) override { return false; } // for debug and extensions
diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp
index 3a927acc310..c96adb6c87c 100644
--- a/src/common/Collision/Maps/MapTree.cpp
+++ b/src/common/Collision/Maps/MapTree.cpp
@@ -236,6 +236,19 @@ namespace VMAP
return(height);
}
+ float StaticMapTree::getCeil(const G3D::Vector3 & pPos, float maxSearchDist) const
+ {
+ float height = G3D::finf();
+ Vector3 dir = Vector3(0, 0, 1);
+ G3D::Ray ray(pPos, dir); // direction with length of 1
+ float maxDist = maxSearchDist;
+ if (getIntersectionTime(ray, maxDist, false, ModelIgnoreFlags::Nothing))
+ {
+ height = pPos.z + maxDist;
+ }
+ return(height);
+ }
+
//=========================================================
LoadResult StaticMapTree::CanLoadMap(const std::string &vmapPath, uint32 mapID, uint32 tileX, uint32 tileY)
{
diff --git a/src/common/Collision/Maps/MapTree.h b/src/common/Collision/Maps/MapTree.h
index 48470bf0261..186f1120915 100644
--- a/src/common/Collision/Maps/MapTree.h
+++ b/src/common/Collision/Maps/MapTree.h
@@ -75,6 +75,7 @@ namespace VMAP
bool isInLineOfSight(const G3D::Vector3& pos1, const G3D::Vector3& pos2, ModelIgnoreFlags ignoreFlags) const;
bool getObjectHitPos(const G3D::Vector3& pos1, const G3D::Vector3& pos2, G3D::Vector3& pResultHitPos, float pModifyDist) const;
float getHeight(const G3D::Vector3& pPos, float maxSearchDist) const;
+ float getCeil(const G3D::Vector3& pPos, float maxSearchDist) const;
bool getAreaInfo(G3D::Vector3 &pos, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const;
bool GetLocationInfo(const G3D::Vector3 &pos, LocationInfo &info) const;