pub struct PhysicsConfig {
pub floor_y: f32,
pub terrain_half_width: f32,
pub terrain_half_depth: f32,
pub terrain_subdivisions: u32,
pub terrain_amplitude: f32,
pub terrain_offset_y: f32,
pub terrain_mesh: Option<AssetId>,
pub layers: Vec<String>,
pub no_collide: Vec<[String; 2]>,
pub contact_min_impulse: f32,
pub spawn_headroom: u32,
}Expand description
Configures the world’s physics floor / terrain.
Optional: a world with physics bodies but no PhysicsConfig simulates over a
flat floor at Y = 0, and receives one carrying these values at start so the
settings are a component rather than a fallback. Physics runs whenever the world
declares a PhysicsConfig, a RigidBody, a
PropBody, a TriggerVolume, or a
SkinnedMesh with a capsule. Declare a PhysicsConfig to
put bodies on terrain or a non-zero floor.
For terrain-based outdoor scenes the terrain parameters must match the terrain mesh exactly.
PhysicsConfig {
terrain_offset_y: -0.5,
..Default::default()
};Fields§
§floor_y: f32Y coordinate of the floor. When left at 0.0 it is auto-detected from the camera; set it explicitly to override.
terrain_half_width: f32Half-width of the terrain mesh along X. Must match the terrain mesh.
Leave at 0.0 (with terrain_subdivisions = 0) for flat-floor scenes.
terrain_half_depth: f32Half-depth of the terrain mesh along Z. Must match the terrain mesh.
terrain_subdivisions: u32Subdivision count of the terrain mesh. When 0, a flat floor at Y = 0 is used instead of a heightfield.
terrain_amplitude: f32Height variation of the terrain mesh. Must match the terrain mesh.
terrain_offset_y: f32World-space Y offset of the terrain: the height of the prop that renders the terrain mesh. Leave at 0.0 when the terrain sits at the origin.
terrain_mesh: Option<AssetId>Name of a ProceduralMesh with generator: "heightfield". When set, the physics surface is built from that mesh’s
source image so props rest on the visible terrain. Takes precedence over
the terrain_* values above.
layers: Vec<String>Extra collision layer names beyond the built-ins (world, prop,
character, trigger). At most 28; referenced by collider layer
fields and no_collide pairs.
no_collide: Vec<[String; 2]>Unordered layer-name pairs that do not collide. Everything collides by
default; each pair here disables collision (and contact solving) between
its two layers symmetrically. Pairs naming character also filter the
character controller’s movement.
contact_min_impulse: f32Minimum contact impulse (mass times velocity change) for a collision to publish a contact event. Resting contact stays below it; raise to hear only hard impacts.
spawn_headroom: u32Extra physics bodies reserved for props created while the world runs
(by a Spawner, a Behavior spawn node, or the
host). Physics reserves every body it will ever need when the world
loads and never grows: once the declared bodies plus this many are
live, a further spawn gets no physics body and is reported as an error.
This is a floor beneath what the build reserves on its own, not the
whole reservation. Every Spawner whose interval and
lifetime bound how many copies can be alive at once is already
reserved for, and the larger of the two numbers wins. Set a value here
for the sources the build cannot count: a Spawner with lifetime: 0
(its copies live forever), a spawn node in a behavior, and spawns the
host drives itself.
Trait Implementations§
Source§impl Authored for PhysicsConfig
impl Authored for PhysicsConfig
Source§impl Clone for PhysicsConfig
impl Clone for PhysicsConfig
Source§fn clone(&self) -> PhysicsConfig
fn clone(&self) -> PhysicsConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for PhysicsConfig
impl Component for PhysicsConfig
Source§const NAME: &'static str = "PhysicsConfig"
const NAME: &'static str = "PhysicsConfig"
Source§fn from_baked(bytes: &[u8]) -> Result<PhysicsConfig, CnResult>
fn from_baked(bytes: &[u8]) -> Result<PhysicsConfig, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§fn inject_name(&mut self, _id: AssetId)
fn inject_name(&mut self, _id: AssetId)
Source§impl ComponentSlot for PhysicsConfig
impl ComponentSlot for PhysicsConfig
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.Source§fn slot(s: &ComponentStorage) -> &Column<PhysicsConfig>
fn slot(s: &ComponentStorage) -> &Column<PhysicsConfig>
Source§fn slot_mut(s: &mut ComponentStorage) -> &mut Column<PhysicsConfig>
fn slot_mut(s: &mut ComponentStorage) -> &mut Column<PhysicsConfig>
Source§impl Debug for PhysicsConfig
impl Debug for PhysicsConfig
Source§impl Default for PhysicsConfig
impl Default for PhysicsConfig
Source§fn default() -> PhysicsConfig
fn default() -> PhysicsConfig
Source§impl<'de> Deserialize<'de> for PhysicsConfigwhere
PhysicsConfig: Default,
impl<'de> Deserialize<'de> for PhysicsConfigwhere
PhysicsConfig: Default,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PhysicsConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PhysicsConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl RuntimeComponent for PhysicsConfig
Source§impl Serialize for PhysicsConfig
impl Serialize for PhysicsConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for PhysicsConfig
impl RefUnwindSafe for PhysicsConfig
impl Send for PhysicsConfig
impl Sync for PhysicsConfig
impl Unpin for PhysicsConfig
impl UnsafeUnpin for PhysicsConfig
impl UnwindSafe for PhysicsConfig
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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<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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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 more