Core-side part for recastnav upgrade:

Corrected values, fixed compile, re-extraction of Mmaps it's required again, mmaps will be updated on wiki.
This commit is contained in:
sucofog
2017-11-15 18:55:04 +01:00
committed by GitHub
parent 17802ab6e5
commit c75ec13191
15 changed files with 95 additions and 56 deletions

View File

@@ -17,7 +17,6 @@
#include "DisableMgr.h"
#include <ace/OS_NS_unistd.h>
uint32 GetLiquidFlags(uint32 /*liquidType*/) { return 0; }
namespace DisableMgr
{
bool IsDisabledFor(DisableType /*type*/, uint32 /*entry*/, Unit const* /*unit*/, uint8 /*flags*/ /*= 0*/) { return false; }
@@ -208,12 +207,14 @@ namespace MMAP
}
/**************************************************************************/
void MapBuilder::getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY)
void MapBuilder::getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY) const
{
maxX = INT_MAX;
maxY = INT_MAX;
minX = INT_MIN;
minY = INT_MIN;
// min and max are initialized to invalid values so the caller iterating the [min, max] range
// will never enter the loop unless valid min/max values are found
maxX = 0;
maxY = 0;
minX = std::numeric_limits<uint32>::max();
minY = std::numeric_limits<uint32>::max();
float bmin[3] = { 0, 0, 0 };
float bmax[3] = { 0, 0, 0 };
@@ -354,7 +355,7 @@ namespace MMAP
void MapBuilder::buildMap(uint32 mapID)
{
#ifndef __APPLE__
printf("[Thread %u] Building map %03u:\n", uint32(ACE_Thread::self()), mapID);
//printf("[Thread %u] Building map %03u:\n", uint32(ACE_Thread::self()), mapID);
#endif
std::set<uint32>* tiles = getTileList(mapID);
@@ -458,7 +459,7 @@ namespace MMAP
//if (tileBits < 1) tileBits = 1; // need at least one bit!
//int polyBits = sizeof(dtPolyRef)*8 - SALT_MIN_BITS - tileBits;
int polyBits = STATIC_POLY_BITS;
int polyBits = DT_POLY_BITS;
int maxTiles = tiles->size();
int maxPolysPerTile = 1 << polyBits;
@@ -570,7 +571,9 @@ namespace MMAP
config.borderSize = config.walkableRadius + 3;
config.maxEdgeLen = VERTEX_PER_TILE + 1; // anything bigger than tileSize
config.walkableHeight = m_bigBaseUnit ? 3 : 6;
config.walkableClimb = m_bigBaseUnit ? 2 : 4; // keep less than walkableHeight
// a value >= 3|6 allows npcs to walk over some fences
// a value >= 4|8 allows npcs to walk over all fences
config.walkableClimb = m_bigBaseUnit ? 2 : 4;
config.minRegionArea = rcSqr(60);
config.mergeRegionArea = rcSqr(50);
config.maxSimplificationError = 1.8f; // eliminates most jagged edges (tiny polygons)
@@ -694,7 +697,7 @@ namespace MMAP
iv.polyMesh = rcAllocPolyMesh();
if (!iv.polyMesh)
{
printf("%s alloc iv.polyMesh FIALED!\n", tileString);
printf("%s alloc iv.polyMesh FAILED!\n", tileString);
delete[] pmmerge;
delete[] dmmerge;
delete[] tiles;
@@ -705,7 +708,7 @@ namespace MMAP
iv.polyMeshDetail = rcAllocPolyMeshDetail();
if (!iv.polyMeshDetail)
{
printf("%s alloc m_dmesh FIALED!\n", tileString);
printf("%s alloc m_dmesh FAILED!\n", tileString);
delete[] pmmerge;
delete[] dmmerge;
delete[] tiles;
@@ -770,12 +773,12 @@ namespace MMAP
if (params.nvp > DT_VERTS_PER_POLYGON)
{
printf("%s Invalid verts-per-polygon value! \n", tileString);
continue;
break;
}
if (params.vertCount >= 0xffff)
{
printf("%s Too many vertices! \n", tileString);
continue;
break;
}
if (!params.vertCount || !params.verts)
{
@@ -783,8 +786,8 @@ namespace MMAP
// loaded but those models don't span into this tile
// message is an annoyance
//printf("%sNo vertices to build tile! \n", tileString);
continue;
printf("%sNo vertices to build tile! \n", tileString);
break;
}
if (!params.polyCount || !params.polys ||
TILES_PER_MAP*TILES_PER_MAP == params.polyCount)
@@ -793,19 +796,19 @@ namespace MMAP
// keep in mind that we do output those into debug info
// drop tiles with only exact count - some tiles may have geometry while having less tiles
printf("%s No polygons to build on tile! \n", tileString);
continue;
break;
}
if (!params.detailMeshes || !params.detailVerts || !params.detailTris)
{
printf("%s No detail mesh to build tile! \n", tileString);
continue;
break;
}
printf("%s Building navmesh tile...\n", tileString);
if (!dtCreateNavMeshData(&params, &navData, &navDataSize))
{
printf("%s Failed building navmesh tile! \n", tileString);
continue;
break;
}
dtTileRef tileRef = 0;
@@ -816,7 +819,7 @@ namespace MMAP
if (!tileRef || dtResult != DT_SUCCESS)
{
printf("%s Failed adding tile to navmesh! \n", tileString);
continue;
break;
}
// file output
@@ -829,7 +832,7 @@ namespace MMAP
sprintf(message, "[Map %03i] Failed to open %s for writing!\n", mapID, fileName);
perror(message);
navMesh->removeTile(tileRef, NULL, NULL);
continue;
break;
}
printf("%s Writing to file...\n", tileString);

View File

@@ -110,7 +110,7 @@ namespace MMAP
void getTileBounds(uint32 tileX, uint32 tileY,
float* verts, int vertCount,
float* bmin, float* bmax);
void getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY);
void getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY) const;
bool shouldSkipMap(uint32 mapID);
bool isTransportMap(uint32 mapID);

