Improved path finding wall avoidance (more distance).

This commit is contained in:
Felix Ableitner 2013-04-05 16:58:37 +02:00
parent d98609063e
commit 2515b23b16
2 changed files with 4 additions and 2 deletions

View File

@ -14,6 +14,7 @@
#include "util/Interval.h"
const float World::WALL_DISTANCE_MULTIPLIER = 1.5f;
/**
* Insert a drawable into the group. Drawables should only be handled with shared_ptr.
* An object can't be inserted more than once at the same level.
@ -203,11 +204,11 @@ World::getPath(const sf::Vector2f& start, const sf::Vector2f& end,
if (percentage < 0 || percentage > 1.0f) {
if (thor::squaredLength(p->start - path.back()) <
thor::squaredLength(p->end - path.back())) {
thor::setLength(startToEnd, radius);
thor::setLength(startToEnd, WALL_DISTANCE_MULTIPLIER * radius);
point = p->start + startToEnd;
}
else {
thor::setLength(startToEnd, radius);
thor::setLength(startToEnd, WALL_DISTANCE_MULTIPLIER * radius);
point = p->end - startToEnd;
}
}

View File

@ -65,6 +65,7 @@ private:
std::vector<Portal*> astarArea(Area* start, Area* end) const;
private:
static const float WALL_DISTANCE_MULTIPLIER;
std::map<Sprite::Category, std::vector<std::shared_ptr<Sprite> > > mDrawables;
std::vector<Area> mAreas; //< This has to be a vector as objects are compared by address.
std::vector<std::shared_ptr<Character> > mCharacters;