fix for issue 85:Make getSpanCount accessible

This commit is contained in:
Mikko Mononen 2010-07-08 11:41:08 +00:00
parent 1d36d4f40b
commit fca9709196
2 changed files with 11 additions and 5 deletions

View File

@ -102,13 +102,12 @@ struct rcCompactHeightfield
{ {
inline rcCompactHeightfield() : inline rcCompactHeightfield() :
maxDistance(0), maxRegions(0), cells(0), maxDistance(0), maxRegions(0), cells(0),
spans(0), dist(0), /*regs(0),*/ areas(0) {} spans(0), dist(0), areas(0) {}
inline ~rcCompactHeightfield() inline ~rcCompactHeightfield()
{ {
delete [] cells; delete [] cells;
delete [] spans; delete [] spans;
delete [] dist; delete [] dist;
// delete [] regs;
delete [] areas; delete [] areas;
} }
int width, height; // Width and height of the heighfield. int width, height; // Width and height of the heighfield.
@ -121,7 +120,6 @@ struct rcCompactHeightfield
rcCompactCell* cells; // Pointer to width*height cells. rcCompactCell* cells; // Pointer to width*height cells.
rcCompactSpan* spans; // Pointer to spans. rcCompactSpan* spans; // Pointer to spans.
unsigned short* dist; // Pointer to per span distance to border. unsigned short* dist; // Pointer to per span distance to border.
// unsigned short* regs; // Pointer to per span region ID.
unsigned char* areas; // Pointer to per span area ID. unsigned char* areas; // Pointer to per span area ID.
}; };
@ -521,10 +519,18 @@ void rcFilterLedgeSpans(const int walkableHeight,
void rcFilterWalkableLowHeightSpans(int walkableHeight, void rcFilterWalkableLowHeightSpans(int walkableHeight,
rcHeightfield& solid); rcHeightfield& solid);
// Returns number of spans contained in a heightfield.
// Params:
// flags - (in) require flags for a cell to be included.
// hf - (in) heightfield to be compacted
// Returns number of spans.
int rcGetHeightFieldSpanCount(const unsigned char flags, rcHeightfield& hf);
// Builds compact representation of the heightfield. // Builds compact representation of the heightfield.
// Params: // Params:
// walkableHeight - (in) minimum height where the agent can still walk // walkableHeight - (in) minimum height where the agent can still walk
// walkableClimb - (in) maximum height between grid cells the agent can climb // walkableClimb - (in) maximum height between grid cells the agent can climb
// flags - (in) require flags for a cell to be included in the compact heightfield.
// hf - (in) heightfield to be compacted // hf - (in) heightfield to be compacted
// chf - (out) compact heightfield representing the open space. // chf - (out) compact heightfield representing the open space.
// Returns false if operation ran out of memory. // Returns false if operation ran out of memory.

View File

@ -105,7 +105,7 @@ void rcMarkWalkableTriangles(const float walkableSlopeAngle,
} }
} }
static int getSpanCount(unsigned char flags, rcHeightfield& hf) int rcGetHeightFieldSpanCount(const unsigned char flags, rcHeightfield& hf)
{ {
const int w = hf.width; const int w = hf.width;
const int h = hf.height; const int h = hf.height;
@ -132,7 +132,7 @@ bool rcBuildCompactHeightfield(const int walkableHeight, const int walkableClimb
const int w = hf.width; const int w = hf.width;
const int h = hf.height; const int h = hf.height;
const int spanCount = getSpanCount(flags, hf); const int spanCount = rcGetHeightFieldSpanCount(flags, hf);
// Fill in header. // Fill in header.
chf.width = w; chf.width = w;