Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3337 closed enhancement (fixed)

[PATCH] Improve the UnitMotion component to improve the pathfinder

Reported by: wraitii Owned by: Itms
Priority: Must Have Milestone: Alpha 19
Component: UI & Simulation Keywords: pathfinding
Cc: Patch:

Description (last modified by wraitii)

This is a general purpose ticket for issues with CcmpUnitMotion, which is somewhat dumb. This is the code that actually makes unit move, including calls to the pathfinding components. It handles a variety of logic and is linked with UnitAI in non-obvious ways.

The most important current issue is that units can get stuck if they need to go around a unit (units aren't counted in the long range pathfinder obstructions), and the short-range pathfinder can't find a path. The attached patch fixes the simpler cases by keeping the waypoints instead of scraping them (so units don't simply forget where they were going if there is an obstruction) and telling potential idle units to move away to clear the space in some cases. It seems to work fairly well, but some edge cases still happen where the units gets stuck. Needs some testing for the "trader route" case. I however believe it improves on the current situation and thus should be committed.

A better fix would probably rely on giving order through unitAI but that requires bigger and more complex changes to unitMotion.

Attachments (1)

PathFixTempr.diff (4.1 KB ) - added by wraitii 9 years ago.

Download all attachments as: .zip

Change History (6)

by wraitii, 9 years ago

Attachment: PathFixTempr.diff added

comment:1 by wraitii, 9 years ago

Description: modified (diff)

comment:2 by Stan, 9 years ago

Summary: Improve the UnitMotion component to improve the pathfinder[PATCH] Improve the UnitMotion component to improve the pathfinder

What is the current state of this patch ?

comment:3 by Itms, 9 years ago

Owner: set to Itms
Resolution: fixed
Status: newclosed

In 16998:

Based on previous experimental changes, major update to the unit motion.

With this change, units will not check their movement against all obstructions when moving: terrain and static obstructions are assumed to be handled by the long-range pathfinder.
However, when static obstructions are changed, the paths have to be invalidated. In order to minimize the performance impact, units will check for obstructions when they move after a passability change. If they collide with something, they will recompute a path that will take into account the new passability map.

Also includes some code cleanup. This patch should not change performance a lot: the lower number of checks should give a small performance improvement while using the message broadcasting system should hurt it a bit.

Fixes #3376, #3337, #1914.

comment:4 by Itms, 9 years ago

Keywords: pathfinder unitmotion removed

I committed a change that somehow covers the problem that patch addressed. I didn't use wraitii's patch though. The unit interaction provided by the formation system should be enough for now I think.

comment:5 by Itms, 9 years ago

In 17028:

Reenable formations and fix/improve the communication between UnitAI and UnitMotion. With the new pathfinder some path requests can be completed instantaneously, so UnitAI has to handle MoveStarted messages even in the IDLE state.

Please note that this commit makes #3410 really visible. Formation members might pass through buildings.

Refs #3410, #3337.

Note: See TracTickets for help on using tickets.