[][src]Trait myelin_engine::simulation::Simulation

pub trait Simulation: Debug {
    fn step(&mut self);
fn add_object(
        &mut self,
        object_description: ObjectDescription,
        object_behavior: Box<dyn ObjectBehavior>
    ) -> Object;
fn objects(&self) -> Snapshot;
fn set_simulated_timestep(&mut self, timestep: f64);
fn objects_in_area(&self, area: Aabb) -> Snapshot; }

A Simulation that can be filled with Object on which it will apply physical rules when calling step. This trait represents our API.

Required methods

fn step(&mut self)

Advance the simulation by one tick. This will apply forces to the objects, handle collisions and allow them to take action.

fn add_object(
    &mut self,
    object_description: ObjectDescription,
    object_behavior: Box<dyn ObjectBehavior>
) -> Object

Add a new object to the world.

fn objects(&self) -> Snapshot

Returns a read-only description of all objects currently inhabiting the simulation.

fn set_simulated_timestep(&mut self, timestep: f64)

Sets how much time in seconds is simulated for each step.

Examples

If you want to run a simulation with 60 steps per second, you can run set_simulated_timestep(1.0/60.0). Note that this method does not block the thread if called faster than expected.

fn objects_in_area(&self, area: Aabb) -> Snapshot

Returns read-only descriptions for all objects either completely contained or intersecting with the given area.

Loading content...

Implementors

impl Simulation for SimulationImpl[src]

Loading content...