From c652cb15687e5956196cb046d88d19f698666b0e Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 18 Apr 2014 15:19:22 +1000 Subject: [PATCH] More cleaning up. --- apps/openmw/mwmechanics/aiwander.cpp | 16 ++++++++-------- apps/openmw/mwmechanics/aiwander.hpp | 3 --- apps/openmw/mwmechanics/obstacle.cpp | 15 --------------- apps/openmw/mwmechanics/pathfinding.cpp | 2 +- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 276d1fac6..260aa72cf 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -47,7 +47,6 @@ namespace MWMechanics mStartTime = MWBase::Environment::get().getWorld()->getTimeStamp(); mPlayedIdle = 0; - //mPathgrid = NULL; mIdleChanceMultiplier = MWBase::Environment::get().getWorld()->getStore().get().find("fIdleChanceMultiplier")->getFloat(); @@ -104,14 +103,15 @@ namespace MWMechanics * TODO: non-time critical operations should be run once every 250ms or so. * * TODO: It would be great if door opening/closing can be detected and pathgrid - * links dynamically updated. Currently (0.29.0) AiWander allows destination - * beyond closed doors which sometimes makes the actors stuck at the door and - * impossible for the player to open the door. + * links dynamically updated. Currently (0.29.0) AiWander allows choosing a + * destination beyond closed doors which sometimes makes the actors stuck at the + * door and impossible for the player to open the door. * * For now detect being stuck at the door and simply delete the nodes from the * allowed set. The issue is when the door opens the allowed set is not - * re-calculated. Normally this would not be an issue since hostile actors will - * enter combat (i.e. no longer wandering) + * re-calculated. However this would not be an issue in most cases since hostile + * actors will enter combat (i.e. no longer wandering) and different pathfinding + * will kick in. */ bool AiWander::execute (const MWWorld::Ptr& actor,float duration) { @@ -473,8 +473,8 @@ namespace MWMechanics ESM::Pathgrid::Point pt = paths.back(); for(int j = 0; j < nodes.size(); j++) { - // NOTE: doesn't hadle a door with the same X/Y - // coordinates but with a different Z + // FIXME: doesn't hadle a door with the same X/Y + // co-ordinates but with a different Z if(nodes[j].mX == pt.mX && nodes[j].mY == pt.mY) { nodes.erase(nodes.begin() + j); diff --git a/apps/openmw/mwmechanics/aiwander.hpp b/apps/openmw/mwmechanics/aiwander.hpp index 8fe35e53d..59c21de89 100644 --- a/apps/openmw/mwmechanics/aiwander.hpp +++ b/apps/openmw/mwmechanics/aiwander.hpp @@ -65,13 +65,10 @@ namespace MWMechanics const PathFinder& pathfinder); PathFinder mPathFinder; - //const ESM::Pathgrid *mPathgrid; ObstacleCheck mObstacleCheck; float mDoorCheckDuration; int mStuckCount; - - //float mReaction; }; } diff --git a/apps/openmw/mwmechanics/obstacle.cpp b/apps/openmw/mwmechanics/obstacle.cpp index 00f97ae01..9a748c052 100644 --- a/apps/openmw/mwmechanics/obstacle.cpp +++ b/apps/openmw/mwmechanics/obstacle.cpp @@ -44,16 +44,7 @@ namespace MWMechanics MWWorld::LiveCellRef& ref = *it; if(pos.squaredDistance(Ogre::Vector3(ref.mRef.mPos.pos)) < minSqr && ref.mData.getLocalRotation().rot[2] == (closed ? 0 : 1)) - { -//#if 0 - std::cout << "\""+actor.getClass().getName(actor)+"\" " - <<"next to door "+ref.mRef.mRefID - //+", enabled? "+std::to_string(ref.mData.isEnabled()) - +", dist "+std::to_string(sqrt(pos.squaredDistance(Ogre::Vector3(ref.mRef.mPos.pos)))) - << std::endl; -//#endif return true; // found, stop searching - } } return false; // none found } @@ -158,12 +149,6 @@ namespace MWMechanics return true; else { -//#if 0 - std::cout << "evade \""+actor.getClass().getName(actor)+"\" " - //<<"dist spot "+std::to_string(mDistSameSpot) - //+", speed "+std::to_string(cls.getSpeed(actor)) - << std::endl; -//#endif // tried to evade, assume all is ok and start again mWalkState = State_Norm; mEvadeDuration = 0; diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index 139553556..11d436700 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -231,7 +231,7 @@ namespace MWMechanics // deleting allowed nodes if not. Hence a path needs to be created // even if the start and the end points are the same. // NOTE: aStarSearch will return an empty path if the start and end - // nodes are the same + // nodes are the same if(startNode == endNode.first) { mPath.push_back(endPoint);