pub struct Agent {
pub position: Vec3,
pub velocity: Vec3,
pub radius: f32,
pub avoidance_responsibility: f32,
}Expand description
A single agent in the simulation.
Fields§
§position: Vec3The position of the agent.
velocity: Vec3The current velocity of the agent.
radius: f32The radius of the agent. Agents will use this to avoid bumping into each other.
avoidance_responsibility: f32The amount of responsibility an agent has to avoid other agents. The amount of avoidance between two agents is then dependent on the ratio of the responsibility between the agents. Note this does not affect avoidance of obstacles.
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn compute_avoiding_velocity(
&self,
neighbours: &[Cow<'_, Agent>],
preferred_velocity: Vec3,
max_speed: f32,
time_step: f32,
avoidance_options: &AvoidanceOptions,
) -> Vec3
pub fn compute_avoiding_velocity( &self, neighbours: &[Cow<'_, Agent>], preferred_velocity: Vec3, max_speed: f32, time_step: f32, avoidance_options: &AvoidanceOptions, ) -> Vec3
Computes a velocity based off the agent’s preferred velocity (usually the
direction to its current goal/waypoint). This new velocity is intended to
avoid running into the agent’s neighbours. This is not always possible,
but agents will attempt to resolve any collisions in a reasonable fashion.
The max_speed is the maximum magnitude of the returned velocity. Even if
the preferred_velocity is larger than max_speed, the resulting vector
will be at most max_speed in length. The time_step helps determine the
velocity in cases of existing collisions, and must be positive.