Skip to main content

PressureModifier

Struct PressureModifier 

Source
pub struct PressureModifier {
    pub config: PressureConfig,
    pub pressure: ScalarField3D,
    pub deformation: ScalarField3D,
    pub enabled: bool,
}
Expand description

Pressure-driven SDF deformation

Fields§

§config: PressureConfig

Configuration

§pressure: ScalarField3D

Current pressure field (transient)

§deformation: ScalarField3D

Accumulated permanent deformation (positive = surface pushed inward)

§enabled: bool

Whether modifier is enabled

Implementations§

Source§

impl PressureModifier

Source

pub fn new( config: PressureConfig, resolution: usize, min: (f32, f32, f32), max: (f32, f32, f32), ) -> Self

Create a new pressure modifier

resolution is clamped to a minimum of 1: ScalarField3D computes its cell size from resolution - 1 and clamps grid reads to resolution - 1, both of which underflow usize for a resolution of 0. Clamping here keeps that invariant instead of deferring a panic to the first call to Self::pressure_at / Self::deformation_at.

Source

pub fn apply_pressure_at( &mut self, x: f32, y: f32, z: f32, force: f32, radius: f32, )

Apply pressure at a point (e.g., from collision contact)

force = contact force magnitude, radius = contact patch radius

Source

pub fn apply_impact( &mut self, x: f32, y: f32, z: f32, impulse: f32, radius: f32, )

Apply impact at a point (immediate dent)

impulse = impact impulse, radius = impact area

Source

pub fn pressure_at(&self, x: f32, y: f32, z: f32) -> f32

Get pressure at a point

Source

pub fn deformation_at(&self, x: f32, y: f32, z: f32) -> f32

Get deformation at a point

Source§

impl PressureModifier

Source

pub const PARTICIPANT_KIND: ParticipantKind

Snapshot tag of this type as a world participant: "PRES", the four ASCII bytes read big endian. Never changes.

Trait Implementations§

Source§

impl Participant for PressureModifier

One update(h) per world substep (h converted with Fix128::to_f32); see the module documentation of crate::sim_modifier for the payload and what is not coupled yet.

Observations: channel 0 the highest cell pressure (absent for a grid without cells), channel 1 the total permanent deformation.

Source§

fn kind(&self) -> ParticipantKind

Snapshot tag of this participant type.
Source§

fn substep( &mut self, _ctx: &mut SubstepCtx<'_>, h: Fix128, ) -> Result<(), ParticipantFault>

Advance by one world substep of width h (ctx.h()). Read bodies from ctx, stage forces on them through ctx. Read more
Source§

fn observe(&self, out: &mut ObservationSink)

Report observable values. The world reports them as Observed::Undecided while a fault is recorded.
Source§

fn write_state(&self, out: &mut Vec<u8>)

Append the whole state to out.
Source§

fn check_state(&self, bytes: &[u8]) -> Result<(), StateError>

Check that bytes is a payload Self::read_state can apply. Must not change self. Read more
Source§

fn read_state(&mut self, bytes: &[u8])

Replace the state with bytes. Only called with a payload Self::check_state accepted.
Source§

fn step_rule(&self) -> StepRule

How this participant’s time step relates to the world substep.
Source§

fn ports(&self) -> &[Port]

The ports this participant reads and writes, empty by default. The world reads them once, at registration, to fix the execution order (execution_order); they must not change while the participant is registered.
Source§

impl PhysicsModifier for PressureModifier

Source§

fn modify_distance(&self, x: f32, y: f32, z: f32, original_dist: f32) -> f32

Modify the SDF distance at a world-space point. Read more
Source§

fn update(&mut self, dt: f32)

Advance the simulation state by dt seconds.
Source§

fn name(&self) -> &'static str

Name of this modifier (for debugging)
Source§

fn is_active(&self) -> bool

Whether this modifier has any active effect

Auto Trait Implementations§

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

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.