Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
dynamic_rigidbody.hpp
1
8
9
#pragma once
10
#include "rigidbody.hpp"
11
12
namespace
physics {
13
14
class
[[ToastNode, Icon(
"RigidBody"
)]] TOAST_API DynamicRigidbody :
public
physics::Rigidbody
{
15
friend
class
Simulator;
16
17
public
:
18
DynamicRigidbody() : Rigidbody(BodyType::dynamic_body) { }
19
20
signals::Signal<> went_to_sleep;
21
signals::Signal<> woke_up;
22
23
[[Reflect]]
24
void
sleep();
25
[[Reflect]]
26
void
wake();
27
[[Reflect]]
28
void
setLinearVelocity(
const
glm::vec3& velocity);
29
[[Reflect]]
30
void
setPosition(
const
glm::vec3& position);
31
[[Reflect]]
32
void
setRotation(
const
glm::quat& rotation);
33
34
[[Reflect, Unit(
"kg"
)]]
35
float
mass = 1.0f;
36
[[Reflect]]
37
float
gravity_scale = 1.0f;
38
[[Reflect]]
39
bool
allow_sleep =
true
;
40
[[Reflect, ReadOnly]]
41
bool
awake =
true
;
42
43
[[Reflect, Group(
"Drag"
), Unit(
"1/s"
)]]
44
float
linear_damping = 0.0f;
45
[[Reflect, Group(
"Drag"
), Unit(
"1/s"
)]]
46
float
angular_damping = 0.0f;
47
[[Reflect, Group(
"Drag"
)]]
48
float
drag_scale = 1.0f;
49
50
// TODO:
51
52
[[Reflect, Group(
"Mass Distribution"
), Unit(
"m"
), ReadOnly]]
53
glm::vec3 center_of_mass = {};
54
[[Reflect, Group(
"Mass Distribution"
), Unit(
"kg•m²"
), ReadOnly]]
55
glm::vec3 inertia = {};
56
57
[[Reflect, Group(
"Velocities"
), Unit(
"m/s"
), ReadOnly]]
58
glm::vec3 linear_velocity = {};
59
[[Reflect, Group(
"Velocities"
), Unit(
"rad/s"
), ReadOnly]]
60
glm::vec3 angular_velocity = {};
61
62
[[Reflect, Group(
"Constant Forces"
), Unit(
"N"
), ReadOnly]]
63
glm::vec3 constant_force = {};
64
[[Reflect, Group(
"Constant Forces"
), Unit(
"N•m"
), ReadOnly]]
65
glm::vec3 constant_torque = {};
66
67
private
:
68
void
publishPhysicsState(
bool
is_awake,
const
glm::vec3& current_linear_velocity,
const
glm::vec3& current_angular_velocity);
69
70
void
configureBodyDescriptor(
BodyDescriptor
& descriptor)
const override
{
71
descriptor.mass = mass;
72
descriptor.gravity_scale = gravity_scale;
73
descriptor.allow_sleep = allow_sleep;
74
descriptor.linear_damping = linear_damping;
75
descriptor.angular_damping = angular_damping;
76
descriptor.drag_scale = drag_scale;
77
}
78
};
79
80
}
physics::Rigidbody
Definition
rigidbody.hpp:22
physics::BodyDescriptor
Definition
body.hpp:32
engine
src
toast
physics
nodes
dynamic_rigidbody.hpp
Generated by
1.17.0