Skip to main content

BoidsFlockSolver

Struct BoidsFlockSolver 

Source
pub struct BoidsFlockSolver { /* private fields */ }
Expand description

Reusable 3D Reynolds Steering and Flocking solver accelerated by SpatialHashGrid3D.

Implementations§

Source§

impl BoidsFlockSolver

Composable Reynolds steering behaviors and SpatialHashGrid3D-accelerated flocking for BoidsFlockSolver.

Source

pub fn new(config: BoidsConfig, seed: u64) -> Self

Creates a new BoidsFlockSolver seeded deterministically for wander behaviors.

§Arguments
  • BoidsConfig - Neighborhood radii and steering force weights.
  • u64 - Deterministic PRNG seed.
§Returns
  • Self - Ready flock solver with pre-allocated SpatialHashGrid3D.
Source

pub fn add_agent(&mut self, agent: BoidsAgent3D) -> usize

Adds a boid agent to the flock and returns its index.

§Arguments
  • BoidsAgent3D - Agent state to add.
§Returns
  • usize - Index of the registered agent.
Source

pub fn add_obstacle(&mut self, obstacle: BoidsObstacle3D)

Registers a spherical obstacle avoided by all boids in the flock.

§Arguments
  • BoidsObstacle3D - Spherical obstacle descriptor.
Source

pub fn set_goal(&mut self, goal: Option<Vec3>)

Sets or clears the optional shared target point that attracts the flock.

§Arguments
  • Option<Vec3> - Optional 3D target coordinates.
Source

pub fn steer_seek( position: Vec3, velocity: Vec3, target: Vec3, max_speed: f32, max_force: f32, ) -> Vec3

Computes Reynolds Seek steering force toward target.

§Arguments
  • Vec3 - Agent position.
  • Vec3 - Agent current velocity.
  • Vec3 - Target position.
  • f32 - Maximum speed.
  • f32 - Maximum steering force.
§Returns
  • Vec3 - Clamped steering force vector.
Source

pub fn steer_flee( position: Vec3, velocity: Vec3, threat: Vec3, max_speed: f32, max_force: f32, ) -> Vec3

Computes Reynolds Flee steering force directly away from threat.

§Arguments
  • Vec3 - Agent position.
  • Vec3 - Agent current velocity.
  • Vec3 - Threat position.
  • f32 - Maximum speed.
  • f32 - Maximum steering force.
§Returns
  • Vec3 - Clamped repulsion force vector.
Source

pub fn steer_arrive( position: Vec3, velocity: Vec3, target: Vec3, slowing_radius: f32, max_speed: f32, max_force: f32, ) -> Vec3

Computes Reynolds Arrive steering force decelerating smoothly inside slowing_radius.

§Arguments
  • Vec3 - Agent position.
  • Vec3 - Agent current velocity.
  • Vec3 - Destination target position.
  • f32 - Deceleration radius around target.
  • f32 - Maximum speed.
  • f32 - Maximum steering force.
§Returns
  • Vec3 - Clamped arrival steering force.
Source

pub fn steer_pursue( position: Vec3, velocity: Vec3, target_pos: Vec3, target_vel: Vec3, max_speed: f32, max_force: f32, ) -> Vec3

Computes predictive Reynolds Pursue steering force anticipating a moving quarry.

§Arguments
  • Vec3 - Pursuer position.
  • Vec3 - Pursuer velocity.
  • Vec3 - Quarry position.
  • Vec3 - Quarry velocity.
  • f32 - Maximum speed.
  • f32 - Maximum steering force.
§Returns
  • Vec3 - Clamped pursuit steering force.
Source

pub fn steer_evade( position: Vec3, velocity: Vec3, threat_pos: Vec3, threat_vel: Vec3, max_speed: f32, max_force: f32, ) -> Vec3

Computes predictive Reynolds Evade steering force escaping a moving pursuer.

§Arguments
  • Vec3 - Evader position.
  • Vec3 - Evader velocity.
  • Vec3 - Threat position.
  • Vec3 - Threat velocity.
  • f32 - Maximum speed.
  • f32 - Maximum steering force.
§Returns
  • Vec3 - Clamped evasion steering force.
Source

pub fn steer_wander( velocity: Vec3, wander_angle: f32, params: BoidsWanderParams, rng: &mut DeterministicRng, max_speed: f32, max_force: f32, ) -> (Vec3, f32)

Computes continuous Reynolds Wander steering force and updated wander angle.

§Arguments
  • Vec3 - Current velocity vector.
  • f32 - Current wander phase angle in radians.
  • BoidsWanderParams - Wander circle distance, radius, and angular jitter parameters.
  • &mut DeterministicRng - Deterministic PRNG.
  • f32 - Maximum speed.
  • f32 - Maximum steering force.
§Returns
  • (Vec3, f32) - (steering_force, updated_wander_angle).
Source

pub fn step(&mut self, dt: f32)

Advances the entire flock by dt using SpatialHashGrid3D neighbor queries with zero steady-state allocations.

§Arguments
  • f32 - Simulation time step in seconds.
Source§

impl BoidsFlockSolver

Implements impl #impl_generics #name #ty_generics #where_clause.

Source

pub fn get_config(&self) -> BoidsConfig

Source

pub fn get_mut_config(&mut self) -> &mut BoidsConfig

Source

pub fn set_config(&mut self, val: BoidsConfig) -> &mut Self

Source

pub fn get_agents(&self) -> &Vec<BoidsAgent3D>

Source

pub fn get_mut_agents(&mut self) -> &mut Vec<BoidsAgent3D>

Source

pub fn set_agents(&mut self, val: Vec<BoidsAgent3D>) -> &mut Self

Source

pub fn get_obstacles(&self) -> &Vec<BoidsObstacle3D>

Source

pub fn get_mut_obstacles(&mut self) -> &mut Vec<BoidsObstacle3D>

Source

pub fn set_obstacles(&mut self, val: Vec<BoidsObstacle3D>) -> &mut Self

Source

pub fn get_goal_target(&self) -> Vec3

Source

pub fn get_mut_goal_target(&mut self) -> &mut Vec3

Source

pub fn set_goal_target(&mut self, val: Vec3) -> &mut Self

Source

pub fn get_has_goal(&self) -> bool

Source

pub fn get_mut_has_goal(&mut self) -> &mut bool

Source

pub fn set_has_goal(&mut self, val: bool) -> &mut Self

Source

pub fn get_rng(&self) -> DeterministicRng

Source

pub fn get_mut_rng(&mut self) -> &mut DeterministicRng

Source

pub fn set_rng(&mut self, val: DeterministicRng) -> &mut Self

Trait Implementations§

Source§

impl Clone for BoidsFlockSolver

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BoidsFlockSolver

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.