pub struct BuoyancyForce {
pub fluid_density: f32,
pub gravity: f32,
pub drag: f32,
}Expand description
Compute the buoyant force on a rigid body submerged in a WaterSurface.
Uses a simplified integration: sample the water height at the body’s XZ position and compute the submerged volume fraction of the body’s bounding box.
Fields§
§fluid_density: f32Fluid density (kg/m³).
gravity: f32Gravity magnitude.
drag: f32Drag coefficient for water resistance.
Implementations§
Source§impl BuoyancyForce
impl BuoyancyForce
pub fn new(fluid_density: f32) -> Self
Sourcepub fn compute(
&self,
position: Vec3,
velocity: Vec3,
half_extents: Vec3,
water_h: f32,
) -> Vec3
pub fn compute( &self, position: Vec3, velocity: Vec3, half_extents: Vec3, water_h: f32, ) -> Vec3
Returns the buoyant force vector (upward) for a body at position with
bounding box half_extents, given a water surface height water_h.
Sourcepub fn apply_to_body(
&self,
position: Vec3,
velocity: Vec3,
half_extents: Vec3,
water_surface: &WaterSurface,
) -> Vec3
pub fn apply_to_body( &self, position: Vec3, velocity: Vec3, half_extents: Vec3, water_surface: &WaterSurface, ) -> Vec3
Apply buoyancy and drag to a rigid body from joints.rs. Returns the net upward force to be applied.
Sourcepub fn compute_with_torque(
&self,
position: Vec3,
velocity: Vec3,
half_extents: Vec3,
orientation: Quat,
water_surface: &WaterSurface,
) -> (Vec3, Vec3)
pub fn compute_with_torque( &self, position: Vec3, velocity: Vec3, half_extents: Vec3, orientation: Quat, water_surface: &WaterSurface, ) -> (Vec3, Vec3)
Compute torque from buoyancy when body is tilted (tilted buoyancy center). Returns (force, torque_moment) in world space.
Auto Trait Implementations§
impl Freeze for BuoyancyForce
impl RefUnwindSafe for BuoyancyForce
impl Send for BuoyancyForce
impl Sync for BuoyancyForce
impl Unpin for BuoyancyForce
impl UnsafeUnpin for BuoyancyForce
impl UnwindSafe for BuoyancyForce
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
Mutably borrows from an owned value. Read more
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>
Convert
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> 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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.