SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::Physics Namespace Reference

Collision shapes, the broadphase tree, and the world that steps them. More...

Classes

struct  AABB
struct  BoundingCapsule
struct  BoundingSphere
struct  CollisionManifold
struct  CollisionPair
struct  ContactPoint
class  DynamicAABBTree
class  PhysicsWorld
struct  RayHit
struct  SweepResult
struct  TreeNode
struct  TriangleMesh
class  Vector3D

Typedefs

using ColliderShape = std::variant<AABB, BoundingSphere, BoundingCapsule, TriangleMesh>
 Tagged union of the shapes a ColliderComponent can hold.

Enumerations

enum class  ColliderType { ColliderType::AABB , ColliderType::Sphere , ColliderType::Capsule , ColliderType::Mesh }

Functions

static Vector3D ClosestPointOnAABB (const AABB &aabb, const Vector3D &point)
 Clamps point into the box, giving the nearest surface or interior point.
Vector3D ClosestPointOnSegment (const Vector3D &point, const Vector3D &a, const Vector3D &b)
 Nearest point on segment [a, b] to the given point.
void ClosestPointsSegmentSegment (const Vector3D &a1, const Vector3D &a2, const Vector3D &b1, const Vector3D &b2, Vector3D &closestA, Vector3D &closestB)
 Nearest points between two line segments, used for capsule-vs-capsule tests.
AABB GetWorldAABB (const ColliderShape &shape, const Vector3D &worldPos, const Vector3D &worldScale)
 Transforms a local-space collider shape into a world-space AABB for broadphase queries.
CollisionManifold TestAABBvsAABB (const AABB &a, const AABB &b)
 Narrow-phase collision tests; the resulting normal always points from A to B.
CollisionManifold TestAABBvsCapsule (const AABB &a, const BoundingCapsule &b)
CollisionManifold TestAABBvsMesh (const AABB &a, const TriangleMesh &b)
CollisionManifold TestAABBvsSphere (const AABB &a, const BoundingSphere &b)
CollisionManifold TestCapsuleVsCapsule (const BoundingCapsule &a, const BoundingCapsule &b)
CollisionManifold TestCollision (const ColliderShape &shapeA, const Vector3D &posA, const Vector3D &scaleA, const ColliderShape &shapeB, const Vector3D &posB, const Vector3D &scaleB)
 Dispatches to the right narrow-phase test based on the runtime shape held by each variant.
CollisionManifold TestSphereVsCapsule (const BoundingSphere &a, const BoundingCapsule &b)
CollisionManifold TestSphereVsMesh (const BoundingSphere &a, const TriangleMesh &b)
CollisionManifold TestSphereVsSphere (const BoundingSphere &a, const BoundingSphere &b)
CollisionManifold TestSphereVsTriangle (const BoundingSphere &sphere, const Vector3D &v0, const Vector3D &v1, const Vector3D &v2)
static AABB TransformAABB (const AABB &aabb, const Vector3D &pos, const Vector3D &scale)
static BoundingCapsule TransformCapsule (const BoundingCapsule &c, const Vector3D &pos, const Vector3D &scale)
static TriangleMesh TransformMesh (const TriangleMesh &m, const Vector3D &pos, const Vector3D &scale)
static BoundingSphere TransformSphere (const BoundingSphere &s, const Vector3D &pos, const Vector3D &scale)

Variables

static constexpr float FAT_AABB_MARGIN = 0.1f
static constexpr int NULL_NODE = -1

Detailed Description

Collision shapes, the broadphase tree, and the world that steps them.

PhysicsWorld owns a DynamicAABBTree plus every registered collider, and exposes raycast, sweep, and overlap queries. Each Scene creates one PhysicsWorld and steps it from its update.

Typedef Documentation

◆ ColliderShape

Tagged union of the shapes a ColliderComponent can hold.

Definition at line 233 of file Colliders.hpp.

Function Documentation

◆ ClosestPointOnAABB()

Vector3D Sleak::Physics::ClosestPointOnAABB ( const AABB & aabb,
const Vector3D & point )
static

Clamps point into the box, giving the nearest surface or interior point.

Definition at line 72 of file CollisionDetection.cpp.

◆ ClosestPointOnSegment()

Vector3D Sleak::Physics::ClosestPointOnSegment ( const Vector3D & point,
const Vector3D & a,
const Vector3D & b )

Nearest point on segment [a, b] to the given point.

Definition at line 9 of file CollisionDetection.cpp.

◆ ClosestPointsSegmentSegment()

