Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
rigidbody.hpp
1
8
9
#pragma once
10
#include "
../body.hpp
"
11
#include "
../collision.hpp
"
12
#include "
../physics_material.hpp
"
13
#include "
../shape.hpp
"
14
15
#include <
toast/world/node_3d.hpp
>
16
#include <vector>
17
18
namespace
physics {
19
20
class
Simulator
;
21
22
class
[[ToastNode, Hidden, Interface, Icon(
"PhysicsBody"
), Color(
"Green"
)]] TOAST_API Rigidbody :
public
toast::Node3D
{
23
friend
class
Simulator;
24
25
public
:
26
signals::Signal<toast::Box<toast::Node>> contact_begin;
27
signals::Signal<toast::Box<toast::Node>> contact_end;
28
29
[[Reflect, Layers(
"excluded"
), Name(
"Layers"
)]]
30
uint32_t included = 1;
// Default
31
32
[[Reflect, LayersExcluded]]
33
uint32_t excluded = 0;
34
35
[[Reflect]]
36
void
setLayers(
int
included_layers,
int
excluded_layers);
37
38
[[Reflect]]
39
void
includeLayer(
int
layer,
bool
value =
true
);
40
41
[[Reflect]]
42
void
excludeLayer(
int
layer,
bool
value =
true
);
43
44
protected
:
45
explicit
Rigidbody(BodyType
type
) : m_body_type(
type
) { }
46
47
virtual
void
configureBodyDescriptor(
BodyDescriptor
& descriptor)
const
{ }
48
49
[[nodiscard]]
50
auto
bodyID()
const
noexcept
->
BodyID
{
51
return
m_body;
52
}
53
54
[[Reflect]]
55
assets::Handle<assets::PhysicsMaterial>
material;
56
57
[[Reflect, Name(
"Lock X"
), Group(
"Position Locks"
)]]
58
bool
lock_pos_x =
false
;
59
[[Reflect, Name(
"Lock Y"
), Group(
"Position Locks"
)]]
60
bool
lock_pos_y =
false
;
61
[[Reflect, Name(
"Lock Z"
), Group(
"Position Locks"
)]]
62
bool
lock_pos_z =
false
;
63
[[Reflect, Name(
"Lock X"
), Group(
"Rotation Locks"
)]]
64
bool
lock_rot_x =
false
;
65
[[Reflect, Name(
"Lock Y"
), Group(
"Rotation Locks"
)]]
66
bool
lock_rot_y =
false
;
67
[[Reflect, Name(
"Lock Z"
), Group(
"Rotation Locks"
)]]
68
bool
lock_rot_z =
false
;
69
70
private
:
71
struct
ActiveContact {
72
BodyID
other_body;
73
toast::Box<toast::Node>
other_node;
74
uint32_t shape_pair_count = 0;
75
};
76
77
void
updateInspectorMessages()
override
;
78
void
begin();
79
void
end();
80
void
onEnable();
81
void
onDisable();
82
void
handleContactBegin(
const
BroadPhasePair
& pair);
83
void
handleContactEnd(
const
BroadPhasePair
& pair);
84
85
[[nodiscard]]
86
auto
descriptor()
const
->
BodyDescriptor
;
87
88
void
assignBody(
BodyID
body)
noexcept
{ m_body = body; }
89
90
void
applyPhysicsTransform(
const
glm::vec3& position,
const
glm::quat& rotation);
91
92
void
onEditorTransformChanged()
override
;
93
94
BodyType m_body_type;
95
BodyID
m_body;
96
std::vector<ActiveContact> m_active_contacts;
97
bool
m_registration_requested =
false
;
98
};
99
100
}
body.hpp
Body identifiers, creation data, and copied runtime state.
assets::Handle
Type-safe smart pointer for assets.
Definition
core_types.hpp:149
physics::Simulator
Definition
simulator.hpp:57
toast::Box
Intrusive reference-counted handle to a Node.
Definition
box.hpp:35
toast::Node3D
Definition
node_3d.hpp:25
toast::Node::type
auto type() const noexcept -> NodeType
Definition
node.hpp:192
collision.hpp
Canonical collision-pair records shared by broad and narrow phases.
node_3d.hpp
Node with 3D spatial transforms.
physics_material.hpp
TODO: Brief description of the file's purpose.
shape.hpp
Shape identifiers, geometry, and runtime records.
physics::BodyDescriptor
Definition
body.hpp:32
physics::BodyID
Definition
body.hpp:20
physics::BroadPhasePair
Definition
collision.hpp:24
engine
src
toast
physics
nodes
rigidbody.hpp
Generated by
1.17.0