summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorWilson E. Alvarez <wilson.e.alvarez1@gmail.com>2021-09-16 15:28:20 -0400
committerWilson E. Alvarez <wilson.e.alvarez1@gmail.com>2021-09-16 17:51:51 -0400
commitf3a564f9a5bf7f5a9c99253b7d9ac37fb65bff8e (patch)
tree1c69b67416382df32ff0aae33f5eaadd01840e6a /scene/main
parent3581b893ed2dc1e444618ac40dc26dd58fe1219a (diff)
Rename Listener2D/Listener3D to AudioListener2D/AudioListener3D
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/viewport.cpp100
-rw-r--r--scene/main/viewport.h42
2 files changed, 71 insertions, 71 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index fb86d37280..cef1b830df 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -35,13 +35,13 @@
#include "core/object/message_queue.h"
#include "core/string/translation.h"
#include "core/templates/pair.h"
+#include "scene/2d/audio_listener_2d.h"
#include "scene/2d/camera_2d.h"
#include "scene/2d/collision_object_2d.h"
-#include "scene/2d/listener_2d.h"
#ifndef _3D_DISABLED
+#include "scene/3d/audio_listener_3d.h"
#include "scene/3d/camera_3d.h"
#include "scene/3d/collision_object_3d.h"
-#include "scene/3d/listener_3d.h"
#include "scene/3d/world_environment.h"
#endif // _3D_DISABLED
#include "scene/gui/control.h"
@@ -381,10 +381,10 @@ void Viewport::_notification(int p_what) {
current_canvas = find_world_2d()->get_canvas();
RenderingServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas);
- _update_listener_2d();
+ _update_audio_listener_2d();
#ifndef _3D_DISABLED
RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world_3d()->get_scenario());
- _update_listener_3d();
+ _update_audio_listener_3d();
#endif // _3D_DISABLED
add_to_group("_viewports");
@@ -408,9 +408,9 @@ void Viewport::_notification(int p_what) {
} break;
case NOTIFICATION_READY: {
#ifndef _3D_DISABLED
- if (listener_3d_set.size() && !listener_3d) {
- Listener3D *first = nullptr;
- for (Set<Listener3D *>::Element *E = listener_3d_set.front(); E; E = E->next()) {
+ if (audio_listener_3d_set.size() && !audio_listener_3d) {
+ AudioListener3D *first = nullptr;
+ for (Set<AudioListener3D *>::Element *E = audio_listener_3d_set.front(); E; E = E->next()) {
if (first == nullptr || first->is_greater_than(E->get())) {
first = E->get();
}
@@ -822,27 +822,27 @@ Rect2 Viewport::get_visible_rect() const {
return r;
}
-void Viewport::_update_listener_2d() {
+void Viewport::_update_audio_listener_2d() {
if (AudioServer::get_singleton()) {
AudioServer::get_singleton()->notify_listener_changed();
}
}
void Viewport::set_as_audio_listener_2d(bool p_enable) {
- if (p_enable == audio_listener_2d) {
+ if (p_enable == is_audio_listener_2d_enabled) {
return;
}
- audio_listener_2d = p_enable;
- _update_listener_2d();
+ is_audio_listener_2d_enabled = p_enable;
+ _update_audio_listener_2d();
}
bool Viewport::is_audio_listener_2d() const {
- return audio_listener_2d;
+ return is_audio_listener_2d_enabled;
}
-Listener2D *Viewport::get_listener_2d() const {
- return listener_2d;
+AudioListener2D *Viewport::get_audio_listener_2d() const {
+ return audio_listener_2d;
}
void Viewport::enable_canvas_transform_override(bool p_enable) {
@@ -909,18 +909,18 @@ void Viewport::_camera_2d_set(Camera2D *p_camera_2d) {
camera_2d = p_camera_2d;
}
-void Viewport::_listener_2d_set(Listener2D *p_listener) {
- if (listener_2d == p_listener) {
+void Viewport::_audio_listener_2d_set(AudioListener2D *p_listener) {
+ if (audio_listener_2d == p_listener) {
return;
- } else if (listener_2d) {
- listener_2d->clear_current();
+ } else if (audio_listener_2d) {
+ audio_listener_2d->clear_current();
}
- listener_2d = p_listener;
+ audio_listener_2d = p_listener;
}
-void Viewport::_listener_2d_remove(Listener2D *p_listener) {
- if (listener_2d == p_listener) {
- listener_2d = nullptr;
+void Viewport::_audio_listener_2d_remove(AudioListener2D *p_listener) {
+ if (audio_listener_2d == p_listener) {
+ audio_listener_2d = nullptr;
}
}
@@ -962,7 +962,7 @@ void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) {
world_2d = Ref<World2D>(memnew(World2D));
}
- _update_listener_2d();
+ _update_audio_listener_2d();
if (is_inside_tree()) {
current_canvas = find_world_2d()->get_canvas();
@@ -3047,24 +3047,24 @@ Viewport::SDFScale Viewport::get_sdf_scale() const {
}
#ifndef _3D_DISABLED
-Listener3D *Viewport::get_listener_3d() const {
- return listener_3d;
+AudioListener3D *Viewport::get_audio_listener_3d() const {
+ return audio_listener_3d;
}
void Viewport::set_as_audio_listener_3d(bool p_enable) {
- if (p_enable == audio_listener_3d) {
+ if (p_enable == is_audio_listener_3d_enabled) {
return;
}
- audio_listener_3d = p_enable;
- _update_listener_3d();
+ is_audio_listener_3d_enabled = p_enable;
+ _update_audio_listener_3d();
}
bool Viewport::is_audio_listener_3d() const {
- return audio_listener_3d;
+ return is_audio_listener_3d_enabled;
}
-void Viewport::_update_listener_3d() {
+void Viewport::_update_audio_listener_3d() {
if (AudioServer::get_singleton()) {
AudioServer::get_singleton()->notify_listener_changed();
}
@@ -3073,39 +3073,39 @@ void Viewport::_update_listener_3d() {
void Viewport::_listener_transform_3d_changed_notify() {
}
-void Viewport::_listener_3d_set(Listener3D *p_listener) {
- if (listener_3d == p_listener) {
+void Viewport::_audio_listener_3d_set(AudioListener3D *p_listener) {
+ if (audio_listener_3d == p_listener) {
return;
}
- listener_3d = p_listener;
+ audio_listener_3d = p_listener;
- _update_listener_3d();
+ _update_audio_listener_3d();
_listener_transform_3d_changed_notify();
}
-bool Viewport::_listener_3d_add(Listener3D *p_listener) {
- listener_3d_set.insert(p_listener);
- return listener_3d_set.size() == 1;
+bool Viewport::_audio_listener_3d_add(AudioListener3D *p_listener) {
+ audio_listener_3d_set.insert(p_listener);
+ return audio_listener_3d_set.size() == 1;
}
-void Viewport::_listener_3d_remove(Listener3D *p_listener) {
- listener_3d_set.erase(p_listener);
- if (listener_3d == p_listener) {
- listener_3d = nullptr;
+void Viewport::_audio_listener_3d_remove(AudioListener3D *p_listener) {
+ audio_listener_3d_set.erase(p_listener);
+ if (audio_listener_3d == p_listener) {
+ audio_listener_3d = nullptr;
}
}
-void Viewport::_listener_3d_make_next_current(Listener3D *p_exclude) {
- if (listener_3d_set.size() > 0) {
- for (Set<Listener3D *>::Element *E = listener_3d_set.front(); E; E = E->next()) {
+void Viewport::_audio_listener_3d_make_next_current(AudioListener3D *p_exclude) {
+ if (audio_listener_3d_set.size() > 0) {
+ for (Set<AudioListener3D *>::Element *E = audio_listener_3d_set.front(); E; E = E->next()) {
if (p_exclude == E->get()) {
continue;
}
if (!E->get()->is_inside_tree()) {
continue;
}
- if (listener_3d != nullptr) {
+ if (audio_listener_3d != nullptr) {
return;
}
@@ -3114,7 +3114,7 @@ void Viewport::_listener_3d_make_next_current(Listener3D *p_exclude) {
} else {
// Attempt to reset listener to the camera position.
if (camera_3d != nullptr) {
- _update_listener_3d();
+ _update_audio_listener_3d();
_camera_3d_transform_changed_notify();
}
}
@@ -3168,7 +3168,7 @@ void Viewport::_camera_3d_set(Camera3D *p_camera) {
camera_3d->notification(Camera3D::NOTIFICATION_BECAME_CURRENT);
}
- _update_listener_3d();
+ _update_audio_listener_3d();
_camera_3d_transform_changed_notify();
}
@@ -3330,7 +3330,7 @@ void Viewport::set_world_3d(const Ref<World3D> &p_world_3d) {
RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world_3d()->get_scenario());
}
- _update_listener_3d();
+ _update_audio_listener_3d();
}
void Viewport::_own_world_3d_changed() {
@@ -3351,7 +3351,7 @@ void Viewport::_own_world_3d_changed() {
RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world_3d()->get_scenario());
}
- _update_listener_3d();
+ _update_audio_listener_3d();
}
void Viewport::set_use_own_world_3d(bool p_world_3d) {
@@ -3385,7 +3385,7 @@ void Viewport::set_use_own_world_3d(bool p_world_3d) {
RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world_3d()->get_scenario());
}
- _update_listener_3d();
+ _update_audio_listener_3d();
}
bool Viewport::is_using_own_world_3d() const {
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index bfb52c4b98..3732f9cfd1 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -37,11 +37,11 @@
#ifndef _3D_DISABLED
class Camera3D;
class CollisionObject3D;
-class Listener3D;
+class AudioListener3D;
class World3D;
#endif // _3D_DISABLED
-class Listener2D;
+class AudioListener2D;
class Camera2D;
class CanvasItem;
class CanvasLayer;
@@ -202,7 +202,7 @@ private:
Viewport *parent = nullptr;
- Listener2D *listener_2d = nullptr;
+ AudioListener2D *audio_listener_2d = nullptr;
Camera2D *camera_2d = nullptr;
Set<CanvasLayer *> canvas_layers;
@@ -210,8 +210,8 @@ private:
RID current_canvas;
RID subwindow_canvas;
- bool audio_listener_2d = false;
- RID internal_listener_2d;
+ bool is_audio_listener_2d_enabled = false;
+ RID internal_audio_listener_2d;
bool override_canvas_transform = false;
@@ -274,7 +274,7 @@ private:
StringName unhandled_input_group;
StringName unhandled_key_input_group;
- void _update_listener_2d();
+ void _update_audio_listener_2d();
bool disable_3d = false;
@@ -418,9 +418,9 @@ private:
bool _gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check);
- friend class Listener2D;
- void _listener_2d_set(Listener2D *p_listener);
- void _listener_2d_remove(Listener2D *p_listener);
+ friend class AudioListener2D;
+ void _audio_listener_2d_set(AudioListener2D *p_listener);
+ void _audio_listener_2d_remove(AudioListener2D *p_listener);
friend class Camera2D;
void _camera_2d_set(Camera2D *p_camera_2d);
@@ -463,7 +463,7 @@ protected:
public:
uint64_t get_processed_events_count() const { return event_count; }
- Listener2D *get_listener_2d() const;
+ AudioListener2D *get_audio_listener_2d() const;
Camera2D *get_camera_2d() const;
void set_as_audio_listener_2d(bool p_enable);
bool is_audio_listener_2d() const;
@@ -593,20 +593,20 @@ public:
#ifndef _3D_DISABLED
bool use_xr = false;
Scale3D scale_3d = SCALE_3D_DISABLED;
- friend class Listener3D;
- Listener3D *listener_3d = nullptr;
- Set<Listener3D *> listener_3d_set;
- bool audio_listener_3d = false;
- RID internal_listener_3d;
- Listener3D *get_listener_3d() const;
+ friend class AudioListener3D;
+ AudioListener3D *audio_listener_3d = nullptr;
+ Set<AudioListener3D *> audio_listener_3d_set;
+ bool is_audio_listener_3d_enabled = false;
+ RID internal_audio_listener_3d;
+ AudioListener3D *get_audio_listener_3d() const;
void set_as_audio_listener_3d(bool p_enable);
bool is_audio_listener_3d() const;
- void _update_listener_3d();
+ void _update_audio_listener_3d();
void _listener_transform_3d_changed_notify();
- void _listener_3d_set(Listener3D *p_listener);
- bool _listener_3d_add(Listener3D *p_listener); //true if first
- void _listener_3d_remove(Listener3D *p_listener);
- void _listener_3d_make_next_current(Listener3D *p_exclude);
+ void _audio_listener_3d_set(AudioListener3D *p_listener);
+ bool _audio_listener_3d_add(AudioListener3D *p_listener); //true if first
+ void _audio_listener_3d_remove(AudioListener3D *p_listener);
+ void _audio_listener_3d_make_next_current(AudioListener3D *p_exclude);
void _collision_object_3d_input_event(CollisionObject3D *p_object, Camera3D *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape);