1
This commit is contained in:
parent
e57d842cba
commit
1f57e552ff
@ -26,6 +26,7 @@ include_directories(
|
|||||||
../../third_party/recastnavigation/Recast/Include
|
../../third_party/recastnavigation/Recast/Include
|
||||||
../../third_party/recastnavigation/Detour/Include
|
../../third_party/recastnavigation/Detour/Include
|
||||||
../../third_party/recastnavigation/DetourTileCache/Include
|
../../third_party/recastnavigation/DetourTileCache/Include
|
||||||
|
../../third_party/recastnavigation/RecastDemo/Contrib/fastlz
|
||||||
.
|
.
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,6 +48,10 @@ aux_source_directory(../../third_party/recastnavigation/Recast/Source
|
|||||||
SRC_LIST
|
SRC_LIST
|
||||||
)
|
)
|
||||||
|
|
||||||
|
aux_source_directory(../../third_party/recastnavigation/RecastDemo/Contrib/fastlz
|
||||||
|
SRC_LIST
|
||||||
|
)
|
||||||
|
|
||||||
aux_source_directory(../../third_party/recastnavigation/Detour/Source
|
aux_source_directory(../../third_party/recastnavigation/Detour/Source
|
||||||
SRC_LIST
|
SRC_LIST
|
||||||
)
|
)
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "DetourNavMeshQuery.h"
|
#include "DetourNavMeshQuery.h"
|
||||||
#include "DetourCommon.h"
|
#include "DetourCommon.h"
|
||||||
#include "DetourNavMesh.h"
|
#include "DetourNavMesh.h"
|
||||||
|
#include "fastlz.h"
|
||||||
|
|
||||||
#include "navmeshbuilder.h"
|
#include "navmeshbuilder.h"
|
||||||
#include "mapinstance.h"
|
#include "mapinstance.h"
|
||||||
@ -50,106 +51,107 @@ struct TileCacheData
|
|||||||
|
|
||||||
struct LinearAllocator : public dtTileCacheAlloc
|
struct LinearAllocator : public dtTileCacheAlloc
|
||||||
{
|
{
|
||||||
unsigned char* buffer;
|
unsigned char* buffer;
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
size_t top;
|
size_t top;
|
||||||
size_t high;
|
size_t high;
|
||||||
|
|
||||||
LinearAllocator(const size_t cap) : buffer(0), capacity(0), top(0), high(0)
|
LinearAllocator(const size_t cap) : buffer(0), capacity(0), top(0), high(0)
|
||||||
{
|
{
|
||||||
resize(cap);
|
resize(cap);
|
||||||
}
|
}
|
||||||
|
|
||||||
~LinearAllocator()
|
~LinearAllocator()
|
||||||
{
|
{
|
||||||
dtFree(buffer);
|
dtFree(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resize(const size_t cap)
|
void resize(const size_t cap)
|
||||||
{
|
{
|
||||||
if (buffer) dtFree(buffer);
|
if (buffer) dtFree(buffer);
|
||||||
buffer = (unsigned char*)dtAlloc(cap, DT_ALLOC_PERM);
|
buffer = (unsigned char*)dtAlloc(cap, DT_ALLOC_PERM);
|
||||||
capacity = cap;
|
capacity = cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void reset()
|
virtual void reset()
|
||||||
{
|
{
|
||||||
high = dtMax(high, top);
|
high = dtMax(high, top);
|
||||||
top = 0;
|
top = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void* alloc(const size_t size)
|
virtual void* alloc(const size_t size)
|
||||||
{
|
{
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return 0;
|
return 0;
|
||||||
if (top+size > capacity)
|
if (top+size > capacity)
|
||||||
return 0;
|
return 0;
|
||||||
unsigned char* mem = &buffer[top];
|
unsigned char* mem = &buffer[top];
|
||||||
top += size;
|
top += size;
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void free(void* /*ptr*/)
|
virtual void free(void* /*ptr*/)
|
||||||
{
|
{
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FastLZCompressor : public dtTileCacheCompressor
|
struct FastLZCompressor : public dtTileCacheCompressor
|
||||||
{
|
{
|
||||||
virtual int maxCompressedSize(const int bufferSize)
|
virtual int maxCompressedSize(const int bufferSize)
|
||||||
{
|
{
|
||||||
return (int)(bufferSize* 1.05f);
|
return (int)(bufferSize* 1.05f);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual dtStatus compress(const unsigned char* buffer, const int bufferSize,
|
virtual dtStatus compress(const unsigned char* buffer, const int bufferSize,
|
||||||
unsigned char* compressed, const int /*maxCompressedSize*/, int* compressedSize)
|
unsigned char* compressed, const int /*maxCompressedSize*/, int* compressedSize)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
*compressedSize = fastlz_compress((const void *const)buffer, bufferSize, compressed);
|
*compressedSize = fastlz_compress((const void *const)buffer, bufferSize, compressed);
|
||||||
#endif
|
#endif
|
||||||
return DT_SUCCESS;
|
return DT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual dtStatus decompress(const unsigned char* compressed, const int compressedSize,
|
virtual dtStatus decompress(const unsigned char* compressed, const int compressedSize,
|
||||||
unsigned char* buffer, const int maxBufferSize, int* bufferSize)
|
unsigned char* buffer, const int maxBufferSize, int* bufferSize)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
*bufferSize = fastlz_decompress(compressed, compressedSize, buffer, maxBufferSize);
|
*bufferSize = fastlz_decompress(compressed, compressedSize, buffer, maxBufferSize);
|
||||||
#endif
|
#endif
|
||||||
return *bufferSize < 0 ? DT_FAILURE : DT_SUCCESS;
|
return *bufferSize < 0 ? DT_FAILURE : DT_SUCCESS;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MeshProcess : public dtTileCacheMeshProcess
|
struct MeshProcess : public dtTileCacheMeshProcess
|
||||||
{
|
{
|
||||||
inline MeshProcess()
|
inline MeshProcess()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void process(struct dtNavMeshCreateParams* params,
|
virtual void process(struct dtNavMeshCreateParams* params,
|
||||||
unsigned char* polyAreas, unsigned short* polyFlags)
|
unsigned char* polyAreas,
|
||||||
{
|
unsigned short* polyFlags)
|
||||||
#if 0
|
{
|
||||||
// Update poly flags from areas.
|
#if 0
|
||||||
for (int i = 0; i < params->polyCount; ++i)
|
// Update poly flags from areas.
|
||||||
{
|
for (int i = 0; i < params->polyCount; ++i)
|
||||||
polyFlags[i] = sampleAreaToFlags(polyAreas[i]);
|
{
|
||||||
}
|
polyFlags[i] = sampleAreaToFlags(polyAreas[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// Pass in off-mesh connections.
|
// Pass in off-mesh connections.
|
||||||
if (m_geom)
|
if (m_geom)
|
||||||
{
|
{
|
||||||
params->offMeshConVerts = m_geom->getOffMeshConnectionVerts();
|
params->offMeshConVerts = m_geom->getOffMeshConnectionVerts();
|
||||||
params->offMeshConRad = m_geom->getOffMeshConnectionRads();
|
params->offMeshConRad = m_geom->getOffMeshConnectionRads();
|
||||||
params->offMeshConDir = m_geom->getOffMeshConnectionDirs();
|
params->offMeshConDir = m_geom->getOffMeshConnectionDirs();
|
||||||
params->offMeshConAreas = m_geom->getOffMeshConnectionAreas();
|
params->offMeshConAreas = m_geom->getOffMeshConnectionAreas();
|
||||||
params->offMeshConFlags = m_geom->getOffMeshConnectionFlags();
|
params->offMeshConFlags = m_geom->getOffMeshConnectionFlags();
|
||||||
params->offMeshConUserID = m_geom->getOffMeshConnectionId();
|
params->offMeshConUserID = m_geom->getOffMeshConnectionId();
|
||||||
params->offMeshConCount = m_geom->getOffMeshConnectionCount();
|
params->offMeshConCount = m_geom->getOffMeshConnectionCount();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void NavMeshBuilder::Init()
|
void NavMeshBuilder::Init()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user