Ticket #3577: isInRange.patch
File isInRange.patch, 1020 bytes (added by , 9 years ago) |
---|
-
source/simulation2/components/CCmpUnitMotion.cpp
1717 1717 entity_pos_t circleDistance = (pos - CFixedVector2D(obstruction.x, obstruction.z)).Length() - circleRadius; 1718 1718 entity_pos_t previousCircleDistance = (pos - CFixedVector2D(previousObstruction.x, previousObstruction.z)).Length() - circleRadius; 1719 1719 1720 if (circleDistance <= maxRange || previousCircleDistance <= maxRange) 1721 return true; 1720 return circleDistance <= maxRange || previousCircleDistance <= maxRange; 1722 1721 } 1723 1722 1724 return false; 1723 // take minimal clearance required in MoveToTargetRange into account, multiplying by 3/2 for diagonals 1724 entity_pos_t maxDist = std::max(maxRange, (m_Clearance + entity_pos_t::FromInt(TERRAIN_TILE_SIZE)/16)*3/2); 1725 return distance <= maxDist || distance <= maxDist; 1725 1726 } 1726 1727 else 1727 1728 {