Skip to main content

CharacterConfig

Struct CharacterConfig 

Source
pub struct CharacterConfig {
    pub radius: f64,
    pub half_height: f64,
    pub min_ground_normal_y: f64,
    pub step_offset: f64,
    pub skin_width: f64,
    pub max_slides: u32,
    pub depenetration_passes: u32,
}
Expand description

The shape of a character and the limits it moves under.

Fields§

§radius: f64

Radius of the capsule.

§half_height: f64

Half the length of the capsule’s cylindrical section, as Capsule::half_height means it: the standing height is 2 * (half_height + radius).

§min_ground_normal_y: f64

The smallest normal · +Y a surface can have and still be ground the character stands and walks on — the cosine of the steepest walkable slope, not the angle.

A cosine and not an angle because this crate is a determinism-bearing one and cos is a platform transcendental: see the determinism rule in docs/notes/simulation.md. Authoring an angle is the caller’s job, done once, outside the tick. This is the same runtime form Quake’s normal[2] > 0.7 and Unreal’s WalkableFloorZ keep.

Where the behaviour actually flips is measured by tests::the_slope_the_controller_stops_walking_up_is_the_one_it_was_configured_with.

§step_offset: f64

The tallest ledge the character walks up without leaving the ground.

Also how far it will drop to stay attached to ground that falls away under it, which is Godot’s floor_snap_length and the reason walking down stairs does not become a series of falls.

The rise is taken with a skin_width to spare, so a step of exactly this height is climbed and the true cut-off is up to one skin width above it. The band is measured by tests::the_step_the_controller_stops_climbing_is_the_offset_it_was_configured_with.

§skin_width: f64

The gap kept between the capsule and every surface it touches.

Every sweep of a move stops this far short of its contact, measured along the surface’s normal, and one that met a surface already nearer than this backs off to it. The next sweep then starts outside the surface instead of on it, where a touching start would be reported as an overlap and a sweep with a tolerance can meet the surface again for motion along it. Unity’s CharacterController calls the same quantity skinWidth; Unreal spends it as MAX_FLOOR_DIST. A move whose physical sweep misses also checks the skin envelope, so subdividing an approach into sub-skin requests cannot consume the gap. The envelope only blocks incoming motion, not parallel or departing moves.

§max_slides: u32

How many times one move may be clipped and redirected before it stops.

Quake’s numbumps and Godot’s max_slides.

§depenetration_passes: u32

How many times the move may push the capsule out of what it overlaps before giving up and moving anyway.

One pass resolves one contact completely, so this is the number of distinct surfaces a character can be dug out of in a single call — a corner needs two, a hole in a wall three.

Trait Implementations§

Source§

impl Clone for CharacterConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CharacterConfig

Source§

impl Debug for CharacterConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CharacterConfig

Source§

fn default() -> Self

An adult-sized character: 1.8 m tall, 0.6 m across, 45° slopes.

45° is expressed as std::f64::consts::FRAC_1_SQRT_2 rather than (PI / 4.0).cos() so the default costs no transcendental at all — see min_ground_normal_y.

Source§

impl PartialEq for CharacterConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CharacterConfig

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.