Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
volume.hpp
Go to the documentation of this file.
1
8
9
#pragma once
10
#include "
toast/events/signals.hpp
"
11
12
#include <
toast/export.hpp
>
13
#include <
toast/world/node_3d.hpp
>
14
15
namespace
toast {
16
class
AudioListener
;
17
19
struct
VolumeTarget
{
21
Box<AudioListener>
listener
;
22
23
glm::vec3 position;
24
glm::vec3 forward;
25
};
26
27
class
TOAST_API [[ToastNode, Hidden, Interface, Icon(
"Area"
)]]
Volume
:
public
Node3D
{
28
public
:
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
59
protected:
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
77
private:
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
}
toast::AudioListener
Definition
audio_listener.hpp:15
toast::Box
Intrusive reference-counted handle to a Node.
Definition
box.hpp:35
toast::Node3D
Definition
node_3d.hpp:25
toast::Node
Definition
node.hpp:81
toast::Reflect
Definition
reflect.hpp:244
toast::Volume
Definition
volume.hpp:27
toast::Volume::evaluateTarget
virtual auto evaluateTarget(const VolumeTarget &target, float weight=1.0f) -> bool=0
Evaluates if a target is inside the volume or not.
toast::Volume::calculateWeight
auto calculateWeight(const VolumeTarget &target) const -> float
<
Definition
volume.cpp:103
toast::Volume::closestPointOnBounds
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
export.hpp
node_3d.hpp
Node with 3D spatial transforms.
signals.hpp
toast::VolumeTarget
What a volume is being evaluated against: a listener, a camera, anything with a position.
Definition
volume.hpp:19
toast::VolumeTarget::listener
Box< AudioListener > listener
Audio only, and the identity AudioVolume tracks enter/exit by. Empty for every other kind of target.
Definition
volume.hpp:21
engine
src
toast
world
volume.hpp
Generated by
1.17.0