mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-17 16:10:49 +01:00
Update recast to 1dd5cf1883
Fix 2 warnings.
These changes have no effect on MMAPs and it's not needed to re-extact them.
357 lines
12 KiB
Diff
357 lines
12 KiB
Diff
From 37b4c6d3d78ea676d8b300a282013a27a51912c1 Mon Sep 17 00:00:00 2001
|
|
From: jackpoz <giacomopoz@gmail.com>
|
|
Date: Fri, 20 Jun 2014 23:15:04 +0200
|
|
Subject: [PATCH] Add custom trinitycore changes
|
|
|
|
---
|
|
Detour/Include/DetourNavMesh.h | 76 ++++++++++++------------------------
|
|
Detour/Source/DetourNavMesh.cpp | 30 +++++---------
|
|
Detour/Source/DetourNavMeshQuery.cpp | 5 ++-
|
|
Detour/Source/DetourNode.cpp | 29 ++++----------
|
|
Recast/Include/Recast.h | 8 ++--
|
|
Recast/Source/RecastMeshDetail.cpp | 2 +-
|
|
Recast/Source/RecastRegion.cpp | 2 +-
|
|
7 files changed, 50 insertions(+), 102 deletions(-)
|
|
|
|
diff --git a/Detour/Include/DetourNavMesh.h b/Detour/Include/DetourNavMesh.h
|
|
index 1060845..782ddbc 100644
|
|
--- a/Detour/Include/DetourNavMesh.h
|
|
+++ b/Detour/Include/DetourNavMesh.h
|
|
@@ -22,39 +22,35 @@
|
|
#include "DetourAlloc.h"
|
|
#include "DetourStatus.h"
|
|
|
|
-// Undefine (or define in a build cofnig) the following line to use 64bit polyref.
|
|
-// Generally not needed, useful for very large worlds.
|
|
-// Note: tiles build using 32bit refs are not compatible with 64bit refs!
|
|
-//#define DT_POLYREF64 1
|
|
-
|
|
-#ifdef DT_POLYREF64
|
|
-// TODO: figure out a multiplatform version of uint64_t
|
|
-// - maybe: https://code.google.com/p/msinttypes/
|
|
-// - or: http://www.azillionmonkeys.com/qed/pstdint.h
|
|
+
|
|
+// Edited by TC
|
|
+#if defined(WIN32) && !defined(__MINGW32__)
|
|
+/// Do not rename back to uint64. Otherwise mac complains about typedef redefinition
|
|
+typedef unsigned __int64 uint64_d;
|
|
+#else
|
|
#include <stdint.h>
|
|
+#ifndef uint64_t
|
|
+#ifdef __linux__
|
|
+#include <linux/types.h>
|
|
+#endif
|
|
#endif
|
|
+/// Do not rename back to uint64. Otherwise mac complains about typedef redefinition
|
|
+typedef uint64_t uint64_d;
|
|
+#endif
|
|
|
|
// Note: If you want to use 64-bit refs, change the types of both dtPolyRef & dtTileRef.
|
|
// It is also recommended that you change dtHashRef() to a proper 64-bit hash.
|
|
|
|
+// Edited by TC
|
|
+// We cannot have over 31 bits for either tile nor poly
|
|
+// without changing polyCount to use 64bits too.
|
|
/// A handle to a polygon within a navigation mesh tile.
|
|
/// @ingroup detour
|
|
-#ifdef DT_POLYREF64
|
|
-static const unsigned int DT_SALT_BITS = 16;
|
|
-static const unsigned int DT_TILE_BITS = 28;
|
|
-static const unsigned int DT_POLY_BITS = 20;
|
|
-typedef uint64_t dtPolyRef;
|
|
-#else
|
|
-typedef unsigned int dtPolyRef;
|
|
-#endif
|
|
+typedef uint64_d dtPolyRef; // Edited by TC
|
|
|
|
/// A handle to a tile within a navigation mesh.
|
|
/// @ingroup detour
|
|
-#ifdef DT_POLYREF64
|
|
-typedef uint64_t dtTileRef;
|
|
-#else
|
|
-typedef unsigned int dtTileRef;
|
|
-#endif
|
|
+typedef uint64_d dtTileRef; // Edited by TC
|
|
|
|
/// The maximum number of vertices per navigation polygon.
|
|
/// @ingroup detour
|
|
@@ -94,6 +90,12 @@ static const unsigned int DT_OFFMESH_CON_BIDIR = 1;
|
|
/// @ingroup detour
|
|
static const int DT_MAX_AREAS = 64;
|
|
|
|
+static const int STATIC_SALT_BITS = 12;
|
|
+static const int STATIC_TILE_BITS = 21;
|
|
+static const int STATIC_POLY_BITS = 31;
|
|
+// we cannot have over 31 bits for either tile nor poly
|
|
+// without changing polyCount to use 64bits too.
|
|
+
|
|
/// Tile flags used for various functions and fields.
|
|
/// For an example, see dtNavMesh::addTile().
|
|
enum dtTileFlags
|
|
@@ -511,11 +513,7 @@ public:
|
|
/// @param[in] ip The index of the polygon within the tile.
|
|
inline dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
|
|
{
|
|
-#ifdef DT_POLYREF64
|
|
- return ((dtPolyRef)salt << (DT_POLY_BITS+DT_TILE_BITS)) | ((dtPolyRef)it << DT_POLY_BITS) | (dtPolyRef)ip;
|
|
-#else
|
|
return ((dtPolyRef)salt << (m_polyBits+m_tileBits)) | ((dtPolyRef)it << m_polyBits) | (dtPolyRef)ip;
|
|
-#endif
|
|
}
|
|
|
|
/// Decodes a standard polygon reference.
|
|
@@ -527,21 +525,12 @@ public:
|
|
/// @see #encodePolyId
|
|
inline void decodePolyId(dtPolyRef ref, unsigned int& salt, unsigned int& it, unsigned int& ip) const
|
|
{
|
|
-#ifdef DT_POLYREF64
|
|
- const dtPolyRef saltMask = ((dtPolyRef)1<<DT_SALT_BITS)-1;
|
|
- const dtPolyRef tileMask = ((dtPolyRef)1<<DT_TILE_BITS)-1;
|
|
- const dtPolyRef polyMask = ((dtPolyRef)1<<DT_POLY_BITS)-1;
|
|
- salt = (unsigned int)((ref >> (DT_POLY_BITS+DT_TILE_BITS)) & saltMask);
|
|
- it = (unsigned int)((ref >> DT_POLY_BITS) & tileMask);
|
|
- ip = (unsigned int)(ref & polyMask);
|
|
-#else
|
|
const dtPolyRef saltMask = ((dtPolyRef)1<<m_saltBits)-1;
|
|
const dtPolyRef tileMask = ((dtPolyRef)1<<m_tileBits)-1;
|
|
const dtPolyRef polyMask = ((dtPolyRef)1<<m_polyBits)-1;
|
|
salt = (unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
|
|
it = (unsigned int)((ref >> m_polyBits) & tileMask);
|
|
ip = (unsigned int)(ref & polyMask);
|
|
-#endif
|
|
}
|
|
|
|
/// Extracts a tile's salt value from the specified polygon reference.
|
|
@@ -550,13 +539,8 @@ public:
|
|
/// @see #encodePolyId
|
|
inline unsigned int decodePolyIdSalt(dtPolyRef ref) const
|
|
{
|
|
-#ifdef DT_POLYREF64
|
|
- const dtPolyRef saltMask = ((dtPolyRef)1<<DT_SALT_BITS)-1;
|
|
- return (unsigned int)((ref >> (DT_POLY_BITS+DT_TILE_BITS)) & saltMask);
|
|
-#else
|
|
const dtPolyRef saltMask = ((dtPolyRef)1<<m_saltBits)-1;
|
|
return (unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
|
|
-#endif
|
|
}
|
|
|
|
/// Extracts the tile's index from the specified polygon reference.
|
|
@@ -565,13 +549,8 @@ public:
|
|
/// @see #encodePolyId
|
|
inline unsigned int decodePolyIdTile(dtPolyRef ref) const
|
|
{
|
|
-#ifdef DT_POLYREF64
|
|
- const dtPolyRef tileMask = ((dtPolyRef)1<<DT_TILE_BITS)-1;
|
|
- return (unsigned int)((ref >> DT_POLY_BITS) & tileMask);
|
|
-#else
|
|
const dtPolyRef tileMask = ((dtPolyRef)1<<m_tileBits)-1;
|
|
return (unsigned int)((ref >> m_polyBits) & tileMask);
|
|
-#endif
|
|
}
|
|
|
|
/// Extracts the polygon's index (within its tile) from the specified polygon reference.
|
|
@@ -580,13 +559,8 @@ public:
|
|
/// @see #encodePolyId
|
|
inline unsigned int decodePolyIdPoly(dtPolyRef ref) const
|
|
{
|
|
-#ifdef DT_POLYREF64
|
|
- const dtPolyRef polyMask = ((dtPolyRef)1<<DT_POLY_BITS)-1;
|
|
- return (unsigned int)(ref & polyMask);
|
|
-#else
|
|
const dtPolyRef polyMask = ((dtPolyRef)1<<m_polyBits)-1;
|
|
return (unsigned int)(ref & polyMask);
|
|
-#endif
|
|
}
|
|
|
|
/// @}
|
|
@@ -645,11 +619,9 @@ private:
|
|
dtMeshTile* m_nextFree; ///< Freelist of tiles.
|
|
dtMeshTile* m_tiles; ///< List of tiles.
|
|
|
|
-#ifndef DT_POLYREF64
|
|
unsigned int m_saltBits; ///< Number of salt bits in the tile ID.
|
|
unsigned int m_tileBits; ///< Number of tile bits in the tile ID.
|
|
unsigned int m_polyBits; ///< Number of poly bits in the tile ID.
|
|
-#endif
|
|
};
|
|
|
|
/// Allocates a navigation mesh object using the Detour allocator.
|
|
diff --git a/Detour/Source/DetourNavMesh.cpp b/Detour/Source/DetourNavMesh.cpp
|
|
index d353d08..e8a679b 100644
|
|
--- a/Detour/Source/DetourNavMesh.cpp
|
|
+++ b/Detour/Source/DetourNavMesh.cpp
|
|
@@ -193,13 +193,11 @@ dtNavMesh::dtNavMesh() :
|
|
m_tileLutMask(0),
|
|
m_posLookup(0),
|
|
m_nextFree(0),
|
|
- m_tiles(0)
|
|
+ m_tiles(0),
|
|
+ m_saltBits(0),
|
|
+ m_tileBits(0),
|
|
+ m_polyBits(0)
|
|
{
|
|
-#ifndef DT_POLYREF64
|
|
- m_saltBits = 0;
|
|
- m_tileBits = 0;
|
|
- m_polyBits = 0;
|
|
-#endif
|
|
memset(&m_params, 0, sizeof(dtNavMeshParams));
|
|
m_orig[0] = 0;
|
|
m_orig[1] = 0;
|
|
@@ -250,17 +248,11 @@ dtStatus dtNavMesh::init(const dtNavMeshParams* params)
|
|
m_nextFree = &m_tiles[i];
|
|
}
|
|
|
|
- // Init ID generator values.
|
|
-#ifndef DT_POLYREF64
|
|
- m_tileBits = dtIlog2(dtNextPow2((unsigned int)params->maxTiles));
|
|
- m_polyBits = dtIlog2(dtNextPow2((unsigned int)params->maxPolys));
|
|
- // Only allow 31 salt bits, since the salt mask is calculated using 32bit uint and it will overflow.
|
|
- m_saltBits = dtMin((unsigned int)31, 32 - m_tileBits - m_polyBits);
|
|
-
|
|
- if (m_saltBits < 10)
|
|
- return DT_FAILURE | DT_INVALID_PARAM;
|
|
-#endif
|
|
-
|
|
+ // Edited by TC
|
|
+ m_tileBits = STATIC_TILE_BITS;
|
|
+ m_polyBits = STATIC_POLY_BITS;
|
|
+ m_saltBits = STATIC_SALT_BITS;
|
|
+
|
|
return DT_SUCCESS;
|
|
}
|
|
|
|
@@ -1242,11 +1234,7 @@ dtStatus dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSiz
|
|
tile->offMeshCons = 0;
|
|
|
|
// Update salt, salt should never be zero.
|
|
-#ifdef DT_POLYREF64
|
|
- tile->salt = (tile->salt+1) & ((1<<DT_SALT_BITS)-1);
|
|
-#else
|
|
tile->salt = (tile->salt+1) & ((1<<m_saltBits)-1);
|
|
-#endif
|
|
if (tile->salt == 0)
|
|
tile->salt++;
|
|
|
|
diff --git a/Detour/Source/DetourNavMeshQuery.cpp b/Detour/Source/DetourNavMeshQuery.cpp
|
|
index 5fbc83e..fbf3724 100644
|
|
--- a/Detour/Source/DetourNavMeshQuery.cpp
|
|
+++ b/Detour/Source/DetourNavMeshQuery.cpp
|
|
@@ -100,7 +100,8 @@ inline float dtQueryFilter::getCost(const float* pa, const float* pb,
|
|
}
|
|
#endif
|
|
|
|
-static const float H_SCALE = 0.999f; // Search heuristic scale.
|
|
+// Edited by TC
|
|
+static const float H_SCALE = 2.0f; // Search heuristic scale.
|
|
|
|
|
|
dtNavMeshQuery* dtAllocNavMeshQuery()
|
|
@@ -3501,7 +3502,7 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen
|
|
dtVsub(hitNormal, centerPos, hitPos);
|
|
dtVnormalize(hitNormal);
|
|
|
|
- *hitDist = dtMathSqrtf(radiusSqr);
|
|
+ *hitDist = sqrtf(radiusSqr);
|
|
|
|
return status;
|
|
}
|
|
diff --git a/Detour/Source/DetourNode.cpp b/Detour/Source/DetourNode.cpp
|
|
index 5cf6548..1d18977 100644
|
|
--- a/Detour/Source/DetourNode.cpp
|
|
+++ b/Detour/Source/DetourNode.cpp
|
|
@@ -22,30 +22,17 @@
|
|
#include "DetourCommon.h"
|
|
#include <string.h>
|
|
|
|
-#ifdef DT_POLYREF64
|
|
-// From Thomas Wang, https://gist.github.com/badboy/6267743
|
|
inline unsigned int dtHashRef(dtPolyRef a)
|
|
{
|
|
- a = (~a) + (a << 18); // a = (a << 18) - a - 1;
|
|
- a = a ^ (a >> 31);
|
|
- a = a * 21; // a = (a + (a << 2)) + (a << 4);
|
|
- a = a ^ (a >> 11);
|
|
- a = a + (a << 6);
|
|
- a = a ^ (a >> 22);
|
|
- return (unsigned int)a;
|
|
+ // Edited by TC
|
|
+ a = (~a) + (a << 18);
|
|
+ a = a ^ (a >> 31);
|
|
+ a = a * 21;
|
|
+ a = a ^ (a >> 11);
|
|
+ a = a + (a << 6);
|
|
+ a = a ^ (a >> 22);
|
|
+ return (unsigned int)a;
|
|
}
|
|
-#else
|
|
-inline unsigned int dtHashRef(dtPolyRef a)
|
|
-{
|
|
- a += ~(a<<15);
|
|
- a ^= (a>>10);
|
|
- a += (a<<3);
|
|
- a ^= (a>>6);
|
|
- a += ~(a<<11);
|
|
- a ^= (a>>16);
|
|
- return (unsigned int)a;
|
|
-}
|
|
-#endif
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
dtNodePool::dtNodePool(int maxNodes, int hashSize) :
|
|
diff --git a/Recast/Include/Recast.h b/Recast/Include/Recast.h
|
|
index d8bdde2..d3e9219 100644
|
|
--- a/Recast/Include/Recast.h
|
|
+++ b/Recast/Include/Recast.h
|
|
@@ -243,7 +243,7 @@ struct rcConfig
|
|
};
|
|
|
|
/// Defines the number of bits allocated to rcSpan::smin and rcSpan::smax.
|
|
-static const int RC_SPAN_HEIGHT_BITS = 13;
|
|
+static const int RC_SPAN_HEIGHT_BITS = 16; // EDITED BY TC
|
|
/// Defines the maximum value for rcSpan::smin and rcSpan::smax.
|
|
static const int RC_SPAN_MAX_HEIGHT = (1<<RC_SPAN_HEIGHT_BITS)-1;
|
|
|
|
@@ -255,9 +255,9 @@ static const int RC_SPANS_PER_POOL = 2048;
|
|
/// @see rcHeightfield
|
|
struct rcSpan
|
|
{
|
|
- unsigned int smin : 13; ///< The lower limit of the span. [Limit: < #smax]
|
|
- unsigned int smax : 13; ///< The upper limit of the span. [Limit: <= #RC_SPAN_MAX_HEIGHT]
|
|
- unsigned int area : 6; ///< The area id assigned to the span.
|
|
+ unsigned int smin : 16; ///< The lower limit of the span. [Limit: < #smax]
|
|
+ unsigned int smax : 16; ///< The upper limit of the span. [Limit: <= #RC_SPAN_MAX_HEIGHT]
|
|
+ unsigned char area; ///< The area id assigned to the span.
|
|
rcSpan* next; ///< The next span higher up in column.
|
|
};
|
|
|
|
diff --git a/Recast/Source/RecastMeshDetail.cpp b/Recast/Source/RecastMeshDetail.cpp
|
|
index c0bba6f..56b059d 100644
|
|
--- a/Recast/Source/RecastMeshDetail.cpp
|
|
+++ b/Recast/Source/RecastMeshDetail.cpp
|
|
@@ -511,7 +511,7 @@ static float polyMinExtent(const float* verts, const int nverts)
|
|
inline int prev(int i, int n) { return i-1 >= 0 ? i-1 : n-1; }
|
|
inline int next(int i, int n) { return i+1 < n ? i+1 : 0; }
|
|
|
|
-static void triangulateHull(const int nverts, const float* verts, const int nhull, const int* hull, rcIntArray& tris)
|
|
+static void triangulateHull(const int /*nverts*/, const float* verts, const int nhull, const int* hull, rcIntArray& tris)
|
|
{
|
|
int start = 0, left = 1, right = nhull-1;
|
|
|
|
diff --git a/Recast/Source/RecastRegion.cpp b/Recast/Source/RecastRegion.cpp
|
|
index 38bc4ff..352ba57 100644
|
|
--- a/Recast/Source/RecastRegion.cpp
|
|
+++ b/Recast/Source/RecastRegion.cpp
|
|
@@ -1041,7 +1041,7 @@ static void addUniqueConnection(rcRegion& reg, int n)
|
|
static bool mergeAndFilterLayerRegions(rcContext* ctx, int minRegionArea,
|
|
unsigned short& maxRegionId,
|
|
rcCompactHeightfield& chf,
|
|
- unsigned short* srcReg, rcIntArray& overlaps)
|
|
+ unsigned short* srcReg, rcIntArray& /*overlaps*/)
|
|
{
|
|
const int w = chf.width;
|
|
const int h = chf.height;
|
|
--
|
|
1.9.5.msysgit.0
|
|
|