mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-19 19:35:26 +00:00
Updated recast to 1.5.1
This commit is contained in:
parent
630949514a
commit
c7e5b35744
55 changed files with 3277 additions and 1460 deletions
|
|
@ -3,9 +3,9 @@
|
|||
#include "DetourNavMeshBuilder.h"
|
||||
#include "DetourNavMesh.h"
|
||||
#include "DetourCommon.h"
|
||||
#include "DetourMath.h"
|
||||
#include "DetourAlloc.h"
|
||||
#include "DetourAssert.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <new>
|
||||
|
||||
|
|
@ -40,10 +40,10 @@ inline int computeTileHash(int x, int y, const int mask)
|
|||
}
|
||||
|
||||
|
||||
struct BuildContext
|
||||
struct NavMeshTileBuildContext
|
||||
{
|
||||
inline BuildContext(struct dtTileCacheAlloc* a) : layer(0), lcset(0), lmesh(0), alloc(a) {}
|
||||
inline ~BuildContext() { purge(); }
|
||||
inline NavMeshTileBuildContext(struct dtTileCacheAlloc* a) : layer(0), lcset(0), lmesh(0), alloc(a) {}
|
||||
inline ~NavMeshTileBuildContext() { purge(); }
|
||||
void purge()
|
||||
{
|
||||
dtFreeTileCacheLayer(alloc, layer);
|
||||
|
|
@ -213,14 +213,14 @@ dtCompressedTile* dtTileCache::getTileAt(const int tx, const int ty, const int t
|
|||
dtCompressedTileRef dtTileCache::getTileRef(const dtCompressedTile* tile) const
|
||||
{
|
||||
if (!tile) return 0;
|
||||
const unsigned int it = tile - m_tiles;
|
||||
const unsigned int it = (unsigned int)(tile - m_tiles);
|
||||
return (dtCompressedTileRef)encodeTileId(tile->salt, it);
|
||||
}
|
||||
|
||||
dtObstacleRef dtTileCache::getObstacleRef(const dtTileCacheObstacle* ob) const
|
||||
{
|
||||
if (!ob) return 0;
|
||||
const unsigned int idx = ob - m_obstacles;
|
||||
const unsigned int idx = (unsigned int)(ob - m_obstacles);
|
||||
return encodeObstacleId(ob->salt, idx);
|
||||
}
|
||||
|
||||
|
|
@ -350,7 +350,7 @@ dtStatus dtTileCache::removeTile(dtCompressedTileRef ref, unsigned char** data,
|
|||
}
|
||||
|
||||
|
||||
dtObstacleRef dtTileCache::addObstacle(const float* pos, const float radius, const float height, dtObstacleRef* result)
|
||||
dtStatus dtTileCache::addObstacle(const float* pos, const float radius, const float height, dtObstacleRef* result)
|
||||
{
|
||||
if (m_nreqs >= MAX_REQUESTS)
|
||||
return DT_FAILURE | DT_BUFFER_TOO_SMALL;
|
||||
|
|
@ -384,7 +384,7 @@ dtObstacleRef dtTileCache::addObstacle(const float* pos, const float radius, con
|
|||
return DT_SUCCESS;
|
||||
}
|
||||
|
||||
dtObstacleRef dtTileCache::removeObstacle(const dtObstacleRef ref)
|
||||
dtStatus dtTileCache::removeObstacle(const dtObstacleRef ref)
|
||||
{
|
||||
if (!ref)
|
||||
return DT_SUCCESS;
|
||||
|
|
@ -409,10 +409,10 @@ dtStatus dtTileCache::queryTiles(const float* bmin, const float* bmax,
|
|||
|
||||
const float tw = m_params.width * m_params.cs;
|
||||
const float th = m_params.height * m_params.cs;
|
||||
const int tx0 = (int)floorf((bmin[0]-m_params.orig[0]) / tw);
|
||||
const int tx1 = (int)floorf((bmax[0]-m_params.orig[0]) / tw);
|
||||
const int ty0 = (int)floorf((bmin[2]-m_params.orig[2]) / th);
|
||||
const int ty1 = (int)floorf((bmax[2]-m_params.orig[2]) / th);
|
||||
const int tx0 = (int)dtMathFloorf((bmin[0]-m_params.orig[0]) / tw);
|
||||
const int tx1 = (int)dtMathFloorf((bmax[0]-m_params.orig[0]) / tw);
|
||||
const int ty0 = (int)dtMathFloorf((bmin[2]-m_params.orig[2]) / th);
|
||||
const int ty1 = (int)dtMathFloorf((bmax[2]-m_params.orig[2]) / th);
|
||||
|
||||
for (int ty = ty0; ty <= ty1; ++ty)
|
||||
{
|
||||
|
|
@ -587,7 +587,7 @@ dtStatus dtTileCache::buildNavMeshTile(const dtCompressedTileRef ref, dtNavMesh*
|
|||
|
||||
m_talloc->reset();
|
||||
|
||||
BuildContext bc(m_talloc);
|
||||
NavMeshTileBuildContext bc(m_talloc);
|
||||
const int walkableClimbVx = (int)(m_params.walkableClimb / m_params.ch);
|
||||
dtStatus status;
|
||||
|
||||
|
|
@ -631,7 +631,11 @@ dtStatus dtTileCache::buildNavMeshTile(const dtCompressedTileRef ref, dtNavMesh*
|
|||
|
||||
// Early out if the mesh tile is empty.
|
||||
if (!bc.lmesh->npolys)
|
||||
{
|
||||
// Remove existing tile.
|
||||
navmesh->removeTile(navmesh->getTileRefAt(tile->header->tx,tile->header->ty,tile->header->tlayer),0,0);
|
||||
return DT_SUCCESS;
|
||||
}
|
||||
|
||||
dtNavMeshCreateParams params;
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@
|
|||
//
|
||||
|
||||
#include "DetourCommon.h"
|
||||
#include "DetourMath.h"
|
||||
#include "DetourStatus.h"
|
||||
#include "DetourAssert.h"
|
||||
#include "DetourTileCacheBuilder.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
template<class T> class dtFixedArray
|
||||
|
|
@ -1068,6 +1068,7 @@ static bool buildMeshAdjacency(dtTileCacheAlloc* alloc,
|
|||
}
|
||||
|
||||
|
||||
// Last time I checked the if version got compiled using cmov, which was a lot faster than module (with idiv).
|
||||
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; }
|
||||
|
||||
|
|
@ -1968,12 +1969,12 @@ dtStatus dtMarkCylinderArea(dtTileCacheLayer& layer, const float* orig, const fl
|
|||
const float px = (pos[0]-orig[0])*ics;
|
||||
const float pz = (pos[2]-orig[2])*ics;
|
||||
|
||||
int minx = (int)floorf((bmin[0]-orig[0])*ics);
|
||||
int miny = (int)floorf((bmin[1]-orig[1])*ich);
|
||||
int minz = (int)floorf((bmin[2]-orig[2])*ics);
|
||||
int maxx = (int)floorf((bmax[0]-orig[0])*ics);
|
||||
int maxy = (int)floorf((bmax[1]-orig[1])*ich);
|
||||
int maxz = (int)floorf((bmax[2]-orig[2])*ics);
|
||||
int minx = (int)dtMathFloorf((bmin[0]-orig[0])*ics);
|
||||
int miny = (int)dtMathFloorf((bmin[1]-orig[1])*ich);
|
||||
int minz = (int)dtMathFloorf((bmin[2]-orig[2])*ics);
|
||||
int maxx = (int)dtMathFloorf((bmax[0]-orig[0])*ics);
|
||||
int maxy = (int)dtMathFloorf((bmax[1]-orig[1])*ich);
|
||||
int maxz = (int)dtMathFloorf((bmax[2]-orig[2])*ics);
|
||||
|
||||
if (maxx < 0) return DT_SUCCESS;
|
||||
if (minx >= w) return DT_SUCCESS;
|
||||
|
|
@ -2116,6 +2117,7 @@ dtStatus dtDecompressTileCacheLayer(dtTileCacheAlloc* alloc, dtTileCacheCompress
|
|||
|
||||
bool dtTileCacheHeaderSwapEndian(unsigned char* data, const int dataSize)
|
||||
{
|
||||
dtIgnoreUnused(dataSize);
|
||||
dtTileCacheLayerHeader* header = (dtTileCacheLayerHeader*)data;
|
||||
|
||||
int swappedMagic = DT_TILECACHE_MAGIC;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue