mirror of
https://github.com/recastnavigation/recastnavigation.git
synced 2026-10-20 15:51:12 +00:00
Added more bits to compact neighbour indices, moved region id to rcCompactSpan to save memory.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user