Improved path finding wall avoidance (more distance).
This commit is contained in:
parent
d98609063e
commit
2515b23b16
2 changed files with 4 additions and 2 deletions
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "util/Interval.h"
|
#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.
|
* 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.
|
* 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 (percentage < 0 || percentage > 1.0f) {
|
||||||
if (thor::squaredLength(p->start - path.back()) <
|
if (thor::squaredLength(p->start - path.back()) <
|
||||||
thor::squaredLength(p->end - path.back())) {
|
thor::squaredLength(p->end - path.back())) {
|
||||||
thor::setLength(startToEnd, radius);
|
thor::setLength(startToEnd, WALL_DISTANCE_MULTIPLIER * radius);
|
||||||
point = p->start + startToEnd;
|
point = p->start + startToEnd;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
thor::setLength(startToEnd, radius);
|
thor::setLength(startToEnd, WALL_DISTANCE_MULTIPLIER * radius);
|
||||||
point = p->end - startToEnd;
|
point = p->end - startToEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ private:
|
||||||
std::vector<Portal*> astarArea(Area* start, Area* end) const;
|
std::vector<Portal*> astarArea(Area* start, Area* end) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const float WALL_DISTANCE_MULTIPLIER;
|
||||||
std::map<Sprite::Category, std::vector<std::shared_ptr<Sprite> > > mDrawables;
|
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<Area> mAreas; //< This has to be a vector as objects are compared by address.
|
||||||
std::vector<std::shared_ptr<Character> > mCharacters;
|
std::vector<std::shared_ptr<Character> > mCharacters;
|
||||||
|
|
Reference in a new issue