NextFrameSetupSystem

Struct NextFrameSetupSystem 

Source
pub struct NextFrameSetupSystem<P, R, I, A, T, D> { /* private fields */ }
Expand description

Setup the next frames positions and velocities.

§Type parameters:

  • P: Positional quantity, usually Point2 or Point3
  • R: Rotational quantity, usually Basis2 or Quaternion
  • I: Inertia, usually Scalar or Matrix3
  • A: Angular velocity, usually Scalar or Vector3
  • T: Transform type (BodyPose2 or similar)

§System function

fn(DeltaTime, Mass, T, ForceAccumulator) -> (ForceAccumulator, NextFrame<Velocity>, NextFrame<T>)

Implementations§

Source§

impl<P, R, I, A, T, D> NextFrameSetupSystem<P, R, I, A, T, D>
where T: Pose<P, R>, P: EuclideanSpace, P::Scalar: BaseFloat, P::Diff: VectorSpace + InnerSpace + Debug, R: Rotation<P> + ApplyAngular<P::Scalar, A>, I: Inertia<Orientation = R> + Mul<A, Output = A>, A: Mul<P::Scalar, Output = A> + Zero + Clone + Copy, D: PhysicsTime<P::Scalar> + Default,

Source

pub fn new() -> Self

Create system.

