fix for Issue 84: Zero Byte Allocations
This commit is contained in:
parent
4ac6b64050
commit
0c3474f9c1
@ -257,26 +257,30 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
|
|||||||
|
|
||||||
// Classify off-mesh connection points. We store only the connections
|
// Classify off-mesh connection points. We store only the connections
|
||||||
// whose start point is inside the tile.
|
// whose start point is inside the tile.
|
||||||
unsigned char* offMeshConClass = new unsigned char [params->offMeshConCount*2];
|
unsigned char* offMeshConClass = 0;
|
||||||
if (!offMeshConClass)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int storedOffMeshConCount = 0;
|
int storedOffMeshConCount = 0;
|
||||||
int offMeshConLinkCount = 0;
|
int offMeshConLinkCount = 0;
|
||||||
|
|
||||||
for (int i = 0; i < params->offMeshConCount; ++i)
|
if (params->offMeshConCount > 0)
|
||||||
{
|
{
|
||||||
offMeshConClass[i*2+0] = classifyOffMeshPoint(¶ms->offMeshConVerts[(i*2+0)*3], params->bmin, params->bmax);
|
offMeshConClass = new unsigned char [params->offMeshConCount*2];
|
||||||
offMeshConClass[i*2+1] = classifyOffMeshPoint(¶ms->offMeshConVerts[(i*2+1)*3], params->bmin, params->bmax);
|
if (!offMeshConClass)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Cound how many links should be allocated for off-mesh connections.
|
for (int i = 0; i < params->offMeshConCount; ++i)
|
||||||
if (offMeshConClass[i*2+0] == 0xff)
|
{
|
||||||
offMeshConLinkCount++;
|
offMeshConClass[i*2+0] = classifyOffMeshPoint(¶ms->offMeshConVerts[(i*2+0)*3], params->bmin, params->bmax);
|
||||||
if (offMeshConClass[i*2+1] == 0xff)
|
offMeshConClass[i*2+1] = classifyOffMeshPoint(¶ms->offMeshConVerts[(i*2+1)*3], params->bmin, params->bmax);
|
||||||
offMeshConLinkCount++;
|
|
||||||
|
|
||||||
if (offMeshConClass[i*2+0] == 0xff)
|
// Cound how many links should be allocated for off-mesh connections.
|
||||||
storedOffMeshConCount++;
|
if (offMeshConClass[i*2+0] == 0xff)
|
||||||
|
offMeshConLinkCount++;
|
||||||
|
if (offMeshConClass[i*2+1] == 0xff)
|
||||||
|
offMeshConLinkCount++;
|
||||||
|
|
||||||
|
if (offMeshConClass[i*2+0] == 0xff)
|
||||||
|
storedOffMeshConCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Off-mesh connectionss are stored as polygons, adjust values.
|
// Off-mesh connectionss are stored as polygons, adjust values.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user