aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/Collision/Maps/MMapDefines.h19
-rw-r--r--src/server/game/Movement/PathGenerator.cpp6
-rw-r--r--src/tools/mmaps_generator/MapBuilder.cpp26
-rw-r--r--src/tools/mmaps_generator/MapBuilder.h4
-rw-r--r--src/tools/mmaps_generator/PathGenerator.cpp20
5 files changed, 40 insertions, 35 deletions
diff --git a/src/common/Collision/Maps/MMapDefines.h b/src/common/Collision/Maps/MMapDefines.h
index e12c8cac49e..6298775ba6f 100644
--- a/src/common/Collision/Maps/MMapDefines.h
+++ b/src/common/Collision/Maps/MMapDefines.h
@@ -51,17 +51,22 @@ enum NavArea
NAV_AREA_EMPTY = 0,
// areas 1-60 will be used for destructible areas (currently skipped in vmaps, WMO with flag 1)
// ground is the highest value to make recast choose ground over water when merging surfaces very close to each other (shallow water would be walkable)
- NAV_AREA_GROUND = 63,
- NAV_AREA_WATER = 62,
- NAV_AREA_MAGMA_SLIME = 61 // don't need to differentiate between them
+ NAV_AREA_GROUND_STEEP = 11,
+ NAV_AREA_GROUND = 10,
+ NAV_AREA_WATER = 9,
+ NAV_AREA_MAGMA_SLIME = 8, // don't need to differentiate between them
+ NAV_AREA_MAX_VALUE = NAV_AREA_GROUND_STEEP,
+ NAV_AREA_MIN_VALUE = NAV_AREA_MAGMA_SLIME,
+ NAV_AREA_ALL_MASK = 0x3F // max allowed value
};
enum NavTerrainFlag
{
- NAV_EMPTY = 0x00,
- NAV_GROUND = 1 << (63 - NAV_AREA_GROUND),
- NAV_WATER = 1 << (63 - NAV_AREA_WATER),
- NAV_MAGMA_SLIME = 1 << (63 - NAV_AREA_MAGMA_SLIME)
+ NAV_EMPTY = 0x00,
+ NAV_GROUND_STEEP = 1 << (NAV_AREA_MAX_VALUE - NAV_AREA_GROUND_STEEP),
+ NAV_GROUND = 1 << (NAV_AREA_MAX_VALUE - NAV_AREA_GROUND),
+ NAV_WATER = 1 << (NAV_AREA_MAX_VALUE - NAV_AREA_WATER),
+ NAV_MAGMA_SLIME = 1 << (NAV_AREA_MAX_VALUE - NAV_AREA_MAGMA_SLIME)
};
#endif // MMapDefines_h__
diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp
index 0effe2a5d87..a4b15baadb3 100644
--- a/src/server/game/Movement/PathGenerator.cpp
+++ b/src/server/game/Movement/PathGenerator.cpp
@@ -679,6 +679,7 @@ void PathGenerator::UpdateFilter()
// allow creatures to cheat and use different movement types if they are moved
// forcefully into terrain they can't normally move in
if (Unit const* _sourceUnit = _source->ToUnit())
+ {
if (_sourceUnit->IsInWater() || _sourceUnit->IsUnderWater())
{
uint16 includedFlags = _filter.getIncludeFlags();
@@ -688,6 +689,11 @@ void PathGenerator::UpdateFilter()
_filter.setIncludeFlags(includedFlags);
}
+
+ if (Creature const* _sourceCreature = _source->ToCreature())
+ if (_sourceCreature->IsInCombat() || _sourceCreature->IsInEvadeMode())
+ _filter.setIncludeFlags(_filter.getIncludeFlags() | NAV_GROUND_STEEP);
+ }
}
NavTerrainFlag PathGenerator::GetNavTerrain(float x, float y, float z)
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp
index 6e3adc79a04..1b83daf1c1c 100644
--- a/src/tools/mmaps_generator/MapBuilder.cpp
+++ b/src/tools/mmaps_generator/MapBuilder.cpp
@@ -31,7 +31,7 @@
namespace MMAP
{
- MapBuilder::MapBuilder(float maxWalkableAngle, bool skipLiquid,
+ MapBuilder::MapBuilder(bool skipLiquid,
bool skipContinents, bool skipJunkMaps, bool skipBattlegrounds,
bool debugOutput, bool bigBaseUnit, int mapid, char const* offMeshFilePath) :
m_terrainBuilder (nullptr),
@@ -40,7 +40,6 @@ namespace MMAP
m_skipContinents (skipContinents),
m_skipJunkMaps (skipJunkMaps),
m_skipBattlegrounds (skipBattlegrounds),
- m_maxWalkableAngle (maxWalkableAngle),
m_bigBaseUnit (bigBaseUnit),
m_mapid (mapid),
m_totalTiles (0u),
@@ -588,16 +587,26 @@ namespace MMAP
}
// mark all walkable tiles, both liquids and solids
+
+ /* we want to have triangles with slope less than walkableSlopeAngleNotSteep (<= 55) to have NAV_AREA_GROUND
+ * and with slope between walkableSlopeAngleNotSteep and walkableSlopeAngle (55 < .. <= 70) to have NAV_AREA_GROUND_STEEP.
+ * we achieve this using recast API: memset everything to NAV_AREA_GROUND_STEEP, call rcClearUnwalkableTriangles with 70 so
+ * any area above that will get RC_NULL_AREA (unwalkable), then call rcMarkWalkableTriangles with 55 to set NAV_AREA_GROUND
+ * on anything below 55 . Players and idle Creatures can use NAV_AREA_GROUND, while Creatures in combat can use NAV_AREA_GROUND_STEEP.
+ */
unsigned char* triFlags = new unsigned char[tTriCount];
- memset(triFlags, NAV_AREA_GROUND, tTriCount*sizeof(unsigned char));
+ memset(triFlags, NAV_AREA_GROUND_STEEP, tTriCount*sizeof(unsigned char));
rcClearUnwalkableTriangles(m_rcContext, tileCfg.walkableSlopeAngle, tVerts, tVertCount, tTris, tTriCount, triFlags);
+ rcMarkWalkableTriangles(m_rcContext, tileCfg.walkableSlopeAngleNotSteep, tVerts, tVertCount, tTris, tTriCount, triFlags, NAV_AREA_GROUND);
rcRasterizeTriangles(m_rcContext, tVerts, tVertCount, tTris, triFlags, tTriCount, *tile.solid, config.walkableClimb);
delete[] triFlags;
rcFilterLowHangingWalkableObstacles(m_rcContext, config.walkableClimb, *tile.solid);
- rcFilterLedgeSpans(m_rcContext, tileCfg.walkableHeight, tileCfg.walkableClimb, *tile.solid);
+ // disabled as it ignores walkableSlopeAngle settings
+ //rcFilterLedgeSpans(m_rcContext, tileCfg.walkableHeight, tileCfg.walkableClimb, *tile.solid);
rcFilterWalkableLowHeightSpans(m_rcContext, tileCfg.walkableHeight, *tile.solid);
+ // add liquid triangles
rcRasterizeTriangles(m_rcContext, lVerts, lVertCount, lTris, lTriFlags, lTriCount, *tile.solid, config.walkableClimb);
// compact heightfield spans
@@ -702,10 +711,10 @@ namespace MMAP
// TODO: special flags for DYNAMIC polygons, ie surfaces that can be turned on and off
for (int i = 0; i < iv.polyMesh->npolys; ++i)
{
- if (uint8 area = iv.polyMesh->areas[i] & RC_WALKABLE_AREA)
+ if (uint8 area = iv.polyMesh->areas[i] & NAV_AREA_ALL_MASK)
{
- if (area >= NAV_AREA_MAGMA_SLIME)
- iv.polyMesh->flags[i] = 1 << (63 - area);
+ if (area >= NAV_AREA_MIN_VALUE)
+ iv.polyMesh->flags[i] = 1 << (NAV_AREA_MAX_VALUE - area);
else
iv.polyMesh->flags[i] = NAV_GROUND; // TODO: these will be dynamic in future
}
@@ -978,7 +987,8 @@ namespace MMAP
config.maxVertsPerPoly = DT_VERTS_PER_POLYGON;
config.cs = tileConfig.BASE_UNIT_DIM;
config.ch = tileConfig.BASE_UNIT_DIM;
- config.walkableSlopeAngle = m_maxWalkableAngle;
+ config.walkableSlopeAngle = 85;
+ config.walkableSlopeAngleNotSteep = 55;
config.tileSize = tileConfig.VERTEX_PER_TILE;
config.walkableRadius = m_bigBaseUnit ? 1 : 2;
config.borderSize = config.walkableRadius + 3;
diff --git a/src/tools/mmaps_generator/MapBuilder.h b/src/tools/mmaps_generator/MapBuilder.h
index f2fd5d296d7..312d3c07786 100644
--- a/src/tools/mmaps_generator/MapBuilder.h
+++ b/src/tools/mmaps_generator/MapBuilder.h
@@ -96,8 +96,7 @@ namespace MMAP
class MapBuilder
{
public:
- MapBuilder(float maxWalkableAngle = 70.f,
- bool skipLiquid = false,
+ MapBuilder(bool skipLiquid = false,
bool skipContinents = false,
bool skipJunkMaps = true,
bool skipBattlegrounds = false,
@@ -164,7 +163,6 @@ namespace MMAP
bool m_skipJunkMaps;
bool m_skipBattlegrounds;
- float m_maxWalkableAngle;
bool m_bigBaseUnit;
int32 m_mapid;
diff --git a/src/tools/mmaps_generator/PathGenerator.cpp b/src/tools/mmaps_generator/PathGenerator.cpp
index 9625b1d7f1f..2e9f3913edf 100644
--- a/src/tools/mmaps_generator/PathGenerator.cpp
+++ b/src/tools/mmaps_generator/PathGenerator.cpp
@@ -99,7 +99,6 @@ bool handleArgs(int argc, char** argv,
int &mapnum,
int &tileX,
int &tileY,
- float &maxAngle,
bool &skipLiquid,
bool &skipContinents,
bool &skipJunkMaps,
@@ -114,19 +113,7 @@ bool handleArgs(int argc, char** argv,
char* param = nullptr;
for (int i = 1; i < argc; ++i)
{
- if (strcmp(argv[i], "--maxAngle") == 0)
- {
- param = argv[++i];
- if (!param)
- return false;
-
- float maxangle = atof(param);
- if (maxangle <= 90.f && maxangle >= 45.f)
- maxAngle = maxangle;
- else
- printf("invalid option for '--maxAngle', using default\n");
- }
- else if (strcmp(argv[i], "--threads") == 0)
+ if (strcmp(argv[i], "--threads") == 0)
{
param = argv[++i];
if (!param)
@@ -353,7 +340,6 @@ int main(int argc, char** argv)
unsigned int threads = std::thread::hardware_concurrency();
int mapnum = -1;
- float maxAngle = 70.0f;
int tileX = -1, tileY = -1;
bool skipLiquid = false,
skipContinents = false,
@@ -366,7 +352,7 @@ int main(int argc, char** argv)
char* file = nullptr;
bool validParam = handleArgs(argc, argv, mapnum,
- tileX, tileY, maxAngle,
+ tileX, tileY,
skipLiquid, skipContinents, skipJunkMaps, skipBattlegrounds,
debugOutput, silent, bigBaseUnit, offMeshInputPath, file, threads);
@@ -400,7 +386,7 @@ int main(int argc, char** argv)
return itr != _liquidTypes.end() ? (1 << itr->second) : 0;
};
- MapBuilder builder(maxAngle, skipLiquid, skipContinents, skipJunkMaps,
+ MapBuilder builder(skipLiquid, skipContinents, skipJunkMaps,
skipBattlegrounds, debugOutput, bigBaseUnit, mapnum, offMeshInputPath);
uint32 start = getMSTime();