Examples found in repository?
examples/spatial3d.rs (line 42)
35pub fn main() {
36    let mut world = World::new();
37    let mut sort = SpatialSortingSystem3::<f32, BodyPose3<f32>, ()>::new();
38    let mut collide =
39        SpatialCollisionSystem3::<f32, BodyPose3<f32>, ()>::new().with_narrow_phase(GJK3::new());
40    let mut raycast = RayCastSystem;
41    let mut impulse_solver = CurrentFrameUpdateSystem3::<f32, BodyPose3<f32>>::new();
42    let mut next_frame = NextFrameSetupSystem3::<f32, BodyPose3<f32>>::new();
43    let mut contact_resolution = ContactResolutionSystem3::<f32, BodyPose3<f32>>::new();
44
45    sort.setup(&mut world.res);
46    collide.setup(&mut world.res);
47    raycast.setup(&mut world.res);
48    impulse_solver.setup(&mut world.res);
49    next_frame.setup(&mut world.res);
50    contact_resolution.setup(&mut world.res);
51
52    world
53        .create_entity()
54        .with_static_physical_entity(
55            CollisionShape3::<f32, BodyPose3<f32>, ()>::new_simple(
56                CollisionStrategy::FullResolution,
57                CollisionMode::Discrete,
58                Cuboid::new(10., 10., 10.).into(),
59            ),
60            BodyPose3::one(),
61            PhysicalEntity::default(),
62            Mass3::new(1.),
63        ).build();
64
65    world
66        .create_entity()
67        .with_static_physical_entity(
68            CollisionShape3::<f32, BodyPose3<f32>, ()>::new_simple(
69                CollisionStrategy::FullResolution,
70                CollisionMode::Discrete,
71                Cuboid::new(10., 10., 10.).into(),
72            ),
73            BodyPose3::new(Point3::new(3., 2., 0.), Quaternion::from_angle_z(Rad(0.))),
74            PhysicalEntity::default(),
75            Mass3::new(1.),
76        ).build();
77
78    let mut reader_1 = world
79        .write_resource::<EventChannel<ContactEvent3<f32>>>()
80        .register_reader();
81    {
82        use specs::prelude::RunNow;
83        sort.run_now(&world.res);
84        collide.run_now(&world.res);
85        println!(
86            "Contacts: {:?}",
87            world
88                .read_resource::<EventChannel<ContactEvent3<f32>>>()
89                .read(&mut reader_1)
90                .collect::<Vec<_>>()
91        );
92        raycast.run_now(&world.res);
93
94        impulse_solver.run_now(&world.res);
95        next_frame.run_now(&world.res);
96        contact_resolution.run_now(&world.res);
97    }
98}
More examples
Hide additional examples
examples/spatial2d.rs (line 43)
36pub fn main() {
37    let mut world = World::new();
38    let mut sort = SpatialSortingSystem2::<f32, BodyPose2<f32>, ()>::new();
39    let mut collide =
40        SpatialCollisionSystem2::<f32, BodyPose2<f32>, ()>::new().with_narrow_phase(GJK2::new());
41    let mut raycast = RayCastSystem;
42    let mut impulse_solver = CurrentFrameUpdateSystem2::<f32, BodyPose2<f32>>::new();
43    let mut next_frame = NextFrameSetupSystem2::<f32, BodyPose2<f32>>::new();
44    let mut contact_resolution = ContactResolutionSystem2::<f32, BodyPose2<f32>>::new();
45
46    sort.setup(&mut world.res);
47    collide.setup(&mut world.res);
48    raycast.setup(&mut world.res);
49    impulse_solver.setup(&mut world.res);
50    next_frame.setup(&mut world.res);
51    contact_resolution.setup(&mut world.res);
52
53    world
54        .create_entity()
55        .with_static_physical_entity(
56            CollisionShape2::<f32, BodyPose2<f32>, ()>::new_simple(
57                CollisionStrategy::FullResolution,
58                CollisionMode::Discrete,
59                Rectangle::new(10., 10.).into(),
60            ),
61            BodyPose2::<f32>::one(),
62            PhysicalEntity::default(),
63            Mass2::new(1.),
64        ).build();
65
66    world
67        .create_entity()
68        .with_static_physical_entity(
69            CollisionShape2::<f32, BodyPose2<f32>, ()>::new_simple(
70                CollisionStrategy::FullResolution,
71                CollisionMode::Discrete,
72                Rectangle::new(10., 10.).into(),
73            ),
74            BodyPose2::<f32>::new(Point2::new(2., 2.), Rotation2::from_angle(Rad(0.))),
75            PhysicalEntity::default(),
76            Mass2::new(1.),
77        ).build();
78
79    let mut reader_1 = world
80        .write_resource::<EventChannel<ContactEvent2<f32>>>()
81        .register_reader();
82
83    {
84        use specs::prelude::RunNow;
85        sort.run_now(&world.res);
86        collide.run_now(&world.res);
87
88        println!(
89            "Contacts: {:?}",
90            world
91                .read_resource::<EventChannel<ContactEvent2<f32>>>()
92                .read(&mut reader_1)
93                .collect::<Vec<_>>()
94        );
95
96        raycast.run_now(&world.res);
97        impulse_solver.run_now(&world.res);
98        next_frame.run_now(&world.res);
99        contact_resolution.run_now(&world.res);
100    }
101}

Trait Implementations§

Source§

impl<'a, P, R, I, A, T, D> System<'a> for NextFrameSetupSystem<P, R, I, A, T, D>
where T: Pose<P, R> + Component + Send + Sync + 'static, P: EuclideanSpace + Send + Sync + 'static, P::Scalar: BaseFloat + Send + Sync + 'static, P::Diff: VectorSpace + InnerSpace + Debug + Send + Sync + 'static, R: Rotation<P> + ApplyAngular<P::Scalar, A> + Send + Sync + 'static, I: Inertia<Orientation = R> + Mul<A, Output = A> + Send + Sync + 'static, A: Mul<P::Scalar, Output = A> + Zero + Clone + Copy + Send + Sync + 'static, D: PhysicsTime<P::Scalar> + Default + Send + Sync + 'static,

Source§

