aboutsummaryrefslogtreecommitdiff
path: root/src/common/Collision/Maps
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/Collision/Maps')
-rw-r--r--src/common/Collision/Maps/MapDefines.h17
-rw-r--r--src/common/Collision/Maps/MapTree.cpp64
-rw-r--r--src/common/Collision/Maps/MapTree.h4
3 files changed, 51 insertions, 34 deletions
diff --git a/src/common/Collision/Maps/MapDefines.h b/src/common/Collision/Maps/MapDefines.h
index 4935e991259..50f7e93e4c3 100644
--- a/src/common/Collision/Maps/MapDefines.h
+++ b/src/common/Collision/Maps/MapDefines.h
@@ -1,3 +1,20 @@
+/*
+ * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef _MAPDEFINES_H
#define _MAPDEFINES_H
diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp
index 313a95d855b..04f914fb4f1 100644
--- a/src/common/Collision/Maps/MapTree.cpp
+++ b/src/common/Collision/Maps/MapTree.cpp
@@ -35,26 +35,26 @@ namespace VMAP
class MapRayCallback
{
public:
- MapRayCallback(ModelInstance* val, ModelIgnoreFlags ignoreFlags): prims(val), hit(false), flags(ignoreFlags) { }
- bool operator()(const G3D::Ray& ray, uint32 entry, float& distance, bool pStopAtFirstHit=true)
+ 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, flags);
if (result)
hit = true;
return result;
}
- bool didHit() { return hit; }
- protected:
- ModelInstance* prims;
- bool hit;
- ModelIgnoreFlags flags;
+ bool didHit() { return hit; }
+ protected:
+ ModelInstance* prims;
+ bool hit;
+ ModelIgnoreFlags flags;
};
class AreaInfoCallback
{
public:
- AreaInfoCallback(ModelInstance* val): prims(val) { }
- void operator()(const Vector3& point, uint32 entry)
+ AreaInfoCallback(ModelInstance* val) : prims(val) { }
+ void operator()(Vector3 const& point, uint32 entry)
{
#ifdef VMAP_DEBUG
TC_LOG_DEBUG("maps", "AreaInfoCallback: trying to intersect '%s'", prims[entry].name.c_str());
@@ -69,8 +69,8 @@ namespace VMAP
class LocationInfoCallback
{
public:
- LocationInfoCallback(ModelInstance* val, LocationInfo &info): prims(val), locInfo(info), result(false) { }
- void operator()(const Vector3& point, uint32 entry)
+ LocationInfoCallback(ModelInstance* val, LocationInfo& info) : prims(val), locInfo(info), result(false) { }
+ void operator()(Vector3 const& point, uint32 entry)
{
#ifdef VMAP_DEBUG
TC_LOG_DEBUG("maps", "LocationInfoCallback: trying to intersect '%s'", prims[entry].name.c_str());
@@ -80,7 +80,7 @@ namespace VMAP
}
ModelInstance* prims;
- LocationInfo &locInfo;
+ LocationInfo& locInfo;
bool result;
};
@@ -96,7 +96,7 @@ namespace VMAP
return tilefilename.str();
}
- bool StaticMapTree::getAreaInfo(Vector3 &pos, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const
+ bool StaticMapTree::getAreaInfo(Vector3& pos, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const
{
AreaInfoCallback intersectionCallBack(iTreeValues);
iTree.intersectPoint(pos, intersectionCallBack);
@@ -112,17 +112,17 @@ namespace VMAP
return false;
}
- bool StaticMapTree::GetLocationInfo(const Vector3 &pos, LocationInfo &info) const
+ bool StaticMapTree::GetLocationInfo(Vector3 const& pos, LocationInfo& info) const
{
LocationInfoCallback intersectionCallBack(iTreeValues, info);
iTree.intersectPoint(pos, intersectionCallBack);
return intersectionCallBack.result;
}
- StaticMapTree::StaticMapTree(uint32 mapID, const std::string &basePath)
+ StaticMapTree::StaticMapTree(uint32 mapID, std::string const& basePath)
: iMapID(mapID), iTreeValues(nullptr), iNTreeValues(0), iBasePath(basePath)
{
- if (iBasePath.length() > 0 && iBasePath[iBasePath.length()-1] != '/' && iBasePath[iBasePath.length()-1] != '\\')
+ if (iBasePath.length() > 0 && iBasePath[iBasePath.length() - 1] != '/' && iBasePath[iBasePath.length() - 1] != '\\')
{
iBasePath.push_back('/');
}
@@ -141,7 +141,7 @@ namespace VMAP
Else, pMaxDist is not modified and returns false;
*/
- bool StaticMapTree::getIntersectionTime(const G3D::Ray& pRay, float &pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const
+ bool StaticMapTree::getIntersectionTime(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const
{
float distance = pMaxDist;
MapRayCallback intersectionCallBack(iTreeValues, ignoreFlags);
@@ -152,7 +152,7 @@ namespace VMAP
}
//=========================================================
- bool StaticMapTree::isInLineOfSight(const Vector3& pos1, const Vector3& pos2, ModelIgnoreFlags ignoreFlag) const
+ bool StaticMapTree::isInLineOfSight(Vector3 const& pos1, Vector3 const& 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
@@ -165,7 +165,7 @@ namespace VMAP
if (maxDist < 1e-10f)
return true;
// direction with length of 1
- G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1)/maxDist);
+ G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1) / maxDist);
if (getIntersectionTime(ray, maxDist, true, ignoreFlag))
return false;
@@ -177,9 +177,9 @@ namespace VMAP
Return the hit pos or the original dest pos
*/
- bool StaticMapTree::getObjectHitPos(const Vector3& pPos1, const Vector3& pPos2, Vector3& pResultHitPos, float pModifyDist) const
+ bool StaticMapTree::getObjectHitPos(Vector3 const& pPos1, Vector3 const& pPos2, Vector3& pResultHitPos, float pModifyDist) const
{
- bool result=false;
+ bool result = false;
float maxDist = (pPos2 - pPos1).magnitude();
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too
ASSERT(maxDist < std::numeric_limits<float>::max());
@@ -189,7 +189,7 @@ namespace VMAP
pResultHitPos = pPos2;
return false;
}
- Vector3 dir = (pPos2 - pPos1)/maxDist; // direction with length of 1
+ Vector3 dir = (pPos2 - pPos1) / maxDist; // direction with length of 1
G3D::Ray ray(pPos1, dir);
float dist = maxDist;
if (getIntersectionTime(ray, dist, false, ModelIgnoreFlags::Nothing))
@@ -199,7 +199,7 @@ namespace VMAP
{
if ((pResultHitPos - pPos1).magnitude() > -pModifyDist)
{
- pResultHitPos = pResultHitPos + dir*pModifyDist;
+ pResultHitPos = pResultHitPos + dir * pModifyDist;
}
else
{
@@ -208,7 +208,7 @@ namespace VMAP
}
else
{
- pResultHitPos = pResultHitPos + dir*pModifyDist;
+ pResultHitPos = pResultHitPos + dir * pModifyDist;
}
result = true;
}
@@ -222,7 +222,7 @@ namespace VMAP
//=========================================================
- float StaticMapTree::getHeight(const Vector3& pPos, float maxSearchDist) const
+ float StaticMapTree::getHeight(Vector3 const& pPos, float maxSearchDist) const
{
float height = G3D::finf();
Vector3 dir = Vector3(0, 0, -1);
@@ -258,10 +258,10 @@ namespace VMAP
}
//=========================================================
- LoadResult StaticMapTree::CanLoadMap(const std::string &vmapPath, uint32 mapID, uint32 tileX, uint32 tileY, VMapManager2* vm)
+ LoadResult StaticMapTree::CanLoadMap(const std::string& vmapPath, uint32 mapID, uint32 tileX, uint32 tileY, VMapManager2* vm)
{
std::string basePath = vmapPath;
- if (basePath.length() > 0 && basePath[basePath.length()-1] != '/' && basePath[basePath.length()-1] != '\\')
+ if (basePath.length() > 0 && basePath[basePath.length() - 1] != '/' && basePath[basePath.length() - 1] != '\\')
basePath.push_back('/');
std::string fullname = basePath + VMapManager2::getMapFileName(mapID);
@@ -377,7 +377,7 @@ namespace VMAP
uint32 numSpawns = 0;
if (result && fread(&numSpawns, sizeof(uint32), 1, fileResult.File) != 1)
result = false;
- for (uint32 i=0; i<numSpawns && result; ++i)
+ for (uint32 i = 0; i < numSpawns && result; ++i)
{
// read model spawns
ModelSpawn spawn;
@@ -446,14 +446,14 @@ namespace VMAP
TileFileOpenResult fileResult = OpenMapTileFile(iBasePath, iMapID, tileX, tileY, vm);
if (fileResult.File)
{
- bool result=true;
+ bool result = true;
char chunk[8];
if (!readChunk(fileResult.File, chunk, VMAP_MAGIC, 8))
result = false;
uint32 numSpawns;
if (fread(&numSpawns, sizeof(uint32), 1, fileResult.File) != 1)
result = false;
- for (uint32 i=0; i<numSpawns && result; ++i)
+ for (uint32 i = 0; i < numSpawns && result; ++i)
{
// read model spawns
ModelSpawn spawn;
@@ -471,7 +471,7 @@ namespace VMAP
{
uint32 referencedNode = spawnIndex->second;
if (!iLoadedSpawns.count(referencedNode))
- TC_LOG_ERROR("misc", "StaticMapTree::UnloadMapTile() : trying to unload non-referenced model '%s' (ID:%u)", spawn.name.c_str(), spawn.ID);
+ TC_LOG_ERROR("misc", "StaticMapTree::UnloadMapTile() : trying to unload non-referenced model '%s' (ID:%u)", spawn.name.c_str(), spawn.ID);
else if (--iLoadedSpawns[referencedNode] == 0)
{
iTreeValues[referencedNode].setUnloaded();
@@ -488,7 +488,7 @@ namespace VMAP
"Map: " + std::to_string(iMapID) + " TileX: " + std::to_string(tileX) + " TileY: " + std::to_string(tileY));
}
- void StaticMapTree::getModelInstances(ModelInstance* &models, uint32 &count)
+ void StaticMapTree::getModelInstances(ModelInstance*& models, uint32& count)
{
models = iTreeValues;
count = iNTreeValues;
diff --git a/src/common/Collision/Maps/MapTree.h b/src/common/Collision/Maps/MapTree.h
index a9eb70c6bab..d2012ea7a30 100644
--- a/src/common/Collision/Maps/MapTree.h
+++ b/src/common/Collision/Maps/MapTree.h
@@ -34,8 +34,8 @@ namespace VMAP
{
LocationInfo(): rootId(-1), hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::finf()) { }
int32 rootId;
- const ModelInstance* hitInstance;
- const GroupModel* hitModel;
+ ModelInstance const* hitInstance;
+ GroupModel const* hitModel;
float ground_Z;
};