pub struct SoftBody {
pub builder: SoftBodyBuilder,
}Expand description
Describes a soft body to create.
The particle positions of Self::builder are expressed in the local frame of the entity (see
the module documentation for the conventions). Changes made to this component after
the soft body was created are ignored.
The collider-related components of the entity (crate::geometry::Friction,
crate::geometry::Restitution, crate::geometry::CollisionGroups,
crate::geometry::SolverGroups, crate::geometry::ActiveEvents,
crate::geometry::ActiveHooks, crate::geometry::ActiveCollisionTypes,
crate::geometry::ContactForceEventThreshold, crate::geometry::ContactSkin and
crate::geometry::Sensor) configure the soft body’s surface colliders (see
RapierRigidBodySet::soft_body_colliders), like for a Collider: they override the
builder’s collider template, their changes are applied, and removing them restores the
template’s values (the particle radius for the contact skin). The user_data of the builder
and of its collider template are overwritten with the entity bits.
Fields§
§builder: SoftBodyBuilderThe Rapier builder of the soft body, in the local frame of the entity.
Implementations§
Source§impl SoftBody
impl SoftBody
Sourcepub fn new(builder: SoftBodyBuilder) -> Self
pub fn new(builder: SoftBodyBuilder) -> Self
A soft body created from the given Rapier builder (positions in the entity’s local frame).
Sourcepub fn map(self, f: impl FnOnce(SoftBodyBuilder) -> SoftBodyBuilder) -> Self
pub fn map(self, f: impl FnOnce(SoftBodyBuilder) -> SoftBodyBuilder) -> Self
Applies f to the builder of this soft body.
This is useful to chain the builder’s methods, e.g.
SoftBody::rope(a, b, 20).map(|b| b.particle_mass(0.1).pinned_particles([0])).
Sourcepub fn rope(start: Vect, end: Vect, num_particles: usize) -> Self
pub fn rope(start: Vect, end: Vect, num_particles: usize) -> Self
A rope of num_particles particles from start to end (see SoftBodyBuilder::rope).
Sourcepub fn trimesh(vertices: Vec<Vect>, indices: Vec<[u32; 3]>) -> Option<Self>
pub fn trimesh(vertices: Vec<Vect>, indices: Vec<[u32; 3]>) -> Option<Self>
A triangle-mesh soft body without volumetric cells (see SoftBodyBuilder::trimesh).
Returns None if the mesh is empty.
Sourcepub fn volumetric(
vertices: &[Vect],
indices: &[[u32; 2]],
cell_size: Real,
) -> Option<Self>
pub fn volumetric( vertices: &[Vect], indices: &[[u32; 2]], cell_size: Real, ) -> Option<Self>
A volumetric soft body filling a closed, outward-oriented mesh (triangles in 3D, segments
in 2D) with cells of size cell_size (see SoftBodyBuilder::volumetric).
Returns None if the mesh is empty, open, or encloses nothing at that cell size.
Sourcepub fn volumetric_skinned(
vertices: &[Vect],
indices: &[[u32; 2]],
cell_size: Real,
) -> Option<Self>
pub fn volumetric_skinned( vertices: &[Vect], indices: &[[u32; 2]], cell_size: Real, ) -> Option<Self>
Same as Self::volumetric, keeping the given polyline as the soft body’s skin (see
SoftBodyBuilder::volumetric_skinned).
Sourcepub fn polygon(points: Vec<Vect>) -> Self
pub fn polygon(points: Vec<Vect>) -> Self
A closed polygon with counter-clockwise points, with area preservation (see
SoftBodyBuilder::polygon).
Sourcepub fn disk(radius: Real, num_particles: usize) -> Self
pub fn disk(radius: Real, num_particles: usize) -> Self
A regular polygon centered at the entity’s origin with num_particles boundary particles
(see SoftBodyBuilder::disk).
Trait Implementations§
Source§impl Component for SoftBody
impl Component for SoftBody
Source§const STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreSource§const HAS_SUMMARY_TICK: bool = false
const HAS_SUMMARY_TICK: bool = false
Source§impl From<SoftBodyBuilder> for SoftBody
impl From<SoftBodyBuilder> for SoftBody
Source§fn from(builder: SoftBodyBuilder) -> Self
fn from(builder: SoftBodyBuilder) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for SoftBody
impl !UnwindSafe for SoftBody
impl Freeze for SoftBody
impl Send for SoftBody
impl Sync for SoftBody
impl Unpin for SoftBody
impl UnsafeUnpin for SoftBody
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.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
Source§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§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>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§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.Source§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.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
Source§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Source§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
impl<T> MaybeSync for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Settings for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
self.