[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40084] trunk/blender: recast and detour patch now builds again with GCC

Daniel Salazar - 3Developer.com zanqdo at gmail.com
Sat Sep 10 05:20:10 CEST 2011


http://www.pasteall.org/24760

getting this after this commit

Daniel Salazar
3Developer.com



On Fri, Sep 9, 2011 at 9:07 PM, Campbell Barton <ideasman42 at gmail.com> wrote:
> Revision: 40084
>          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40084
> Author:   campbellbarton
> Date:     2011-09-10 03:07:26 +0000 (Sat, 10 Sep 2011)
> Log Message:
> -----------
> 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
>
> Modified Paths:
> --------------
>    trunk/blender/extern/recastnavigation/Recast/Source/Recast.cpp
>    trunk/blender/extern/recastnavigation/Recast/Source/RecastFilter.cpp
>    trunk/blender/extern/recastnavigation/Recast/Source/RecastMesh.cpp
>    trunk/blender/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp
>    trunk/blender/source/blender/editors/util/navmesh_conversion.cpp
>    trunk/blender/source/blender/makesdna/DNA_scene_types.h
>    trunk/blender/source/blender/python/intern/gpu.c
>    trunk/blender/source/gameengine/Ketsji/KX_NavMeshObject.cpp
>
> Modified: trunk/blender/extern/recastnavigation/Recast/Source/Recast.cpp
> ===================================================================
> --- trunk/blender/extern/recastnavigation/Recast/Source/Recast.cpp      2011-09-10 01:39:21 UTC (rev 40083)
> +++ trunk/blender/extern/recastnavigation/Recast/Source/Recast.cpp      2011-09-10 03:07:26 UTC (rev 40084)
> @@ -188,7 +188,7 @@
>                                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++;
>
> Modified: trunk/blender/extern/recastnavigation/Recast/Source/RecastFilter.cpp
> ===================================================================
> --- trunk/blender/extern/recastnavigation/Recast/Source/RecastFilter.cpp        2011-09-10 01:39:21 UTC (rev 40083)
> +++ trunk/blender/extern/recastnavigation/Recast/Source/RecastFilter.cpp        2011-09-10 03:07:26 UTC (rev 40084)
> @@ -46,7 +46,7 @@
>                                        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 @@
>                                        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 @@
>                        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 @@
>                                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 @@
>                                                        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;
>
> Modified: trunk/blender/extern/recastnavigation/Recast/Source/RecastMesh.cpp
> ===================================================================
> --- trunk/blender/extern/recastnavigation/Recast/Source/RecastMesh.cpp  2011-09-10 01:39:21 UTC (rev 40083)
> +++ trunk/blender/extern/recastnavigation/Recast/Source/RecastMesh.cpp  2011-09-10 03:07:26 UTC (rev 40084)
> @@ -489,6 +489,9 @@
>
>  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 @@
>        }
>
>        // 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 @@
>                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 @@
>
>  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 @@
>                        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 @@
>                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 @@
>                return true;
>
>        rcTimeVal startTime = rcGetPerformanceTimer();
> +       rcTimeVal endTime;
>
>        int* nextVert = 0;
>        int* firstVert = 0;
> @@ -1196,7 +1202,7 @@
>        delete [] nextVert;
>        delete [] vremap;
>
> -       rcTimeVal endTime = rcGetPerformanceTimer();
> +       endTime = rcGetPerformanceTimer();
>
>        if (rcGetBuildTimes())
>                rcGetBuildTimes()->mergePolyMesh += rcGetDeltaTimeUsec(startTime, endTime);
>
> Modified: trunk/blender/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp
> ===================================================================
> --- trunk/blender/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp    2011-09-10 01:39:21 UTC (rev 40083)
> +++ trunk/blender/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp    2011-09-10 03:07:26 UTC (rev 40084)
> @@ -95,7 +95,11 @@
>        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 @@
>        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 @@
>                                                   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 @@
>                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 @@
>        delete [] bounds;
>        delete [] poly;
>
> -       rcTimeVal endTime = rcGetPerformanceTimer();
> +       endTime = rcGetPerformanceTimer();
>
>        if (rcGetBuildTimes())
>                rcGetBuildTimes()->buildDetailMesh += rcGetDeltaTimeUsec(startTime, endTime);
>
> Modified: trunk/blender/source/blender/editors/util/navmesh_conversion.cpp
> ===================================================================
> --- trunk/blender/source/blender/editors/util/navmesh_conversion.cpp    2011-09-10 01:39:21 UTC (rev 40083)
> +++ trunk/blender/source/blender/editors/util/navmesh_conversion.cpp    2011-09-10 03:07:26 UTC (rev 40084)
> @@ -146,7 +146,6 @@
>                                                                                  const float* verts, const unsigned short* dtris,
>                                                                                  const int* dtrisToPolysMap)
>  {
> -       bool res = false;
>        int capacity = vertsPerPoly;
>        unsigned short* newPoly =  new unsigned short[capacity];
>        memset(newPoly, 0xff, sizeof(unsigned short)*capacity);
> @@ -268,7 +267,6 @@
>                        }
>                }
>        }
> -       res = true;
>
>  returnLabel:
>        delete newPoly;
> @@ -280,8 +278,13 @@
>        const int* recastData;
>        const int* trisToFacesMap;
>  };
> -static int compareByData(void* data, const void * a, const void * b){
> -       SortContext* context = (SortContext*)data;
> +#if defined(_MSC_VER)
> +static int compareByData(const void* data, void * a, void * b)
> +#else
> +static int compareByData(const void * a, const void * b, void* data)
> +#endif
> +{
> +       const SortContext* context = (const SortContext*)data;
>        return ( context->recastData[context->trisToFacesMap[*(int*)a]] -
>                context->recastData[context->trisToFacesMap[*(int*)b]] );
>  }
> @@ -307,8 +310,11 @@
>        SortContext context;
>        context.recastData = recastData;
>        context.trisToFacesMap = trisToFacesMap;
> +#if defined(_MSC_VER)
>        qsort_s(trisMapping, ntris, sizeof(int), compareByData, &context);
> -
> +#else
> +       qsort_r(trisMapping, ntris, sizeof(int), compareByData, &context);
> +#endif
>        //search first valid triangle - triangle of convex polygon
>        int validTriStart = -1;
>        for (int i=0; i< ntris; i++)
>
> Modified: trunk/blender/source/blender/makesdna/DNA_scene_types.h
> ===================================================================
> --- trunk/blender/source/blender/makesdna/DNA_scene_types.h     2011-09-10 01:39:21 UTC (rev 40083)
> +++ trunk/blender/source/blender/makesdna/DNA_scene_types.h     2011-09-10 03:07:26 UTC (rev 40084)
> @@ -445,6 +445,19 @@
>
>  typedef struct GameData {
>
> +       /*  standalone player */
> +       struct GameFraming framing;
> +       short fullscreen, xplay, yplay, freqplay;
> +       short depth, attrib, rt1, rt2;
> +
> +       /* stereo/dome mode */
> +       struct GameDome dome;
> +       short stereoflag, stereomode;
> +       short pad2, pad3;
> +       float eyeseparation, pad1;
> +       RecastData recastData;
> +
> +
>        /* physics (it was in world)*/
>        float gravity; /*Gravitation constant for the game world*/
>
> @@ -463,19 +476,6 @@
>        short ticrate, maxlogicstep, physubstep, maxphystep;
>        short obstacleSimulation;
>        float levelHeight;
> -
> -
> -       /*  standalone player */
> -       struct GameFraming framing;
> -       short fullscreen, xplay, yplay, freqplay;
> -       short depth, attrib, rt1, rt2;
> -
> -       /* stereo/dome mode */
> -       struct GameDome dome;
> -       short stereoflag, stereomode;
> -       short pad2, pad3;
> -       float eyeseparation, pad1;
> -       RecastData recastData;
>  } GameData;
>
>  #define STEREO_NOSTEREO                1
>
> Modified: trunk/blender/source/blender/python/intern/gpu.c
> ===================================================================
> --- trunk/blender/source/blender/python/intern/gpu.c    2011-09-10 01:39:21 UTC (rev 40083)
> +++ trunk/blender/source/blender/python/intern/gpu.c    2011-09-10 03:07:26 UTC (rev 40084)
> @@ -147,7 +147,6 @@
>        PyObject* pymat;
>        PyObject* as_pointer;
>        PyObject* pointer;
> -       PyObject* noargs;
>        PyObject* result;
>        PyObject* dict;
>        PyObject* val;
> @@ -170,9 +169,7 @@
>                (as_pointer = PyObject_GetAttrString(pyscene, "as_pointer")) != NULL &&
>
> @@ Diff output truncated at 10240 characters. @@
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>


More information about the Bf-committers mailing list