Toast Engine
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>
14#include <vector>
15
16namespace physics {
17
22class TOAST_API [[ToastNode, Icon("Area"), Color("Green")]] Trigger : public toast::Node3D {
23 friend class Simulator;
24
25public:
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
60private:
61 struct Overlap {
62 BodyID body;
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 identifiers, creation data, and copied runtime state.
Definition trigger.hpp:22
glm::vec4 empty_color
Color of the collider while nothing is inside.
Definition trigger.hpp:58
glm::vec4 debug_color
Color of the collider while something is inside.
Definition trigger.hpp:54
Intrusive reference-counted handle to a Node.
Definition box.hpp:35
Definition node_3d.hpp:25
Node with 3D spatial transforms.
Definition body.hpp:20