sandbox
Loading...
Searching...
No Matches
shape_collider.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_PHYSICS_SHAPE_COLLIDER_HPP_
3#define LIBSBX_PHYSICS_SHAPE_COLLIDER_HPP_
4
5#include <variant>
6#include <algorithm>
7
8#include <libsbx/units/mass.hpp>
9#include <libsbx/units/distance.hpp>
10#include <libsbx/units/time.hpp>
11
12#include <libsbx/math/vector3.hpp>
13#include <libsbx/math/matrix4x4.hpp>
14#include <libsbx/math/volume.hpp>
15
16namespace sbx::physics {
17
18struct sphere {
19 std::float_t radius{0.5f};
20}; // struct sphere
21
22struct cylinder {
23 std::float_t radius{0.5f};
24 std::float_t half_height{0.5f};
25}; // struct cylinder
26
27struct capsule {
28 std::float_t radius{0.5f};
29 std::float_t half_height{0.5f};
30}; // struct capsule
31
32struct box {
33 math::vector3 half_extents{0.5f, 0.5f, 0.5f};
34}; // struct box
35
36struct triangle {
40}; // struct triangle
41
42using convex_shape = std::variant<sphere, cylinder, capsule, box, triangle>;
43
45 convex_shape shape;
46 math::vector3 offset{math::vector3::zero};
47 std::float_t friction{0.5f};
48 std::float_t restitution{0.0f};
49}; // struct collider
50
51auto inverse_inertia_tensor(const shape_collider& collider, std::float_t mass) -> math::matrix3x3;
52
53auto get_bounding_volume(const shape_collider& collider, const math::matrix4x4& transform) -> math::volume;
54
55} // namespace sbx::physics
56
57#endif // LIBSBX_PHYSICS_SHAPE_COLLIDER_HPP_
58
Definition: matrix3x3.hpp:26
Definition: matrix4x4.hpp:26
Definition: vector3.hpp:23
Definition: volume.hpp:14
Definition: shape_collider.hpp:32
Definition: shape_collider.hpp:27
Definition: shape_collider.hpp:22
Definition: shape_collider.hpp:44
Definition: shape_collider.hpp:18
Definition: shape_collider.hpp:36