Compact heighfield dump and debug project to load it.
This commit is contained in:
parent
dbf95000e6
commit
af0d41f5ff
@ -22,4 +22,7 @@
|
||||
bool duDumpPolyMeshToObj(struct rcPolyMesh& pmesh, const char* filepath);
|
||||
bool duDumpPolyMeshDetailToObj(struct rcPolyMeshDetail& dmesh, const char* filepath);
|
||||
|
||||
bool duDumpCompactHeightfield(struct rcCompactHeightfield& chf, const char* filepath);
|
||||
bool duReadCompactHeightfield(struct rcCompactHeightfield& chf, const char* filepath);
|
||||
|
||||
#endif // RECAST_DUMP_H
|
||||
|
@ -104,3 +104,168 @@ bool duDumpPolyMeshDetailToObj(rcPolyMeshDetail& dmesh, const char* filepath)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static const int CHF_MAGIC = ('r' << 24) | ('c' << 16) | ('h' << 8) | 'f';
|
||||
static const int CHF_VERSION = 1;
|
||||
|
||||
bool duDumpCompactHeightfield(struct rcCompactHeightfield& chf, const char* filepath)
|
||||
{
|
||||
FILE* fp = fopen(filepath, "wb");
|
||||
if (!fp)
|
||||
{
|
||||
printf("duDumpCompactHeightfield: Could not open '%s' for writing.\n", filepath);
|
||||
return false;
|
||||
}
|
||||
|
||||
fwrite(&CHF_MAGIC, sizeof(CHF_MAGIC), 1, fp);
|
||||
fwrite(&CHF_VERSION, sizeof(CHF_VERSION), 1, fp);
|
||||
|
||||
fwrite(&chf.width, sizeof(chf.width), 1, fp);
|
||||
fwrite(&chf.height, sizeof(chf.height), 1, fp);
|
||||
fwrite(&chf.spanCount, sizeof(chf.spanCount), 1, fp);
|
||||
|
||||
fwrite(&chf.walkableHeight, sizeof(chf.walkableHeight), 1, fp);
|
||||
fwrite(&chf.walkableClimb, sizeof(chf.walkableClimb), 1, fp);
|
||||
|
||||
fwrite(&chf.maxDistance, sizeof(chf.maxDistance), 1, fp);
|
||||
fwrite(&chf.maxRegions, sizeof(chf.maxRegions), 1, fp);
|
||||
|
||||
fwrite(chf.bmin, sizeof(chf.bmin), 1, fp);
|
||||
fwrite(chf.bmax, sizeof(chf.bmax), 1, fp);
|
||||
|
||||
fwrite(&chf.cs, sizeof(chf.cs), 1, fp);
|
||||
fwrite(&chf.ch, sizeof(chf.ch), 1, fp);
|
||||
|
||||
int tmp;
|
||||
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;
|
||||
|
||||
fwrite(&tmp, sizeof(tmp), 1, fp);
|
||||
|
||||
if (chf.cells)
|
||||
fwrite(chf.cells, sizeof(rcCompactCell)*chf.width*chf.height, 1, fp);
|
||||
if (chf.spans)
|
||||
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);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool duReadCompactHeightfield(struct rcCompactHeightfield& chf, const char* filepath)
|
||||
{
|
||||
FILE* fp = fopen(filepath, "rb");
|
||||
if (!fp)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Could not open '%s' for reading.\n", filepath);
|
||||
return false;
|
||||
}
|
||||
int magic = 0;
|
||||
int version = 0;
|
||||
|
||||
fread(&magic, sizeof(magic), 1, fp);
|
||||
fread(&version, sizeof(version), 1, fp);
|
||||
|
||||
if (magic != CHF_MAGIC)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Bad voodoo.\n");
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
if (version != CHF_VERSION)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Bad version.\n");
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
|
||||
fread(&chf.width, sizeof(chf.width), 1, fp);
|
||||
fread(&chf.height, sizeof(chf.height), 1, fp);
|
||||
fread(&chf.spanCount, sizeof(chf.spanCount), 1, fp);
|
||||
|
||||
fread(&chf.walkableHeight, sizeof(chf.walkableHeight), 1, fp);
|
||||
fread(&chf.walkableClimb, sizeof(chf.walkableClimb), 1, fp);
|
||||
|
||||
fread(&chf.maxDistance, sizeof(chf.maxDistance), 1, fp);
|
||||
fread(&chf.maxRegions, sizeof(chf.maxRegions), 1, fp);
|
||||
|
||||
fread(chf.bmin, sizeof(chf.bmin), 1, fp);
|
||||
fread(chf.bmax, sizeof(chf.bmax), 1, fp);
|
||||
|
||||
fread(&chf.cs, sizeof(chf.cs), 1, fp);
|
||||
fread(&chf.ch, sizeof(chf.ch), 1, fp);
|
||||
|
||||
int tmp = 0;
|
||||
fread(&tmp, sizeof(tmp), 1, fp);
|
||||
|
||||
if (tmp & 1)
|
||||
{
|
||||
chf.cells = new rcCompactCell[chf.width*chf.height];
|
||||
if (!chf.cells)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Could not alloc cells (%d)\n", chf.width*chf.height);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fread(chf.cells, sizeof(rcCompactCell)*chf.width*chf.height, 1, fp);
|
||||
}
|
||||
if (tmp & 2)
|
||||
{
|
||||
chf.spans = new rcCompactSpan[chf.spanCount];
|
||||
if (!chf.spans)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Could not alloc spans (%d)\n", chf.spanCount);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fread(chf.spans, sizeof(rcCompactSpan)*chf.spanCount, 1, fp);
|
||||
}
|
||||
if (tmp & 4)
|
||||
{
|
||||
chf.dist = new unsigned short[chf.spanCount];
|
||||
if (!chf.dist)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Could not alloc dist (%d)\n", chf.spanCount);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
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)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Could not alloc areas (%d)\n", chf.spanCount);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fread(chf.areas, sizeof(unsigned char)*chf.spanCount, 1, fp);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ static void simplifyContour(rcIntArray& points, rcIntArray& simplified, float ma
|
||||
llz = z;
|
||||
lli = i/4;
|
||||
}
|
||||
if (x >= urx || (x == urx && z > urz))
|
||||
if (x > urx || (x == urx && z > urz))
|
||||
{
|
||||
urx = x;
|
||||
ury = y;
|
||||
|
Binary file not shown.
BIN
RecastDemo/Bin/test.chf
Normal file
BIN
RecastDemo/Bin/test.chf
Normal file
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, 0}, {358, 643}}</string>
|
||||
<string>{{0, 370}, {358, 643}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@ -323,7 +323,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>DetourNavMesh.cpp</string>
|
||||
<string>RecastDump.cpp</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -331,24 +331,19 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A40F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>DetourNavMesh.cpp</string>
|
||||
<string>RecastDump.cpp</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6B324FD41125A7BB00EBD2FD</string>
|
||||
<string>6B8036ED113BB067005ED67B</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6B8DE70D10B01BBF00DF20FB</string>
|
||||
<string>6BBB883C10EA9B6F008FEA1F</string>
|
||||
<string>6BB7FDC010F37703006DA0A6</string>
|
||||
<string>6BCF341A1105EC43009445BF</string>
|
||||
<string>6BF7BE1F110F0792002B3F46</string>
|
||||
<string>6BF7C0E511116E74002B3F46</string>
|
||||
<string>6BF7C1D01111BCF2002B3F46</string>
|
||||
<string>6BF7C2441111DAC1002B3F46</string>
|
||||
<string>6BF7C2761112BE4F002B3F46</string>
|
||||
<string>6BF7C2851112C348002B3F46</string>
|
||||
<string>6BF7C394111316AD002B3F46</string>
|
||||
<string>6BF7C395111316AD002B3F46</string>
|
||||
<string>6BF7C4641115C514002B3F46</string>
|
||||
<string>6BF7C4831115C7C4002B3F46</string>
|
||||
@ -361,69 +356,67 @@
|
||||
<string>6B324AFB111C0F2700EBD2FD</string>
|
||||
<string>6B324B1F111C10C700EBD2FD</string>
|
||||
<string>6B324B4F111C1AC800EBD2FD</string>
|
||||
<string>6B324B50111C1AC800EBD2FD</string>
|
||||
<string>6B324B51111C1AC800EBD2FD</string>
|
||||
<string>6B324B52111C1AC800EBD2FD</string>
|
||||
<string>6B324C45111C5C5A00EBD2FD</string>
|
||||
<string>6B324C92111C604500EBD2FD</string>
|
||||
<string>6B324CC3111C6F6300EBD2FD</string>
|
||||
<string>6B324D0F1121C78000EBD2FD</string>
|
||||
<string>6B324D101121C78000EBD2FD</string>
|
||||
<string>6B324D511121D61A00EBD2FD</string>
|
||||
<string>6B324E2C1125598400EBD2FD</string>
|
||||
<string>6B324E3B11255BA700EBD2FD</string>
|
||||
<string>6B324E6D11256D1000EBD2FD</string>
|
||||
<string>6B324E6E11256D1000EBD2FD</string>
|
||||
<string>6B324E7011256D1000EBD2FD</string>
|
||||
<string>6B324E7111256D1000EBD2FD</string>
|
||||
<string>6B324E7311256D1000EBD2FD</string>
|
||||
<string>6B324E7411256D1000EBD2FD</string>
|
||||
<string>6B324E7511256D1000EBD2FD</string>
|
||||
<string>6B324EE51125799900EBD2FD</string>
|
||||
<string>6B324F1311257F9A00EBD2FD</string>
|
||||
<string>6B324F1511257F9A00EBD2FD</string>
|
||||
<string>6B324F1E1125818400EBD2FD</string>
|
||||
<string>6B324F1F1125818400EBD2FD</string>
|
||||
<string>6B324F201125818400EBD2FD</string>
|
||||
<string>6B324F2E112584FB00EBD2FD</string>
|
||||
<string>6B324F3A1125891F00EBD2FD</string>
|
||||
<string>6B324F3C1125891F00EBD2FD</string>
|
||||
<string>6B324F3D1125891F00EBD2FD</string>
|
||||
<string>6B324F4A11258C7000EBD2FD</string>
|
||||
<string>6B324F5011258F7F00EBD2FD</string>
|
||||
<string>6B324F541125904E00EBD2FD</string>
|
||||
<string>6B324F551125904E00EBD2FD</string>
|
||||
<string>6B324F9A11259A5800EBD2FD</string>
|
||||
<string>6B324F9B11259A5800EBD2FD</string>
|
||||
<string>6B324FC711259FFA00EBD2FD</string>
|
||||
<string>6B324FCD1125A7BB00EBD2FD</string>
|
||||
<string>6B324FCE1125A7BB00EBD2FD</string>
|
||||
<string>6B324FCF1125A7BB00EBD2FD</string>
|
||||
<string>6BE90FDE112A770600F5C17A</string>
|
||||
<string>6BE90FDF112A770600F5C17A</string>
|
||||
<string>6BE91032112A7D9600F5C17A</string>
|
||||
<string>6BE91033112A7D9600F5C17A</string>
|
||||
<string>6BE91085112A898E00F5C17A</string>
|
||||
<string>6BE91087112A898E00F5C17A</string>
|
||||
<string>6BE91095112A8AC800F5C17A</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>6BE911011130618A00F5C17A</string>
|
||||
<string>6BE9113A11379F5000F5C17A</string>
|
||||
<string>6BE9113C11379F5000F5C17A</string>
|
||||
<string>6B803699113BAA82005ED67B</string>
|
||||
<string>6B80369C113BAA82005ED67B</string>
|
||||
<string>6B8036B8113BAF47005ED67B</string>
|
||||
<string>6B8036B9113BAF47005ED67B</string>
|
||||
<string>6B8036BA113BAF47005ED67B</string>
|
||||
<string>6B8036BB113BAF47005ED67B</string>
|
||||
<string>6B8036BC113BAF47005ED67B</string>
|
||||
<string>6B8036BE113BAF47005ED67B</string>
|
||||
<string>6B8036CF113BAF79005ED67B</string>
|
||||
<string>6B8036D0113BAF79005ED67B</string>
|
||||
<string>6B8036D1113BAF79005ED67B</string>
|
||||
<string>6B8036EA113BB055005ED67B</string>
|
||||
<string>6B8036E9113BB051005ED67B</string>
|
||||
</array>
|
||||
<key>prevStack</key>
|
||||
<array>
|
||||
<string>6B9869FC10DFFA98007D8D84</string>
|
||||
<string>6BBB87E510EA97CC008FEA1F</string>
|
||||
<string>6BBB883F10EA9B6F008FEA1F</string>
|
||||
<string>6BBB885510EA9ECC008FEA1F</string>
|
||||
<string>6BB7FDC710F37703006DA0A6</string>
|
||||
<string>6BB7FDDA10F37703006DA0A6</string>
|
||||
<string>6BB7FE1A10F37CF7006DA0A6</string>
|
||||
<string>6BB7FE2110F37CF7006DA0A6</string>
|
||||
<string>6BB7FE5410F3817A006DA0A6</string>
|
||||
<string>6BB7FF9610F4E8E2006DA0A6</string>
|
||||
<string>6BB700C310FA3AB1006DA0A6</string>
|
||||
<string>6B6973A210FFCA4500984788</string>
|
||||
<string>6BCF32441104CDB5009445BF</string>
|
||||
<string>6BCF324A1104CDB5009445BF</string>
|
||||
<string>6BCF331E11059E23009445BF</string>
|
||||
<string>6BCF33381105B2B5009445BF</string>
|
||||
<string>6BCF33541105B986009445BF</string>
|
||||
<string>6BCF33811105BBA2009445BF</string>
|
||||
<string>6BCF340B1105E98C009445BF</string>
|
||||
<string>6BCF340C1105E98C009445BF</string>
|
||||
<string>6BF7C0F611116E74002B3F46</string>
|
||||
<string>6BF7C10811116E74002B3F46</string>
|
||||
<string>6BF7C10E11116E74002B3F46</string>
|
||||
<string>6BF7C16E11119D8F002B3F46</string>
|
||||
<string>6BF7C1E51111BD81002B3F46</string>
|
||||
@ -431,154 +424,57 @@
|
||||
<string>6BF7C30C1112D8C1002B3F46</string>
|
||||
<string>6BF7C39C111316AD002B3F46</string>
|
||||
<string>6BB7FDD910F37703006DA0A6</string>
|
||||
<string>6BF7C16711119C69002B3F46</string>
|
||||
<string>6BF7C46A1115C514002B3F46</string>
|
||||
<string>6BF7C52F1115FA3B002B3F46</string>
|
||||
<string>6BF7C11111116E74002B3F46</string>
|
||||
<string>6BF7C6801117163B002B3F46</string>
|
||||
<string>6B324AA9111BF92500EBD2FD</string>
|
||||
<string>6B324AB6111BFEFD00EBD2FD</string>
|
||||
<string>6B324ACD111C00D700EBD2FD</string>
|
||||
<string>6B324ACE111C00D700EBD2FD</string>
|
||||
<string>6B324AD1111C00D700EBD2FD</string>
|
||||
<string>6B324AD2111C00D700EBD2FD</string>
|
||||
<string>6B324AD3111C00D700EBD2FD</string>
|
||||
<string>6B324AD4111C00D700EBD2FD</string>
|
||||
<string>6B324AD7111C00D700EBD2FD</string>
|
||||
<string>6B324AE8111C07AB00EBD2FD</string>
|
||||
<string>6B324AEE111C0D9700EBD2FD</string>
|
||||
<string>6B324AEF111C0D9700EBD2FD</string>
|
||||
<string>6B324AF0111C0D9700EBD2FD</string>
|
||||
<string>6B324B02111C0F2700EBD2FD</string>
|
||||
<string>6B324B03111C0F2700EBD2FD</string>
|
||||
<string>6B324B04111C0F2700EBD2FD</string>
|
||||
<string>6B324B05111C0F2700EBD2FD</string>
|
||||
<string>6B324B06111C0F2700EBD2FD</string>
|
||||
<string>6B324B07111C0F2700EBD2FD</string>
|
||||
<string>6B324B08111C0F2700EBD2FD</string>
|
||||
<string>6B324B09111C0F2700EBD2FD</string>
|
||||
<string>6B324B11111C103600EBD2FD</string>
|
||||
<string>6B324B14111C103600EBD2FD</string>
|
||||
<string>6B324B15111C103600EBD2FD</string>
|
||||
<string>6B324B18111C103600EBD2FD</string>
|
||||
<string>6B324B23111C10C700EBD2FD</string>
|
||||
<string>6B324B33111C153D00EBD2FD</string>
|
||||
<string>6B324B35111C153D00EBD2FD</string>
|
||||
<string>6B324B37111C153D00EBD2FD</string>
|
||||
<string>6B324B3A111C153D00EBD2FD</string>
|
||||
<string>6B324B56111C1AC800EBD2FD</string>
|
||||
<string>6B324B57111C1AC800EBD2FD</string>
|
||||
<string>6B324B5C111C1AC800EBD2FD</string>
|
||||
<string>6B324B5E111C1AC800EBD2FD</string>
|
||||
<string>6B324B61111C1AC800EBD2FD</string>
|
||||
<string>6B324B63111C1AC800EBD2FD</string>
|
||||
<string>6B324B64111C1AC800EBD2FD</string>
|
||||
<string>6B324B65111C1AC800EBD2FD</string>
|
||||
<string>6B324B66111C1AC800EBD2FD</string>
|
||||
<string>6B324B6C111C1B7500EBD2FD</string>
|
||||
<string>6B324B74111C1C4F00EBD2FD</string>
|
||||
<string>6B324B7D111C1C8200EBD2FD</string>
|
||||
<string>6B324B82111C1CF000EBD2FD</string>
|
||||
<string>6B324BBD111C4C2B00EBD2FD</string>
|
||||
<string>6B324C21111C5B8D00EBD2FD</string>
|
||||
<string>6B324C23111C5B8D00EBD2FD</string>
|
||||
<string>6B324C25111C5B8D00EBD2FD</string>
|
||||
<string>6B324C27111C5B8D00EBD2FD</string>
|
||||
<string>6B324C29111C5B8D00EBD2FD</string>
|
||||
<string>6B324C2B111C5B8D00EBD2FD</string>
|
||||
<string>6B324C2D111C5B8D00EBD2FD</string>
|
||||
<string>6B324C2F111C5B8D00EBD2FD</string>
|
||||
<string>6B324C33111C5B8D00EBD2FD</string>
|
||||
<string>6B324C49111C5C5A00EBD2FD</string>
|
||||
<string>6B324C59111C5D1400EBD2FD</string>
|
||||
<string>6B324C61111C5D1400EBD2FD</string>
|
||||
<string>6B324C71111C5DDC00EBD2FD</string>
|
||||
<string>6B324C80111C5EF800EBD2FD</string>
|
||||
<string>6B324CA4111C6DD400EBD2FD</string>
|
||||
<string>6B324CC5111C6F6300EBD2FD</string>
|
||||
<string>6B324CD1111C759F00EBD2FD</string>
|
||||
<string>6B324CE1111C789800EBD2FD</string>
|
||||
<string>6BF7C678111715D1002B3F46</string>
|
||||
<string>6B324CF5111C7A9800EBD2FD</string>
|
||||
<string>6B324D00111C7B0900EBD2FD</string>
|
||||
<string>6B324D02111C7B0900EBD2FD</string>
|
||||
<string>6B324D0B111C7C1700EBD2FD</string>
|
||||
<string>6B324D0C111C7C1700EBD2FD</string>
|
||||
<string>6B324D131121C78000EBD2FD</string>
|
||||
<string>6B324D141121C78000EBD2FD</string>
|
||||
<string>6B324D151121C78000EBD2FD</string>
|
||||
<string>6B324D281121CD2000EBD2FD</string>
|
||||
<string>6B324D321121CDAF00EBD2FD</string>
|
||||
<string>6B324D3B1121CFCF00EBD2FD</string>
|
||||
<string>6B324D3C1121CFCF00EBD2FD</string>
|
||||
<string>6B324D531121D61A00EBD2FD</string>
|
||||
<string>6B324D541121D61A00EBD2FD</string>
|
||||
<string>6B324B5A111C1AC800EBD2FD</string>
|
||||
<string>6B324D5E1121D71800EBD2FD</string>
|
||||
<string>6B324D691121DE7A00EBD2FD</string>
|
||||
<string>6B324D6A1121DE7A00EBD2FD</string>
|
||||
<string>6B324D6B1121DE7A00EBD2FD</string>
|
||||
<string>6B324D6D1121DE7A00EBD2FD</string>
|
||||
<string>6B324D6F1121DE7A00EBD2FD</string>
|
||||
<string>6B324D711121DE7A00EBD2FD</string>
|
||||
<string>6B324D731121DE7A00EBD2FD</string>
|
||||
<string>6B324D751121DE7A00EBD2FD</string>
|
||||
<string>6B324D771121DE7A00EBD2FD</string>
|
||||
<string>6B324D791121DE7A00EBD2FD</string>
|
||||
<string>6B324D7B1121DE7A00EBD2FD</string>
|
||||
<string>6B324D7D1121DE7A00EBD2FD</string>
|
||||
<string>6B324D7F1121DE7A00EBD2FD</string>
|
||||
<string>6B324D8411253B8E00EBD2FD</string>
|
||||
<string>6B324D95112542DA00EBD2FD</string>
|
||||
<string>6B324D97112542DA00EBD2FD</string>
|
||||
<string>6B324DD011254E0400EBD2FD</string>
|
||||
<string>6B324DE51125511B00EBD2FD</string>
|
||||
<string>6B324E0C1125554800EBD2FD</string>
|
||||
<string>6B324E0E1125554800EBD2FD</string>
|
||||
<string>6B324E101125554800EBD2FD</string>
|
||||
<string>6B324E1B1125566A00EBD2FD</string>
|
||||
<string>6B324E311125598400EBD2FD</string>
|
||||
<string>6B324E321125598400EBD2FD</string>
|
||||
<string>6B324E331125598400EBD2FD</string>
|
||||
<string>6B324E341125598400EBD2FD</string>
|
||||
<string>6B324E351125598400EBD2FD</string>
|
||||
<string>6B324E3E11255BA700EBD2FD</string>
|
||||
<string>6B324E3F11255BA700EBD2FD</string>
|
||||
<string>6B324E4311255DB700EBD2FD</string>
|
||||
<string>6B324E7C11256D1000EBD2FD</string>
|
||||
<string>6B324E7D11256D1000EBD2FD</string>
|
||||
<string>6B324E7E11256D1000EBD2FD</string>
|
||||
<string>6B324E8011256D1000EBD2FD</string>
|
||||
<string>6B324E8211256D1000EBD2FD</string>
|
||||
<string>6B324E8311256D1000EBD2FD</string>
|
||||
<string>6B324E8611256D1000EBD2FD</string>
|
||||
<string>6B324E8711256D1000EBD2FD</string>
|
||||
<string>6B324E8811256D1000EBD2FD</string>
|
||||
<string>6B324E8911256D1000EBD2FD</string>
|
||||
<string>6B324ED41125770F00EBD2FD</string>
|
||||
<string>6B324EE91125799900EBD2FD</string>
|
||||
<string>6B324EEA1125799900EBD2FD</string>
|
||||
<string>6B324F251125818400EBD2FD</string>
|
||||
<string>6B324F261125818400EBD2FD</string>
|
||||
<string>6B324F271125818400EBD2FD</string>
|
||||
<string>6B324F281125818400EBD2FD</string>
|
||||
<string>6B324F291125818400EBD2FD</string>
|
||||
<string>6B324F31112584FB00EBD2FD</string>
|
||||
<string>6B324F3F1125891F00EBD2FD</string>
|
||||
<string>6B324F401125891F00EBD2FD</string>
|
||||
<string>6B324F411125891F00EBD2FD</string>
|
||||
<string>6B324F421125891F00EBD2FD</string>
|
||||
<string>6B324F441125891F00EBD2FD</string>
|
||||
<string>6B324F4D11258C7000EBD2FD</string>
|
||||
<string>6B324F5211258F7F00EBD2FD</string>
|
||||
<string>6B324F571125904E00EBD2FD</string>
|
||||
<string>6B324F581125904E00EBD2FD</string>
|
||||
<string>6BF7C4661115C514002B3F46</string>
|
||||
<string>6B324B5F111C1AC800EBD2FD</string>
|
||||
<string>6B324FD01125A7BB00EBD2FD</string>
|
||||
<string>6B324FD11125A7BB00EBD2FD</string>
|
||||
<string>6B324FD21125A7BB00EBD2FD</string>
|
||||
<string>6B324FD31125A7BB00EBD2FD</string>
|
||||
<string>6BE90FE6112A770600F5C17A</string>
|
||||
<string>6BE90FEF112A770600F5C17A</string>
|
||||
<string>6BE91016112A78D400F5C17A</string>
|
||||
<string>6BE91035112A7D9600F5C17A</string>
|
||||
<string>6BE91089112A898E00F5C17A</string>
|
||||
<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>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@ -592,18 +488,18 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {876, 561}}</string>
|
||||
<string>{{0, 0}, {876, 587}}</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>561pt</string>
|
||||
<string>587pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>95pt</string>
|
||||
<string>69pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -617,7 +513,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {876, 48}}</string>
|
||||
<string>{{10, 27}, {876, 42}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>XCDetailModule</string>
|
||||
@ -671,7 +567,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {876, 68}}</string>
|
||||
<string>{{10, 27}, {876, 42}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>11 76 1256 702 0 0 1280 778 </string>
|
||||
</dict>
|
||||
@ -701,11 +597,11 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6B324A80111BF65400EBD2FD</string>
|
||||
<string>6B803671113BA319005ED67B</string>
|
||||
<string>1CA23ED40692098700951B8B</string>
|
||||
<string>6B324A81111BF65400EBD2FD</string>
|
||||
<string>6B803672113BA319005ED67B</string>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<string>6B324A82111BF65400EBD2FD</string>
|
||||
<string>6B803673113BA319005ED67B</string>
|
||||
<string>1CA23EDF0692099D00951B8B</string>
|
||||
<string>1CA23EE00692099D00951B8B</string>
|
||||
<string>1CA23EE10692099D00951B8B</string>
|
||||
@ -756,12 +652,12 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {1256, 173}}</string>
|
||||
<string>{{0, 0}, {1256, 229}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugCLIModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>173pt</string>
|
||||
<string>229pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ContentConfiguration</key>
|
||||
@ -780,8 +676,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {628, 115}}</string>
|
||||
<string>{{628, 0}, {628, 115}}</string>
|
||||
<string>{{0, 0}, {628, 102}}</string>
|
||||
<string>{{628, 0}, {628, 102}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>VerticalSplitView</key>
|
||||
@ -796,8 +692,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {1256, 115}}</string>
|
||||
<string>{{0, 115}, {1256, 368}}</string>
|
||||
<string>{{0, 0}, {1256, 102}}</string>
|
||||
<string>{{0, 102}, {1256, 325}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
@ -817,7 +713,7 @@
|
||||
<key>DebugSTDIOWindowFrame</key>
|
||||
<string>{{200, 200}, {500, 300}}</string>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 178}, {1256, 483}}</string>
|
||||
<string>{{0, 234}, {1256, 427}}</string>
|
||||
<key>PBXDebugSessionStackFrameViewKey</key>
|
||||
<dict>
|
||||
<key>DebugVariablesTableConfiguration</key>
|
||||
@ -830,13 +726,13 @@
|
||||
<real>398</real>
|
||||
</array>
|
||||
<key>Frame</key>
|
||||
<string>{{628, 0}, {628, 115}}</string>
|
||||
<string>{{628, 0}, {628, 102}}</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugSessionModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>483pt</string>
|
||||
<string>427pt</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Name</key>
|
||||
@ -854,14 +750,14 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6B324A8E111BF7C400EBD2FD</string>
|
||||
<string>6B803679113BA44E005ED67B</string>
|
||||
<string>1CCC7628064C1048000F2A68</string>
|
||||
<string>1CCC7629064C1048000F2A68</string>
|
||||
<string>6B324A8F111BF7C400EBD2FD</string>
|
||||
<string>6B324A90111BF7C400EBD2FD</string>
|
||||
<string>6B324A91111BF7C400EBD2FD</string>
|
||||
<string>6B324A92111BF7C400EBD2FD</string>
|
||||
<string>6B324A93111BF7C400EBD2FD</string>
|
||||
<string>6B80367A113BA44E005ED67B</string>
|
||||
<string>6B80367B113BA44E005ED67B</string>
|
||||
<string>6B80367C113BA44E005ED67B</string>
|
||||
<string>6B80367D113BA44E005ED67B</string>
|
||||
<string>6B80367E113BA44E005ED67B</string>
|
||||
</array>
|
||||
<key>ToolbarConfigUserDefaultsMinorVersion</key>
|
||||
<string>2</string>
|
||||
@ -893,8 +789,8 @@
|
||||
<integer>5</integer>
|
||||
<key>WindowOrderList</key>
|
||||
<array>
|
||||
<string>6B324BD2111C4F7D00EBD2FD</string>
|
||||
<string>6B324BD3111C4F7D00EBD2FD</string>
|
||||
<string>6B803688113BA4F1005ED67B</string>
|
||||
<string>6B803689113BA4F1005ED67B</string>
|
||||
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
|
||||
</array>
|
||||
<key>WindowString</key>
|
||||
|
@ -28,6 +28,7 @@
|
||||
6B324C66111C5D9A00EBD2FD /* ConvexVolumeTool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B324C65111C5D9A00EBD2FD /* ConvexVolumeTool.cpp */; };
|
||||
6B555DB1100B212E00247EA3 /* imguiRenderGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B555DB0100B212E00247EA3 /* imguiRenderGL.cpp */; };
|
||||
6B62416A103434880002E346 /* RecastMeshDetail.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B624169103434880002E346 /* RecastMeshDetail.cpp */; };
|
||||
6B8036AE113BAABE005ED67B /* Sample_Debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B8036AD113BAABE005ED67B /* Sample_Debug.cpp */; };
|
||||
6B8632DA0F78122C00E2684A /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B8632D90F78122C00E2684A /* SDL.framework */; };
|
||||
6B8632DC0F78123E00E2684A /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B8632DB0F78123E00E2684A /* OpenGL.framework */; };
|
||||
6B8DE88910B69E3E00DF20FB /* DetourNavMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B8DE88710B69E3E00DF20FB /* DetourNavMesh.cpp */; };
|
||||
@ -89,6 +90,8 @@
|
||||
6B555DB0100B212E00247EA3 /* imguiRenderGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imguiRenderGL.cpp; path = ../../Source/imguiRenderGL.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6B555DF6100B273500247EA3 /* stb_truetype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = stb_truetype.h; path = ../../Contrib/stb_truetype.h; sourceTree = SOURCE_ROOT; };
|
||||
6B624169103434880002E346 /* RecastMeshDetail.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastMeshDetail.cpp; path = ../../../Recast/Source/RecastMeshDetail.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6B8036AC113BAABE005ED67B /* Sample_Debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sample_Debug.h; path = ../../Include/Sample_Debug.h; sourceTree = SOURCE_ROOT; };
|
||||
6B8036AD113BAABE005ED67B /* Sample_Debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Sample_Debug.cpp; path = ../../Source/Sample_Debug.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6B8632D90F78122C00E2684A /* SDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL.framework; path = Library/Frameworks/SDL.framework; sourceTree = SDKROOT; };
|
||||
6B8632DB0F78123E00E2684A /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
|
||||
6B8DE88710B69E3E00DF20FB /* DetourNavMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DetourNavMesh.cpp; path = ../../../Detour/Source/DetourNavMesh.cpp; sourceTree = SOURCE_ROOT; };
|
||||
@ -263,6 +266,8 @@
|
||||
6BA1E88910C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp */,
|
||||
6B2AEC510FFB8946005BE9CC /* Sample_TileMesh.h */,
|
||||
6B2AEC520FFB8958005BE9CC /* Sample_TileMesh.cpp */,
|
||||
6B8036AC113BAABE005ED67B /* Sample_Debug.h */,
|
||||
6B8036AD113BAABE005ED67B /* Sample_Debug.cpp */,
|
||||
);
|
||||
name = Samples;
|
||||
sourceTree = "<group>";
|
||||
@ -399,6 +404,7 @@
|
||||
6BF7C1401111953A002B3F46 /* TestCase.cpp in Sources */,
|
||||
6BF7C4541115C277002B3F46 /* RecastArea.cpp in Sources */,
|
||||
6B324C66111C5D9A00EBD2FD /* ConvexVolumeTool.cpp in Sources */,
|
||||
6B8036AE113BAABE005ED67B /* Sample_Debug.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -123,6 +123,8 @@ public:
|
||||
virtual float getAgentRadius() { return m_agentRadius; }
|
||||
virtual float getAgentHeight() { return m_agentHeight; }
|
||||
virtual float getAgentClimb() { return m_agentMaxClimb; }
|
||||
virtual const float* getBoundsMin();
|
||||
virtual const float* getBoundsMax();
|
||||
|
||||
inline unsigned char getNavMeshDrawFlags() const { return m_navMeshDrawFlags; }
|
||||
inline void setNavMeshDrawFlags(unsigned char flags) { m_navMeshDrawFlags = flags; }
|
||||
|
52
RecastDemo/Include/Sample_Debug.h
Normal file
52
RecastDemo/Include/Sample_Debug.h
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#ifndef RECASTSAMPLEDEBUG_H
|
||||
#define RECASTSAMPLEDEBUG_H
|
||||
|
||||
#include "Sample.h"
|
||||
#include "DetourNavMesh.h"
|
||||
#include "Recast.h"
|
||||
#include "RecastLog.h"
|
||||
|
||||
// Sample used for random debugging.
|
||||
class Sample_Debug : public Sample
|
||||
{
|
||||
protected:
|
||||
rcCompactHeightfield* m_chf;
|
||||
|
||||
public:
|
||||
Sample_Debug();
|
||||
virtual ~Sample_Debug();
|
||||
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
virtual void handleDebugMode();
|
||||
virtual void handleClick(const float* p, bool shift);
|
||||
virtual void handleStep();
|
||||
virtual void handleRender();
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
||||
virtual void handleMeshChanged(class InputGeom* geom);
|
||||
virtual bool handleBuild();
|
||||
|
||||
virtual const float* getBoundsMin();
|
||||
virtual const float* getBoundsMax();
|
||||
};
|
||||
|
||||
|
||||
#endif // RECASTSAMPLE_H
|
@ -181,8 +181,15 @@ bool rcMeshLoaderObj::load(const char* filename)
|
||||
{
|
||||
// Faces
|
||||
nv = parseFace(row+1, face, 32, m_vertCount);
|
||||
for (int i = 2; i < nv; ++i)
|
||||
addTriangle(face[0], face[i-1], face[i], tcap);
|
||||
for (int i = 2; i < nv; ++i)
|
||||
{
|
||||
const int a = face[0];
|
||||
const int b = face[i-1];
|
||||
const int c = face[i];
|
||||
if (a < 0 || a >= m_vertCount || b < 0 || b >= m_vertCount || c < 0 || c >= m_vertCount)
|
||||
continue;
|
||||
addTriangle(a, b, c, tcap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,18 @@ void Sample::handleMeshChanged(InputGeom* geom)
|
||||
m_geom = geom;
|
||||
}
|
||||
|
||||
const float* Sample::getBoundsMin()
|
||||
{
|
||||
if (!m_geom) return 0;
|
||||
return m_geom->getMeshBoundsMin();
|
||||
}
|
||||
|
||||
const float* Sample::getBoundsMax()
|
||||
{
|
||||
if (!m_geom) return 0;
|
||||
return m_geom->getMeshBoundsMax();
|
||||
}
|
||||
|
||||
void Sample::resetCommonSettings()
|
||||
{
|
||||
m_cellSize = 0.3f;
|
||||
@ -215,11 +227,3 @@ bool Sample::handleBuild()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
void Sample::handleNavMeshChanged()
|
||||
{
|
||||
if (m_geom)
|
||||
m_geom->updateOffMeshConnectionVisibility(m_navMesh);
|
||||
}
|
||||
*/
|
114
RecastDemo/Source/Sample_Debug.cpp
Normal file
114
RecastDemo/Source/Sample_Debug.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
//
|
||||
// Copyright (c) 2009 Mikko Mononen memon@inside.org
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "Sample_Debug.h"
|
||||
#include "InputGeom.h"
|
||||
#include "Recast.h"
|
||||
#include "DetourNavMesh.h"
|
||||
#include "RecastLog.h"
|
||||
#include "RecastDebugDraw.h"
|
||||
#include "DetourDebugDraw.h"
|
||||
#include "RecastDump.h"
|
||||
#include "imgui.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL_opengl.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
||||
Sample_Debug::Sample_Debug() :
|
||||
m_chf(0)
|
||||
{
|
||||
resetCommonSettings();
|
||||
|
||||
// Test
|
||||
m_chf = new rcCompactHeightfield;
|
||||
if (!duReadCompactHeightfield(*m_chf, "test.chf"))
|
||||
{
|
||||
delete m_chf;
|
||||
m_chf = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Sample_Debug::~Sample_Debug()
|
||||
{
|
||||
delete m_chf;
|
||||
}
|
||||
|
||||
void Sample_Debug::handleSettings()
|
||||
{
|
||||
}
|
||||
|
||||
void Sample_Debug::handleTools()
|
||||
{
|
||||
}
|
||||
|
||||
void Sample_Debug::handleDebugMode()
|
||||
{
|
||||
}
|
||||
|
||||
void Sample_Debug::handleRender()
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
|
||||
if (m_chf)
|
||||
duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
|
||||
}
|
||||
|
||||
void Sample_Debug::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
{
|
||||
}
|
||||
|
||||
void Sample_Debug::handleMeshChanged(InputGeom* geom)
|
||||
{
|
||||
m_geom = geom;
|
||||
}
|
||||
|
||||
const float* Sample_Debug::getBoundsMin()
|
||||
{
|
||||
if (!m_chf) return 0;
|
||||
return m_chf->bmin;
|
||||
}
|
||||
|
||||
const float* Sample_Debug::getBoundsMax()
|
||||
{
|
||||
if (!m_chf) return 0;
|
||||
return m_chf->bmax;
|
||||
}
|
||||
|
||||
void Sample_Debug::handleClick(const float* p, bool shift)
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleClick(p, shift);
|
||||
}
|
||||
|
||||
void Sample_Debug::handleStep()
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleStep();
|
||||
}
|
||||
|
||||
bool Sample_Debug::handleBuild()
|
||||
{
|
||||
return true;
|
||||
}
|
@ -490,7 +490,12 @@ bool Sample_SoloMeshSimple::handleBuild()
|
||||
if (rcGetLog())
|
||||
rcGetLog()->log(RC_LOG_ERROR, "buildNavigation: Could not build regions.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
duDumpCompactHeightfield(*m_chf, "test.chf");
|
||||
|
||||
|
||||
//
|
||||
// Step 5. Trace and simplify region contours.
|
||||
//
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "Sample_SoloMeshSimple.h"
|
||||
#include "Sample_SoloMeshTiled.h"
|
||||
#include "Sample_TileMesh.h"
|
||||
#include "Sample_Debug.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define snprintf _snprintf
|
||||
@ -132,15 +133,18 @@ struct SampleItem
|
||||
Sample* createSoloSimple() { return new Sample_SoloMeshSimple(); }
|
||||
Sample* createSoloTiled() { return new Sample_SoloMeshTiled(); }
|
||||
Sample* createTile() { return new Sample_TileMesh(); }
|
||||
Sample* createDebug() { return new Sample_Debug(); }
|
||||
|
||||
static SampleItem g_samples[] =
|
||||
{
|
||||
{ createSoloSimple, "Solo Mesh Simple" },
|
||||
{ createSoloTiled, "Solo Mesh Tiled" },
|
||||
{ createTile, "Tile Mesh" },
|
||||
{ createDebug, "Debug" },
|
||||
};
|
||||
static const int g_nsamples = sizeof(g_samples)/sizeof(SampleItem);
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Init SDL
|
||||
@ -184,7 +188,7 @@ int main(int argc, char *argv[])
|
||||
float rx = 45;
|
||||
float ry = -45;
|
||||
float moveW = 0, moveS = 0, moveA = 0, moveD = 0;
|
||||
float camx = 0, camy = 0, camz = 0, camr=10;
|
||||
float camx = 0, camy = 0, camz = 0, camr = 1000;
|
||||
float origrx = 0, origry = 0;
|
||||
int origx = 0, origy = 0;
|
||||
bool rotate = false;
|
||||
@ -224,8 +228,8 @@ int main(int argc, char *argv[])
|
||||
float fogCol[4] = { 0.32f,0.25f,0.25f,1 };
|
||||
glEnable(GL_FOG);
|
||||
glFogi(GL_FOG_MODE, GL_LINEAR);
|
||||
glFogf(GL_FOG_START, 0);
|
||||
glFogf(GL_FOG_END, 10);
|
||||
glFogf(GL_FOG_START, camr*0.2f);
|
||||
glFogf(GL_FOG_END, camr*1.25f);
|
||||
glFogfv(GL_FOG_COLOR, fogCol);
|
||||
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
@ -286,18 +290,31 @@ int main(int argc, char *argv[])
|
||||
sample->handleMeshChanged(geom);
|
||||
}
|
||||
|
||||
if (geom)
|
||||
if (geom || sample)
|
||||
{
|
||||
const float* bmin = geom->getMeshBoundsMin();
|
||||
const float* bmax = geom->getMeshBoundsMax();
|
||||
const float* bmin = 0;
|
||||
const float* bmax = 0;
|
||||
if (sample)
|
||||
{
|
||||
bmin = sample->getBoundsMin();
|
||||
bmax = sample->getBoundsMax();
|
||||
}
|
||||
else
|
||||
{
|
||||
bmin = geom->getMeshBoundsMin();
|
||||
bmax = geom->getMeshBoundsMax();
|
||||
}
|
||||
// Reset camera and fog to match the mesh bounds.
|
||||
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;
|
||||
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);
|
||||
@ -464,6 +481,7 @@ int main(int argc, char *argv[])
|
||||
if (test)
|
||||
test->handleRender();
|
||||
|
||||
|
||||
glDisable(GL_FOG);
|
||||
|
||||
// Render GUI
|
||||
@ -526,34 +544,31 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (sample)
|
||||
imguiSeparator();
|
||||
imguiLabel("Input Mesh");
|
||||
if (imguiButton(meshName))
|
||||
{
|
||||
imguiSeparator();
|
||||
imguiLabel("Input Mesh");
|
||||
if (imguiButton(meshName))
|
||||
if (showLevels)
|
||||
{
|
||||
if (showLevels)
|
||||
{
|
||||
showLevels = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
showSample = false;
|
||||
showTestCases = false;
|
||||
showLevels = true;
|
||||
scanDirectory("Meshes", ".obj", files);
|
||||
}
|
||||
showLevels = false;
|
||||
}
|
||||
if (geom)
|
||||
else
|
||||
{
|
||||
char text[64];
|
||||
snprintf(text, 64, "Verts: %.1fk Tris: %.1fk",
|
||||
geom->getMesh()->getVertCount()/1000.0f,
|
||||
geom->getMesh()->getTriCount()/1000.0f);
|
||||
imguiValue(text);
|
||||
showSample = false;
|
||||
showTestCases = false;
|
||||
showLevels = true;
|
||||
scanDirectory("Meshes", ".obj", files);
|
||||
}
|
||||
imguiSeparator();
|
||||
}
|
||||
if (geom)
|
||||
{
|
||||
char text[64];
|
||||
snprintf(text, 64, "Verts: %.1fk Tris: %.1fk",
|
||||
geom->getMesh()->getVertCount()/1000.0f,
|
||||
geom->getMesh()->getTriCount()/1000.0f);
|
||||
imguiValue(text);
|
||||
}
|
||||
imguiSeparator();
|
||||
|
||||
if (geom && sample)
|
||||
{
|
||||
@ -670,18 +685,31 @@ int main(int argc, char *argv[])
|
||||
sample->handleMeshChanged(geom);
|
||||
}
|
||||
|
||||
if (geom)
|
||||
if (geom || sample)
|
||||
{
|
||||
const float* bmin = geom->getMeshBoundsMin();
|
||||
const float* bmax = geom->getMeshBoundsMax();
|
||||
const float* bmin = 0;
|
||||
const float* bmax = 0;
|
||||
if (sample)
|
||||
{
|
||||
bmin = sample->getBoundsMin();
|
||||
bmax = sample->getBoundsMax();
|
||||
}
|
||||
else
|
||||
{
|
||||
bmin = geom->getMeshBoundsMin();
|
||||
bmax = geom->getMeshBoundsMax();
|
||||
}
|
||||
// Reset camera and fog to match the mesh bounds.
|
||||
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;
|
||||
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);
|
||||
@ -774,24 +802,37 @@ int main(int argc, char *argv[])
|
||||
printf("%s\n", log.getMessageText(i));
|
||||
}
|
||||
|
||||
if (geom)
|
||||
if (geom || sample)
|
||||
{
|
||||
const float* bmin = geom->getMeshBoundsMin();
|
||||
const float* bmax = geom->getMeshBoundsMax();
|
||||
const float* bmin = 0;
|
||||
const float* bmax = 0;
|
||||
if (sample)
|
||||
{
|
||||
bmin = sample->getBoundsMin();
|
||||
bmax = sample->getBoundsMax();
|
||||
}
|
||||
else
|
||||
{
|
||||
bmin = geom->getMeshBoundsMin();
|
||||
bmax = geom->getMeshBoundsMax();
|
||||
}
|
||||
// Reset camera and fog to match the mesh bounds.
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// Do the tests.
|
||||
if (sample)
|
||||
test->doTests(sample->getNavMesh());
|
||||
|
Loading…
x
Reference in New Issue
Block a user