From b493e7e6f61aed026cc874f45bbac9b8a70425eb Mon Sep 17 00:00:00 2001 From: grahamboree Date: Mon, 14 Oct 2013 16:32:20 -0400 Subject: [PATCH 1/4] Added rcIngoreUnused which can be called to ignore unused parameters. --- Recast/Include/Recast.h | 5 +++++ Recast/Source/Recast.cpp | 20 ++++++++------------ RecastDemo/Source/CrowdTool.cpp | 4 ++++ RecastDemo/Source/NavMeshPruneTool.cpp | 11 ++++++++--- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Recast/Include/Recast.h b/Recast/Include/Recast.h index 1ea40a3..88ce11c 100644 --- a/Recast/Include/Recast.h +++ b/Recast/Include/Recast.h @@ -549,6 +549,11 @@ static const int RC_NOT_CONNECTED = 0x3f; /// @name General helper functions /// @{ +/// Used to ignore a function parameter. VS complains about unused parameters +/// and this silences the warning. +/// @param [in] _ Unused parameter +template void rcIgnoreUnused(const T&) { } + /// Swaps the values of the two parameters. /// @param[in,out] a Value A /// @param[in,out] b Value B diff --git a/Recast/Source/Recast.cpp b/Recast/Source/Recast.cpp index 803daac..b9d8603 100644 --- a/Recast/Source/Recast.cpp +++ b/Recast/Source/Recast.cpp @@ -208,12 +208,11 @@ void rcCalcGridSize(const float* bmin, const float* bmax, float cs, int* w, int* /// See the #rcConfig documentation for more information on the configuration parameters. /// /// @see rcAllocHeightfield, rcHeightfield -bool rcCreateHeightfield(rcContext* /*ctx*/, rcHeightfield& hf, int width, int height, +bool rcCreateHeightfield(rcContext* ctx, rcHeightfield& hf, int width, int height, const float* bmin, const float* bmax, float cs, float ch) { - // TODO: VC complains about unref formal variable, figure out a way to handle this better. -// rcAssert(ctx); + rcIgnoreUnused(ctx); hf.width = width; hf.height = height; @@ -245,13 +244,12 @@ static void calcTriNormal(const float* v0, const float* v1, const float* v2, flo /// See the #rcConfig documentation for more information on the configuration parameters. /// /// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles -void rcMarkWalkableTriangles(rcContext* /*ctx*/, const float walkableSlopeAngle, +void rcMarkWalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, const float* verts, int /*nv*/, const int* tris, int nt, unsigned char* areas) { - // TODO: VC complains about unref formal variable, figure out a way to handle this better. -// rcAssert(ctx); + rcIgnoreUnused(ctx); const float walkableThr = cosf(walkableSlopeAngle/180.0f*RC_PI); @@ -275,13 +273,12 @@ void rcMarkWalkableTriangles(rcContext* /*ctx*/, const float walkableSlopeAngle, /// See the #rcConfig documentation for more information on the configuration parameters. /// /// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles -void rcClearUnwalkableTriangles(rcContext* /*ctx*/, const float walkableSlopeAngle, +void rcClearUnwalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, const float* verts, int /*nv*/, const int* tris, int nt, unsigned char* areas) { - // TODO: VC complains about unref formal variable, figure out a way to handle this better. -// rcAssert(ctx); + rcIgnoreUnused(ctx); const float walkableThr = cosf(walkableSlopeAngle/180.0f*RC_PI); @@ -297,10 +294,9 @@ void rcClearUnwalkableTriangles(rcContext* /*ctx*/, const float walkableSlopeAng } } -int rcGetHeightFieldSpanCount(rcContext* /*ctx*/, rcHeightfield& hf) +int rcGetHeightFieldSpanCount(rcContext* ctx, rcHeightfield& hf) { - // TODO: VC complains about unref formal variable, figure out a way to handle this better. -// rcAssert(ctx); + rcIgnoreUnused(ctx); const int w = hf.width; const int h = hf.height; diff --git a/RecastDemo/Source/CrowdTool.cpp b/RecastDemo/Source/CrowdTool.cpp index 5caa6bd..98ded8e 100644 --- a/RecastDemo/Source/CrowdTool.cpp +++ b/RecastDemo/Source/CrowdTool.cpp @@ -1068,6 +1068,7 @@ void CrowdTool::handleToggle() void CrowdTool::handleUpdate(const float dt) { + rcIgnoreUnused(dt); } void CrowdTool::handleRender() @@ -1076,6 +1077,9 @@ void CrowdTool::handleRender() void CrowdTool::handleRenderOverlay(double* proj, double* model, int* view) { + rcIgnoreUnused(model); + rcIgnoreUnused(proj); + // Tool help const int h = view[3]; int ty = h-40; diff --git a/RecastDemo/Source/NavMeshPruneTool.cpp b/RecastDemo/Source/NavMeshPruneTool.cpp index 36e8e1a..193d79a 100644 --- a/RecastDemo/Source/NavMeshPruneTool.cpp +++ b/RecastDemo/Source/NavMeshPruneTool.cpp @@ -261,8 +261,11 @@ void NavMeshPruneTool::handleMenu() } } -void NavMeshPruneTool::handleClick(const float* /*s*/, const float* p, bool shift) +void NavMeshPruneTool::handleClick(const float* s, const float* p, bool shift) { + rcIgnoreUnused(s); + rcIgnoreUnused(shift); + if (!m_sample) return; InputGeom* geom = m_sample->getInputGeom(); if (!geom) return; @@ -341,9 +344,11 @@ void NavMeshPruneTool::handleRender() void NavMeshPruneTool::handleRenderOverlay(double* proj, double* model, int* view) { + rcIgnoreUnused(model); + rcIgnoreUnused(proj); + // Tool help const int h = view[3]; - imguiDrawText(280, h-40, IMGUI_ALIGN_LEFT, "LMB: Click fill area.", imguiRGBA(255,255,255,192)); - + imguiDrawText(280, h-40, IMGUI_ALIGN_LEFT, "LMB: Click fill area.", imguiRGBA(255,255,255,192)); } From 35db2af8726814f1ffa3362d12ce1556fc500361 Mon Sep 17 00:00:00 2001 From: grahamboree Date: Mon, 14 Oct 2013 16:36:49 -0400 Subject: [PATCH 2/4] Silenced additional unused parameter warning. --- DetourTileCache/Source/DetourTileCacheBuilder.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DetourTileCache/Source/DetourTileCacheBuilder.cpp b/DetourTileCache/Source/DetourTileCacheBuilder.cpp index 19b5e91..18a26d0 100644 --- a/DetourTileCache/Source/DetourTileCacheBuilder.cpp +++ b/DetourTileCache/Source/DetourTileCacheBuilder.cpp @@ -21,6 +21,7 @@ #include "DetourStatus.h" #include "DetourAssert.h" #include "DetourTileCacheBuilder.h" +#include "Recast.h" #include @@ -2116,6 +2117,7 @@ dtStatus dtDecompressTileCacheLayer(dtTileCacheAlloc* alloc, dtTileCacheCompress bool dtTileCacheHeaderSwapEndian(unsigned char* data, const int dataSize) { + rcIgnoreUnused(dataSize); dtTileCacheLayerHeader* header = (dtTileCacheLayerHeader*)data; int swappedMagic = DT_TILECACHE_MAGIC; From 683acbb11c7e0144590dd89777f4612d6ccb731a Mon Sep 17 00:00:00 2001 From: grahamboree Date: Mon, 14 Oct 2013 16:38:03 -0400 Subject: [PATCH 3/4] Silenced double->float conversion warning. --- RecastDemo/Source/NavMeshTesterTool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecastDemo/Source/NavMeshTesterTool.cpp b/RecastDemo/Source/NavMeshTesterTool.cpp index 4784624..146624e 100644 --- a/RecastDemo/Source/NavMeshTesterTool.cpp +++ b/RecastDemo/Source/NavMeshTesterTool.cpp @@ -1297,7 +1297,7 @@ void NavMeshTesterTool::handleRender() for (int i = 0; i < m_nrandPoints; i++) { const float* p = &m_randPoints[i*3]; - dd.vertex(p[0],p[1]+0.1,p[2], duRGBA(220,32,16,192)); + dd.vertex(p[0],p[1]+0.1f,p[2], duRGBA(220,32,16,192)); } dd.end(); From dc7e248de6e0da2a3a533977081c461137a75b4d Mon Sep 17 00:00:00 2001 From: grahamboree Date: Tue, 15 Oct 2013 17:29:14 -0400 Subject: [PATCH 4/4] Removed header dependency between Detour and Recast due to addition of rcIgnoreUnused. Added dtIgnoreUnused. --- Detour/Include/DetourCommon.h | 5 +++++ DetourTileCache/Source/DetourTileCacheBuilder.cpp | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Detour/Include/DetourCommon.h b/Detour/Include/DetourCommon.h index ed7c514..0888614 100644 --- a/Detour/Include/DetourCommon.h +++ b/Detour/Include/DetourCommon.h @@ -32,6 +32,11 @@ feature to find minor members. /// @name General helper functions /// @{ +/// Used to ignore a function parameter. VS complains about unused parameters +/// and this silences the warning. +/// @param [in] _ Unused parameter +template void dtIgnoreUnused(const T&) { } + /// Swaps the values of the two parameters. /// @param[in,out] a Value A /// @param[in,out] b Value B diff --git a/DetourTileCache/Source/DetourTileCacheBuilder.cpp b/DetourTileCache/Source/DetourTileCacheBuilder.cpp index 18a26d0..d6602b7 100644 --- a/DetourTileCache/Source/DetourTileCacheBuilder.cpp +++ b/DetourTileCache/Source/DetourTileCacheBuilder.cpp @@ -21,7 +21,6 @@ #include "DetourStatus.h" #include "DetourAssert.h" #include "DetourTileCacheBuilder.h" -#include "Recast.h" #include @@ -2117,7 +2116,7 @@ dtStatus dtDecompressTileCacheLayer(dtTileCacheAlloc* alloc, dtTileCacheCompress bool dtTileCacheHeaderSwapEndian(unsigned char* data, const int dataSize) { - rcIgnoreUnused(dataSize); + dtIgnoreUnused(dataSize); dtTileCacheLayerHeader* header = (dtTileCacheLayerHeader*)data; int swappedMagic = DT_TILECACHE_MAGIC;