View File

@@ -7,11 +7,10 @@
#ifndef _MMAP_COMMON_H
#define _MMAP_COMMON_H
#include "Common.h"
#include <string>
#include <vector>
#include "Common.h"
#ifndef _WIN32
#include <stddef.h>
#include <dirent.h>
@@ -52,7 +51,7 @@ namespace MMAP
if (*++filter == '\0') // wildcard at end of filter means all remaing chars match
return true;
while (true)
for (;;)
{
if (*filter == *str)
break;

View File

@@ -264,7 +264,7 @@ int main(int argc, char** argv)
}
if (!checkDirectories(debugOutput))
return silent ? -3 : finish("Press any key to close...", -3);
return silent ? -3 : finish("Press ENTER to close...", -3);
MapBuilder builder(maxAngle, skipLiquid, skipContinents, skipJunkMaps,
skipBattlegrounds, debugOutput, bigBaseUnit, offMeshInputPath);

View File

@@ -700,7 +700,7 @@ namespace MMAP
uint8 type = NAV_EMPTY;
// convert liquid type to NavTerrain
switch (liquid->GetType())
switch (liquid->GetType() & 3)
{
case 0:
case 1:
@@ -754,12 +754,12 @@ namespace MMAP
}
uint32 liqOffset = meshData.liquidVerts.size() / 3;
for (uint32 i = 0; i < liqVerts.size(); ++i)
meshData.liquidVerts.append(liqVerts[i].y, liqVerts[i].z, liqVerts[i].x);
for (uint32 j = 0; j < liqVerts.size(); ++j)
meshData.liquidVerts.append(liqVerts[j].y, liqVerts[j].z, liqVerts[j].x);
for (uint32 i = 0; i < liqTris.size() / 3; ++i)
for (uint32 j = 0; j < liqTris.size() / 3; ++j)
{
meshData.liquidTris.append(liqTris[i*3+1] + liqOffset, liqTris[i*3+2] + liqOffset, liqTris[i*3] + liqOffset);
meshData.liquidTris.append(liqTris[j*3+1] + liqOffset, liqTris[j*3+2] + liqOffset, liqTris[j*3] + liqOffset);
meshData.liquidType.append(type);
}
}
@@ -894,7 +894,7 @@ namespace MMAP
float p0[3], p1[3];
uint32 mid, tx, ty;
float size;
if (sscanf(buf, "%d %d,%d (%f %f %f) (%f %f %f) %f", &mid, &tx, &ty,
if (sscanf(buf, "%u %u,%u (%f %f %f) (%f %f %f) %f", &mid, &tx, &ty,
&p0[0], &p0[1], &p0[2], &p1[0], &p1[1], &p1[2], &size) != 10)
continue;

View File

@@ -69,11 +69,13 @@ namespace MMAP
TerrainBuilder(bool skipLiquid);
~TerrainBuilder();
TerrainBuilder(const TerrainBuilder &tb) = delete;
void loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData);
bool loadVMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData);
void loadOffMeshConnections(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData, const char* offMeshFilePath);
bool usesLiquids() { return !m_skipLiquid; }
bool usesLiquids() const { return !m_skipLiquid; }
// vert and triangle methods
static void transform(std::vector<G3D::Vector3> &original, std::vector<G3D::Vector3> &transformed,
@@ -109,10 +111,6 @@ namespace MMAP
/// Get the liquid type for a specific position
uint8 getLiquidType(int square, const uint8 liquid_type[16][16]);
// hide parameterless and copy constructor
TerrainBuilder();
TerrainBuilder(const TerrainBuilder &tb);
};
}

