Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
audio_volume.hpp
1
8
9
#pragma once
10
#include <
toast/export.hpp
>
11
#include <
toast/world/box.hpp
>
12
#include <
toast/world/volume.hpp
>
13
#include <vector>
14
15
namespace
toast {
16
class
AudioListener
;
17
25
class
TOAST_API [[ToastNode, Hidden, Interface, Color(
"Beige"
)]]
AudioVolume
:
public
Volume
{
26
public
:
27
virtual
void
onAudioTargetEnter(
const
VolumeTarget
& target) = 0;
28
virtual
void
onAudioTargetExit(
const
VolumeTarget
& target) = 0;
29
void
resetAccumulators()
override
;
30
void
finalizeAccumulators();
31
32
void
setListeners(
const
std::vector<
Box<AudioListener>
>& listeners);
33
34
protected
:
35
[[nodiscard]]
36
auto
trackTarget
(
const
VolumeTarget
& target,
bool
inside) -> bool;
37
[[nodiscard]]
38
auto
hasListenersInside()
const
-> bool;
39
40
virtual
void
onVolumeTick
() { }
41
42
private
:
43
void
begin();
44
void
end();
45
void
onEnable();
46
void
onDisable();
47
void
lateTick();
48
49
struct
ListenerState {
50
VolumeTarget
target;
51
bool
inside =
false
;
52
};
53
54
std::vector<ListenerState> m_listeners_inside;
55
std::vector<ListenerState> m_pending_targets;
56
std::vector<Box<AudioListener>> m_listeners;
57
};
58
59
}
box.hpp
pseudo shared pointer for Nodes
toast::AudioListener
Definition
audio_listener.hpp:15
toast::AudioVolume
Base interface for audio-reactive volumes.
Definition
audio_volume.hpp:25
toast::AudioVolume::onVolumeTick
virtual void onVolumeTick()
called after accumulators are finalized, safe to push to FMOD here
Definition
audio_volume.hpp:40
toast::AudioVolume::trackTarget
auto trackTarget(const VolumeTarget &target, bool inside) -> bool
returns true if the inside state changed
Definition
audio_volume.cpp:34
toast::Box
Intrusive reference-counted handle to a Node.
Definition
box.hpp:35
toast::Volume
Definition
volume.hpp:27
export.hpp
toast::VolumeTarget
What a volume is being evaluated against: a listener, a camera, anything with a position.
Definition
volume.hpp:19
volume.hpp
Generic cubic volume.
engine
src
toast
audio
nodes
audio_volume.hpp
Generated by
1.17.0