From 0128218254df07f804b15088036a1e7ef4938664 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 10 Sep 2011 03:07:26 +0000 Subject: recast and detour patch now builds again with GCC - rearrange structs to work for 64bit - define all vars before goto's - ifdefs for qsort_r/qsort_s - dont cast pointers to int only for NULL checks - dont printf STR_String directly, get the char pointer from it also minor change to gpu py module, no need to pass empty tuple to PyObject_CallObject, can just be NULL --- extern/recastnavigation/Recast/Source/Recast.cpp | 2 +- .../Recast/Source/RecastFilter.cpp | 10 ++++----- .../recastnavigation/Recast/Source/RecastMesh.cpp | 16 ++++++++++----- .../Recast/Source/RecastMeshDetail.cpp | 24 ++++++++++++++-------- 4 files changed, 33 insertions(+), 19 deletions(-) (limited to 'extern/recastnavigation') diff --git a/extern/recastnavigation/Recast/Source/Recast.cpp b/extern/recastnavigation/Recast/Source/Recast.cpp index 4bd8b7a12a9..0db26c2c1cd 100644 --- a/extern/recastnavigation/Recast/Source/Recast.cpp +++ b/extern/recastnavigation/Recast/Source/Recast.cpp @@ -188,7 +188,7 @@ bool rcBuildCompactHeightfield(const int walkableHeight, const int walkableClimb if (s->flags == flags) { const int bot = (int)s->smax; - const int top = (int)s->next ? (int)s->next->smin : MAX_HEIGHT; + const int top = s->next ? (int)s->next->smin : MAX_HEIGHT; chf.spans[idx].y = (unsigned short)rcClamp(bot, 0, 0xffff); chf.spans[idx].h = (unsigned char)rcClamp(top - bot, 0, 0xff); idx++; diff --git a/extern/recastnavigation/Recast/Source/RecastFilter.cpp b/extern/recastnavigation/Recast/Source/RecastFilter.cpp index 3421ea1899e..ebe60714a18 100644 --- a/extern/recastnavigation/Recast/Source/RecastFilter.cpp +++ b/extern/recastnavigation/Recast/Source/RecastFilter.cpp @@ -46,7 +46,7 @@ void rcFilterLedgeSpans(const int walkableHeight, continue; const int bot = (int)s->smax; - const int top = (int)s->next ? (int)s->next->smin : MAX_HEIGHT; + const int top = s->next ? (int)s->next->smin : MAX_HEIGHT; // Find neighbours minimum height. int minh = MAX_HEIGHT; @@ -74,7 +74,7 @@ void rcFilterLedgeSpans(const int walkableHeight, for (ns = solid.spans[dx + dy*w]; ns; ns = ns->next) { nbot = (int)ns->smax; - ntop = (int)ns->next ? (int)ns->next->smin : MAX_HEIGHT; + ntop = ns->next ? (int)ns->next->smin : MAX_HEIGHT; // Skip neightbour if the gap between the spans is too small. if (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight) minh = rcMin(minh, nbot - bot); @@ -115,7 +115,7 @@ void rcFilterWalkableLowHeightSpans(int walkableHeight, for (rcSpan* s = solid.spans[x + y*w]; s; s = s->next) { const int bot = (int)s->smax; - const int top = (int)s->next ? (int)s->next->smin : MAX_HEIGHT; + const int top = s->next ? (int)s->next->smin : MAX_HEIGHT; if ((top - bot) <= walkableHeight) s->flags &= ~RC_WALKABLE; } @@ -194,7 +194,7 @@ bool rcMarkReachableSpans(const int walkableHeight, rcReachableSeed cur = stack[stackSize]; const int bot = (int)cur.s->smax; - const int top = (int)cur.s->next ? (int)cur.s->next->smin : MAX_HEIGHT; + const int top = cur.s->next ? (int)cur.s->next->smin : MAX_HEIGHT; // Visit neighbours in all 4 directions. for (int dir = 0; dir < 4; ++dir) @@ -214,7 +214,7 @@ bool rcMarkReachableSpans(const int walkableHeight, continue; const int nbot = (int)ns->smax; - const int ntop = (int)ns->next ? (int)ns->next->smin : MAX_HEIGHT; + const int ntop = ns->next ? (int)ns->next->smin : MAX_HEIGHT; // Skip neightbour if the gap between the spans is too small. if (rcMin(top,ntop) - rcMax(bot,nbot) < walkableHeight) continue; diff --git a/extern/recastnavigation/Recast/Source/RecastMesh.cpp b/extern/recastnavigation/Recast/Source/RecastMesh.cpp index 45ed4a2fdc6..38d62904213 100644 --- a/extern/recastnavigation/Recast/Source/RecastMesh.cpp +++ b/extern/recastnavigation/Recast/Source/RecastMesh.cpp @@ -489,6 +489,9 @@ static void pushBack(int v, int* arr, int& an) static bool removeVertex(rcPolyMesh& mesh, const unsigned short rem, const int maxTris) { + unsigned short* tmpPoly; + int ntris; + static const int nvp = mesh.nvp; int* edges = 0; @@ -671,7 +674,7 @@ static bool removeVertex(rcPolyMesh& mesh, const unsigned short rem, const int m } // Triangulate the hole. - int ntris = triangulate(nhole, &tverts[0], &thole[0], tris); + ntris = triangulate(nhole, &tverts[0], &thole[0], tris); // Merge the hole triangles back to polygons. polys = new unsigned short[(ntris+1)*nvp]; @@ -689,7 +692,7 @@ static bool removeVertex(rcPolyMesh& mesh, const unsigned short rem, const int m goto failure; } - unsigned short* tmpPoly = &polys[ntris*nvp]; + tmpPoly = &polys[ntris*nvp]; // Build initial polygons. memset(polys, 0xff, ntris*nvp*sizeof(unsigned short)); @@ -793,7 +796,9 @@ failure: bool rcBuildPolyMesh(rcContourSet& cset, int nvp, rcPolyMesh& mesh) { + unsigned short* tmpPoly; rcTimeVal startTime = rcGetPerformanceTimer(); + rcTimeVal endTime; vcopy(mesh.bmin, cset.bmin); vcopy(mesh.bmax, cset.bmax); @@ -902,7 +907,7 @@ bool rcBuildPolyMesh(rcContourSet& cset, int nvp, rcPolyMesh& mesh) rcGetLog()->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'polys' (%d).", maxVertsPerCont*nvp); goto failure; } - unsigned short* tmpPoly = &polys[maxVertsPerCont*nvp]; + tmpPoly = &polys[maxVertsPerCont*nvp]; for (int i = 0; i < cset.nconts; ++i) { @@ -1050,7 +1055,7 @@ bool rcBuildPolyMesh(rcContourSet& cset, int nvp, rcPolyMesh& mesh) return false; } - rcTimeVal endTime = rcGetPerformanceTimer(); + endTime = rcGetPerformanceTimer(); // if (rcGetLog()) // rcGetLog()->log(RC_LOG_PROGRESS, "Build polymesh: %.3f ms", rcGetDeltaTimeUsec(startTime, endTime)/1000.0f); @@ -1076,6 +1081,7 @@ bool rcMergePolyMeshes(rcPolyMesh** meshes, const int nmeshes, rcPolyMesh& mesh) return true; rcTimeVal startTime = rcGetPerformanceTimer(); + rcTimeVal endTime; int* nextVert = 0; int* firstVert = 0; @@ -1196,7 +1202,7 @@ bool rcMergePolyMeshes(rcPolyMesh** meshes, const int nmeshes, rcPolyMesh& mesh) delete [] nextVert; delete [] vremap; - rcTimeVal endTime = rcGetPerformanceTimer(); + endTime = rcGetPerformanceTimer(); if (rcGetBuildTimes()) rcGetBuildTimes()->mergePolyMesh += rcGetDeltaTimeUsec(startTime, endTime); diff --git a/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp b/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp index ef17531d7bc..b43346c53e2 100644 --- a/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp +++ b/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp @@ -95,7 +95,11 @@ static int circumCircle(const float xp, const float yp, return (drsqr <= rsqr) ? 1 : 0; } +#if defined(_MSC_VER) static int ptcmp(void* up, const void *v1, const void *v2) +#else +static int ptcmp(const void *v1, const void *v2, void* up) +#endif { const float* verts = (const float*)up; const float* p1 = &verts[(*(const int*)v1)*3]; @@ -116,10 +120,10 @@ static void delaunay(const int nv, float *verts, rcIntArray& idx, rcIntArray& tr idx.resize(nv); for (int i = 0; i < nv; ++i) idx[i] = i; -#ifdef WIN32 +#if defined(_MSC_VER) 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), ptcmp, verts); #endif // Find the maximum and minimum vertex bounds. @@ -673,11 +677,15 @@ bool rcBuildPolyMeshDetail(const rcPolyMesh& mesh, const rcCompactHeightfield& c const float sampleDist, const float sampleMaxError, rcPolyMeshDetail& dmesh) { - rcTimeVal startTime = rcGetPerformanceTimer(); - if (mesh.nverts == 0 || mesh.npolys == 0) return true; - + + rcTimeVal startTime = rcGetPerformanceTimer(); + rcTimeVal endTime; + + int vcap; + int tcap; + const int nvp = mesh.nvp; const float cs = mesh.cs; const float ch = mesh.ch; @@ -760,8 +768,8 @@ bool rcBuildPolyMeshDetail(const rcPolyMesh& mesh, const rcCompactHeightfield& c goto failure; } - int vcap = nPolyVerts+nPolyVerts/2; - int tcap = vcap*2; + vcap = nPolyVerts+nPolyVerts/2; + tcap = vcap*2; dmesh.nverts = 0; dmesh.verts = new float[vcap*3]; @@ -882,7 +890,7 @@ bool rcBuildPolyMeshDetail(const rcPolyMesh& mesh, const rcCompactHeightfield& c delete [] bounds; delete [] poly; - rcTimeVal endTime = rcGetPerformanceTimer(); + endTime = rcGetPerformanceTimer(); if (rcGetBuildTimes()) rcGetBuildTimes()->buildDetailMesh += rcGetDeltaTimeUsec(startTime, endTime); -- cgit v1.2.3