Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
trigger.hpp
Go to the documentation of this file.
1
7
8
#pragma once
9
#include "
../body.hpp
"
10
11
#include <span>
12
#include <
toast/events/signals.hpp
>
13
#include <
toast/world/node_3d.hpp
>
14
#include <vector>
15
16
namespace
physics {
17
22
class
TOAST_API [[ToastNode, Icon(
"Area"
), Color(
"Green"
)]]
Trigger
:
public
toast::Node3D
{
23
friend
class
Simulator;
24
25
public
:
26
signals::Signal<toast::Box<toast::Node3D>> on_enter;
27
signals::Signal<toast::Box<toast::Node3D>> on_exit;
28
29
[[Reflect]]
30
auto
getCurrentCollisions()
const
-> std::vector<toast::Box<toast::Node3D>>;
31
32
auto
isInside(
const
toast::Node3D
& node)
const
-> bool;
33
34
[[Reflect]]
35
auto
empty()
const
-> bool;
36
37
[[Reflect]]
38
void
enableCollider(
bool
value);
39
40
[[Reflect]]
41
void
includeLayer(
int
layer,
bool
value =
true
);
42
43
[[Reflect]]
44
void
excludeLayer(
int
layer,
bool
value =
true
);
45
46
[[Reflect, Layers(
"excluded"
), Name(
"Layers"
)]]
47
uint32_t included = 2;
// Trigger
48
49
[[Reflect, LayersExcluded]]
50
uint32_t excluded = 0;
51
53
[[Reflect, Color]]
54
glm::vec4
debug_color
= glm::vec4(0.0f, 1.0f, 0.251f, 0.5f);
55
57
[[Reflect, Color]]
58
glm::vec4
empty_color
= glm::vec4(0.5f, 0.5f, 0.5f, 0.5f);
59
60
private
:
61
struct
Overlap {
62
BodyID
body;
63
toast::Box<toast::Node3D>
node;
64
};
65
66
void
begin();
67
void
end();
68
void
onDisable();
69
void
updateOverlaps(std::span<const BodyID> bodies);
70
void
applyDebugColor();
71
72
void
updateInspectorMessages()
override
;
73
74
std::vector<Overlap> m_current;
75
};
76
77
}
body.hpp
Body identifiers, creation data, and copied runtime state.
physics::Trigger
Definition
trigger.hpp:22
physics::Trigger::empty_color
glm::vec4 empty_color
Color of the collider while nothing is inside.
Definition
trigger.hpp:58
physics::Trigger::debug_color
glm::vec4 debug_color
Color of the collider while something is inside.
Definition
trigger.hpp:54
toast::Box
Intrusive reference-counted handle to a Node.
Definition
box.hpp:35
toast::Node3D
Definition
node_3d.hpp:25
node_3d.hpp
Node with 3D spatial transforms.
signals.hpp
physics::BodyID
Definition
body.hpp:20
engine
src
toast
physics
nodes
trigger.hpp
Generated by
1.17.0