Toast Engine
Loading...
Searching...
No Matches
volume.hpp
Go to the documentation of this file.
1
8
9#pragma once
11
12#include <toast/export.hpp>
14
15namespace toast {
16class AudioListener;
17
22
23 glm::vec3 position;
24 glm::vec3 forward;
25};
26
27class TOAST_API [[ToastNode, Hidden, Interface, Icon("Area")]] Volume : public Node3D {
28public:
29 [[Reflect, Color]]
30 glm::vec4 debug_color = glm::vec4(0.0f, 1.0f, 0.251f, 0.5f);
31 [[Reflect]]
32 bool debug_fill = true;
37 virtual auto evaluateTarget(const VolumeTarget& target, float weight = 1.0f) -> bool = 0;
38 virtual void resetAccumulators() = 0;
39
40 [[nodiscard]]
41 auto isGlobal() const -> bool;
42 void isGlobal(bool value);
43
44 [[nodiscard]]
45 auto priority() const -> int8_t;
46 void priority(int8_t value);
47
48 [[nodiscard]]
49 auto weight() const -> float;
50 void weight(float value);
51
52 [[nodiscard]]
53 auto blendDistance() const -> float;
54 void blendDistance(float value);
55
56 signals::Signal<Box<Node>> node_exited; // TODO:
57 signals::Signal<Box<Node>> node_entered; // TODO:
58
59protected:
60 void updateInspectorMessages() override;
61
62 [[nodiscard]]
64 auto calculateWeight(const VolumeTarget& target) const -> float;
65
74 [[nodiscard]]
75 virtual auto closestPointOnBounds(glm::vec3 point) const -> glm::vec3;
76
77private:
78 void init();
79 void destroy();
80 void onEnable();
81 void onDisable();
82 void drawDebug();
83 bool m_debug_visible = false;
84 [[Reflect]]
85 bool m_is_global = false;
86
87 [[Reflect]]
88 int8_t m_priority = 0;
89
90 [[Reflect, Range(0.0, 1.0)]]
91 float m_weight = 1.0f;
92
93 [[Reflect, Unit("m")]]
94 float m_blend_distance = 0.0f;
95};
96
97}
Definition audio_listener.hpp:15
Intrusive reference-counted handle to a Node.
Definition box.hpp:35
Definition node_3d.hpp:25
Definition node.hpp:81
Definition reflect.hpp:244
Definition volume.hpp:27
virtual auto evaluateTarget(const VolumeTarget &target, float weight=1.0f) -> bool=0
Evaluates if a target is inside the volume or not.
auto calculateWeight(const VolumeTarget &target) const -> float
<
Definition volume.cpp:103
virtual auto closestPointOnBounds(glm::vec3 point) const -> glm::vec3
Calculates the point on the bounds of the volume that is closest to the given point.
Definition volume.cpp:119
Node with 3D spatial transforms.
What a volume is being evaluated against: a listener, a camera, anything with a position.
Definition volume.hpp:19
Box< AudioListener > listener
Audio only, and the identity AudioVolume tracks enter/exit by. Empty for every other kind of target.
Definition volume.hpp:21