mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 14:36:39 +00:00
Remove fix for #1317
Expanding the AiWander distance for path grid nodes causes bigger problems than it solved.
This commit is contained in:
parent
164994f3d3
commit
46a654286b
2 changed files with 0 additions and 33 deletions
|
@ -719,36 +719,10 @@ namespace MWMechanics
|
||||||
mCurrentNode = mAllowedNodes[index];
|
mCurrentNode = mAllowedNodes[index];
|
||||||
mAllowedNodes.erase(mAllowedNodes.begin() + index);
|
mAllowedNodes.erase(mAllowedNodes.begin() + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In vanilla Morrowind, sometimes distance is too small to include at least two points,
|
|
||||||
// in which case, we will take the two closest points regardless of the wander distance
|
|
||||||
// This is a backup option, as std::sort is potentially O(n^2) in time.
|
|
||||||
if (mAllowedNodes.empty())
|
|
||||||
{
|
|
||||||
// Start with list of PathGrid nodes, sorted by distance from actor
|
|
||||||
std::vector<PathDistance> nodeDistances;
|
|
||||||
for (unsigned int counter = 0; counter < pathgrid->mPoints.size(); counter++)
|
|
||||||
{
|
|
||||||
float distance = (npcPos - PathFinder::MakeOsgVec3(pathgrid->mPoints[counter])).length2();
|
|
||||||
nodeDistances.push_back(std::make_pair(distance, &pathgrid->mPoints.at(counter)));
|
|
||||||
}
|
|
||||||
std::sort(nodeDistances.begin(), nodeDistances.end(), sortByDistance);
|
|
||||||
|
|
||||||
// make closest node the current node
|
|
||||||
mCurrentNode = *nodeDistances[0].second;
|
|
||||||
|
|
||||||
// give Actor a 2nd node to walk to
|
|
||||||
mAllowedNodes.push_back(*nodeDistances[1].second);
|
|
||||||
}
|
|
||||||
mStoredAvailableNodes = true; // set only if successful in finding allowed nodes
|
mStoredAvailableNodes = true; // set only if successful in finding allowed nodes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AiWander::sortByDistance(const PathDistance& left, const PathDistance& right)
|
|
||||||
{
|
|
||||||
return left.first < right.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AiWander::writeState(ESM::AiSequence::AiSequence &sequence) const
|
void AiWander::writeState(ESM::AiSequence::AiSequence &sequence) const
|
||||||
{
|
{
|
||||||
std::auto_ptr<ESM::AiSequence::AiWander> wander(new ESM::AiSequence::AiWander());
|
std::auto_ptr<ESM::AiSequence::AiWander> wander(new ESM::AiSequence::AiWander());
|
||||||
|
|
|
@ -120,13 +120,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
/// lookup table for converting idleSelect value to groupName
|
/// lookup table for converting idleSelect value to groupName
|
||||||
static const std::string sIdleSelectToGroupName[GroupIndex_MaxIdle - GroupIndex_MinIdle + 1];
|
static const std::string sIdleSelectToGroupName[GroupIndex_MaxIdle - GroupIndex_MinIdle + 1];
|
||||||
|
|
||||||
/// record distances of pathgrid point nodes to actor
|
|
||||||
/// first value is distance between actor and node, second value is PathGrid node
|
|
||||||
typedef std::pair<float, const ESM::Pathgrid::Point*> PathDistance;
|
|
||||||
|
|
||||||
/// used to sort array of PathDistance objects into ascending order
|
|
||||||
static bool sortByDistance(const PathDistance& left, const PathDistance& right);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue