Fixed a couple of bounds checks in detail mesh height query.

This commit is contained in:
Mikko Mononen 2009-11-20 08:15:09 +00:00
parent 5ecdda0a18
commit b93bd10fa4

View File

@ -762,8 +762,8 @@ static void getHeightData(const rcCompactHeightfield& chf,
cy /= npoly;
cz /= npoly;
if (cx >= hp.xmin || cx < hp.xmin+hp.width ||
cz >= hp.ymin || cz < hp.ymin+hp.height)
if (cx >= hp.xmin && cx < hp.xmin+hp.width &&
cz >= hp.ymin && cz < hp.ymin+hp.height)
{
const rcCompactCell& c = chf.cells[cx+cz*chf.width];
int dmin = 0xffff;
@ -928,7 +928,7 @@ bool rcBuildPolyMeshDetail(const rcPolyMesh& mesh, const rcCompactHeightfield& c
return false;
}
rcScopedDelete<float> poly = new float[nvp*3];
if (!bounds)
if (!poly)
{
if (rcGetLog())
rcGetLog()->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'poly' (%d).", nvp*3);
@ -1017,7 +1017,7 @@ bool rcBuildPolyMeshDetail(const rcPolyMesh& mesh, const rcCompactHeightfield& c
{
const unsigned short* p = &mesh.polys[i*nvp*2];
// Find polygon bounding box.
// Store polygon vertices for processing.
int npoly = 0;
for (int j = 0; j < nvp; ++j)
{