mirror of
https://github.com/recastnavigation/recastnavigation.git
synced 2026-08-19 09:39:57 +00:00
Added more bits to compact neighbour indices, moved region id to rcCompactSpan to save memory.
This commit is contained in:
@@ -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