Struct let_engine::objects::scenes::Layer
source · pub struct Layer { /* private fields */ }
Expand description
A layer struct holding it’s own object hierarchy, camera and physics iteration.
Implementations§
source§impl Layer
impl Layer
sourcepub fn set_camera(&self, camera: &Object) -> Result<(), ObjectError>
pub fn set_camera(&self, camera: &Object) -> Result<(), ObjectError>
Sets the camera of this layer.
sourcepub fn camera_scaling(&self) -> CameraScaling
pub fn camera_scaling(&self) -> CameraScaling
Returns the scaling of the camera settings.
pub fn set_zoom(&self, zoom: f32)
sourcepub fn set_camera_settings(&self, settings: CameraSettings)
pub fn set_camera_settings(&self, settings: CameraSettings)
Sets the camera settings.
sourcepub fn camera_settings(&self) -> CameraSettings
pub fn camera_settings(&self) -> CameraSettings
Gets the camera settins.
sourcepub fn side_to_world(&self, direction: Vec2, dimensions: Vec2) -> Vec2
pub fn side_to_world(&self, direction: Vec2, dimensions: Vec2) -> Vec2
Returns the position of a given side with given window dimensions to world space.
x -1.0 to 1.0 for left to right
y -1.0 to 1.0 for up to down
sourcepub fn contains_object(&self, object_id: &usize) -> bool
pub fn contains_object(&self, object_id: &usize) -> bool
Checks if the layer contains this object.
sourcepub fn move_to(&self, object: &Object, index: usize) -> Result<(), ObjectError>
pub fn move_to(&self, object: &Object, index: usize) -> Result<(), ObjectError>
Moves an object on the given index in it’s parents children order.
Returns
sourcepub fn move_up(&self, object: &Object) -> Result<(), ObjectError>
pub fn move_up(&self, object: &Object) -> Result<(), ObjectError>
Moves an object one up in it’s parents children order.
sourcepub fn move_down(&self, object: &Object) -> Result<(), ObjectError>
pub fn move_down(&self, object: &Object) -> Result<(), ObjectError>
Moves an object one down in it’s parents children order.
sourcepub fn move_to_top(&self, object: &Object) -> Result<(), ObjectError>
pub fn move_to_top(&self, object: &Object) -> Result<(), ObjectError>
Moves an object all the way to the top of it’s parents children list.
sourcepub fn move_to_bottom(&self, object: &Object) -> Result<(), ObjectError>
pub fn move_to_bottom(&self, object: &Object) -> Result<(), ObjectError>
Moves an object all the way to the bottom of it’s parents children list.
pub fn children_count(&self, parent: &Object) -> Result<usize, ObjectError>
source§impl Layer
impl Layer
Physics
sourcepub fn query_nearest_collider_at(&self, position: Vec2) -> Option<usize>
pub fn query_nearest_collider_at(&self, position: Vec2) -> Option<usize>
Returns the nearest collider id from a specific location.
sourcepub fn cast_ray(
&self,
position: Vec2,
direction: Vec2,
time_of_impact: Real,
solid: bool
) -> Option<usize>
pub fn cast_ray( &self, position: Vec2, direction: Vec2, time_of_impact: Real, solid: bool ) -> Option<usize>
Returns id of the first collider intersecting with given ray.
sourcepub fn cast_ray_and_get_normal(
&self,
position: Vec2,
direction: Vec2,
time_of_impact: Real,
solid: bool
) -> Option<(usize, Vec2)>
pub fn cast_ray_and_get_normal( &self, position: Vec2, direction: Vec2, time_of_impact: Real, solid: bool ) -> Option<(usize, Vec2)>
Returns id of the first collider intersecting with given ray and returns a normal.
sourcepub fn intersections_with_ray(
&self,
position: Vec2,
direction: Vec2,
time_of_impact: Real,
solid: bool
) -> Vec<usize>
pub fn intersections_with_ray( &self, position: Vec2, direction: Vec2, time_of_impact: Real, solid: bool ) -> Vec<usize>
Returns id of the first collider intersecting with given ray.
sourcepub fn intersection_with_shape(
&self,
shape: Shape,
position: (Vec2, f32)
) -> Option<usize>
pub fn intersection_with_shape( &self, shape: Shape, position: (Vec2, f32) ) -> Option<usize>
Cast a shape and return the first collider intersecting with it.
sourcepub fn intersections_with_shape(
&self,
shape: Shape,
position: (Vec2, f32)
) -> Vec<usize>
pub fn intersections_with_shape( &self, shape: Shape, position: (Vec2, f32) ) -> Vec<usize>
Cast a shape and return the first collider intersecting with it.
sourcepub fn set_gravity(&self, gravity: Vec2)
pub fn set_gravity(&self, gravity: Vec2)
Sets the gravity parameter.
sourcepub fn physics_enabled(&self) -> bool
pub fn physics_enabled(&self) -> bool
Returns if physics is enabled.
sourcepub fn set_physics_enabled(&self, enabled: bool)
pub fn set_physics_enabled(&self, enabled: bool)
Set physics to be enabled or disabled.
sourcepub fn physics_parameters(&self) -> IntegrationParameters
pub fn physics_parameters(&self) -> IntegrationParameters
Takes the physics simulation parameters.
sourcepub fn set_physics_parameters(&self, parameters: IntegrationParameters)
pub fn set_physics_parameters(&self, parameters: IntegrationParameters)
Sets the physics simulation parameters.
sourcepub fn add_joint(
&self,
object1: &Object,
object2: &Object,
data: impl Into<GenericJoint>,
wake_up: bool
) -> Result<ImpulseJointHandle, NoRigidBodyError>
pub fn add_joint( &self, object1: &Object, object2: &Object, data: impl Into<GenericJoint>, wake_up: bool ) -> Result<ImpulseJointHandle, NoRigidBodyError>
Adds a joint between object 1 and 2.
sourcepub fn joint(&self, handle: ImpulseJointHandle) -> Option<GenericJoint>
pub fn joint(&self, handle: ImpulseJointHandle) -> Option<GenericJoint>
Returns if the joint exists.
sourcepub fn set_joint(
&self,
data: impl Into<GenericJoint>,
handle: ImpulseJointHandle
) -> Result<(), NoJointError>
pub fn set_joint( &self, data: impl Into<GenericJoint>, handle: ImpulseJointHandle ) -> Result<(), NoJointError>
Updates a joint.
sourcepub fn remove_joint(&self, handle: ImpulseJointHandle, wake_up: bool)
pub fn remove_joint(&self, handle: ImpulseJointHandle, wake_up: bool)
Removes a joint.
Trait Implementations§
source§impl PartialEq for Layer
impl PartialEq for Layer
impl Eq for Layer
Auto Trait Implementations§
impl !RefUnwindSafe for Layer
impl Send for Layer
impl Sync for Layer
impl Unpin for Layer
impl !UnwindSafe for Layer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.