View File

@@ -14,7 +14,7 @@
#include "World.h"
// memory management
inline void* dtCustomAlloc(int size, dtAllocHint /*hint*/)
inline void* dtCustomAlloc(size_t size, dtAllocHint /*hint*/)
{
return (void*)new unsigned char[size];
}

View File

@@ -1,7 +1,19 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: http://github.com/azerothcore/azerothcore-wotlk/LICENSE-GPL2
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
* Copyright (C)
* Copyright (C)
*
* 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/>.
*/
#include <iostream>
@@ -26,6 +38,7 @@ namespace VMAP
{
VMapManager2::VMapManager2()
{
GetLiquidFlagsPtr = &GetLiquidFlagsDummy;
}
VMapManager2::~VMapManager2(void)
@@ -76,7 +89,7 @@ namespace VMAP
}
// load one tile (internal use only)
bool VMapManager2::_loadMap(unsigned int mapId, const std::string& basePath, uint32 tileX, uint32 tileY)
bool VMapManager2::_loadMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY)
{
InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree == iInstanceMapTrees.end())
@@ -84,10 +97,10 @@ namespace VMAP
std::string mapFileName = getMapFileName(mapId);
StaticMapTree* newTree = new StaticMapTree(mapId, basePath);
if (!newTree->InitMap(mapFileName, this))
{
delete newTree;
{
delete newTree;
return false;
}
}
instanceTree = iInstanceMapTrees.insert(InstanceTreeMap::value_type(mapId, newTree)).first;
}
@@ -236,7 +249,7 @@ namespace VMAP
floor = info.ground_Z;
ASSERT(floor < std::numeric_limits<float>::max());
type = info.hitModel->GetLiquidType(); // entry from LiquidType.dbc
if (reqLiquidType && !(GetLiquidFlags(type) & reqLiquidType))
if (reqLiquidType && !(GetLiquidFlagsPtr(type) & reqLiquidType))
return false;
if (info.hitInstance->GetLiquidLevel(pos, info, level))
return true;
@@ -276,7 +289,6 @@ namespace VMAP
{
//! Critical section, thread safe access to iLoadedModelFiles
TRINITY_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock);
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
if (model == iLoadedModelFiles.end())
{
@@ -298,4 +310,4 @@ namespace VMAP
return StaticMapTree::CanLoadMap(std::string(basePath), mapId, x, y);
}
} // namespace VMAP
} // namespace VMAP

View File

@@ -1,7 +1,19 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: http://github.com/azerothcore/azerothcore-wotlk/LICENSE-GPL2
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
* Copyright (C)
* Copyright (C)
*
* 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 _VMAPMANAGER2_H
@@ -66,6 +78,8 @@ namespace VMAP
bool _loadMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY);
/* void _unloadMap(uint32 pMapId, uint32 x, uint32 y); */
static uint32 GetLiquidFlagsDummy(uint32) { return 0; }
public:
// public for debug
G3D::Vector3 convertPositionToInternalRep(float x, float y, float z) const;
@@ -102,7 +116,10 @@ namespace VMAP
virtual bool existsMap(const char* basePath, unsigned int mapId, int x, int y);
public:
void getInstanceMapTree(InstanceTreeMap &instanceMapTree);
typedef uint32(*GetLiquidFlagsFn)(uint32 liquidType);
GetLiquidFlagsFn GetLiquidFlagsPtr;
};
}
#endif
#endif

