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: f64Radius of the capsule.
half_height: f64Half 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: f64The 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: f64The 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: f64The 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: u32How many times one move may be clipped and redirected before it stops.
Quake’s numbumps and Godot’s max_slides.
depenetration_passes: u32How 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
impl Clone for CharacterConfig
impl Copy for CharacterConfig
Source§impl Debug for CharacterConfig
impl Debug for CharacterConfig
Source§impl Default for CharacterConfig
impl Default for CharacterConfig
Source§fn default() -> Self
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.