Win32 binary and VC compile fixes.

This commit is contained in:
Mikko Mononen 2009-08-24 13:20:15 +00:00
parent f142f33415
commit c3e9d7fcb3
3 changed files with 21 additions and 5 deletions

View File

@ -116,8 +116,12 @@ static void delaunay(const int nv, float *verts, rcIntArray& idx, rcIntArray& tr
idx.resize(nv); idx.resize(nv);
for (int i = 0; i < nv; ++i) for (int i = 0; i < nv; ++i)
idx[i] = i; idx[i] = i;
#ifdef WIN32
qsort_s(&idx[0], idx.size(), sizeof(int), ptcmp, verts);
#else
qsort_r(&idx[0], idx.size(), sizeof(int), verts, ptcmp); qsort_r(&idx[0], idx.size(), sizeof(int), verts, ptcmp);
#endif
// Find the maximum and minimum vertex bounds. // Find the maximum and minimum vertex bounds.
// This is to allow calculation of the bounding triangle // This is to allow calculation of the bounding triangle
float xmin = verts[0]; float xmin = verts[0];
@ -134,8 +138,8 @@ static void delaunay(const int nv, float *verts, rcIntArray& idx, rcIntArray& tr
float dx = xmax - xmin; float dx = xmax - xmin;
float dy = ymax - ymin; float dy = ymax - ymin;
float dmax = (dx > dy) ? dx : dy; float dmax = (dx > dy) ? dx : dy;
float xmid = (xmax + xmin) / 2.0; float xmid = (xmax + xmin) / 2.0f;
float ymid = (ymax + ymin) / 2.0; float ymid = (ymax + ymin) / 2.0f;
// Set up the supertriangle // Set up the supertriangle
// This is a triangle which encompasses all the sample points. // This is a triangle which encompasses all the sample points.
@ -685,20 +689,26 @@ bool rcBuildPolyMeshDetail(const rcPolyMesh& mesh, const rcCompactHeightfield& c
rcIntArray stack(512); rcIntArray stack(512);
rcIntArray samples(512); rcIntArray samples(512);
float verts[256*3]; float verts[256*3];
float poly[nvp*3]; float* poly = 0;
int* bounds = 0; int* bounds = 0;
rcHeightPatch hp; rcHeightPatch hp;
int nPolyVerts = 0; int nPolyVerts = 0;
int maxhw = 0, maxhh = 0; int maxhw = 0, maxhh = 0;
bounds = new int[mesh.npolys*4]; bounds = new int[mesh.npolys*4];
if (!bounds) if (!bounds)
{ {
if (rcGetLog()) if (rcGetLog())
rcGetLog()->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'bounds' (%d).", mesh.npolys*4); rcGetLog()->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'bounds' (%d).", mesh.npolys*4);
goto failure; goto failure;
} }
poly = new float[nvp*3];
if (!bounds)
{
if (rcGetLog())
rcGetLog()->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'poly' (%d).", nvp*3);
goto failure;
}
// Find max size for a polygon area. // Find max size for a polygon area.
for (int i = 0; i < mesh.npolys; ++i) for (int i = 0; i < mesh.npolys; ++i)
@ -870,6 +880,7 @@ bool rcBuildPolyMeshDetail(const rcPolyMesh& mesh, const rcCompactHeightfield& c
} }
delete [] bounds; delete [] bounds;
delete [] poly;
rcTimeVal endTime = rcGetPerformanceTimer(); rcTimeVal endTime = rcGetPerformanceTimer();
@ -881,6 +892,7 @@ bool rcBuildPolyMeshDetail(const rcPolyMesh& mesh, const rcCompactHeightfield& c
failure: failure:
delete [] bounds; delete [] bounds;
delete [] poly;
return false; return false;
} }

Binary file not shown.

View File

@ -227,6 +227,10 @@
RelativePath="..\..\..\Recast\Source\RecastMesh.cpp" RelativePath="..\..\..\Recast\Source\RecastMesh.cpp"
> >
</File> </File>
<File
RelativePath="..\..\..\Recast\Source\RecastMeshDetail.cpp"
>
</File>
<File <File
RelativePath="..\..\..\Recast\Source\RecastRasterization.cpp" RelativePath="..\..\..\Recast\Source\RecastRasterization.cpp"
> >