diff --git a/Detour/Include/DetourTiledNavMesh.h b/Detour/Include/DetourTiledNavMesh.h index 45272c0..a2a48f2 100644 --- a/Detour/Include/DetourTiledNavMesh.h +++ b/Detour/Include/DetourTiledNavMesh.h @@ -83,16 +83,16 @@ struct dtTile dtTile* next; }; -inline dtTilePolyRef encodeId(unsigned int salt, unsigned int it, unsigned int ip) +inline dtTilePolyRef encodeId(int salt, int it, int ip) { - return (salt << (DT_TILE_REF_POLY_BITS+DT_TILE_REF_TILE_BITS)) | ((it+1) << DT_TILE_REF_POLY_BITS) | ip; + return ((unsigned int)salt << (DT_TILE_REF_POLY_BITS+DT_TILE_REF_TILE_BITS)) | ((unsigned int)(it+1) << DT_TILE_REF_POLY_BITS) | (unsigned int)ip; } -inline void decodeId(dtTilePolyRef ref, unsigned int& salt, unsigned int& it, unsigned int& ip) +inline void decodeId(dtTilePolyRef ref, int& salt, int& it, int& ip) { - salt = (ref >> (DT_TILE_REF_POLY_BITS+DT_TILE_REF_TILE_BITS)) & DT_TILE_REF_SALT_MASK; - it = ((ref >> DT_TILE_REF_POLY_BITS) & DT_TILE_REF_TILE_MASK) - 1; - ip = ref & DT_TILE_REF_POLY_MASK; + salt = (int)((ref >> (DT_TILE_REF_POLY_BITS+DT_TILE_REF_TILE_BITS)) & DT_TILE_REF_SALT_MASK); + it = (int)(((ref >> DT_TILE_REF_POLY_BITS) & DT_TILE_REF_TILE_MASK) - 1); + ip = (int)(ref & DT_TILE_REF_POLY_MASK); } static const int DT_TILE_LOOKUP_SIZE = DT_MAX_TILES/4; @@ -150,7 +150,7 @@ public: inline const dtTilePoly* getPolyByRef(dtTilePolyRef ref) const { - unsigned int salt, it, ip; + int salt, it, ip; decodeId(ref, salt, it, ip); if (it >= DT_MAX_TILES) return 0; if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return 0; @@ -160,7 +160,7 @@ public: inline const float* getPolyVertsByRef(dtTilePolyRef ref) const { - unsigned int salt, it, ip; + int salt, it, ip; decodeId(ref, salt, it, ip); if (it >= DT_MAX_TILES) return 0; if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return 0; diff --git a/Detour/Source/DetourStatNavMesh.cpp b/Detour/Source/DetourStatNavMesh.cpp index 9fe438a..d726911 100755 --- a/Detour/Source/DetourStatNavMesh.cpp +++ b/Detour/Source/DetourStatNavMesh.cpp @@ -671,7 +671,7 @@ int dtStatNavMesh::findPath(dtPolyRef startRef, dtPolyRef endRef, m_openList->push(startNode); dtNode* lastBestNode = startNode; - unsigned short lastBestNodeCost = startNode->total; + float lastBestNodeCost = startNode->total; while (!m_openList->empty()) { dtNode* bestNode = m_openList->pop(); @@ -1204,7 +1204,7 @@ int dtStatNavMesh::findPolysAround(dtPolyRef centerRef, const float* centerPos, if (resultCost) resultCost[n] = actualNode->total; if (resultDepth) - resultDepth[n] = actualNode->cost; + resultDepth[n] = (unsigned short)actualNode->cost; ++n; } actualNode->flags = dtNode::OPEN; diff --git a/Detour/Source/DetourTiledNavMesh.cpp b/Detour/Source/DetourTiledNavMesh.cpp index d905b35..2fed134 100644 --- a/Detour/Source/DetourTiledNavMesh.cpp +++ b/Detour/Source/DetourTiledNavMesh.cpp @@ -610,7 +610,7 @@ bool dtTiledNavMesh::init(const float* orig, float tileSize, float portalHeight) int dtTiledNavMesh::getPolyNeighbours(dtTilePolyRef ref, dtTilePolyRef* nei, int maxNei) const { - unsigned int salt, it, ip; + int salt, it, ip; decodeId(ref, salt, it, ip); if (it >= DT_MAX_TILES) return 0; if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return 0; @@ -934,7 +934,7 @@ bool dtTiledNavMesh::removeTile(int x, int y) bool dtTiledNavMesh::closestPointToPoly(dtTilePolyRef ref, const float* pos, float* closest) const { - unsigned int salt, it, ip; + int salt, it, ip; decodeId(ref, salt, it, ip); if (it >= DT_MAX_TILES) return false; if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return false; @@ -1063,7 +1063,7 @@ int dtTiledNavMesh::queryPolygons(const float* center, const float* extents, float dtTiledNavMesh::getCost(dtTilePolyRef prev, dtTilePolyRef from, dtTilePolyRef to) const { - unsigned int salt, it, ip; + int salt, it, ip; if (prev) from = prev; // The API input has been cheked already, skip checking internal data. decodeId(from, salt, it, ip); @@ -1086,7 +1086,7 @@ float dtTiledNavMesh::getCost(dtTilePolyRef prev, dtTilePolyRef from, dtTilePoly float dtTiledNavMesh::getHeuristic(dtTilePolyRef from, dtTilePolyRef to) const { - unsigned int salt, it, ip; + int salt, it, ip; // The API input has been cheked already, skip checking internal data. decodeId(from, salt, it, ip); const dtTileHeader* fromHeader = m_tiles[it].header; @@ -1139,7 +1139,7 @@ int dtTiledNavMesh::findPath(dtTilePolyRef startRef, dtTilePolyRef endRef, m_openList->push(startNode); dtTileNode* lastBestNode = startNode; - unsigned short lastBestNodeCost = startNode->total; + float lastBestNodeCost = startNode->total; while (!m_openList->empty()) { dtTileNode* bestNode = m_openList->pop(); @@ -1151,7 +1151,7 @@ int dtTiledNavMesh::findPath(dtTilePolyRef startRef, dtTilePolyRef endRef, } // Get poly and tile. - unsigned int salt, it, ip; + int salt, it, ip; decodeId(bestNode->id, salt, it, ip); // The API input has been cheked already, skip checking internal data. const dtTileHeader* h = m_tiles[it].header; @@ -1383,7 +1383,7 @@ int dtTiledNavMesh::findStraightPath(const float* startPos, const float* endPos, // Returns portal points between two polygons. bool dtTiledNavMesh::getPortalPoints(dtTilePolyRef from, dtTilePolyRef to, float* left, float* right) const { - unsigned int salt, it, ip; + int salt, it, ip; decodeId(from, salt, it, ip); if (it >= DT_MAX_TILES) return false; if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return false; @@ -1440,7 +1440,7 @@ int dtTiledNavMesh::raycast(dtTilePolyRef centerRef, const float* startPos, cons // Cast ray against current polygon. // The API input has been cheked already, skip checking internal data. - unsigned int salt, it, ip; + int salt, it, ip; decodeId(curRef, salt, it, ip); const dtTileHeader* h = m_tiles[it].header; const dtTilePoly* poly = &h->polys[ip]; @@ -1564,7 +1564,7 @@ int dtTiledNavMesh::findPolysAround(dtTilePolyRef centerRef, const float* center dtTileNode* bestNode = m_openList->pop(); // Get poly and tile. - unsigned int salt, it, ip; + int salt, it, ip; decodeId(bestNode->id, salt, it, ip); // The API input has been cheked already, skip checking internal data. const dtTileHeader* h = m_tiles[it].header; @@ -1623,7 +1623,7 @@ int dtTiledNavMesh::findPolysAround(dtTilePolyRef centerRef, const float* center if (resultCost) resultCost[n] = actualNode->total; if (resultDepth) - resultDepth[n] = actualNode->cost; + resultDepth[n] = (unsigned short)actualNode->cost; ++n; } actualNode->flags = dtTileNode::OPEN; @@ -1662,7 +1662,7 @@ float dtTiledNavMesh::findDistanceToWall(dtTilePolyRef centerRef, const float* c dtTileNode* bestNode = m_openList->pop(); // Get poly and tile. - unsigned int salt, it, ip; + int salt, it, ip; decodeId(bestNode->id, salt, it, ip); // The API input has been cheked already, skip checking internal data. const dtTileHeader* h = m_tiles[it].header; diff --git a/RecastDemo/Bin/Recast.exe b/RecastDemo/Bin/Recast.exe index 3a18c70..51cbaa7 100644 Binary files a/RecastDemo/Bin/Recast.exe and b/RecastDemo/Bin/Recast.exe differ diff --git a/RecastDemo/Build/VC9/Recast.vcproj b/RecastDemo/Build/VC9/Recast.vcproj index 566f3ca..1651016 100644 --- a/RecastDemo/Build/VC9/Recast.vcproj +++ b/RecastDemo/Build/VC9/Recast.vcproj @@ -189,7 +189,7 @@ > + + + + @@ -279,7 +287,15 @@ > + + + + + + + + diff --git a/RecastDemo/Source/BuilderStatMeshTiled.cpp b/RecastDemo/Source/BuilderStatMeshTiled.cpp index 13d774b..8dec830 100644 --- a/RecastDemo/Source/BuilderStatMeshTiled.cpp +++ b/RecastDemo/Source/BuilderStatMeshTiled.cpp @@ -390,20 +390,20 @@ static void drawLabels(int x, int y, int w, int h, float d = nicenum(range/(float)(nticks-1), 1); float graphmin = floorf(vmin/d)*d; float graphmax = ceilf(vmax/d)*d; - int nfrac = -floorf(log10f(d)); + int nfrac = (int)-floorf(log10f(d)); if (nfrac < 0) nfrac = 0; snprintf(str, 6, "%%.%df %%s", nfrac); for (float v = graphmin; v < graphmax+d/2; v += d) { - int lx = x + (int)((v-vmin) / (vmax-vmin) * w); + float lx = x + (v-vmin)/(vmax-vmin)*w; if (lx < 0 || lx > w) continue; snprintf(temp, 20, str, v, unit); - font->drawText(lx+2, y+2, temp, GLFont::RGBA(255,255,255)); + font->drawText(lx+2, (float)y+2, temp, GLFont::RGBA(255,255,255)); glColor4ub(0,0,0,64); glBegin(GL_LINES); - glVertex2f(lx,y); - glVertex2f(lx,y+h); + glVertex2f(lx,(float)y); + glVertex2f(lx,(float)(y+h)); glEnd(); } } @@ -459,9 +459,9 @@ static void drawGraph(const char* name, int x, int y, int w, int h, float sd, glEnd(); snprintf(text,64,"%d", maxval); - font->drawText(x+w-20+2,y+h-2-font->getLineHeight(),text,GLFont::RGBA(0,0,0)); + font->drawText((float)x+w-20+2,(float)y+h-2-font->getLineHeight(),text,GLFont::RGBA(0,0,0)); - font->drawText(x+2,y+h-2-font->getLineHeight(),name,GLFont::RGBA(255,255,255)); + font->drawText((float)x+2,(float)y+h-2-font->getLineHeight(),name,GLFont::RGBA(255,255,255)); drawLabels(x, y, w, h, 10, first*sd, last*sd, unit, font); }