Struct JobDestinationReached Extends IJob
Calculates if the agent has reached the end of its path and if its blocked from further progress towards it.
If many agents have the same destination they can often end up crowded around a single point. It is often desirable to detect this and mark all agents around that destination as having at least partially reached the end of their paths.
This job uses the following heuristics to determine this:
1. If an agent wants to move in a particular direction, but there's another agent in the way that makes it have to reduce its velocity, the other agent is considered to be "blocking" the current agent. 2. If the agent is within a small distance of the destination THEN it is considered to have reached the end of its path. 3. If the agent is blocked by another agent, AND the other agent is blocked by this agent in turn, AND if the destination is between the two agents, THEN the the agent is considered to have reached the end of its path. 4. If the agent is blocked by another agent which has reached the end of its path, AND this agent is is moving slowly AND this agent cannot move furter forward than 50% of its radius. THEN the agent is considered to have reached the end of its path.
Heuristics 2 and 3 are calculated initially, and then using heuristic 4 the set of agents which have reached their destinations expands outwards.
These heuristics are robust enough that they can be used even if for example the agents are stuck in a winding maze and only one agent is actually able to reach the destination.
This job doesn't affect the movement of the agents by itself. However, it is built with the intention that the FlowFollowingStrength parameter will be set elsewhere to 1 for agents which have reached the end of their paths. This will make the agents stop gracefully when the end of their paths is crowded instead of continuing to try to desperately reach the destination.