Toast Engine
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
14namespace physics {
15
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 identifiers, creation data, and copied runtime state.
Shape identifiers, geometry, and runtime records.
Definition body.hpp:20
Definition body.hpp:98
Definition body.hpp:60
Definition collision_world.hpp:16
Definition shape.hpp:29
Definition shape.hpp:197
Definition shape.hpp:161
Definition shape.hpp:148
Definition voxel_shape_data.hpp:26
Definition voxel_shape_data.hpp:47
Voxel data structures for physics system.