Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
collision_world.hpp
Go to the documentation of this file.
1
5
6
#pragma once
7
8
#include "
body.hpp
"
9
#include "
shape.hpp
"
10
#include "
voxel_shape_data.hpp
"
11
12
#include <span>
13
14
namespace
physics {
15
16
struct
CollisionWorldView
{
17
std::span<const BodySlot> bodies;
18
std::span<const ShapeSlot> shapes;
19
std::span<const VoxelShapeSlot> voxel_shapes;
20
21
[[nodiscard]]
22
auto
body(
BodyID
id
)
const
->
const
Body
* {
23
if
(
id
.slot >= bodies.size()) {
24
return
nullptr
;
25
}
26
27
const
BodySlot
& slot = bodies[
id
.slot];
28
return
slot.occupied && slot.generation ==
id
.generation ? &slot.body :
nullptr
;
29
}
30
31
[[nodiscard]]
32
auto
shape(
ShapeID
id
)
const
->
const
Shape
* {
33
if
(
id
.slot >= shapes.size()) {
34
return
nullptr
;
35
}
36
37
const
ShapeSlot
& slot = shapes[
id
.slot];
38
return
slot.occupied && slot.generation ==
id
.generation ? &slot.shape :
nullptr
;
39
}
40
41
[[nodiscard]]
42
auto
voxelData(
VoxelDataID
id
)
const
->
const
VoxelShapeData
* {
43
if
(
id
.slot >= voxel_shapes.size()) {
44
return
nullptr
;
45
}
46
47
const
VoxelShapeSlot
& slot = voxel_shapes[
id
.slot];
48
return
slot.generation ==
id
.generation && slot.data.has_value() ? &slot.data.value() :
nullptr
;
49
}
50
};
51
52
}
body.hpp
Body identifiers, creation data, and copied runtime state.
shape.hpp
Shape identifiers, geometry, and runtime records.
physics::BodyID
Definition
body.hpp:20
physics::BodySlot
Definition
body.hpp:98
physics::Body
Definition
body.hpp:60
physics::CollisionWorldView
Definition
collision_world.hpp:16
physics::ShapeID
Definition
shape.hpp:29
physics::ShapeSlot
Definition
shape.hpp:197
physics::Shape
Definition
shape.hpp:161
physics::VoxelDataID
Definition
shape.hpp:148
physics::VoxelShapeData
Definition
voxel_shape_data.hpp:26
physics::VoxelShapeSlot
Definition
voxel_shape_data.hpp:47
voxel_shape_data.hpp
Voxel data structures for physics system.
engine
src
toast
physics
collision_world.hpp
Generated by
1.17.0