group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
CollisionShape Struct Reference

Collision shape attached to an entity. More...

#include <CollisionShape.hpp>

Public Member Functions

float minkowskiExtent (const glm::vec3 &n) const noexcept
 Minkowski extent of the shape along a unit direction n.

Public Attributes

CollisionShapeType type = CollisionShapeType::AABB
 Which kind of shape this is — selects the runtime collision path.
glm::vec3 halfExtents {16.0f, 36.0f, 16.0f}
 AABB half-dimensions.
float radius = 16.0f
 Capsule cylinder radius. Unused when type == AABB.
float halfHeight = 20.0f
 Capsule cylinder half-height (excludes spherical caps).

Detailed Description

Collision shape attached to an entity.

The shape is positioned at the entity's Position component. For an AABB the full extent spans [pos - halfExtents, pos + halfExtents]. For a capsule, the segment endpoints are pos ± (0, halfHeight, 0) and the radius r wraps around the segment.

Default is a standing-player AABB in Quake-ish units:

  • Width = 32 (halfExtents.x/z = 16)
  • Height = 72 (halfExtents.y = 36) Switch the player to capsule at creation time by setting:
  • type = CollisionShapeType::Capsule
  • radius = 16 (cylinder cross-section)
  • halfHeight = 20 (segment ends 20 u above/below centre)
  • halfExtents = (16, 36, 16) (conservative bounding-box used by axis-aligned swept queries — exact for axis-aligned face normals)

Member Function Documentation

◆ minkowskiExtent()

float CollisionShape::minkowskiExtent ( const glm::vec3 & n) const
inlinenodiscardnoexcept

Minkowski extent of the shape along a unit direction n.

Used by every Minkowski-sum-based collision query (plane sweep, box slab, triangle plane). Returns the half-width of the shape's projection on n.

Member Data Documentation

◆ halfExtents

glm::vec3 CollisionShape::halfExtents {16.0f, 36.0f, 16.0f}

AABB half-dimensions.

Used directly when type == AABB, and as the conservative bounding-box for the capsule when type == Capsule (matches the capsule's swept-AABB Minkowski hull).

◆ halfHeight

float CollisionShape::halfHeight = 20.0f

Capsule cylinder half-height (excludes spherical caps).

Total visual height = 2 * (halfHeight + radius). Unused when type == AABB.

◆ radius

float CollisionShape::radius = 16.0f

Capsule cylinder radius. Unused when type == AABB.

◆ type

Which kind of shape this is — selects the runtime collision path.


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