Make a compromise between f240374b28
and f134ac63bb
by making the filtering of pathfinding-blocking shapes conditional.
Those shapes need to be taken into account when computing a short path, but they need to be discarded when checking movements or they will create long/short inconsistencies. This was SVN commit r16981.
This commit is contained in:
parent
ad9736b5a5
commit
3005637370
@ -724,7 +724,7 @@ void CCmpPathfinder::ProcessShortRequests(const std::vector<AsyncShortPathReques
|
||||
{
|
||||
const AsyncShortPathRequest& req = shortRequests[i];
|
||||
WaypointPath path;
|
||||
ControlGroupMovementObstructionFilter filter(req.avoidMovingUnits, req.group);
|
||||
ControlGroupMovementObstructionFilter filter(true, req.avoidMovingUnits, req.group);
|
||||
ComputeShortPath(filter, req.x0, req.z0, req.clearance, req.range, req.goal, req.passClass, path);
|
||||
CMessagePathResult msg(req.ticket, path);
|
||||
GetSimContext().GetComponentManager().PostMessage(req.notify, msg);
|
||||
|
@ -1291,7 +1291,9 @@ ControlGroupMovementObstructionFilter CCmpUnitMotion::GetObstructionFilter(bool
|
||||
else
|
||||
group = GetEntityId();
|
||||
|
||||
return ControlGroupMovementObstructionFilter(forceAvoidMovingUnits || ShouldAvoidMovingUnits(), group);
|
||||
// If an obstruction blocks tile-based pathfinding, it will be handled during the path computation
|
||||
// and doesn't need to be matched by this filter for the movement
|
||||
return ControlGroupMovementObstructionFilter(false, forceAvoidMovingUnits || ShouldAvoidMovingUnits(), group);
|
||||
}
|
||||
|
||||
|
||||
|
@ -333,12 +333,13 @@ public:
|
||||
*/
|
||||
class ControlGroupMovementObstructionFilter : public IObstructionTestFilter
|
||||
{
|
||||
bool m_AvoidPathfindingShapes;
|
||||
bool m_AvoidMoving;
|
||||
entity_id_t m_Group;
|
||||
|
||||
public:
|
||||
ControlGroupMovementObstructionFilter(bool avoidMoving, entity_id_t group) :
|
||||
m_AvoidMoving(avoidMoving), m_Group(group)
|
||||
ControlGroupMovementObstructionFilter(bool avoidPathfindingShapes, bool avoidMoving, entity_id_t group) :
|
||||
m_AvoidPathfindingShapes(avoidPathfindingShapes), m_AvoidMoving(avoidMoving), m_Group(group)
|
||||
{}
|
||||
|
||||
virtual bool TestShape(tag_t UNUSED(tag), flags_t flags, entity_id_t group, entity_id_t group2) const
|
||||
@ -346,10 +347,7 @@ public:
|
||||
if (group == m_Group || (group2 != INVALID_ENTITY && group2 == m_Group))
|
||||
return false;
|
||||
|
||||
// If an obstruction already blocks tile-based pathfinding,
|
||||
// it will be handled as part of the terrain passability handling
|
||||
// and doesn't need to be matched by this filter
|
||||
if (flags & ICmpObstructionManager::FLAG_BLOCK_PATHFINDING)
|
||||
if ((flags & ICmpObstructionManager::FLAG_BLOCK_PATHFINDING) && !m_AvoidPathfindingShapes)
|
||||
return false;
|
||||
|
||||
if (!(flags & ICmpObstructionManager::FLAG_BLOCK_MOVEMENT))
|
||||
|
Loading…
Reference in New Issue
Block a user