mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Add tolerance to offset destination checks
The 0 tolerance to prevent the "waltzing" that was set before this cannot happen anymore as we now since check for being at destination before sending a move request in UnitAI. Adding a new small tolerance now prevents some small movement adjustments of formation members near their destination. Fixes #8592
This commit is contained in:
parent
8e15b9c000
commit
6cdbdae87c
1 changed files with 18 additions and 10 deletions
|
|
@ -1175,25 +1175,33 @@ bool CCmpUnitMotion::PossiblyAtDestination() const
|
|||
CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity());
|
||||
ENSURE(cmpObstructionManager);
|
||||
|
||||
if (m_MoveRequest.m_Type == MoveRequest::POINT)
|
||||
return cmpObstructionManager->IsInPointRange(GetEntityId(), m_MoveRequest.m_Position.X, m_MoveRequest.m_Position.Y, m_MoveRequest.m_MinRange, m_MoveRequest.m_MaxRange, false);
|
||||
if (m_MoveRequest.m_Type == MoveRequest::ENTITY)
|
||||
return cmpObstructionManager->IsInTargetRange(GetEntityId(), m_MoveRequest.m_Entity, m_MoveRequest.m_MinRange, m_MoveRequest.m_MaxRange, false);
|
||||
if (m_MoveRequest.m_Type == MoveRequest::OFFSET)
|
||||
switch (m_MoveRequest.m_Type)
|
||||
{
|
||||
case MoveRequest::POINT:
|
||||
return cmpObstructionManager->IsInPointRange(
|
||||
GetEntityId(), m_MoveRequest.m_Position.X, m_MoveRequest.m_Position.Y,
|
||||
m_MoveRequest.m_MinRange, m_MoveRequest.m_MaxRange, false);
|
||||
|
||||
case MoveRequest::ENTITY:
|
||||
return cmpObstructionManager->IsInTargetRange(
|
||||
GetEntityId(), m_MoveRequest.m_Entity,
|
||||
m_MoveRequest.m_MinRange, m_MoveRequest.m_MaxRange, false);
|
||||
|
||||
case MoveRequest::OFFSET:
|
||||
{
|
||||
CmpPtr<ICmpUnitMotion> cmpControllerMotion(GetSimContext(), m_MoveRequest.m_Entity);
|
||||
if (cmpControllerMotion && cmpControllerMotion->IsMoveRequested())
|
||||
return false;
|
||||
|
||||
// In formation, return a match only if we are exactly at the target position.
|
||||
// Otherwise, units can go in an infinite "walzting" loop when the Idle formation timer
|
||||
// reforms them.
|
||||
CFixedVector2D targetPos;
|
||||
ComputeTargetPosition(targetPos);
|
||||
CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle());
|
||||
return (targetPos-cmpPosition->GetPosition2D()).CompareLength(fixed::Zero()) <= 0;
|
||||
return (targetPos - cmpPosition->GetPosition2D()).CompareLength(Pathfinding::NAVCELL_SIZE) <= 0;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCmpUnitMotion::PerformMove(fixed dt, const fixed& turnRate, WaypointPath& shortPath, WaypointPath& longPath, CFixedVector2D& pos, fixed& speed, entity_angle_t& angle, uint8_t pushingPressure) const
|
||||
|
|
|
|||
Loading…
Reference in a new issue