type SystemData = (Read<'a, D>, Read<'a, WorldParameters<<P as EuclideanSpace>::Diff, <P as EuclideanSpace>::Scalar>>, Storage<'a, PhysicalEntity<<P as EuclideanSpace>::Scalar>, Fetch<'a, MaskedStorage<PhysicalEntity<<P as EuclideanSpace>::Scalar>>>>, Storage<'a, Mass<<P as EuclideanSpace>::Scalar, I>, Fetch<'a, MaskedStorage<Mass<<P as EuclideanSpace>::Scalar, I>>>>, Storage<'a, NextFrame<Velocity<<P as EuclideanSpace>::Diff, A>>, FetchMut<'a, MaskedStorage<NextFrame<Velocity<<P as EuclideanSpace>::Diff, A>>>>>, Storage<'a, T, Fetch<'a, MaskedStorage<T>>>, Storage<'a, NextFrame<T>, FetchMut<'a, MaskedStorage<NextFrame<T>>>>, Storage<'a, ForceAccumulator<<P as EuclideanSpace>::Diff, A>, FetchMut<'a, MaskedStorage<ForceAccumulator<<P as EuclideanSpace>::Diff, A>>>>)

The resource bundle required to execute this system. Read more
Source§

fn run(&mut self, data: Self::SystemData)

Executes the system with the required system data.
Source§

fn running_time(&self) -> RunningTime

Returns a hint how long the system needs for running. This is used to optimize the way they’re executed (might allow more parallelization). Read more
Source§

fn accessor<'b>(&'b self) -> AccessorCow<'a, 'b, Self>

Return the accessor from the SystemData.
Source§

fn setup(&mut self, res: &mut Resources)

Sets up the Resources using Self::SystemData::setup.
Source§

fn dispose(self, res: &mut Resources)
where Self: Sized,

Performs clean up that requires resources from the Resources. Read more

Auto Trait Implementations§

§

impl<P, R, I, A, T, D> Freeze for NextFrameSetupSystem<P, R, I, A, T, D>

§

impl<P, R, I, A, T, D> RefUnwindSafe for NextFrameSetupSystem<P, R, I, A, T, D>

§

impl<P, R, I, A, T, D> Send for NextFrameSetupSystem<P, R, I, A, T, D>
where P: Send, R: Send, I: Send, A: Send, T: Send, D: Send,

§

impl<P, R, I, A, T, D> Sync for NextFrameSetupSystem<P, R, I, A, T, D>
where P: Sync, R: Sync, I: Sync, A: Sync, T: Sync, D: Sync,

§

impl<P, R, I, A, T, D> Unpin for NextFrameSetupSystem<P, R, I, A, T, D>
where P: Unpin, R: Unpin, I: Unpin, A: Unpin, T: Unpin, D: Unpin,

§

impl<P, R, I, A, T, D> UnwindSafe for NextFrameSetupSystem<P, R, I, A, T, D>

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> Any for T
where T: Any,

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<'a, T> RunNow<'a> for T
where T: System<'a>,

Source§

fn run_now(&mut self, res: &'a Resources)

Runs the system now. Read more
Source§

fn setup(&mut self, res: &mut Resources)

Sets up Resources for a later call to run_now.
Source§

fn dispose(self: Box<T>, res: &mut Resources)

Performs clean up that requires resources from the Resources. Read more
Source§

impl<'a, T> RunWithPool<'a> for T
where T: System<'a>,

Source§

fn setup(&mut self, res: &mut Resources)

Sets up Resources for a later call to run.
Source§

fn run(&mut self, res: &'a Resources, _: &ThreadPool)

Runs the system/group of systems. Possibly in parallel depending on how the structure is set up. Read more
Source§

fn reads(&self, reads: &mut Vec<ResourceId>)

Accumulates the necessary read/shared resources from the systems in this group.
Source§

fn writes(&self, writes: &mut Vec<ResourceId>)

Accumulates the necessary write/exclusive resources from the systems in this group.
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<T> Erased for T

Source§

impl<T> Event for T
where T: Send + Sync + 'static,

Source§

impl<T> Resource for T
where T: Any + Send + Sync,