Reverted portal detection change from R332.

This commit is contained in:
Mikko Mononen 2012-03-28 17:38:23 +00:00
parent db0baf4741
commit 0723805f96

View File

@ -938,14 +938,6 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe
return false;
}
memset(vflags, 0, maxVertices);
rcScopedDelete<unsigned short> vportal = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxVertices, RC_ALLOC_TEMP);
if (!vportal)
{
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'vportal' (%d).", maxVertices);
return false;
}
memset(vportal, 0xff, maxVertices);
mesh.verts = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxVertices*3, RC_ALLOC_PERM);
if (!mesh.verts)
@ -1062,14 +1054,6 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe
}
}
// Store portal edges
for (int j = 0; j < cont.nverts; ++j)
{
const int* v = &cont.verts[j*4];
if ((v[3] & RC_AREA_BORDER) == 0)
vportal[indices[j]] = indices[(j+1) % cont.nverts];
}
// Build initial polygons.
int npolys = 0;
memset(polys, 0xff, maxVertsPerCont*nvp*sizeof(unsigned short));
@ -1169,14 +1153,6 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe
// Fixup vertex flags
for (int j = i; j < mesh.nverts; ++j)
vflags[j] = vflags[j+1];
// Fixup portal indices
for (int j = i; j < mesh.nverts; ++j)
vportal[j] = vportal[j+1];
for (int j = 0; j < mesh.nverts; ++j)
{
if (vportal[j] > (unsigned short)i)
vportal[j]--;
}
--i;
}
}
@ -1207,10 +1183,6 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe
const unsigned short* va = &mesh.verts[p[j]*3];
const unsigned short* vb = &mesh.verts[p[nj]*3];
// Make sure the edge is marked as portal.
if (vportal[p[j]] != p[nj])
continue;
if ((int)va[0] == 0 && (int)vb[0] == 0)
p[nvp+j] = 0x8000 | 0;
else if ((int)va[2] == h && (int)vb[2] == h)