group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
physics::CapsuleShape Struct Reference

Capsule shape input for swept-collision queries. More...

#include <SweptCollision.hpp>

Public Member Functions

glm::vec3 segA (glm::vec3 center) const noexcept
 Top endpoint of the inner segment at center.
glm::vec3 segB (glm::vec3 center) const noexcept
 Bottom endpoint of the inner segment at center.
glm::vec3 enclosingHalfExtents () const noexcept
 Tight half-extents of the AABB that encloses the capsule at center.
float minkowskiExtent (glm::vec3 n) const noexcept
 Minkowski half-extent of the capsule along a unit direction n.
float effectiveStepHeight (float requestedStepHeight) const noexcept
 Clamp a requested step height to a value the capsule can safely support — never larger than the segment half-length, leaving a small numerical margin so the derived walkShape() always has a positive halfHeight.
CapsuleShape walkShape (float requestedStepHeight) const noexcept
 "Walk" capsule — a shorter capsule whose foot is lifted by stepHeight (using effectiveStepHeight) and whose head is unchanged.
glm::vec3 walkCenterOffset (float requestedStepHeight) const noexcept
 Centre-position offset that takes a full-capsule centre to the matching walk-capsule centre (head aligned).

Public Attributes

float radius {16.0f}
 Cylinder cross-section radius.
float halfHeight {20.0f}
 Half the segment length (excludes spherical caps).
glm::vec3 up {0.0f, 1.0f, 0.0f}
 Unit-length axis direction.

Detailed Description

Capsule shape input for swept-collision queries.

A capsule is a line segment thickened by a radius. The segment endpoints are center ± up * halfHeight; the surface is every point within radius of the segment. up defaults to +Y but may be any unit vector — this supports gravity-flipped play (where the capsule axis is -Y) and any future arbitrarily-oriented characters without changing the query API.

Functions taking a CapsuleShape treat center as the capsule's centre of mass (the midpoint of the segment), matching the semantics of the AABB family that takes a centre + halfExtents.

Member Function Documentation

◆ effectiveStepHeight()

float physics::CapsuleShape::effectiveStepHeight ( float requestedStepHeight) const
inlinenodiscardnoexcept

Clamp a requested step height to a value the capsule can safely support — never larger than the segment half-length, leaving a small numerical margin so the derived walkShape() always has a positive halfHeight.

Crouched players (small halfHeight) get a proportionally smaller effective step.

Here is the caller graph for this function:

◆ enclosingHalfExtents()

glm::vec3 physics::CapsuleShape::enclosingHalfExtents ( ) const
inlinenodiscardnoexcept

Tight half-extents of the AABB that encloses the capsule at center.

Used for BVH broad-phase culling. For a Y-aligned capsule of radius r and half-height h, this returns (r, h + r, r).

Here is the caller graph for this function:

◆ minkowskiExtent()

float physics::CapsuleShape::minkowskiExtent ( glm::vec3 n) const
inlinenodiscardnoexcept

Minkowski half-extent of the capsule along a unit direction n.

For a Y-aligned capsule this is r + h * |n.y|; for an arbitrary axis it is r + h * |dot(up, n)|. Used by every plane / slab / Minkowski-sum query as the capsule analogue of |n.x|*hx + |n.y|*hy + |n.z|*hz for an AABB.

Here is the caller graph for this function:

◆ segA()

glm::vec3 physics::CapsuleShape::segA ( glm::vec3 center) const
inlinenodiscardnoexcept

Top endpoint of the inner segment at center.

Here is the caller graph for this function:

◆ segB()

glm::vec3 physics::CapsuleShape::segB ( glm::vec3 center) const
inlinenodiscardnoexcept

Bottom endpoint of the inner segment at center.

Here is the caller graph for this function:

◆ walkCenterOffset()

glm::vec3 physics::CapsuleShape::walkCenterOffset ( float requestedStepHeight) const
inlinenodiscardnoexcept

Centre-position offset that takes a full-capsule centre to the matching walk-capsule centre (head aligned).

Always points along +up — for gravity-flipped play the caller should negate the result.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ walkShape()

CapsuleShape physics::CapsuleShape::walkShape ( float requestedStepHeight) const
inlinenodiscardnoexcept

"Walk" capsule — a shorter capsule whose foot is lifted by stepHeight (using effectiveStepHeight) and whose head is unchanged.

Used by the two-capsule character controller for horizontal motion: a sweep with this shape is physically incapable of contacting anything ≤ stepHeight tall, so steps / curbs / stair risers within that height are transparently ignored. Vertical settle later snaps the foot onto whatever is below.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ halfHeight

float physics::CapsuleShape::halfHeight {20.0f}

Half the segment length (excludes spherical caps).

◆ radius

float physics::CapsuleShape::radius {16.0f}

Cylinder cross-section radius.

◆ up

glm::vec3 physics::CapsuleShape::up {0.0f, 1.0f, 0.0f}

Unit-length axis direction.


The documentation for this struct was generated from the following file: