From 3b231b85bb1c7ed8c00cf7f1a5a583299e23e3bc Mon Sep 17 00:00:00 2001 From: dteviot Date: Fri, 21 Aug 2015 06:55:54 +1200 Subject: [PATCH 1/4] removed incorrect optimization. Now it fixes #2871 --- apps/openmw/mwmechanics/pathfinding.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index 9013d32699..9c9c111060 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -53,13 +53,13 @@ namespace { assert(grid && !grid->mPoints.empty()); - float closestDistanceBetween = distanceSquared(grid->mPoints[0], pos); - float closestDistanceReachable = closestDistanceBetween; + float closestDistanceBetween = FLT_MAX; + float closestDistanceReachable = FLT_MAX; int closestIndex = 0; int closestReachableIndex = 0; // TODO: if this full scan causes performance problems mapping pathgrid // points to a quadtree may help - for(unsigned int counter = 1; counter < grid->mPoints.size(); counter++) + for(unsigned int counter = 0; counter < grid->mPoints.size(); counter++) { float potentialDistBetween = distanceSquared(grid->mPoints[counter], pos); if (potentialDistBetween < closestDistanceReachable) From 85bc41dedb9db07da2c4609ea39be95b508bb5e2 Mon Sep 17 00:00:00 2001 From: dteviot Date: Fri, 21 Aug 2015 19:34:28 +1200 Subject: [PATCH 2/4] replaced FLT_MAX with numeric_limits. --- apps/openmw/mwmechanics/aiwander.cpp | 2 +- apps/openmw/mwmechanics/autocalcspell.cpp | 2 +- apps/openmw/mwmechanics/pathfinding.cpp | 6 +++--- apps/openmw/mwmechanics/spellcasting.cpp | 2 +- apps/openmw/mwrender/renderingmanager.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index afe34218e4..7b846cb975 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -806,7 +806,7 @@ namespace MWMechanics void AiWander::SetCurrentNodeToClosestAllowedNode(osg::Vec3f npcPos) { - float distanceToClosestNode = FLT_MAX; + float distanceToClosestNode = std::numeric_limits::max(); unsigned int index = 0; for (unsigned int counterThree = 0; counterThree < mAllowedNodes.size(); counterThree++) { diff --git a/apps/openmw/mwmechanics/autocalcspell.cpp b/apps/openmw/mwmechanics/autocalcspell.cpp index e4b1438260..5dfe388a84 100644 --- a/apps/openmw/mwmechanics/autocalcspell.cpp +++ b/apps/openmw/mwmechanics/autocalcspell.cpp @@ -181,7 +181,7 @@ namespace MWMechanics void calcWeakestSchool (const ESM::Spell* spell, const int* actorSkills, int& effectiveSchool, float& skillTerm) { - float minChance = FLT_MAX; + float minChance = std::numeric_limits::max(); const ESM::EffectList& effects = spell->mEffects; for (std::vector::const_iterator it = effects.mList.begin(); it != effects.mList.end(); ++it) diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index 9c9c111060..f40624ae82 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -53,8 +53,8 @@ namespace { assert(grid && !grid->mPoints.empty()); - float closestDistanceBetween = FLT_MAX; - float closestDistanceReachable = FLT_MAX; + float closestDistanceBetween = std::numeric_limits::max(); + float closestDistanceReachable = std::numeric_limits::max(); int closestIndex = 0; int closestReachableIndex = 0; // TODO: if this full scan causes performance problems mapping pathgrid @@ -78,7 +78,7 @@ namespace } } - // invariant: start and endpoint must be connected + // post-condition: start and endpoint must be connected assert(cell->isPointConnected(start, closestReachableIndex)); // AiWander has logic that depends on whether a path was created, deleting diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index b98bf9f96f..59410001ff 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -92,7 +92,7 @@ namespace MWMechanics if (stats.getMagicEffects().get(ESM::MagicEffect::Silence).getMagnitude()) return 0; - float y = FLT_MAX; + float y = std::numeric_limits::max(); float lowestSkill = 0; for (std::vector::const_iterator it = spell->mEffects.mList.begin(); it != spell->mEffects.mList.end(); ++it) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index bac8fca6cb..1a1b04d181 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -383,7 +383,7 @@ namespace MWRender if (mFogDepth == 0.f) { mStateUpdater->setFogStart(0.f); - mStateUpdater->setFogEnd(FLT_MAX); + mStateUpdater->setFogEnd(std::numeric_limits::max()); } else { diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 1eed841bde..36f275cf4a 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2659,8 +2659,8 @@ namespace MWWorld MWRender::RenderingManager::RayResult result2 = mRendering->castRay(origin, dest, true, true); - float dist1 = FLT_MAX; - float dist2 = FLT_MAX; + float dist1 = std::numeric_limits::max(); + float dist2 = std::numeric_limits::max(); if (result1.mHit) dist1 = (origin - result1.mHitPos).length(); @@ -2853,7 +2853,7 @@ namespace MWWorld MWWorld::Ptr World::getClosestMarkerFromExteriorPosition( const osg::Vec3f& worldPos, const std::string &id ) { MWWorld::Ptr closestMarker; - float closestDistance = FLT_MAX; + float closestDistance = std::numeric_limits::max(); std::vector markers; mCells.getExteriorPtrs(id, markers); From 3fa5c6a0e781e7cd4f659694f56a71d2671bf06b Mon Sep 17 00:00:00 2001 From: dteviot Date: Fri, 21 Aug 2015 22:00:08 +1200 Subject: [PATCH 3/4] fixed travis build failure --- apps/openmw/mwrender/renderingmanager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 1a1b04d181..f4b8aa451e 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -1,6 +1,7 @@ #include "renderingmanager.hpp" #include +#include #include #include From 5dd0ad684123f9e9fcee602c37ed30f8747f9ecf Mon Sep 17 00:00:00 2001 From: dteviot Date: Fri, 21 Aug 2015 22:41:31 +1200 Subject: [PATCH 4/4] Fixed rest of travis errors. --- apps/openmw/mwmechanics/autocalcspell.cpp | 1 + apps/openmw/mwmechanics/pathfinding.cpp | 1 + apps/openmw/mwmechanics/spellcasting.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/apps/openmw/mwmechanics/autocalcspell.cpp b/apps/openmw/mwmechanics/autocalcspell.cpp index 5dfe388a84..b798ff5dce 100644 --- a/apps/openmw/mwmechanics/autocalcspell.cpp +++ b/apps/openmw/mwmechanics/autocalcspell.cpp @@ -1,6 +1,7 @@ #include "autocalcspell.hpp" #include +#include #include "../mwworld/esmstore.hpp" diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index f40624ae82..f53badbf46 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -1,4 +1,5 @@ #include "pathfinding.hpp" +#include #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 59410001ff..99625e90a3 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -1,6 +1,7 @@ #include "spellcasting.hpp" #include +#include #include