View File

@@ -213,7 +213,7 @@ namespace Trinity
inline bool IsValidMapCoord(float x, float y, float z)
{
return IsValidMapCoord(x, y) && isfinite(z);
return IsValidMapCoord(x, y) && IsValidMapCoord(z);
}
inline bool IsValidMapCoord(float x, float y, float z, float o)

View File

@@ -2012,7 +2012,7 @@ uint32 Map::GetAreaId(float x, float y, float z, bool *isOutdoors) const
atEntry = sAreaTableStore.LookupEntry(wmoEntry->areaId);
}
uint16 areaId;
uint16 areaId = 0;
if (atEntry)
areaId = atEntry->ID;
@@ -2021,7 +2021,7 @@ uint32 Map::GetAreaId(float x, float y, float z, bool *isOutdoors) const
if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
areaId = gmap->getArea(x, y);
// this used while not all *.map files generated (instances)
else
if (!areaId)
areaId = i_mapEntry->linked_zone;
}

View File

@@ -909,7 +909,7 @@ dtStatus PathGenerator::FindSmoothPath(float const* startPos, float const* endPo
// Find movement delta.
float delta[VERTEX_SIZE];
dtVsub(delta, steerPos, iterPos);
float len = dtMathSqrtf(dtVdot(delta,delta));
float len = dtMathSqrtf(dtVdot(delta, delta));
// If the steer target is end of path or off-mesh link, do not move past the location.
if ((endOfPath || offMeshConnection) && len < SMOOTH_PATH_STEP_SIZE)
len = 1.0f;

View File

@@ -55,6 +55,9 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T* owner, bool ini
if (!i_offset)
{
if (i_target->IsWithinDistInMap(owner, CONTACT_DISTANCE))
return;
float allowedRange = MELEE_RANGE;
if ((!initial || (owner->movespline->Finalized() && this->GetMovementGeneratorType() == CHASE_MOTION_TYPE)) && i_target->IsWithinMeleeRange(owner, allowedRange) && i_target->IsWithinLOS(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ()))
return;

View File

@@ -5788,7 +5788,7 @@ SpellCastResult Spell::CheckCast(bool strict)
m_pathFinder = new PathGenerator(m_caster);
m_pathFinder->CalculatePath(pos.m_positionX, pos.m_positionY, pos.m_positionZ+0.15f, false);
G3D::Vector3 endPos = m_pathFinder->GetEndPosition(); // also check distance between target and the point calculated by mmaps
if (m_pathFinder->GetPathType()&PATHFIND_NOPATH || target->GetExactDistSq(endPos.x, endPos.y, endPos.z) > maxdist*maxdist || m_pathFinder->getPathLength() > (40.0f + (m_caster->HasAura(58097) ? 5.0f : 0.0f)))
if (m_pathFinder->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE) || target->GetExactDistSq(endPos.x, endPos.y, endPos.z) > maxdist*maxdist || m_pathFinder->getPathLength() > (40.0f + (m_caster->HasAura(58097) ? 5.0f : 0.0f)))
return SPELL_FAILED_NOPATH;
}
break;

View File

@@ -75,6 +75,7 @@
#include "WhoListCache.h"
#include "AsyncAuctionListing.h"
#include "SavingSystem.h"
#include <VMapManager2.h>
ACE_Atomic_Op<ACE_Thread_Mutex, bool> World::m_stopEvent = false;
uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
@@ -1276,6 +1277,12 @@ void World::SetInitialWorldSettings()
sLog->outString("Initializing Scripts...");
sScriptMgr->Initialize();
///- Initialize VMapManager function pointers (to untangle game/collision circular deps)
if (VMAP::VMapManager2* vmmgr2 = dynamic_cast<VMAP::VMapManager2*>(VMAP::VMapFactory::createOrGetVMapManager()))
{
vmmgr2->GetLiquidFlagsPtr = &GetLiquidFlags;
}
///- Initialize config settings
LoadConfigSettings();