aboutsummaryrefslogtreecommitdiff
path: root/src/common/Collision/Maps
diff options
context:
space:
mode:
authorHelloKitty <andrew.blakely@ymail.com>2017-01-21 14:44:31 +0100
committerShauren <shauren.trinity@gmail.com>2018-12-09 14:18:42 +0100
commit46c69df3a7cd3f863a7a3cca59a136a0a5cdec9d (patch)
tree4c7c6df7b9ca316c3086478b5a69127d4a64a769 /src/common/Collision/Maps
parentda3783876b141f716d5daf09f9d69d8248a8382a (diff)
Core/Vmaps: Stop M2s from occluding for spellcast LoS
Closes #18528 (cherry-picked from 01d715eaef99e91f0959dc85fb7f69eb26d01a22)
Diffstat (limited to 'src/common/Collision/Maps')
-rw-r--r--src/common/Collision/Maps/MapTree.cpp20
-rw-r--r--src/common/Collision/Maps/MapTree.h5
2 files changed, 13 insertions, 12 deletions
diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp
index 3ba9c860d6f..ab48c4ebe0c 100644
--- a/src/common/Collision/Maps/MapTree.cpp
+++ b/src/common/Collision/Maps/MapTree.cpp
@@ -33,14 +33,13 @@ using G3D::Vector3;
namespace VMAP
{
-
class MapRayCallback
{
public:
- MapRayCallback(ModelInstance* val): prims(val), hit(false) { }
+ MapRayCallback(ModelInstance* val, ModelIgnoreFlags ignoreFlags): prims(val), hit(false), flags(ignoreFlags) { }
bool operator()(const G3D::Ray& ray, uint32 entry, float& distance, bool pStopAtFirstHit=true)
{
- bool result = prims[entry].intersectRay(ray, distance, pStopAtFirstHit);
+ bool result = prims[entry].intersectRay(ray, distance, pStopAtFirstHit, flags);
if (result)
hit = true;
return result;
@@ -49,6 +48,7 @@ namespace VMAP
protected:
ModelInstance* prims;
bool hit;
+ ModelIgnoreFlags flags;
};
class AreaInfoCallback
@@ -142,10 +142,10 @@ namespace VMAP
Else, pMaxDist is not modified and returns false;
*/
- bool StaticMapTree::getIntersectionTime(const G3D::Ray& pRay, float &pMaxDist, bool pStopAtFirstHit) const
+ bool StaticMapTree::getIntersectionTime(const G3D::Ray& pRay, float &pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const
{
float distance = pMaxDist;
- MapRayCallback intersectionCallBack(iTreeValues);
+ MapRayCallback intersectionCallBack(iTreeValues, ignoreFlags);
iTree.intersectRay(pRay, intersectionCallBack, distance, pStopAtFirstHit);
if (intersectionCallBack.didHit())
pMaxDist = distance;
@@ -153,7 +153,7 @@ namespace VMAP
}
//=========================================================
- bool StaticMapTree::isInLineOfSight(const Vector3& pos1, const Vector3& pos2) const
+ bool StaticMapTree::isInLineOfSight(const Vector3& pos1, const Vector3& pos2, ModelIgnoreFlags ignoreFlag) const
{
float maxDist = (pos2 - pos1).magnitude();
// return false if distance is over max float, in case of cheater teleporting to the end of the universe
@@ -167,7 +167,7 @@ namespace VMAP
return true;
// direction with length of 1
G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1)/maxDist);
- if (getIntersectionTime(ray, maxDist, true))
+ if (getIntersectionTime(ray, maxDist, true, ignoreFlag))
return false;
return true;
@@ -193,7 +193,7 @@ namespace VMAP
Vector3 dir = (pPos2 - pPos1)/maxDist; // direction with length of 1
G3D::Ray ray(pPos1, dir);
float dist = maxDist;
- if (getIntersectionTime(ray, dist, false))
+ if (getIntersectionTime(ray, dist, false, ModelIgnoreFlags::Nothing))
{
pResultHitPos = pPos1 + dir * dist;
if (pModifyDist < 0)
@@ -229,7 +229,7 @@ namespace VMAP
Vector3 dir = Vector3(0, 0, -1);
G3D::Ray ray(pPos, dir); // direction with length of 1
float maxDist = maxSearchDist;
- if (getIntersectionTime(ray, maxDist, false))
+ if (getIntersectionTime(ray, maxDist, false, ModelIgnoreFlags::Nothing))
{
height = pPos.z - maxDist;
}
@@ -371,7 +371,7 @@ namespace VMAP
if (result)
{
// acquire model instance
- WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name);
+ WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name, spawn.flags);
if (!model)
TC_LOG_ERROR("misc", "StaticMapTree::LoadMapTile() : could not acquire WorldModel pointer [%u, %u]", tileX, tileY);
diff --git a/src/common/Collision/Maps/MapTree.h b/src/common/Collision/Maps/MapTree.h
index 122f5dc63eb..9b24c9abb1a 100644
--- a/src/common/Collision/Maps/MapTree.h
+++ b/src/common/Collision/Maps/MapTree.h
@@ -28,6 +28,7 @@ namespace VMAP
class ModelInstance;
class GroupModel;
class VMapManager2;
+ enum class ModelIgnoreFlags : uint32;
struct TC_COMMON_API LocationInfo
{
@@ -65,7 +66,7 @@ namespace VMAP
private:
static TileFileOpenResult OpenMapTileFile(std::string const& basePath, uint32 mapID, uint32 tileX, uint32 tileY, VMapManager2* vm);
- bool getIntersectionTime(const G3D::Ray& pRay, float &pMaxDist, bool pStopAtFirstHit) const;
+ bool getIntersectionTime(const G3D::Ray& pRay, float &pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const;
//bool containsLoadedMapTile(unsigned int pTileIdent) const { return(iLoadedMapTiles.containsKey(pTileIdent)); }
public:
static std::string getTileFileName(uint32 mapID, uint32 tileX, uint32 tileY);
@@ -76,7 +77,7 @@ namespace VMAP
StaticMapTree(uint32 mapID, const std::string &basePath);
~StaticMapTree();
- bool isInLineOfSight(const G3D::Vector3& pos1, const G3D::Vector3& pos2) const;
+ 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;
bool getAreaInfo(G3D::Vector3 &pos, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const;