Skip to main content

RoutePlanner

Struct RoutePlanner 

Source
pub struct RoutePlanner<W> { /* private fields */ }
Expand description

Per-agent route storage and movement controller.

Stores planned routes for agents (keyed by AgentId = u64) and provides move_along_route functions that advance agents along their planned paths at a given speed.

The generic parameter W is the waypoint type (e.g. (f64, f64) or (f64, f64, f64)).

Implementations§

Source§

impl<W> RoutePlanner<W>

Source

pub fn new() -> Self

Create a new empty route planner.

Source

pub fn set_route(&mut self, agent_id: u64, waypoints: Vec<W>)

Set a planned route for an agent, replacing any existing route.

Source

pub fn has_route(&self, agent_id: u64) -> bool

Check whether an agent has a non-empty route.

Source

pub fn is_stationary(&self, agent_id: u64) -> bool

Check whether an agent is stationary (has no route or route is empty).

Source

pub fn route(&self, agent_id: u64) -> Option<&VecDeque<W>>

Get the remaining waypoints for an agent (read-only).

Source

pub fn clear_route(&mut self, agent_id: u64)

Remove all route data for an agent.

Source

pub fn clear_all(&mut self)

Remove all route data for all agents.

Source

pub fn len(&self) -> usize

Number of agents with stored routes.

Source

pub fn is_empty(&self) -> bool

Whether no agents have stored routes.

Source§

impl RoutePlanner<(f64, f64)>

Source

pub fn move_along_route_2d( &mut self, agent_id: u64, current_pos: (f64, f64), speed: f64, dt: f64, periodic: bool, extent_x: f64, extent_y: f64, ) -> MoveResult2D

Move an agent one step along its 2D route at the given speed and timestep dt.

The agent moves from current_pos toward the next waypoint. If it overshoots a waypoint, it continues toward the next one with the remaining distance budget (mirrors Agents.jl move_along_route!).

Returns the new position and whether the route is now complete. If the agent has no route, returns current_pos unchanged.

When periodic is true, movement wraps around [0, extent_x) x [0, extent_y).

Source

pub fn plan_from_path(&mut self, agent_id: u64, waypoints: Vec<(f64, f64)>)

Plan a route from a continuous A* path and store it.

Convenience method: accepts the waypoints from ContinuousPath.

Source§

impl RoutePlanner<(f64, f64, f64)>

Source

pub fn move_along_route_3d( &mut self, agent_id: u64, current_pos: (f64, f64, f64), speed: f64, dt: f64, periodic: bool, extent_x: f64, extent_y: f64, extent_z: f64, ) -> MoveResult3D

Move an agent one step along its 3D route at the given speed and timestep dt.

Same semantics as move_along_route_2d but in 3D.

Source

pub fn plan_from_path(&mut self, agent_id: u64, waypoints: Vec<(f64, f64, f64)>)

Plan a route from a 3D continuous A* path.

Source§

impl RoutePlanner<(usize, usize)>

Grid (integer) route planner for (usize, usize) waypoints.

Source

pub fn next_waypoint(&mut self, agent_id: u64) -> Option<(usize, usize)>

Pop and return the next grid waypoint for an agent.

This is the grid equivalent of move_along_route! – each call advances one step (one cell) along the planned path. Returns None if the agent has no remaining waypoints.

Trait Implementations§

Source§

impl<W: Clone> Clone for RoutePlanner<W>

Source§

fn clone(&self) -> RoutePlanner<W>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<W: Debug> Debug for RoutePlanner<W>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<W> Default for RoutePlanner<W>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<W> Freeze for RoutePlanner<W>

§

impl<W> RefUnwindSafe for RoutePlanner<W>
where W: RefUnwindSafe,

§

impl<W> Send for RoutePlanner<W>
where W: Send,

§

impl<W> Sync for RoutePlanner<W>
where W: Sync,

§

impl<W> Unpin for RoutePlanner<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for RoutePlanner<W>

§

impl<W> UnwindSafe for RoutePlanner<W>
where W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V