SleakEngine
0.1.0
C++23 multi-backend game engine
Toggle main menu visibility
Loading...
Searching...
No Matches
CollisionDetection.hpp
Go to the documentation of this file.
1
#ifndef _COLLISION_DETECTION_HPP_
2
#define _COLLISION_DETECTION_HPP_
3
4
#include <
Physics/Colliders.hpp
>
5
6
namespace
Sleak
{
7
namespace
Physics
{
8
9
/// Single point of contact between two colliding shapes.
10
/// @ingroup physics
11
struct
ContactPoint
{
12
Vector3D
point
;
13
Vector3D
normal
;
14
float
penetration
= 0.0f;
15
};
16
17
/// Result of a narrow-phase test: whether a collision occurred and its contact data.
18
/// @ingroup physics
19
struct
CollisionManifold
{
20
bool
hasCollision
=
false
;
21
ContactPoint
contact
;
22
};
23
24
/// Narrow-phase collision tests; the resulting normal always points from A to B.
25
CollisionManifold
TestAABBvsAABB
(
const
AABB
& a,
const
AABB
& b);
26
CollisionManifold
TestSphereVsSphere
(
const
BoundingSphere
& a,
const
BoundingSphere
& b);
27
CollisionManifold
TestAABBvsSphere
(
const
AABB
& a,
const
BoundingSphere
& b);
28
CollisionManifold
TestSphereVsCapsule
(
const
BoundingSphere
& a,
const
BoundingCapsule
& b);
29
CollisionManifold
TestAABBvsCapsule
(
const
AABB
& a,
const
BoundingCapsule
& b);
30
CollisionManifold
TestCapsuleVsCapsule
(
const
BoundingCapsule
& a,
const
BoundingCapsule
& b);
31
CollisionManifold
TestSphereVsMesh
(
const
BoundingSphere
& a,
const
TriangleMesh
& b);
32
CollisionManifold
TestAABBvsMesh
(
const
AABB
& a,
const
TriangleMesh
& b);
33
34
/// Dispatches to the right narrow-phase test based on the runtime shape held by each variant.
35
CollisionManifold
TestCollision
(
const
ColliderShape
& shapeA,
const
Vector3D
& posA,
const
Vector3D
& scaleA,
36
const
ColliderShape
& shapeB,
const
Vector3D
& posB,
const
Vector3D
& scaleB);
37
38
/// Nearest point on segment [a, b] to the given point.
39
Vector3D
ClosestPointOnSegment
(
const
Vector3D
& point,
const
Vector3D
& a,
const
Vector3D
& b);
40
/// Nearest points between two line segments, used for capsule-vs-capsule tests.
41
void
ClosestPointsSegmentSegment
(
const
Vector3D
& a1,
const
Vector3D
& a2,
42
const
Vector3D
& b1,
const
Vector3D
& b2,
43
Vector3D
& closestA,
Vector3D
& closestB);
44
CollisionManifold
TestSphereVsTriangle
(
const
BoundingSphere
& sphere,
45
const
Vector3D
& v0,
const
Vector3D
& v1,
const
Vector3D
& v2);
46
47
}
// namespace Physics
48
}
// namespace Sleak
49
50
#endif
// _COLLISION_DETECTION_HPP_
Colliders.hpp
Sleak::Math::Vector3D
Definition
Vector.hpp:354
Sleak::Physics
Collision shapes, the broadphase tree, and the world that steps them.
Definition
SceneBase.hpp:29
Sleak::Physics::ClosestPointsSegmentSegment
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.
Definition
CollisionDetection.cpp:18
Sleak::Physics::TestSphereVsTriangle
CollisionManifold TestSphereVsTriangle(const BoundingSphere &sphere, const Vector3D &v0, const Vector3D &v1, const Vector3D &v2)
Definition
CollisionDetection.cpp:184
Sleak::Physics::ColliderShape
std::variant< AABB, BoundingSphere, BoundingCapsule, TriangleMesh > ColliderShape
Tagged union of the shapes a ColliderComponent can hold.
Definition
Colliders.hpp:233
Sleak::Physics::TestCapsuleVsCapsule
CollisionManifold TestCapsuleVsCapsule(const BoundingCapsule &a, const BoundingCapsule &b)
Definition
CollisionDetection.cpp:172
Sleak::Physics::ClosestPointOnSegment
Vector3D ClosestPointOnSegment(const Vector3D &point, const Vector3D &a, const Vector3D &b)
Nearest point on segment [a, b] to the given point.
Definition
CollisionDetection.cpp:9
Sleak::Physics::TestAABBvsCapsule
CollisionManifold TestAABBvsCapsule(const AABB &a, const BoundingCapsule &b)
Definition
CollisionDetection.cpp:160
Sleak::Physics::TestSphereVsMesh
CollisionManifold TestSphereVsMesh(const BoundingSphere &a, const TriangleMesh &b)
Definition
CollisionDetection.cpp:252
Sleak::Physics::TestAABBvsAABB
CollisionManifold TestAABBvsAABB(const AABB &a, const AABB &b)
Narrow-phase collision tests; the resulting normal always points from A to B.
Definition
CollisionDetection.cpp:80
Sleak::Physics::TestAABBvsSphere
CollisionManifold TestAABBvsSphere(const AABB &a, const BoundingSphere &b)
Definition
CollisionDetection.cpp:129
Sleak::Physics::TestSphereVsCapsule
CollisionManifold TestSphereVsCapsule(const BoundingSphere &a, const BoundingCapsule &b)
Definition
CollisionDetection.cpp:150
Sleak::Physics::TestSphereVsSphere
CollisionManifold TestSphereVsSphere(const BoundingSphere &a, const BoundingSphere &b)
Definition
CollisionDetection.cpp:109
Sleak::Physics::TestCollision
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.
Definition
CollisionDetection.cpp:314
Sleak::Physics::TestAABBvsMesh
CollisionManifold TestAABBvsMesh(const AABB &a, const TriangleMesh &b)
Definition
CollisionDetection.cpp:269
Sleak
Root namespace for everything the engine exposes.
Definition
Camera.hpp:10
Sleak::Physics::AABB
Definition
Colliders.hpp:20
Sleak::Physics::BoundingCapsule
Definition
Colliders.hpp:133
Sleak::Physics::BoundingSphere
Definition
Colliders.hpp:99
Sleak::Physics::CollisionManifold
Definition
CollisionDetection.hpp:19
Sleak::Physics::CollisionManifold::contact
ContactPoint contact
Definition
CollisionDetection.hpp:21
Sleak::Physics::CollisionManifold::hasCollision
bool hasCollision
Definition
CollisionDetection.hpp:20
Sleak::Physics::ContactPoint
Definition
CollisionDetection.hpp:11
Sleak::Physics::ContactPoint::penetration
float penetration
Definition
CollisionDetection.hpp:14
Sleak::Physics::ContactPoint::normal
Vector3D normal
Definition
CollisionDetection.hpp:13
Sleak::Physics::ContactPoint::point
Vector3D point
Definition
CollisionDetection.hpp:12
Sleak::Physics::TriangleMesh
Definition
Colliders.hpp:204
include
public
Physics
CollisionDetection.hpp
Generated on
for SleakEngine by
1.18.0