[][src]Trait myelin_engine::simulation::world::World

pub trait World: Debug {
    fn step(&mut self);
fn add_body(&mut self, body: PhysicalBody) -> BodyHandle;
fn remove_body(&mut self, body_handle: BodyHandle) -> Option<PhysicalBody>;
fn body(&self, handle: BodyHandle) -> Option<PhysicalBody>;
fn apply_force(
        &mut self,
        body_handle: BodyHandle,
        force: Force
    ) -> Option<()>;
fn set_simulated_timestep(&mut self, timestep: f64);
fn is_body_passable(&self, body_handle: BodyHandle) -> bool;
fn bodies_in_area(&self, area: Aabb) -> Vec<BodyHandle>; }

A container for PhysicalBodies that will apply physical laws to them on step

Required methods

fn step(&mut self)

Advance the simulation by one tick. This will apply forces to the objects and handle collisions;

fn add_body(&mut self, body: PhysicalBody) -> BodyHandle

Place a PhysicalBody in the world. Returns a unique BodyHandle that can be passed to body() in order to retrieve the PhysicalBody again

fn remove_body(&mut self, body_handle: BodyHandle) -> Option<PhysicalBody>

Removes a previously added PhysicalBody from the world. If body_handle was valid, this will return the removed physical body.

fn body(&self, handle: BodyHandle) -> Option<PhysicalBody>

Returns a PhysicalBody that has previously been placed with add_body() by its BodyHandle.

Errors

Returns None if the BodyHandle did not correspond to any PhysicalBody

fn apply_force(&mut self, body_handle: BodyHandle, force: Force) -> Option<()>

Register a force that will be applied to a body on the next step.

Errors

Returns None if body_handle did not match any sensors.

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 is_body_passable(&self, body_handle: BodyHandle) -> bool

Checks if the given BodyHandle is marked passable

fn bodies_in_area(&self, area: Aabb) -> Vec<BodyHandle>

Returns all bodies either completely contained or intersecting with the area.

Loading content...

Implementors

impl World for NphysicsWorld[src]

Loading content...