Added more bits to compact neighbour indices, moved region id to rcCompactSpan to save memory.
This commit is contained in:
parent
ababd28f59
commit
d9d9fa85a5
@ -179,9 +179,6 @@ void duDebugDrawCompactHeightfieldSolid(duDebugDraw* dd, const rcCompactHeightfi
|
||||
|
||||
void duDebugDrawCompactHeightfieldRegions(duDebugDraw* dd, const rcCompactHeightfield& chf)
|
||||
{
|
||||
if (!chf.regs)
|
||||
return;
|
||||
|
||||
const float cs = chf.cs;
|
||||
const float ch = chf.ch;
|
||||
|
||||
@ -200,8 +197,8 @@ void duDebugDrawCompactHeightfieldRegions(duDebugDraw* dd, const rcCompactHeight
|
||||
const rcCompactSpan& s = chf.spans[i];
|
||||
const float fy = chf.bmin[1] + (s.y)*ch;
|
||||
unsigned int color;
|
||||
if (chf.regs[i])
|
||||
color = duIntToCol(chf.regs[i], 192);
|
||||
if (s.reg)
|
||||
color = duIntToCol(s.reg, 192);
|
||||
else
|
||||
color = duRGBA(0,0,0,64);
|
||||
|
||||
|
@ -107,7 +107,7 @@ bool duDumpPolyMeshDetailToObj(rcPolyMeshDetail& dmesh, const char* filepath)
|
||||
|
||||
|
||||
static const int CHF_MAGIC = ('r' << 24) | ('c' << 16) | ('h' << 8) | 'f';
|
||||
static const int CHF_VERSION = 1;
|
||||
static const int CHF_VERSION = 2;
|
||||
|
||||
bool duDumpCompactHeightfield(struct rcCompactHeightfield& chf, const char* filepath)
|
||||
{
|
||||
@ -141,8 +141,7 @@ bool duDumpCompactHeightfield(struct rcCompactHeightfield& chf, const char* file
|
||||
if (chf.cells) tmp |= 1;
|
||||
if (chf.spans) tmp |= 2;
|
||||
if (chf.dist) tmp |= 4;
|
||||
if (chf.regs) tmp |= 8;
|
||||
if (chf.areas) tmp |= 16;
|
||||
if (chf.areas) tmp |= 8;
|
||||
|
||||
fwrite(&tmp, sizeof(tmp), 1, fp);
|
||||
|
||||
@ -152,8 +151,6 @@ bool duDumpCompactHeightfield(struct rcCompactHeightfield& chf, const char* file
|
||||
fwrite(chf.spans, sizeof(rcCompactSpan)*chf.spanCount, 1, fp);
|
||||
if (chf.dist)
|
||||
fwrite(chf.dist, sizeof(unsigned short)*chf.spanCount, 1, fp);
|
||||
if (chf.regs)
|
||||
fwrite(chf.regs, sizeof(unsigned short)*chf.spanCount, 1, fp);
|
||||
if (chf.areas)
|
||||
fwrite(chf.areas, sizeof(unsigned char)*chf.spanCount, 1, fp);
|
||||
|
||||
@ -242,17 +239,6 @@ bool duReadCompactHeightfield(struct rcCompactHeightfield& chf, const char* file
|
||||
fread(chf.dist, sizeof(unsigned short)*chf.spanCount, 1, fp);
|
||||
}
|
||||
if (tmp & 8)
|
||||
{
|
||||
chf.regs = new unsigned short[chf.spanCount];
|
||||
if (!chf.regs)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Could not alloc regs (%d)\n", chf.spanCount);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fread(chf.regs, sizeof(unsigned short)*chf.spanCount, 1, fp);
|
||||
}
|
||||
if (tmp & 16)
|
||||
{
|
||||
chf.areas = new unsigned char[chf.spanCount];
|
||||
if (!chf.areas)
|
||||
|
@ -92,8 +92,9 @@ struct rcCompactCell
|
||||
struct rcCompactSpan
|
||||
{
|
||||
unsigned short y; // Bottom coordinate of the span.
|
||||
unsigned short con; // Connections to neighbour cells.
|
||||
unsigned char h; // Height of the span.
|
||||
unsigned short reg;
|
||||
unsigned int con : 24; // Connections to neighbour cells.
|
||||
unsigned int h : 8; // Height of the span.
|
||||
};
|
||||
|
||||
// Compact static heightfield.
|
||||
@ -101,13 +102,13 @@ struct rcCompactHeightfield
|
||||
{
|
||||
inline rcCompactHeightfield() :
|
||||
maxDistance(0), maxRegions(0), cells(0),
|
||||
spans(0), dist(0), regs(0), areas(0) {}
|
||||
spans(0), dist(0), /*regs(0),*/ areas(0) {}
|
||||
inline ~rcCompactHeightfield()
|
||||
{
|
||||
delete [] cells;
|
||||
delete [] spans;
|
||||
delete [] dist;
|
||||
delete [] regs;
|
||||
// delete [] regs;
|
||||
delete [] areas;
|
||||
}
|
||||
int width, height; // Width and height of the heighfield.
|
||||
@ -120,7 +121,7 @@ struct rcCompactHeightfield
|
||||
rcCompactCell* cells; // Pointer to width*height cells.
|
||||
rcCompactSpan* spans; // Pointer to spans.
|
||||
unsigned short* dist; // Pointer to per span distance to border.
|
||||
unsigned short* regs; // Pointer to per span region ID.
|
||||
// unsigned short* regs; // Pointer to per span region ID.
|
||||
unsigned char* areas; // Pointer to per span area ID.
|
||||
};
|
||||
|
||||
@ -262,18 +263,20 @@ static const unsigned char RC_NULL_AREA = 0;
|
||||
static const unsigned char RC_WALKABLE_AREA = 255;
|
||||
|
||||
// Value returned by rcGetCon() if the direction is not connected.
|
||||
static const int RC_NOT_CONNECTED = 0xf;
|
||||
static const int RC_NOT_CONNECTED = 0x3f;
|
||||
|
||||
// Compact span neighbour helpers.
|
||||
inline void rcSetCon(rcCompactSpan& s, int dir, int i)
|
||||
{
|
||||
s.con &= ~(0xf << (dir*4));
|
||||
s.con |= (i&0xf) << (dir*4);
|
||||
const unsigned int shift = (unsigned int)dir*6;
|
||||
unsigned int con = s.con;
|
||||
s.con = (con & ~(0x3f << shift)) | (((unsigned int)i & 0x3f) << shift);
|
||||
}
|
||||
|
||||
inline int rcGetCon(const rcCompactSpan& s, int dir)
|
||||
{
|
||||
return (s.con >> (dir*4)) & 0xf;
|
||||
const unsigned int shift = (unsigned int)dir*6;
|
||||
return (s.con >> shift) & 0x3f;
|
||||
}
|
||||
|
||||
inline int rcGetDirOffsetX(int dir)
|
||||
|
@ -202,6 +202,8 @@ bool rcBuildCompactHeightfield(const int walkableHeight, const int walkableClimb
|
||||
}
|
||||
|
||||
// Find neighbour connections.
|
||||
const float MAX_LAYERS = RC_NOT_CONNECTED-1;
|
||||
int tooHighNeighbour = 0;
|
||||
for (int y = 0; y < h; ++y)
|
||||
{
|
||||
for (int x = 0; x < w; ++x)
|
||||
@ -234,7 +236,13 @@ bool rcBuildCompactHeightfield(const int walkableHeight, const int walkableClimb
|
||||
if ((top - bot) >= walkableHeight && rcAbs((int)ns.y - (int)s.y) <= walkableClimb)
|
||||
{
|
||||
// Mark direction as walkable.
|
||||
rcSetCon(s, dir, k - (int)nc.index);
|
||||
const int idx = k - (int)nc.index;
|
||||
if (idx < 0 || idx > MAX_LAYERS)
|
||||
{
|
||||
tooHighNeighbour = rcMax(tooHighNeighbour, idx);
|
||||
continue;
|
||||
}
|
||||
rcSetCon(s, dir, idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -244,6 +252,12 @@ bool rcBuildCompactHeightfield(const int walkableHeight, const int walkableClimb
|
||||
}
|
||||
}
|
||||
|
||||
if (tooHighNeighbour > MAX_LAYERS)
|
||||
{
|
||||
if (rcGetLog())
|
||||
rcGetLog()->log(RC_LOG_ERROR, "rcBuildCompactHeightfield: Heighfield has too many layers %d (max: %d)", tooHighNeighbour, MAX_LAYERS);
|
||||
}
|
||||
|
||||
rcTimeVal endTime = rcGetPerformanceTimer();
|
||||
|
||||
if (rcGetBuildTimes())
|
||||
|
@ -55,7 +55,7 @@ bool rcErodeArea(unsigned char areaId, int radius, rcCompactHeightfield& chf)
|
||||
int nc = 0;
|
||||
for (int dir = 0; dir < 4; ++dir)
|
||||
{
|
||||
if (rcGetCon(s, dir) != 0xf)
|
||||
if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
|
||||
{
|
||||
const int ax = x + rcGetDirOffsetX(dir);
|
||||
const int ay = y + rcGetDirOffsetY(dir);
|
||||
@ -84,7 +84,7 @@ bool rcErodeArea(unsigned char areaId, int radius, rcCompactHeightfield& chf)
|
||||
{
|
||||
const rcCompactSpan& s = chf.spans[i];
|
||||
|
||||
if (rcGetCon(s, 0) != 0xf)
|
||||
if (rcGetCon(s, 0) != RC_NOT_CONNECTED)
|
||||
{
|
||||
// (-1,0)
|
||||
const int ax = x + rcGetDirOffsetX(0);
|
||||
@ -96,7 +96,7 @@ bool rcErodeArea(unsigned char areaId, int radius, rcCompactHeightfield& chf)
|
||||
dist[i] = nd;
|
||||
|
||||
// (-1,-1)
|
||||
if (rcGetCon(as, 3) != 0xf)
|
||||
if (rcGetCon(as, 3) != RC_NOT_CONNECTED)
|
||||
{
|
||||
const int aax = ax + rcGetDirOffsetX(3);
|
||||
const int aay = ay + rcGetDirOffsetY(3);
|
||||
@ -106,7 +106,7 @@ bool rcErodeArea(unsigned char areaId, int radius, rcCompactHeightfield& chf)
|
||||
dist[i] = nd;
|
||||
}
|
||||
}
|
||||
if (rcGetCon(s, 3) != 0xf)
|
||||
if (rcGetCon(s, 3) != RC_NOT_CONNECTED)
|
||||
{
|
||||
// (0,-1)
|
||||
const int ax = x + rcGetDirOffsetX(3);
|
||||
@ -118,7 +118,7 @@ bool rcErodeArea(unsigned char areaId, int radius, rcCompactHeightfield& chf)
|
||||
dist[i] = nd;
|
||||
|
||||
// (1,-1)
|
||||
if (rcGetCon(as, 2) != 0xf)
|
||||
if (rcGetCon(as, 2) != RC_NOT_CONNECTED)
|
||||
{
|
||||
const int aax = ax + rcGetDirOffsetX(2);
|
||||
const int aay = ay + rcGetDirOffsetY(2);
|
||||
@ -142,7 +142,7 @@ bool rcErodeArea(unsigned char areaId, int radius, rcCompactHeightfield& chf)
|
||||
{
|
||||
const rcCompactSpan& s = chf.spans[i];
|
||||
|
||||
if (rcGetCon(s, 2) != 0xf)
|
||||
if (rcGetCon(s, 2) != RC_NOT_CONNECTED)
|
||||
{
|
||||
// (1,0)
|
||||
const int ax = x + rcGetDirOffsetX(2);
|
||||
@ -154,7 +154,7 @@ bool rcErodeArea(unsigned char areaId, int radius, rcCompactHeightfield& chf)
|
||||
dist[i] = nd;
|
||||
|
||||
// (1,1)
|
||||
if (rcGetCon(as, 1) != 0xf)
|
||||
if (rcGetCon(as, 1) != RC_NOT_CONNECTED)
|
||||
{
|
||||
const int aax = ax + rcGetDirOffsetX(1);
|
||||
const int aay = ay + rcGetDirOffsetY(1);
|
||||
@ -164,7 +164,7 @@ bool rcErodeArea(unsigned char areaId, int radius, rcCompactHeightfield& chf)
|
||||
dist[i] = nd;
|
||||
}
|
||||
}
|
||||
if (rcGetCon(s, 1) != 0xf)
|
||||
if (rcGetCon(s, 1) != RC_NOT_CONNECTED)
|
||||
{
|
||||
// (0,1)
|
||||
const int ax = x + rcGetDirOffsetX(1);
|
||||
@ -176,7 +176,7 @@ bool rcErodeArea(unsigned char areaId, int radius, rcCompactHeightfield& chf)
|
||||
dist[i] = nd;
|
||||
|
||||
// (-1,1)
|
||||
if (rcGetCon(as, 0) != 0xf)
|
||||
if (rcGetCon(as, 0) != RC_NOT_CONNECTED)
|
||||
{
|
||||
const int aax = ax + rcGetDirOffsetX(0);
|
||||
const int aay = ay + rcGetDirOffsetY(0);
|
||||
|
@ -37,7 +37,7 @@ static int getCornerHeight(int x, int y, int i, int dir,
|
||||
|
||||
// Combine region and area codes in order to prevent
|
||||
// border vertices which are in between two areas to be removed.
|
||||
regs[0] = chf.regs[i] | (chf.areas[i] << 16);
|
||||
regs[0] = chf.spans[i].reg | (chf.areas[i] << 16);
|
||||
|
||||
if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
|
||||
{
|
||||
@ -46,7 +46,7 @@ static int getCornerHeight(int x, int y, int i, int dir,
|
||||
const int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dir);
|
||||
const rcCompactSpan& as = chf.spans[ai];
|
||||
ch = rcMax(ch, (int)as.y);
|
||||
regs[1] = chf.regs[ai] | (chf.areas[ai] << 16);
|
||||
regs[1] = chf.spans[ai].reg | (chf.areas[ai] << 16);
|
||||
if (rcGetCon(as, dirp) != RC_NOT_CONNECTED)
|
||||
{
|
||||
const int ax2 = ax + rcGetDirOffsetX(dirp);
|
||||
@ -54,7 +54,7 @@ static int getCornerHeight(int x, int y, int i, int dir,
|
||||
const int ai2 = (int)chf.cells[ax2+ay2*chf.width].index + rcGetCon(as, dirp);
|
||||
const rcCompactSpan& as2 = chf.spans[ai2];
|
||||
ch = rcMax(ch, (int)as2.y);
|
||||
regs[2] = chf.regs[ai2] | (chf.areas[ai2] << 16);
|
||||
regs[2] = chf.spans[ai2].reg | (chf.areas[ai2] << 16);
|
||||
}
|
||||
}
|
||||
if (rcGetCon(s, dirp) != RC_NOT_CONNECTED)
|
||||
@ -64,7 +64,7 @@ static int getCornerHeight(int x, int y, int i, int dir,
|
||||
const int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dirp);
|
||||
const rcCompactSpan& as = chf.spans[ai];
|
||||
ch = rcMax(ch, (int)as.y);
|
||||
regs[3] = chf.regs[ai] | (chf.areas[ai] << 16);
|
||||
regs[3] = chf.spans[ai].reg | (chf.areas[ai] << 16);
|
||||
if (rcGetCon(as, dir) != RC_NOT_CONNECTED)
|
||||
{
|
||||
const int ax2 = ax + rcGetDirOffsetX(dir);
|
||||
@ -72,7 +72,7 @@ static int getCornerHeight(int x, int y, int i, int dir,
|
||||
const int ai2 = (int)chf.cells[ax2+ay2*chf.width].index + rcGetCon(as, dir);
|
||||
const rcCompactSpan& as2 = chf.spans[ai2];
|
||||
ch = rcMax(ch, (int)as2.y);
|
||||
regs[2] = chf.regs[ai2] | (chf.areas[ai2] << 16);
|
||||
regs[2] = chf.spans[ai2].reg | (chf.areas[ai2] << 16);
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ static void walkContour(int x, int y, int i,
|
||||
const int ax = x + rcGetDirOffsetX(dir);
|
||||
const int ay = y + rcGetDirOffsetY(dir);
|
||||
const int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dir);
|
||||
r = (int)chf.regs[ai];
|
||||
r = (int)chf.spans[ai].reg;
|
||||
if (area != chf.areas[ai])
|
||||
isAreaBorder = true;
|
||||
}
|
||||
@ -600,7 +600,7 @@ bool rcBuildContours(rcCompactHeightfield& chf,
|
||||
{
|
||||
unsigned char res = 0;
|
||||
const rcCompactSpan& s = chf.spans[i];
|
||||
if (!chf.regs[i] || (chf.regs[i] & RC_BORDER_REG))
|
||||
if (!chf.spans[i].reg || (chf.spans[i].reg & RC_BORDER_REG))
|
||||
{
|
||||
flags[i] = 0;
|
||||
continue;
|
||||
@ -613,9 +613,9 @@ bool rcBuildContours(rcCompactHeightfield& chf,
|
||||
const int ax = x + rcGetDirOffsetX(dir);
|
||||
const int ay = y + rcGetDirOffsetY(dir);
|
||||
const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);
|
||||
r = chf.regs[ai];
|
||||
r = chf.spans[ai].reg;
|
||||
}
|
||||
if (r == chf.regs[i])
|
||||
if (r == chf.spans[i].reg)
|
||||
res |= (1 << dir);
|
||||
}
|
||||
flags[i] = res ^ 0xf; // Inverse, mark non connected edges.
|
||||
@ -642,7 +642,7 @@ bool rcBuildContours(rcCompactHeightfield& chf,
|
||||
flags[i] = 0;
|
||||
continue;
|
||||
}
|
||||
const unsigned short reg = chf.regs[i];
|
||||
const unsigned short reg = chf.spans[i].reg;
|
||||
if (!reg || (reg & RC_BORDER_REG))
|
||||
continue;
|
||||
const unsigned char area = chf.areas[i];
|
||||
|
@ -997,12 +997,6 @@ bool rcBuildRegionsMonotone(rcCompactHeightfield& chf,
|
||||
const int h = chf.height;
|
||||
unsigned short id = 1;
|
||||
|
||||
if (chf.regs)
|
||||
{
|
||||
delete [] chf.regs;
|
||||
chf.regs = 0;
|
||||
}
|
||||
|
||||
rcScopedDelete<unsigned short> srcReg = new unsigned short[chf.spanCount];
|
||||
if (!srcReg)
|
||||
{
|
||||
@ -1131,8 +1125,8 @@ bool rcBuildRegionsMonotone(rcCompactHeightfield& chf,
|
||||
rcTimeVal filterEndTime = rcGetPerformanceTimer();
|
||||
|
||||
// Store the result out.
|
||||
chf.regs = srcReg;
|
||||
srcReg = 0;
|
||||
for (int i = 0; i < chf.spanCount; ++i)
|
||||
chf.spans[i].reg = srcReg[i];
|
||||
|
||||
rcTimeVal endTime = rcGetPerformanceTimer();
|
||||
|
||||
@ -1152,17 +1146,6 @@ bool rcBuildRegions(rcCompactHeightfield& chf,
|
||||
|
||||
const int w = chf.width;
|
||||
const int h = chf.height;
|
||||
|
||||
if (!chf.regs)
|
||||
{
|
||||
chf.regs = new unsigned short[chf.spanCount];
|
||||
if (!chf.regs)
|
||||
{
|
||||
if (rcGetLog())
|
||||
rcGetLog()->log(RC_LOG_ERROR, "rcBuildRegions: Out of memory 'chf.reg' (%d).", chf.spanCount);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
rcScopedDelete<unsigned short> tmp = new unsigned short[chf.spanCount*4];
|
||||
if (!tmp)
|
||||
@ -1260,7 +1243,8 @@ bool rcBuildRegions(rcCompactHeightfield& chf,
|
||||
rcTimeVal filterEndTime = rcGetPerformanceTimer();
|
||||
|
||||
// Write the result out.
|
||||
memcpy(chf.regs, srcReg, sizeof(unsigned short)*chf.spanCount);
|
||||
for (int i = 0; i < chf.spanCount; ++i)
|
||||
chf.spans[i].reg = srcReg[i];
|
||||
|
||||
rcTimeVal endTime = rcGetPerformanceTimer();
|
||||
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -281,14 +281,14 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>13</integer>
|
||||
<integer>12</integer>
|
||||
<integer>45</integer>
|
||||
<integer>35</integer>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||
<string>{{0, 99}, {358, 643}}</string>
|
||||
<string>{{0, 458}, {358, 643}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@ -323,7 +323,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>DetourNavMesh.h</string>
|
||||
<string>Sample_Debug.cpp</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -331,11 +331,11 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A40F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>DetourNavMesh.h</string>
|
||||
<string>Sample_Debug.cpp</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6B80373A113D1079005ED67B</string>
|
||||
<string>6B92D9C8114101C100E82EC3</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6B8DE70D10B01BBF00DF20FB</string>
|
||||
@ -350,7 +350,6 @@
|
||||
<string>6BF7C5F91116F346002B3F46</string>
|
||||
<string>6BF7C67D1117163B002B3F46</string>
|
||||
<string>6BF7C69B11172159002B3F46</string>
|
||||
<string>6B324ACA111C00D700EBD2FD</string>
|
||||
<string>6B324AE6111C07AB00EBD2FD</string>
|
||||
<string>6B324AEA111C0D9700EBD2FD</string>
|
||||
<string>6B324AFB111C0F2700EBD2FD</string>
|
||||
@ -362,45 +361,46 @@
|
||||
<string>6B324E7011256D1000EBD2FD</string>
|
||||
<string>6B324E7111256D1000EBD2FD</string>
|
||||
<string>6B324F1311257F9A00EBD2FD</string>
|
||||
<string>6B324F1E1125818400EBD2FD</string>
|
||||
<string>6B324F1F1125818400EBD2FD</string>
|
||||
<string>6B324F2E112584FB00EBD2FD</string>
|
||||
<string>6B324F3A1125891F00EBD2FD</string>
|
||||
<string>6B324F541125904E00EBD2FD</string>
|
||||
<string>6B324F9B11259A5800EBD2FD</string>
|
||||
<string>6B324FCD1125A7BB00EBD2FD</string>
|
||||
<string>6BE90FDE112A770600F5C17A</string>
|
||||
<string>6BE90FDF112A770600F5C17A</string>
|
||||
<string>6BE91033112A7D9600F5C17A</string>
|
||||
<string>6BE91085112A898E00F5C17A</string>
|
||||
<string>6BE910BA112A91D900F5C17A</string>
|
||||
<string>6BE910BB112A91D900F5C17A</string>
|
||||
<string>6BE910C2112A92A300F5C17A</string>
|
||||
<string>6BE910D4112A933500F5C17A</string>
|
||||
<string>6BE910D9112B1AF000F5C17A</string>
|
||||
<string>6BE910F11130617300F5C17A</string>
|
||||
<string>6BE910F21130617300F5C17A</string>
|
||||
<string>6BE910F31130617300F5C17A</string>
|
||||
<string>6BE9113A11379F5000F5C17A</string>
|
||||
<string>6BE9113C11379F5000F5C17A</string>
|
||||
<string>6B803699113BAA82005ED67B</string>
|
||||
<string>6B80369C113BAA82005ED67B</string>
|
||||
<string>6B8036BB113BAF47005ED67B</string>
|
||||
<string>6B8036BC113BAF47005ED67B</string>
|
||||
<string>6B8036BE113BAF47005ED67B</string>
|
||||
<string>6B8036D0113BAF79005ED67B</string>
|
||||
<string>6B8036EA113BB055005ED67B</string>
|
||||
<string>6B8036EE113BB180005ED67B</string>
|
||||
<string>6B8036F6113BB746005ED67B</string>
|
||||
<string>6B8036F7113BB746005ED67B</string>
|
||||
<string>6B8036F8113BB746005ED67B</string>
|
||||
<string>6B8036F9113BB746005ED67B</string>
|
||||
<string>6B8036FA113BB746005ED67B</string>
|
||||
<string>6B803728113D1079005ED67B</string>
|
||||
<string>6B803729113D1079005ED67B</string>
|
||||
<string>6B80372A113D1079005ED67B</string>
|
||||
<string>6B80372B113D1079005ED67B</string>
|
||||
<string>6B80372C113D1079005ED67B</string>
|
||||
<string>6B803743113D1190005ED67B</string>
|
||||
<string>6B803796113D1629005ED67B</string>
|
||||
<string>6BC8BE261140ED5F00555B22</string>
|
||||
<string>6BC8BE4A1140F01D00555B22</string>
|
||||
<string>6BC8BE4B1140F01D00555B22</string>
|
||||
<string>6B92D9661140FBDA00E82EC3</string>
|
||||
<string>6B92D96A1140FBDA00E82EC3</string>
|
||||
<string>6B92D96B1140FBDA00E82EC3</string>
|
||||
<string>6B92D97A1140FE6000E82EC3</string>
|
||||
<string>6B92D97B1140FE6000E82EC3</string>
|
||||
<string>6B92D97D1140FE6000E82EC3</string>
|
||||
<string>6B92D9881140FE9700E82EC3</string>
|
||||
<string>6B92D99D1141004F00E82EC3</string>
|
||||
<string>6B92D9AF114100A300E82EC3</string>
|
||||
<string>6B92D9B81141017500E82EC3</string>
|
||||
<string>6B92D9B91141017500E82EC3</string>
|
||||
<string>6B92D9BA1141017500E82EC3</string>
|
||||
<string>6B92D9BB1141017500E82EC3</string>
|
||||
<string>6B92D9C5114101C100E82EC3</string>
|
||||
<string>6B92D9C6114101C100E82EC3</string>
|
||||
</array>
|
||||
<key>prevStack</key>
|
||||
<array>
|
||||
@ -433,14 +433,11 @@
|
||||
<string>6B324C71111C5DDC00EBD2FD</string>
|
||||
<string>6B324CA4111C6DD400EBD2FD</string>
|
||||
<string>6B324E341125598400EBD2FD</string>
|
||||
<string>6B324E351125598400EBD2FD</string>
|
||||
<string>6B324ED41125770F00EBD2FD</string>
|
||||
<string>6B324F261125818400EBD2FD</string>
|
||||
<string>6B324F271125818400EBD2FD</string>
|
||||
<string>6B324F291125818400EBD2FD</string>
|
||||
<string>6B324F31112584FB00EBD2FD</string>
|
||||
<string>6B324B5F111C1AC800EBD2FD</string>
|
||||
<string>6B324FD01125A7BB00EBD2FD</string>
|
||||
<string>6BE90FE6112A770600F5C17A</string>
|
||||
<string>6BE90FEF112A770600F5C17A</string>
|
||||
<string>6BE91016112A78D400F5C17A</string>
|
||||
@ -449,51 +446,63 @@
|
||||
<string>6BE9108A112A898E00F5C17A</string>
|
||||
<string>6BE910A5112A8CF900F5C17A</string>
|
||||
<string>6BE910C7112A92A300F5C17A</string>
|
||||
<string>6BE910F91130617300F5C17A</string>
|
||||
<string>6BE9113F11379F5000F5C17A</string>
|
||||
<string>6BE9114011379F5000F5C17A</string>
|
||||
<string>6B80369F113BAA82005ED67B</string>
|
||||
<string>6B8036A1113BAA82005ED67B</string>
|
||||
<string>6B8036A2113BAA82005ED67B</string>
|
||||
<string>6B8036A3113BAA82005ED67B</string>
|
||||
<string>6B8036A5113BAA82005ED67B</string>
|
||||
<string>6B8036A6113BAA82005ED67B</string>
|
||||
<string>6B8036A7113BAA82005ED67B</string>
|
||||
<string>6B8036A8113BAA82005ED67B</string>
|
||||
<string>6B8036A9113BAA82005ED67B</string>
|
||||
<string>6B8036C1113BAF47005ED67B</string>
|
||||
<string>6B8036C2113BAF47005ED67B</string>
|
||||
<string>6B8036C3113BAF47005ED67B</string>
|
||||
<string>6B8036C4113BAF47005ED67B</string>
|
||||
<string>6B8036C5113BAF47005ED67B</string>
|
||||
<string>6B8036C6113BAF47005ED67B</string>
|
||||
<string>6B8036C7113BAF47005ED67B</string>
|
||||
<string>6B8036C8113BAF47005ED67B</string>
|
||||
<string>6B8036CA113BAF47005ED67B</string>
|
||||
<string>6B8036CB113BAF47005ED67B</string>
|
||||
<string>6B8036CC113BAF47005ED67B</string>
|
||||
<string>6B8036D3113BAF79005ED67B</string>
|
||||
<string>6B8036D4113BAF79005ED67B</string>
|
||||
<string>6B8036D5113BAF79005ED67B</string>
|
||||
<string>6B8036F0113BB180005ED67B</string>
|
||||
<string>6B8036FC113BB746005ED67B</string>
|
||||
<string>6B8036FD113BB746005ED67B</string>
|
||||
<string>6B8036FE113BB746005ED67B</string>
|
||||
<string>6B8036FF113BB746005ED67B</string>
|
||||
<string>6B803700113BB746005ED67B</string>
|
||||
<string>6B80372D113D1079005ED67B</string>
|
||||
<string>6B80372E113D1079005ED67B</string>
|
||||
<string>6B80372F113D1079005ED67B</string>
|
||||
<string>6B803730113D1079005ED67B</string>
|
||||
<string>6B803731113D1079005ED67B</string>
|
||||
<string>6B803732113D1079005ED67B</string>
|
||||
<string>6B803733113D1079005ED67B</string>
|
||||
<string>6B803734113D1079005ED67B</string>
|
||||
<string>6B803735113D1079005ED67B</string>
|
||||
<string>6B803736113D1079005ED67B</string>
|
||||
<string>6B803737113D1079005ED67B</string>
|
||||
<string>6B803738113D1079005ED67B</string>
|
||||
<string>6B803739113D1079005ED67B</string>
|
||||
<string>6B80379A113D1629005ED67B</string>
|
||||
<string>6B80379B113D1629005ED67B</string>
|
||||
<string>6BC8BE281140ED5F00555B22</string>
|
||||
<string>6B92D9121140F58200E82EC3</string>
|
||||
<string>6B92D91C1140F5F800E82EC3</string>
|
||||
<string>6B92D9261140F6BF00E82EC3</string>
|
||||
<string>6B92D9321140F7C500E82EC3</string>
|
||||
<string>6B92D9411140F84100E82EC3</string>
|
||||
<string>6BE910F91130617300F5C17A</string>
|
||||
<string>6B92D94E1140F99700E82EC3</string>
|
||||
<string>6B92D94F1140F99700E82EC3</string>
|
||||
<string>6B92D9501140F99700E82EC3</string>
|
||||
<string>6B92D9511140F99700E82EC3</string>
|
||||
<string>6B92D95F1140FB3D00E82EC3</string>
|
||||
<string>6B92D96D1140FBDA00E82EC3</string>
|
||||
<string>6B92D96E1140FBDA00E82EC3</string>
|
||||
<string>6B92D96F1140FBDA00E82EC3</string>
|
||||
<string>6B92D9701140FBDA00E82EC3</string>
|
||||
<string>6B92D9711140FBDA00E82EC3</string>
|
||||
<string>6B92D9721140FBDA00E82EC3</string>
|
||||
<string>6B92D9731140FBDA00E82EC3</string>
|
||||
<string>6B92D9741140FBDA00E82EC3</string>
|
||||
<string>6B92D9751140FBDA00E82EC3</string>
|
||||
<string>6B92D97F1140FE6000E82EC3</string>
|
||||
<string>6B92D9801140FE6000E82EC3</string>
|
||||
<string>6B92D9811140FE6000E82EC3</string>
|
||||
<string>6B92D9821140FE6000E82EC3</string>
|
||||
<string>6B92D9831140FE6000E82EC3</string>
|
||||
<string>6B92D9841140FE6000E82EC3</string>
|
||||
<string>6B92D9851140FE6000E82EC3</string>
|
||||
<string>6B92D98A1140FE9700E82EC3</string>
|
||||
<string>6B92D9A21141004F00E82EC3</string>
|
||||
<string>6B92D9A31141004F00E82EC3</string>
|
||||
<string>6B92D9A41141004F00E82EC3</string>
|
||||
<string>6B92D9A51141004F00E82EC3</string>
|
||||
<string>6B92D9A61141004F00E82EC3</string>
|
||||
<string>6B92D9A71141004F00E82EC3</string>
|
||||
<string>6B92D9A81141004F00E82EC3</string>
|
||||
<string>6B92D9B1114100A300E82EC3</string>
|
||||
<string>6B92D9B2114100A300E82EC3</string>
|
||||
<string>6B92D9BD1141017500E82EC3</string>
|
||||
<string>6B92D9BE1141017500E82EC3</string>
|
||||
<string>6B92D9BF1141017500E82EC3</string>
|
||||
<string>6B92D9C01141017500E82EC3</string>
|
||||
<string>6B92D9C11141017500E82EC3</string>
|
||||
<string>6B92D9C21141017500E82EC3</string>
|
||||
<string>6B92D9C31141017500E82EC3</string>
|
||||
<string>6B92D9C7114101C100E82EC3</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@ -507,18 +516,18 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {876, 587}}</string>
|
||||
<string>{{0, 0}, {876, 377}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>11 76 1256 702 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXNavigatorGroup</string>
|
||||
<key>Proportion</key>
|
||||
<string>587pt</string>
|
||||
<string>377pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>69pt</string>
|
||||
<string>279pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -532,7 +541,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {876, 42}}</string>
|
||||
<string>{{10, 27}, {876, -27}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>XCDetailModule</string>
|
||||
@ -548,7 +557,9 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {876, 192}}</string>
|
||||
<string>{{10, 27}, {876, 252}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>11 76 1256 702 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXProjectFindModule</string>
|
||||
@ -586,9 +597,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {876, 42}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>11 76 1256 702 0 0 1280 778 </string>
|
||||
<string>{{10, 27}, {876, 152}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXBuildResultsModule</string>
|
||||
@ -616,11 +625,11 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6B803671113BA319005ED67B</string>
|
||||
<string>6B92D8EE1140F26D00E82EC3</string>
|
||||
<string>1CA23ED40692098700951B8B</string>
|
||||
<string>6B803672113BA319005ED67B</string>
|
||||
<string>6B92D8EF1140F26D00E82EC3</string>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<string>6B803673113BA319005ED67B</string>
|
||||
<string>6B92D8F01140F26D00E82EC3</string>
|
||||
<string>1CA23EDF0692099D00951B8B</string>
|
||||
<string>1CA23EE00692099D00951B8B</string>
|
||||
<string>1CA23EE10692099D00951B8B</string>
|
||||
@ -671,12 +680,12 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {1256, 229}}</string>
|
||||
<string>{{0, 0}, {1256, 310}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugCLIModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>229pt</string>
|
||||
<string>310pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ContentConfiguration</key>
|
||||
@ -695,8 +704,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {628, 102}}</string>
|
||||
<string>{{628, 0}, {628, 102}}</string>
|
||||
<string>{{0, 0}, {527, 113}}</string>
|
||||
<string>{{527, 0}, {729, 113}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>VerticalSplitView</key>
|
||||
@ -711,8 +720,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {1256, 102}}</string>
|
||||
<string>{{0, 102}, {1256, 325}}</string>
|
||||
<string>{{0, 0}, {1256, 113}}</string>
|
||||
<string>{{0, 113}, {1256, 233}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
@ -732,26 +741,26 @@
|
||||
<key>DebugSTDIOWindowFrame</key>
|
||||
<string>{{200, 200}, {500, 300}}</string>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 234}, {1256, 427}}</string>
|
||||
<string>{{0, 315}, {1256, 346}}</string>
|
||||
<key>PBXDebugSessionStackFrameViewKey</key>
|
||||
<dict>
|
||||
<key>DebugVariablesTableConfiguration</key>
|
||||
<array>
|
||||
<string>Name</string>
|
||||
<real>120</real>
|
||||
<real>183</real>
|
||||
<string>Value</string>
|
||||
<real>85</real>
|
||||
<string>Summary</string>
|
||||
<real>398</real>
|
||||
<real>436</real>
|
||||
</array>
|
||||
<key>Frame</key>
|
||||
<string>{{628, 0}, {628, 102}}</string>
|
||||
<string>{{527, 0}, {729, 113}}</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugSessionModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>427pt</string>
|
||||
<string>346pt</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Name</key>
|
||||
@ -769,14 +778,14 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6B803679113BA44E005ED67B</string>
|
||||
<string>6B92D9001140F44200E82EC3</string>
|
||||
<string>1CCC7628064C1048000F2A68</string>
|
||||
<string>1CCC7629064C1048000F2A68</string>
|
||||
<string>6B80367A113BA44E005ED67B</string>
|
||||
<string>6B80367B113BA44E005ED67B</string>
|
||||
<string>6B80367C113BA44E005ED67B</string>
|
||||
<string>6B80367D113BA44E005ED67B</string>
|
||||
<string>6B80367E113BA44E005ED67B</string>
|
||||
<string>6B92D9011140F44200E82EC3</string>
|
||||
<string>6B92D9021140F44200E82EC3</string>
|
||||
<string>6B92D9031140F44200E82EC3</string>
|
||||
<string>6B92D9041140F44200E82EC3</string>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
</array>
|
||||
<key>ToolbarConfigUserDefaultsMinorVersion</key>
|
||||
<string>2</string>
|
||||
@ -808,8 +817,8 @@
|
||||
<integer>5</integer>
|
||||
<key>WindowOrderList</key>
|
||||
<array>
|
||||
<string>6B803688113BA4F1005ED67B</string>
|
||||
<string>6B803689113BA4F1005ED67B</string>
|
||||
<string>6B92D9071140F44200E82EC3</string>
|
||||
<string>6B92D9081140F44200E82EC3</string>
|
||||
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
|
||||
</array>
|
||||
<key>WindowString</key>
|
||||
|
@ -29,6 +29,7 @@ class Sample_Debug : public Sample
|
||||
{
|
||||
protected:
|
||||
rcCompactHeightfield* m_chf;
|
||||
rcContourSet* m_cset;
|
||||
|
||||
public:
|
||||
Sample_Debug();
|
||||
|
@ -37,7 +37,8 @@
|
||||
|
||||
|
||||
Sample_Debug::Sample_Debug() :
|
||||
m_chf(0)
|
||||
m_chf(0),
|
||||
m_cset(0)
|
||||
{
|
||||
resetCommonSettings();
|
||||
|
||||
@ -48,11 +49,32 @@ Sample_Debug::Sample_Debug() :
|
||||
delete m_chf;
|
||||
m_chf = 0;
|
||||
}
|
||||
|
||||
if (m_chf)
|
||||
{
|
||||
unsigned short ymin = 0xffff;
|
||||
unsigned short ymax = 0;
|
||||
for (int i = 0; i < m_chf->spanCount; ++i)
|
||||
{
|
||||
const rcCompactSpan& s = m_chf->spans[i];
|
||||
if (s.y < ymin) ymin = s.y;
|
||||
if (s.y > ymax) ymax = s.y;
|
||||
}
|
||||
printf("ymin=%d ymax=%d\n", (int)ymin, (int)ymax);
|
||||
|
||||
int maxSpans = 0;
|
||||
for (int i = 0; i < m_chf->width*m_chf->height; ++i)
|
||||
{
|
||||
maxSpans = rcMax(maxSpans, (int)m_chf->cells[i].count);
|
||||
}
|
||||
printf("maxSpans = %d\n", maxSpans);
|
||||
}
|
||||
}
|
||||
|
||||
Sample_Debug::~Sample_Debug()
|
||||
{
|
||||
delete m_chf;
|
||||
delete m_cset;
|
||||
}
|
||||
|
||||
void Sample_Debug::handleSettings()
|
||||
@ -72,7 +94,13 @@ void Sample_Debug::handleRender()
|
||||
DebugDrawGL dd;
|
||||
|
||||
if (m_chf)
|
||||
{
|
||||
duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
|
||||
// duDebugDrawCompactHeightfieldSolid(&dd, *m_chf);
|
||||
}
|
||||
|
||||
if (m_cset)
|
||||
duDebugDrawRawContours(&dd, *m_cset);
|
||||
}
|
||||
|
||||
void Sample_Debug::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
@ -110,5 +138,23 @@ void Sample_Debug::handleStep()
|
||||
|
||||
bool Sample_Debug::handleBuild()
|
||||
{
|
||||
delete m_cset;
|
||||
m_cset = 0;
|
||||
|
||||
// Create contours.
|
||||
m_cset = new rcContourSet;
|
||||
if (!m_cset)
|
||||
{
|
||||
if (rcGetLog())
|
||||
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'cset'.");
|
||||
return false;
|
||||
}
|
||||
if (!rcBuildContours(*m_chf, /*m_cfg.maxSimplificationError*/1.3f, /*m_cfg.maxEdgeLen*/12, *m_cset))
|
||||
{
|
||||
if (rcGetLog())
|
||||
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Could not create contours.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -638,6 +638,37 @@ int main(int argc, char *argv[])
|
||||
showSample = false;
|
||||
}
|
||||
|
||||
if (geom || sample)
|
||||
{
|
||||
const float* bmin = 0;
|
||||
const float* bmax = 0;
|
||||
if (sample)
|
||||
{
|
||||
bmin = sample->getBoundsMin();
|
||||
bmax = sample->getBoundsMax();
|
||||
}
|
||||
else if (geom)
|
||||
{
|
||||
bmin = geom->getMeshBoundsMin();
|
||||
bmax = geom->getMeshBoundsMax();
|
||||
}
|
||||
// Reset camera and fog to match the mesh bounds.
|
||||
if (bmin && bmax)
|
||||
{
|
||||
camr = sqrtf(rcSqr(bmax[0]-bmin[0]) +
|
||||
rcSqr(bmax[1]-bmin[1]) +
|
||||
rcSqr(bmax[2]-bmin[2])) / 2;
|
||||
camx = (bmax[0] + bmin[0]) / 2 + camr;
|
||||
camy = (bmax[1] + bmin[1]) / 2 + camr;
|
||||
camz = (bmax[2] + bmin[2]) / 2 + camr;
|
||||
camr *= 3;
|
||||
}
|
||||
rx = 45;
|
||||
ry = -45;
|
||||
glFogf(GL_FOG_START, camr*0.2f);
|
||||
glFogf(GL_FOG_END, camr*1.25f);
|
||||
}
|
||||
|
||||
imguiEndScrollArea();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user