physics/src/shape.rs#
Source: lib/physics/src/shape.rs
shape -- the collision shapes: sphere, capsule, box, convex hull (convex, solid) and the static triangle
mesh (two-sided triangles)
enum ShapeA collision shape in its own frame. Hulls and meshes are shared ([Arc]): cloning a shape is cheap, one map mesh can sit in several worlds (server, prediction, tests).Sphere { radius: f64 }-- a ball around the originCapsule { half_height: f64, radius: f64 }-- the points withinradiusof the segment (0, -half_height, 0) .. (0, half_height, 0): upright, total height 2 (half_height + radius)Box { half: Vec3 }-- a box around the origin with half sizeshalfHull(Arc<ConvexHull>)-- a convex hull (shared)Mesh(Arc<TriMesh>)-- a triangle mesh: a static or kinematic body (never dynamic), not a query shape
impl Shape
fn sphere(radius: f64) -> Shapea ball ofradiusfn capsule(half_height: f64, radius: f64) -> Shapean upright capsule: the segment (0, ±half_height, 0) grown byradiusfn cuboid(half: Vec3) -> Shapea box with half sizeshalffn hull(hull: ConvexHull) -> Shapea convex hull, sharedfn hull_from_points(points: &[Vec3]) -> Result<Shape, HullError>the convex hull ofpointsfn mesh(mesh: TriMesh) -> Shapea triangle mesh (for a static or kinematic body), sharedfn sizes_ok(&self) -> boolwhether its sizes can make a body: a radius and a box's half sizes finite and positive, a capsule's half height finite and not negative (hulls and meshes check theirs when they are made)fn is_convex(&self) -> booleverything but a meshfn margin(&self) -> f64the radius around the core (spheres and capsules), 0 for the othersfn aabb(&self, iso: &Iso) -> Aabbthe box around the shape placed byiso