void Sleak::Physics::ClosestPointsSegmentSegment ( const Vector3D & a1,
const Vector3D & a2,
const Vector3D & b1,
const Vector3D & b2,
Vector3D & closestA,
Vector3D & closestB )

Nearest points between two line segments, used for capsule-vs-capsule tests.

Definition at line 18 of file CollisionDetection.cpp.

◆ GetWorldAABB()

AABB Sleak::Physics::GetWorldAABB ( const ColliderShape & shape,
const Vector3D & worldPos,
const Vector3D & worldScale )
inline

Transforms a local-space collider shape into a world-space AABB for broadphase queries.

Definition at line 236 of file Colliders.hpp.

◆ TestAABBvsAABB()

CollisionManifold Sleak::Physics::TestAABBvsAABB ( const AABB & a,
const AABB & b )

Narrow-phase collision tests; the resulting normal always points from A to B.

Definition at line 80 of file CollisionDetection.cpp.

◆ TestAABBvsCapsule()

CollisionManifold Sleak::Physics::TestAABBvsCapsule ( const AABB & a,
const BoundingCapsule & b )

Definition at line 160 of file CollisionDetection.cpp.

◆ TestAABBvsMesh()

CollisionManifold Sleak::Physics::TestAABBvsMesh ( const AABB & a,
const TriangleMesh & b )

Definition at line 269 of file CollisionDetection.cpp.

◆ TestAABBvsSphere()

CollisionManifold Sleak::Physics::TestAABBvsSphere ( const AABB & a,
const BoundingSphere & b )

Definition at line 129 of file CollisionDetection.cpp.

◆ TestCapsuleVsCapsule()

CollisionManifold Sleak::Physics::TestCapsuleVsCapsule ( const BoundingCapsule & a,
const BoundingCapsule & b )

Definition at line 172 of file CollisionDetection.cpp.

◆ TestCollision()

CollisionManifold Sleak::Physics::TestCollision ( const ColliderShape & shapeA,
const Vector3D & posA,
const Vector3D & scaleA,
const ColliderShape & shapeB,
const Vector3D & posB,
const Vector3D & scaleB )

Dispatches to the right narrow-phase test based on the runtime shape held by each variant.

Definition at line 314 of file CollisionDetection.cpp.

◆ TestSphereVsCapsule()

CollisionManifold Sleak::Physics::TestSphereVsCapsule ( const BoundingSphere & a,
const BoundingCapsule & b )

Definition at line 150 of file CollisionDetection.cpp.

◆ TestSphereVsMesh()

CollisionManifold Sleak::Physics::TestSphereVsMesh ( const BoundingSphere & a,
const TriangleMesh & b )

Definition at line 252 of file CollisionDetection.cpp.

◆ TestSphereVsSphere()

CollisionManifold Sleak::Physics::TestSphereVsSphere ( const BoundingSphere & a,
const BoundingSphere & b )

Definition at line 109 of file CollisionDetection.cpp.

◆ TestSphereVsTriangle()

CollisionManifold Sleak::Physics::TestSphereVsTriangle ( const BoundingSphere & sphere,
const Vector3D & v0,
const Vector3D & v1,
const Vector3D & v2 )

Definition at line 184 of file CollisionDetection.cpp.

◆ TransformAABB()

AABB Sleak::Physics::TransformAABB ( const AABB & aabb,
const Vector3D & pos,
const Vector3D & scale )
static

Definition at line 275 of file CollisionDetection.cpp.

◆ TransformCapsule()

BoundingCapsule Sleak::Physics::TransformCapsule ( const BoundingCapsule & c,
const Vector3D & pos,
const Vector3D & scale )
static

Definition at line 293 of file CollisionDetection.cpp.

◆ TransformMesh()

TriangleMesh Sleak::Physics::TransformMesh ( const TriangleMesh & m,
const Vector3D & pos,
const Vector3D & scale )
static

Definition at line 303 of file CollisionDetection.cpp.

◆ TransformSphere()

BoundingSphere Sleak::Physics::TransformSphere ( const BoundingSphere & s,
const Vector3D & pos,
const Vector3D & scale )
static

Definition at line 288 of file CollisionDetection.cpp.

Variable Documentation

◆ FAT_AABB_MARGIN

float Sleak::Physics::FAT_AABB_MARGIN = 0.1f
staticconstexpr

Definition at line 12 of file DynamicAABBTree.hpp.

◆ NULL_NODE

int Sleak::Physics::NULL_NODE = -1
staticconstexpr

Definition at line 11 of file DynamicAABBTree.hpp.