Fixed several detail mesh issues. Fixed issue 106.
This commit is contained in:
parent
8a2963bce0
commit
e1355c4a33
@ -595,10 +595,10 @@ void duDebugDrawPolyMeshDetail(duDebugDraw* dd, const struct rcPolyMeshDetail& d
|
|||||||
|
|
||||||
for (int i = 0; i < dmesh.nmeshes; ++i)
|
for (int i = 0; i < dmesh.nmeshes; ++i)
|
||||||
{
|
{
|
||||||
const unsigned short* m = &dmesh.meshes[i*4];
|
const unsigned int* m = &dmesh.meshes[i*4];
|
||||||
const unsigned short bverts = m[0];
|
const unsigned int bverts = m[0];
|
||||||
const unsigned short btris = m[2];
|
const unsigned int btris = m[2];
|
||||||
const unsigned short ntris = m[3];
|
const int ntris = (int)m[3];
|
||||||
const float* verts = &dmesh.verts[bverts*3];
|
const float* verts = &dmesh.verts[bverts*3];
|
||||||
const unsigned char* tris = &dmesh.tris[btris*4];
|
const unsigned char* tris = &dmesh.tris[btris*4];
|
||||||
|
|
||||||
@ -618,10 +618,10 @@ void duDebugDrawPolyMeshDetail(duDebugDraw* dd, const struct rcPolyMeshDetail& d
|
|||||||
const unsigned int coli = duRGBA(0,0,0,64);
|
const unsigned int coli = duRGBA(0,0,0,64);
|
||||||
for (int i = 0; i < dmesh.nmeshes; ++i)
|
for (int i = 0; i < dmesh.nmeshes; ++i)
|
||||||
{
|
{
|
||||||
const unsigned short* m = &dmesh.meshes[i*4];
|
const unsigned int* m = &dmesh.meshes[i*4];
|
||||||
const unsigned short bverts = m[0];
|
const unsigned int bverts = m[0];
|
||||||
const unsigned short btris = m[2];
|
const unsigned int btris = m[2];
|
||||||
const unsigned short ntris = m[3];
|
const int ntris = (int)m[3];
|
||||||
const float* verts = &dmesh.verts[bverts*3];
|
const float* verts = &dmesh.verts[bverts*3];
|
||||||
const unsigned char* tris = &dmesh.tris[btris*4];
|
const unsigned char* tris = &dmesh.tris[btris*4];
|
||||||
|
|
||||||
@ -650,10 +650,10 @@ void duDebugDrawPolyMeshDetail(duDebugDraw* dd, const struct rcPolyMeshDetail& d
|
|||||||
const unsigned int cole = duRGBA(0,0,0,64);
|
const unsigned int cole = duRGBA(0,0,0,64);
|
||||||
for (int i = 0; i < dmesh.nmeshes; ++i)
|
for (int i = 0; i < dmesh.nmeshes; ++i)
|
||||||
{
|
{
|
||||||
const unsigned short* m = &dmesh.meshes[i*4];
|
const unsigned int* m = &dmesh.meshes[i*4];
|
||||||
const unsigned short bverts = m[0];
|
const unsigned int bverts = m[0];
|
||||||
const unsigned short btris = m[2];
|
const unsigned int btris = m[2];
|
||||||
const unsigned short ntris = m[3];
|
const int ntris = (int)m[3];
|
||||||
const float* verts = &dmesh.verts[bverts*3];
|
const float* verts = &dmesh.verts[bverts*3];
|
||||||
const unsigned char* tris = &dmesh.tris[btris*4];
|
const unsigned char* tris = &dmesh.tris[btris*4];
|
||||||
|
|
||||||
@ -678,9 +678,9 @@ void duDebugDrawPolyMeshDetail(duDebugDraw* dd, const struct rcPolyMeshDetail& d
|
|||||||
const unsigned int colv = duRGBA(0,0,0,64);
|
const unsigned int colv = duRGBA(0,0,0,64);
|
||||||
for (int i = 0; i < dmesh.nmeshes; ++i)
|
for (int i = 0; i < dmesh.nmeshes; ++i)
|
||||||
{
|
{
|
||||||
const unsigned short* m = &dmesh.meshes[i*4];
|
const unsigned int* m = &dmesh.meshes[i*4];
|
||||||
const unsigned short bverts = m[0];
|
const unsigned int bverts = m[0];
|
||||||
const unsigned short nverts = m[1];
|
const int nverts = (int)m[1];
|
||||||
const float* verts = &dmesh.verts[bverts*3];
|
const float* verts = &dmesh.verts[bverts*3];
|
||||||
for (int j = 0; j < nverts; ++j)
|
for (int j = 0; j < nverts; ++j)
|
||||||
dd->vertex(&verts[j*3], colv);
|
dd->vertex(&verts[j*3], colv);
|
||||||
|
@ -117,12 +117,12 @@ bool duDumpPolyMeshDetailToObj(rcPolyMeshDetail& dmesh, duFileIO* io)
|
|||||||
|
|
||||||
for (int i = 0; i < dmesh.nmeshes; ++i)
|
for (int i = 0; i < dmesh.nmeshes; ++i)
|
||||||
{
|
{
|
||||||
const unsigned short* m = &dmesh.meshes[i*4];
|
const unsigned int* m = &dmesh.meshes[i*4];
|
||||||
const unsigned short bverts = m[0];
|
const unsigned int bverts = m[0];
|
||||||
const unsigned short btris = m[2];
|
const unsigned int btris = m[2];
|
||||||
const unsigned short ntris = m[3];
|
const unsigned int ntris = m[3];
|
||||||
const unsigned char* tris = &dmesh.tris[btris*4];
|
const unsigned char* tris = &dmesh.tris[btris*4];
|
||||||
for (int j = 0; j < ntris; ++j)
|
for (unsigned int j = 0; j < ntris; ++j)
|
||||||
{
|
{
|
||||||
ioprintf(io, "f %d %d %d\n",
|
ioprintf(io, "f %d %d %d\n",
|
||||||
(int)(bverts+tris[j*4+0])+1,
|
(int)(bverts+tris[j*4+0])+1,
|
||||||
|
@ -81,10 +81,10 @@ struct dtPoly
|
|||||||
// Stucture describing polygon detail triangles.
|
// Stucture describing polygon detail triangles.
|
||||||
struct dtPolyDetail
|
struct dtPolyDetail
|
||||||
{
|
{
|
||||||
unsigned short vertBase; // Offset to detail vertex array.
|
unsigned int vertBase; // Offset to detail vertex array.
|
||||||
unsigned short vertCount; // Number of vertices in the detail mesh.
|
unsigned int triBase; // Offset to detail triangle array.
|
||||||
unsigned short triBase; // Offset to detail triangle array.
|
unsigned char vertCount; // Number of vertices in the detail mesh.
|
||||||
unsigned short triCount; // Number of triangles.
|
unsigned char triCount; // Number of triangles.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Stucture describing a link to another polygon.
|
// Stucture describing a link to another polygon.
|
||||||
|
@ -36,7 +36,7 @@ struct dtNavMeshCreateParams
|
|||||||
int polyCount; // Number of polygons
|
int polyCount; // Number of polygons
|
||||||
int nvp; // Number of verts per polygon.
|
int nvp; // Number of verts per polygon.
|
||||||
// Navmesh Detail
|
// Navmesh Detail
|
||||||
const unsigned short* detailMeshes; // Detail meshes, uses same format as rcPolyMeshDetail.
|
const unsigned int* detailMeshes; // Detail meshes, uses same format as rcPolyMeshDetail.
|
||||||
const float* detailVerts; // Detail mesh vertices, uses same format as rcPolyMeshDetail (wu).
|
const float* detailVerts; // Detail mesh vertices, uses same format as rcPolyMeshDetail (wu).
|
||||||
int detailVertsCount; // Total number of detail vertices
|
int detailVertsCount; // Total number of detail vertices
|
||||||
const unsigned char* detailTris; // Array of detail tris per detail mesh.
|
const unsigned char* detailTris; // Array of detail tris per detail mesh.
|
||||||
|
@ -492,13 +492,13 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
|
|||||||
for (int i = 0; i < params->polyCount; ++i)
|
for (int i = 0; i < params->polyCount; ++i)
|
||||||
{
|
{
|
||||||
dtPolyDetail& dtl = navDMeshes[i];
|
dtPolyDetail& dtl = navDMeshes[i];
|
||||||
const int vb = params->detailMeshes[i*4+0];
|
const int vb = (int)params->detailMeshes[i*4+0];
|
||||||
const int ndv = params->detailMeshes[i*4+1];
|
const int ndv = (int)params->detailMeshes[i*4+1];
|
||||||
const int nv = navPolys[i].vertCount;
|
const int nv = navPolys[i].vertCount;
|
||||||
dtl.vertBase = vbase;
|
dtl.vertBase = (unsigned int)vbase;
|
||||||
dtl.vertCount = (unsigned short)(ndv-nv);
|
dtl.vertCount = (unsigned char)(ndv-nv);
|
||||||
dtl.triBase = params->detailMeshes[i*4+2];
|
dtl.triBase = (unsigned int)params->detailMeshes[i*4+2];
|
||||||
dtl.triCount = params->detailMeshes[i*4+3];
|
dtl.triCount = (unsigned char)params->detailMeshes[i*4+3];
|
||||||
// Copy vertices except the first 'nv' verts which are equal to nav poly verts.
|
// Copy vertices except the first 'nv' verts which are equal to nav poly verts.
|
||||||
if (ndv-nv)
|
if (ndv-nv)
|
||||||
{
|
{
|
||||||
@ -680,9 +680,7 @@ bool dtNavMeshDataSwapEndian(unsigned char* data, const int /*dataSize*/)
|
|||||||
{
|
{
|
||||||
dtPolyDetail* pd = &detailMeshes[i];
|
dtPolyDetail* pd = &detailMeshes[i];
|
||||||
swapEndian(&pd->vertBase);
|
swapEndian(&pd->vertBase);
|
||||||
swapEndian(&pd->vertCount);
|
|
||||||
swapEndian(&pd->triBase);
|
swapEndian(&pd->triBase);
|
||||||
swapEndian(&pd->triCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detail verts
|
// Detail verts
|
||||||
|
@ -248,15 +248,17 @@ void rcFreePolyMesh(rcPolyMesh* pmesh);
|
|||||||
// Each submesh represents a polygon in the polymesh and they are stored in
|
// Each submesh represents a polygon in the polymesh and they are stored in
|
||||||
// exactly same order. Each submesh is described as 4 values:
|
// exactly same order. Each submesh is described as 4 values:
|
||||||
// base vertex, vertex count, base triangle, triangle count. That is,
|
// base vertex, vertex count, base triangle, triangle count. That is,
|
||||||
// const unsigned char* t = &dtl.tris[(tbase+i)*3]; and
|
// const unsigned char* t = &dmesh.tris[(tbase+i)*3]; and
|
||||||
// const float* v = &dtl.verts[(vbase+t[j])*3];
|
// const float* v = &dmesh.verts[(vbase+t[j])*3];
|
||||||
// If the input polygon has 'n' vertices, those vertices are first in the
|
// If the input polygon has 'n' vertices, those vertices are first in the
|
||||||
// submesh vertex list. This allows to compres the mesh by not storing the
|
// submesh vertex list. This allows to compres the mesh by not storing the
|
||||||
// first vertices and using the polymesh vertices instead.
|
// first vertices and using the polymesh vertices instead.
|
||||||
|
// Max number of vertices per submesh is 127 and
|
||||||
|
// max number of triangles per submesh is 255.
|
||||||
|
|
||||||
struct rcPolyMeshDetail
|
struct rcPolyMeshDetail
|
||||||
{
|
{
|
||||||
unsigned short* meshes; // Pointer to all mesh data.
|
unsigned int* meshes; // Pointer to all mesh data.
|
||||||
float* verts; // Pointer to all vertex data.
|
float* verts; // Pointer to all vertex data.
|
||||||
unsigned char* tris; // Pointer to all triangle data.
|
unsigned char* tris; // Pointer to all triangle data.
|
||||||
int nmeshes; // Number of meshes.
|
int nmeshes; // Number of meshes.
|
||||||
|
@ -1163,6 +1163,15 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, int nvp, rcPolyMesh& me
|
|||||||
}
|
}
|
||||||
memset(mesh.flags, 0, sizeof(unsigned short) * mesh.npolys);
|
memset(mesh.flags, 0, sizeof(unsigned short) * mesh.npolys);
|
||||||
|
|
||||||
|
if (mesh.nverts > 0xffff)
|
||||||
|
{
|
||||||
|
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: The resulting mesh has too many vertices %d (max %d). Data can be corrupted.", mesh.nverts, 0xffff);
|
||||||
|
}
|
||||||
|
if (mesh.npolys > 0xffff)
|
||||||
|
{
|
||||||
|
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: The resulting mesh has too many polygons %d (max %d). Data can be corrupted.", mesh.npolys, 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
ctx->stopTimer(RC_TIMER_BUILD_POLYMESH);
|
ctx->stopTimer(RC_TIMER_BUILD_POLYMESH);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1298,6 +1307,15 @@ bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, r
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mesh.nverts > 0xffff)
|
||||||
|
{
|
||||||
|
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: The resulting mesh has too many vertices %d (max %d). Data can be corrupted.", mesh.nverts, 0xffff);
|
||||||
|
}
|
||||||
|
if (mesh.npolys > 0xffff)
|
||||||
|
{
|
||||||
|
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: The resulting mesh has too many polygons %d (max %d). Data can be corrupted.", mesh.npolys, 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
ctx->stopTimer(RC_TIMER_MERGE_POLYMESH);
|
ctx->stopTimer(RC_TIMER_MERGE_POLYMESH);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -484,12 +484,21 @@ static void delaunayHull(rcContext* ctx, const int npts, const float* pts,
|
|||||||
t[2] = tris[tris.size()-2];
|
t[2] = tris[tris.size()-2];
|
||||||
t[3] = tris[tris.size()-1];
|
t[3] = tris[tris.size()-1];
|
||||||
tris.resize(tris.size()-4);
|
tris.resize(tris.size()-4);
|
||||||
|
--i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline float getJitterX(const int i)
|
||||||
|
{
|
||||||
|
return (((i * 0x8da6b343) & 0xffff) / 65535.0f * 2.0f) - 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline float getJitterY(const int i)
|
||||||
|
{
|
||||||
|
return (((i * 0xd8163841) & 0xffff) / 65535.0f * 2.0f) - 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
|
static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
|
||||||
const float sampleDist, const float sampleMaxError,
|
const float sampleDist, const float sampleMaxError,
|
||||||
@ -497,9 +506,10 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
|
|||||||
float* verts, int& nverts, rcIntArray& tris,
|
float* verts, int& nverts, rcIntArray& tris,
|
||||||
rcIntArray& edges, rcIntArray& samples)
|
rcIntArray& edges, rcIntArray& samples)
|
||||||
{
|
{
|
||||||
static const int MAX_VERTS = 256;
|
static const int MAX_VERTS = 127;
|
||||||
static const int MAX_EDGE = 64;
|
static const int MAX_TRIS = 255; // Max tris for delaunay is 2n-2-k (n=num verts, k=num hull verts).
|
||||||
float edge[(MAX_EDGE+1)*3];
|
static const int MAX_VERTS_PER_EDGE = 32;
|
||||||
|
float edge[(MAX_VERTS_PER_EDGE+1)*3];
|
||||||
int hull[MAX_VERTS];
|
int hull[MAX_VERTS];
|
||||||
int nhull = 0;
|
int nhull = 0;
|
||||||
|
|
||||||
@ -546,9 +556,10 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
|
|||||||
float dz = vi[2] - vj[2];
|
float dz = vi[2] - vj[2];
|
||||||
float d = sqrtf(dx*dx + dz*dz);
|
float d = sqrtf(dx*dx + dz*dz);
|
||||||
int nn = 1 + (int)floorf(d/sampleDist);
|
int nn = 1 + (int)floorf(d/sampleDist);
|
||||||
if (nn > MAX_EDGE) nn = MAX_EDGE;
|
if (nn >= MAX_VERTS_PER_EDGE) nn = MAX_VERTS_PER_EDGE-1;
|
||||||
if (nverts+nn >= MAX_VERTS)
|
if (nverts+nn >= MAX_VERTS)
|
||||||
nn = MAX_VERTS-1-nverts;
|
nn = MAX_VERTS-1-nverts;
|
||||||
|
|
||||||
for (int k = 0; k <= nn; ++k)
|
for (int k = 0; k <= nn; ++k)
|
||||||
{
|
{
|
||||||
float u = (float)k/(float)nn;
|
float u = (float)k/(float)nn;
|
||||||
@ -559,7 +570,7 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
|
|||||||
pos[1] = getHeight(pos[0],pos[1],pos[2], cs, ics, chf.ch, hp)*chf.ch;
|
pos[1] = getHeight(pos[0],pos[1],pos[2], cs, ics, chf.ch, hp)*chf.ch;
|
||||||
}
|
}
|
||||||
// Simplify samples.
|
// Simplify samples.
|
||||||
int idx[MAX_EDGE] = {0,nn};
|
int idx[MAX_VERTS_PER_EDGE] = {0,nn};
|
||||||
int nidx = 2;
|
int nidx = 2;
|
||||||
for (int k = 0; k < nidx-1; )
|
for (int k = 0; k < nidx-1; )
|
||||||
{
|
{
|
||||||
@ -667,36 +678,47 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
|
|||||||
samples.push(x);
|
samples.push(x);
|
||||||
samples.push(getHeight(pt[0], pt[1], pt[2], cs, ics, chf.ch, hp));
|
samples.push(getHeight(pt[0], pt[1], pt[2], cs, ics, chf.ch, hp));
|
||||||
samples.push(z);
|
samples.push(z);
|
||||||
|
samples.push(0); // Not added
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the samples starting from the one that has the most
|
// Add the samples starting from the one that has the most
|
||||||
// error. The procedure stops when all samples are added
|
// error. The procedure stops when all samples are added
|
||||||
// or when the max error is within treshold.
|
// or when the max error is within treshold.
|
||||||
const int nsamples = samples.size()/3;
|
const int nsamples = samples.size()/4;
|
||||||
for (int iter = 0; iter < nsamples; ++iter)
|
for (int iter = 0; iter < nsamples; ++iter)
|
||||||
{
|
{
|
||||||
|
if (nverts >= MAX_VERTS)
|
||||||
|
break;
|
||||||
|
|
||||||
// Find sample with most error.
|
// Find sample with most error.
|
||||||
float bestpt[3] = {0,0,0};
|
float bestpt[3] = {0,0,0};
|
||||||
float bestd = 0;
|
float bestd = 0;
|
||||||
|
int besti = -1;
|
||||||
for (int i = 0; i < nsamples; ++i)
|
for (int i = 0; i < nsamples; ++i)
|
||||||
{
|
{
|
||||||
|
const int* s = &samples[i*4];
|
||||||
|
if (s[3]) continue; // skip added.
|
||||||
float pt[3];
|
float pt[3];
|
||||||
pt[0] = samples[i*3+0]*sampleDist;
|
// The sample location is jittered to get rid of some bad triangulations
|
||||||
pt[1] = samples[i*3+1]*chf.ch;
|
// which are cause by symmetrical data from the grid structure.
|
||||||
pt[2] = samples[i*3+2]*sampleDist;
|
pt[0] = s[0]*sampleDist + getJitterX(i)*cs*0.1f;
|
||||||
|
pt[1] = s[1]*chf.ch;
|
||||||
|
pt[2] = s[2]*sampleDist + getJitterY(i)*cs*0.1f;
|
||||||
float d = distToTriMesh(pt, verts, nverts, &tris[0], tris.size()/4);
|
float d = distToTriMesh(pt, verts, nverts, &tris[0], tris.size()/4);
|
||||||
if (d < 0) continue; // did not hit the mesh.
|
if (d < 0) continue; // did not hit the mesh.
|
||||||
if (d > bestd)
|
if (d > bestd)
|
||||||
{
|
{
|
||||||
bestd = d;
|
bestd = d;
|
||||||
|
besti = i;
|
||||||
rcVcopy(bestpt,pt);
|
rcVcopy(bestpt,pt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the max error is within accepted threshold, stop tesselating.
|
// If the max error is within accepted threshold, stop tesselating.
|
||||||
if (bestd <= sampleMaxError)
|
if (bestd <= sampleMaxError || besti == -1)
|
||||||
break;
|
break;
|
||||||
|
// Mark sample as added.
|
||||||
|
samples[besti*4+3] = 1;
|
||||||
// Add the new sample point.
|
// Add the new sample point.
|
||||||
rcVcopy(&verts[nverts*3],bestpt);
|
rcVcopy(&verts[nverts*3],bestpt);
|
||||||
nverts++;
|
nverts++;
|
||||||
@ -706,12 +728,16 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
|
|||||||
edges.resize(0);
|
edges.resize(0);
|
||||||
tris.resize(0);
|
tris.resize(0);
|
||||||
delaunayHull(ctx, nverts, verts, nhull, hull, tris, edges);
|
delaunayHull(ctx, nverts, verts, nhull, hull, tris, edges);
|
||||||
|
|
||||||
if (nverts >= MAX_VERTS)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int ntris = tris.size()/4;
|
||||||
|
if (ntris > MAX_TRIS)
|
||||||
|
{
|
||||||
|
tris.resize(MAX_TRIS*4);
|
||||||
|
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Shrinking triangle count from %d to max %d.", ntris, MAX_TRIS);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -993,7 +1019,7 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
|
|||||||
dmesh.nmeshes = mesh.npolys;
|
dmesh.nmeshes = mesh.npolys;
|
||||||
dmesh.nverts = 0;
|
dmesh.nverts = 0;
|
||||||
dmesh.ntris = 0;
|
dmesh.ntris = 0;
|
||||||
dmesh.meshes = (unsigned short*)rcAlloc(sizeof(unsigned short)*dmesh.nmeshes*4, RC_ALLOC_PERM);
|
dmesh.meshes = (unsigned int*)rcAlloc(sizeof(unsigned int)*dmesh.nmeshes*4, RC_ALLOC_PERM);
|
||||||
if (!dmesh.meshes)
|
if (!dmesh.meshes)
|
||||||
{
|
{
|
||||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.meshes' (%d).", dmesh.nmeshes*4);
|
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.meshes' (%d).", dmesh.nmeshes*4);
|
||||||
@ -1069,10 +1095,10 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
|
|||||||
// Store detail submesh.
|
// Store detail submesh.
|
||||||
const int ntris = tris.size()/4;
|
const int ntris = tris.size()/4;
|
||||||
|
|
||||||
dmesh.meshes[i*4+0] = (unsigned short)dmesh.nverts;
|
dmesh.meshes[i*4+0] = (unsigned int)dmesh.nverts;
|
||||||
dmesh.meshes[i*4+1] = (unsigned short)nverts;
|
dmesh.meshes[i*4+1] = (unsigned int)nverts;
|
||||||
dmesh.meshes[i*4+2] = (unsigned short)dmesh.ntris;
|
dmesh.meshes[i*4+2] = (unsigned int)dmesh.ntris;
|
||||||
dmesh.meshes[i*4+3] = (unsigned short)ntris;
|
dmesh.meshes[i*4+3] = (unsigned int)ntris;
|
||||||
|
|
||||||
// Store vertices, allocate more memory if necessary.
|
// Store vertices, allocate more memory if necessary.
|
||||||
if (dmesh.nverts+nverts > vcap)
|
if (dmesh.nverts+nverts > vcap)
|
||||||
@ -1150,7 +1176,7 @@ bool rcMergePolyMeshDetails(rcContext* ctx, rcPolyMeshDetail** meshes, const int
|
|||||||
}
|
}
|
||||||
|
|
||||||
mesh.nmeshes = 0;
|
mesh.nmeshes = 0;
|
||||||
mesh.meshes = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxMeshes*4, RC_ALLOC_PERM);
|
mesh.meshes = (unsigned int*)rcAlloc(sizeof(unsigned int)*maxMeshes*4, RC_ALLOC_PERM);
|
||||||
if (!mesh.meshes)
|
if (!mesh.meshes)
|
||||||
{
|
{
|
||||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'pmdtl.meshes' (%d).", maxMeshes*4);
|
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'pmdtl.meshes' (%d).", maxMeshes*4);
|
||||||
@ -1180,11 +1206,11 @@ bool rcMergePolyMeshDetails(rcContext* ctx, rcPolyMeshDetail** meshes, const int
|
|||||||
if (!dm) continue;
|
if (!dm) continue;
|
||||||
for (int j = 0; j < dm->nmeshes; ++j)
|
for (int j = 0; j < dm->nmeshes; ++j)
|
||||||
{
|
{
|
||||||
unsigned short* dst = &mesh.meshes[mesh.nmeshes*4];
|
unsigned int* dst = &mesh.meshes[mesh.nmeshes*4];
|
||||||
unsigned short* src = &dm->meshes[j*4];
|
unsigned int* src = &dm->meshes[j*4];
|
||||||
dst[0] = (unsigned short)mesh.nverts+src[0];
|
dst[0] = (unsigned int)mesh.nverts+src[0];
|
||||||
dst[1] = src[1];
|
dst[1] = src[1];
|
||||||
dst[2] = (unsigned short)mesh.ntris+src[2];
|
dst[2] = (unsigned int)mesh.ntris+src[2];
|
||||||
dst[3] = src[3];
|
dst[3] = src[3];
|
||||||
mesh.nmeshes++;
|
mesh.nmeshes++;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -284,14 +284,14 @@
|
|||||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||||
<array>
|
<array>
|
||||||
<array>
|
<array>
|
||||||
<integer>59</integer>
|
<integer>36</integer>
|
||||||
<integer>51</integer>
|
<integer>27</integer>
|
||||||
<integer>1</integer>
|
<integer>1</integer>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
</array>
|
</array>
|
||||||
</array>
|
</array>
|
||||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||||
<string>{{0, 451}, {264, 607}}</string>
|
<string>{{0, 181}, {264, 607}}</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>PBXTopSmartGroupGIDs</key>
|
<key>PBXTopSmartGroupGIDs</key>
|
||||||
<array/>
|
<array/>
|
||||||
@ -326,7 +326,7 @@
|
|||||||
<key>PBXProjectModuleGUID</key>
|
<key>PBXProjectModuleGUID</key>
|
||||||
<string>6B8632A30F78115100E2684A</string>
|
<string>6B8632A30F78115100E2684A</string>
|
||||||
<key>PBXProjectModuleLabel</key>
|
<key>PBXProjectModuleLabel</key>
|
||||||
<string>DetourNavMeshQuery.cpp</string>
|
<string>RecastDebugDraw.cpp</string>
|
||||||
<key>PBXSplitModuleInNavigatorKey</key>
|
<key>PBXSplitModuleInNavigatorKey</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Split0</key>
|
<key>Split0</key>
|
||||||
@ -334,11 +334,11 @@
|
|||||||
<key>PBXProjectModuleGUID</key>
|
<key>PBXProjectModuleGUID</key>
|
||||||
<string>6B8632A40F78115100E2684A</string>
|
<string>6B8632A40F78115100E2684A</string>
|
||||||
<key>PBXProjectModuleLabel</key>
|
<key>PBXProjectModuleLabel</key>
|
||||||
<string>DetourNavMeshQuery.cpp</string>
|
<string>RecastDebugDraw.cpp</string>
|
||||||
<key>_historyCapacity</key>
|
<key>_historyCapacity</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>bookmark</key>
|
<key>bookmark</key>
|
||||||
<string>6BD66861124351D70021A7A4</string>
|
<string>6BD6695E124377D40021A7A4</string>
|
||||||
<key>history</key>
|
<key>history</key>
|
||||||
<array>
|
<array>
|
||||||
<string>6BBB4AA5115B4F3400CF791D</string>
|
<string>6BBB4AA5115B4F3400CF791D</string>
|
||||||
@ -377,27 +377,17 @@
|
|||||||
<string>6BD4029B12243A8000995864</string>
|
<string>6BD4029B12243A8000995864</string>
|
||||||
<string>6BD402B4122441CB00995864</string>
|
<string>6BD402B4122441CB00995864</string>
|
||||||
<string>6B920A521225C0AC00D5B5AD</string>
|
<string>6B920A521225C0AC00D5B5AD</string>
|
||||||
<string>6B920A541225C0AC00D5B5AD</string>
|
|
||||||
<string>6B920A6D1225C5DD00D5B5AD</string>
|
<string>6B920A6D1225C5DD00D5B5AD</string>
|
||||||
<string>6B920A6E1225C5DD00D5B5AD</string>
|
|
||||||
<string>6B920A811225D2EC00D5B5AD</string>
|
<string>6B920A811225D2EC00D5B5AD</string>
|
||||||
<string>6B920A8F1225D3C900D5B5AD</string>
|
<string>6B920A8F1225D3C900D5B5AD</string>
|
||||||
<string>6B920AA81225DBCB00D5B5AD</string>
|
<string>6B920AA81225DBCB00D5B5AD</string>
|
||||||
<string>6BA7F8A81226EF0400C8C47A</string>
|
|
||||||
<string>6BA7F8AA1226EF0400C8C47A</string>
|
|
||||||
<string>6BA7F8AC1226EF0400C8C47A</string>
|
<string>6BA7F8AC1226EF0400C8C47A</string>
|
||||||
<string>6BA7F8B61226EF1100C8C47A</string>
|
<string>6BA7F8B61226EF1100C8C47A</string>
|
||||||
<string>6BA7F8D01226EF9D00C8C47A</string>
|
<string>6BA7F8D01226EF9D00C8C47A</string>
|
||||||
<string>6BA7F8EB1227002300C8C47A</string>
|
|
||||||
<string>6BA7F8EC1227002300C8C47A</string>
|
<string>6BA7F8EC1227002300C8C47A</string>
|
||||||
<string>6BA7F8ED1227002300C8C47A</string>
|
<string>6BA7F8ED1227002300C8C47A</string>
|
||||||
<string>6BA7F8EE1227002300C8C47A</string>
|
<string>6BA7F8EE1227002300C8C47A</string>
|
||||||
<string>6B9EFF0B12281C6200535FF1</string>
|
|
||||||
<string>6B847513122B9F4900ADF63D</string>
|
|
||||||
<string>6B847515122B9F4900ADF63D</string>
|
<string>6B847515122B9F4900ADF63D</string>
|
||||||
<string>6B847516122B9F4900ADF63D</string>
|
|
||||||
<string>6B847634122CE32800ADF63D</string>
|
|
||||||
<string>6B847635122CE32800ADF63D</string>
|
|
||||||
<string>6B8476F9122D000800ADF63D</string>
|
<string>6B8476F9122D000800ADF63D</string>
|
||||||
<string>6B8476FA122D000800ADF63D</string>
|
<string>6B8476FA122D000800ADF63D</string>
|
||||||
<string>6B847779122D223D00ADF63D</string>
|
<string>6B847779122D223D00ADF63D</string>
|
||||||
@ -415,17 +405,27 @@
|
|||||||
<string>6BD66800123D2D230021A7A4</string>
|
<string>6BD66800123D2D230021A7A4</string>
|
||||||
<string>6BD66806123D2F4E0021A7A4</string>
|
<string>6BD66806123D2F4E0021A7A4</string>
|
||||||
<string>6BD6681612434B790021A7A4</string>
|
<string>6BD6681612434B790021A7A4</string>
|
||||||
<string>6BD6681712434B790021A7A4</string>
|
|
||||||
<string>6BD6681812434B790021A7A4</string>
|
<string>6BD6681812434B790021A7A4</string>
|
||||||
<string>6BD6683412434D9D0021A7A4</string>
|
|
||||||
<string>6BD6683512434D9D0021A7A4</string>
|
<string>6BD6683512434D9D0021A7A4</string>
|
||||||
<string>6BD6683712434D9D0021A7A4</string>
|
|
||||||
<string>6BD6684512434DE80021A7A4</string>
|
|
||||||
<string>6BD6684E124350B80021A7A4</string>
|
<string>6BD6684E124350B80021A7A4</string>
|
||||||
<string>6BD66855124350F80021A7A4</string>
|
<string>6BD66855124350F80021A7A4</string>
|
||||||
<string>6BD6685E124351D70021A7A4</string>
|
<string>6BD6685E124351D70021A7A4</string>
|
||||||
<string>6BD6685F124351D70021A7A4</string>
|
<string>6BD6685F124351D70021A7A4</string>
|
||||||
<string>6BD66860124351D70021A7A4</string>
|
<string>6BD6686C124356CE0021A7A4</string>
|
||||||
|
<string>6BD6686E124356CE0021A7A4</string>
|
||||||
|
<string>6BD668A3124361EB0021A7A4</string>
|
||||||
|
<string>6BD668D6124367E30021A7A4</string>
|
||||||
|
<string>6BD6691112436CEC0021A7A4</string>
|
||||||
|
<string>6BD6691212436CEC0021A7A4</string>
|
||||||
|
<string>6BD66930124374D60021A7A4</string>
|
||||||
|
<string>6BD66934124375DF0021A7A4</string>
|
||||||
|
<string>6BD66937124376780021A7A4</string>
|
||||||
|
<string>6BD66938124376780021A7A4</string>
|
||||||
|
<string>6BD66939124376780021A7A4</string>
|
||||||
|
<string>6BD669501243778E0021A7A4</string>
|
||||||
|
<string>6BD669511243778E0021A7A4</string>
|
||||||
|
<string>6BD6695C124377D40021A7A4</string>
|
||||||
|
<string>6BD6695D124377D40021A7A4</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SplitCount</key>
|
<key>SplitCount</key>
|
||||||
@ -439,18 +439,18 @@
|
|||||||
<key>GeometryConfiguration</key>
|
<key>GeometryConfiguration</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{0, 0}, {994, 518}}</string>
|
<string>{{0, 0}, {994, 434}}</string>
|
||||||
<key>RubberWindowFrame</key>
|
<key>RubberWindowFrame</key>
|
||||||
<string>0 112 1280 666 0 0 1280 778 </string>
|
<string>0 112 1280 666 0 0 1280 778 </string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Module</key>
|
<key>Module</key>
|
||||||
<string>PBXNavigatorGroup</string>
|
<string>PBXNavigatorGroup</string>
|
||||||
<key>Proportion</key>
|
<key>Proportion</key>
|
||||||
<string>518pt</string>
|
<string>434pt</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Proportion</key>
|
<key>Proportion</key>
|
||||||
<string>102pt</string>
|
<string>186pt</string>
|
||||||
<key>Tabs</key>
|
<key>Tabs</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
@ -518,7 +518,7 @@
|
|||||||
<key>GeometryConfiguration</key>
|
<key>GeometryConfiguration</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{10, 27}, {994, 75}}</string>
|
<string>{{10, 27}, {994, 159}}</string>
|
||||||
<key>RubberWindowFrame</key>
|
<key>RubberWindowFrame</key>
|
||||||
<string>0 112 1280 666 0 0 1280 778 </string>
|
<string>0 112 1280 666 0 0 1280 778 </string>
|
||||||
</dict>
|
</dict>
|
||||||
@ -602,12 +602,12 @@
|
|||||||
<key>GeometryConfiguration</key>
|
<key>GeometryConfiguration</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{0, 0}, {1280, 462}}</string>
|
<string>{{0, 0}, {1280, 296}}</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Module</key>
|
<key>Module</key>
|
||||||
<string>PBXDebugCLIModule</string>
|
<string>PBXDebugCLIModule</string>
|
||||||
<key>Proportion</key>
|
<key>Proportion</key>
|
||||||
<string>462pt</string>
|
<string>296pt</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>ContentConfiguration</key>
|
<key>ContentConfiguration</key>
|
||||||
@ -626,8 +626,8 @@
|
|||||||
<string>yes</string>
|
<string>yes</string>
|
||||||
<key>sizes</key>
|
<key>sizes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>{{0, 0}, {576, 80}}</string>
|
<string>{{0, 0}, {576, 161}}</string>
|
||||||
<string>{{576, 0}, {704, 80}}</string>
|
<string>{{576, 0}, {704, 161}}</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
<key>VerticalSplitView</key>
|
<key>VerticalSplitView</key>
|
||||||
@ -642,8 +642,8 @@
|
|||||||
<string>yes</string>
|
<string>yes</string>
|
||||||
<key>sizes</key>
|
<key>sizes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>{{0, 0}, {1280, 80}}</string>
|
<string>{{0, 0}, {1280, 161}}</string>
|
||||||
<string>{{0, 78}, {1280, 80}}</string>
|
<string>{{0, 161}, {1280, 163}}</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
@ -663,7 +663,7 @@
|
|||||||
<key>DebugSTDIOWindowFrame</key>
|
<key>DebugSTDIOWindowFrame</key>
|
||||||
<string>{{200, 200}, {500, 300}}</string>
|
<string>{{200, 200}, {500, 300}}</string>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{0, 467}, {1280, 158}}</string>
|
<string>{{0, 301}, {1280, 324}}</string>
|
||||||
<key>PBXDebugSessionStackFrameViewKey</key>
|
<key>PBXDebugSessionStackFrameViewKey</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>DebugVariablesTableConfiguration</key>
|
<key>DebugVariablesTableConfiguration</key>
|
||||||
@ -676,13 +676,13 @@
|
|||||||
<real>328</real>
|
<real>328</real>
|
||||||
</array>
|
</array>
|
||||||
<key>Frame</key>
|
<key>Frame</key>
|
||||||
<string>{{576, 0}, {704, 80}}</string>
|
<string>{{576, 0}, {704, 161}}</string>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Module</key>
|
<key>Module</key>
|
||||||
<string>PBXDebugSessionModule</string>
|
<string>PBXDebugSessionModule</string>
|
||||||
<key>Proportion</key>
|
<key>Proportion</key>
|
||||||
<string>158pt</string>
|
<string>324pt</string>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>Name</key>
|
<key>Name</key>
|
||||||
@ -739,6 +739,7 @@
|
|||||||
<integer>5</integer>
|
<integer>5</integer>
|
||||||
<key>WindowOrderList</key>
|
<key>WindowOrderList</key>
|
||||||
<array>
|
<array>
|
||||||
|
<string>6BD6695F124377D40021A7A4</string>
|
||||||
<string>6BD667A7123D13100021A7A4</string>
|
<string>6BD667A7123D13100021A7A4</string>
|
||||||
<string>6BD667A8123D13100021A7A4</string>
|
<string>6BD667A8123D13100021A7A4</string>
|
||||||
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
|
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
|
||||||
|
@ -43,14 +43,16 @@ void BuildContext::doLog(const rcLogCategory category, const char* msg, const in
|
|||||||
int n = TEXT_POOL_SIZE - m_textPoolSize;
|
int n = TEXT_POOL_SIZE - m_textPoolSize;
|
||||||
if (n < 2)
|
if (n < 2)
|
||||||
return;
|
return;
|
||||||
|
char* cat = dst;
|
||||||
|
char* text = dst+1;
|
||||||
|
const int maxtext = n-1;
|
||||||
// Store category
|
// Store category
|
||||||
*dst = (char)category;
|
*cat = (char)category;
|
||||||
n--;
|
|
||||||
// Store message
|
// Store message
|
||||||
const int count = rcMin(len+1, n);
|
const int count = rcMin(len+1, maxtext);
|
||||||
memcpy(dst+1, msg, count);
|
memcpy(text, msg, count);
|
||||||
dst[count+1] = '\0';
|
text[count-1] = '\0';
|
||||||
m_textPoolSize += count+1;
|
m_textPoolSize += 1 + count;
|
||||||
m_messages[m_messageCount++] = dst;
|
m_messages[m_messageCount++] = dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user