Added more bits to compact neighbour indices, moved region id to rcCompactSpan to save memory.

This commit is contained in:
Mikko Mononen
2010-03-05 09:10:13 +00:00
parent ababd28f59
commit d9d9fa85a5
13 changed files with 2440 additions and 1934 deletions

View File

@@ -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)