Rename Listener2D/Listener3D to AudioListener2D/AudioListener3D
This commit is contained in:
parent
3581b893ed
commit
f3a564f9a5
19 changed files with 191 additions and 191 deletions
35
doc/classes/AudioListener2D.xml
Normal file
35
doc/classes/AudioListener2D.xml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="AudioListener2D" inherits="Node2D" version="4.0">
|
||||
<brief_description>
|
||||
Overrides the location sounds are heard from.
|
||||
</brief_description>
|
||||
<description>
|
||||
Once added to the scene tree and enabled using [method make_current], this node will override the location sounds are heard from. Only one [AudioListener2D] can be current. Using [method make_current] will disable the previous [AudioListener2D].
|
||||
If there is no active [AudioListener2D] in the current [Viewport], center of the screen will be used as a hearing point for the audio. [AudioListener2D] needs to be inside [SceneTree] to function.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="clear_current">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Disables the [AudioListener2D]. If it's not set as current, this method will have no effect.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_current" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if this [AudioListener2D] is currently active.
|
||||
</description>
|
||||
</method>
|
||||
<method name="make_current">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Makes the [AudioListener2D] active, setting it as the hearing point for the sounds. If there is already another active [AudioListener2D], it will be disabled.
|
||||
This method will have no effect if the [AudioListener2D] is not added to [SceneTree].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="Listener3D" inherits="Node3D" version="4.0">
|
||||
<class name="AudioListener3D" inherits="Node3D" version="4.0">
|
||||
<brief_description>
|
||||
Overrides the location sounds are heard from.
|
||||
</brief_description>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the listener was made current using [method make_current], [code]false[/code] otherwise.
|
||||
[b]Note:[/b] There may be more than one Listener3D marked as "current" in the scene tree, but only the one that was made current last will be used.
|
||||
[b]Note:[/b] There may be more than one AudioListener3D marked as "current" in the scene tree, but only the one that was made current last will be used.
|
||||
</description>
|
||||
</method>
|
||||
<method name="make_current">
|
|
@ -5,7 +5,7 @@
|
|||
</brief_description>
|
||||
<description>
|
||||
Plays a sound effect with directed sound effects, dampens with distance if needed, generates effect of hearable position in space. For greater realism, a low-pass filter is automatically applied to distant sounds. This can be disabled by setting [member attenuation_filter_cutoff_hz] to [code]20500[/code].
|
||||
By default, audio is heard from the camera position. This can be changed by adding a [Listener3D] node to the scene and enabling it by calling [method Listener3D.make_current] on it.
|
||||
By default, audio is heard from the camera position. This can be changed by adding a [AudioListener3D] node to the scene and enabling it by calling [method AudioListener3D.make_current] on it.
|
||||
See also [AudioStreamPlayer] to play a sound non-positionally.
|
||||
[b]Note:[/b] Hiding an [AudioStreamPlayer3D] node does not disable its audio output. To temporarily disable an [AudioStreamPlayer3D]'s audio output, set [member unit_db] to a very low value like [code]-100[/code] (which isn't audible to human hearing).
|
||||
</description>
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="Listener2D" inherits="Node2D" version="4.0">
|
||||
<brief_description>
|
||||
Overrides the location sounds are heard from.
|
||||
</brief_description>
|
||||
<description>
|
||||
Once added to the scene tree and enabled using [method make_current], this node will override the location sounds are heard from. Only one [Listener2D] can be current. Using [method make_current] will disable the previous [Listener2D].
|
||||
If there is no active [Listener2D] in the current [Viewport], center of the screen will be used as a hearing point for the audio. [Listener2D] needs to be inside [SceneTree] to function.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="clear_current">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Disables the [Listener2D]. If it's not set as current, this method will have no effect.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_current" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if this [Listener2D] is currently active.
|
||||
</description>
|
||||
</method>
|
||||
<method name="make_current">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Makes the [Listener2D] active, setting it as the hearing point for the sounds. If there is already another active [Listener2D], it will be disabled.
|
||||
This method will have no effect if the [Listener2D] is not added to [SceneTree].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
Before Width: | Height: | Size: 701 B After Width: | Height: | Size: 701 B |
Before Width: | Height: | Size: 701 B After Width: | Height: | Size: 701 B |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
|
@ -34,6 +34,7 @@
|
|||
#include "core/math/geometry_2d.h"
|
||||
#include "core/math/geometry_3d.h"
|
||||
#include "editor/plugins/node_3d_editor_plugin.h"
|
||||
#include "scene/3d/audio_listener_3d.h"
|
||||
#include "scene/3d/audio_stream_player_3d.h"
|
||||
#include "scene/3d/camera_3d.h"
|
||||
#include "scene/3d/collision_polygon_3d.h"
|
||||
|
@ -45,7 +46,6 @@
|
|||
#include "scene/3d/light_3d.h"
|
||||
#include "scene/3d/lightmap_gi.h"
|
||||
#include "scene/3d/lightmap_probe.h"
|
||||
#include "scene/3d/listener_3d.h"
|
||||
#include "scene/3d/mesh_instance_3d.h"
|
||||
#include "scene/3d/navigation_region_3d.h"
|
||||
#include "scene/3d/occluder_instance_3d.h"
|
||||
|
@ -1619,24 +1619,24 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
|
||||
//////
|
||||
|
||||
Listener3DGizmoPlugin::Listener3DGizmoPlugin() {
|
||||
create_icon_material("listener_3d_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoListener3D", "EditorIcons"));
|
||||
AudioListener3DGizmoPlugin::AudioListener3DGizmoPlugin() {
|
||||
create_icon_material("audio_listener_3d_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoAudioListener3D", "EditorIcons"));
|
||||
}
|
||||
|
||||
bool Listener3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
|
||||
return Object::cast_to<Listener3D>(p_spatial) != nullptr;
|
||||
bool AudioListener3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
|
||||
return Object::cast_to<AudioListener3D>(p_spatial) != nullptr;
|
||||
}
|
||||
|
||||
String Listener3DGizmoPlugin::get_gizmo_name() const {
|
||||
return "Listener3D";
|
||||
String AudioListener3DGizmoPlugin::get_gizmo_name() const {
|
||||
return "AudioListener3D";
|
||||
}
|
||||
|
||||
int Listener3DGizmoPlugin::get_priority() const {
|
||||
int AudioListener3DGizmoPlugin::get_priority() const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Listener3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
const Ref<Material> icon = get_material("listener_3d_icon", p_gizmo);
|
||||
void AudioListener3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
const Ref<Material> icon = get_material("audio_listener_3d_icon", p_gizmo);
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05);
|
||||
}
|
||||
|
||||
|
|
|
@ -249,8 +249,8 @@ public:
|
|||
AudioStreamPlayer3DGizmoPlugin();
|
||||
};
|
||||
|
||||
class Listener3DGizmoPlugin : public EditorNode3DGizmoPlugin {
|
||||
GDCLASS(Listener3DGizmoPlugin, EditorNode3DGizmoPlugin);
|
||||
class AudioListener3DGizmoPlugin : public EditorNode3DGizmoPlugin {
|
||||
GDCLASS(AudioListener3DGizmoPlugin, EditorNode3DGizmoPlugin);
|
||||
|
||||
public:
|
||||
bool has_gizmo(Node3D *p_spatial) override;
|
||||
|
@ -259,7 +259,7 @@ public:
|
|||
|
||||
void redraw(EditorNode3DGizmo *p_gizmo) override;
|
||||
|
||||
Listener3DGizmoPlugin();
|
||||
AudioListener3DGizmoPlugin();
|
||||
};
|
||||
|
||||
class Camera3DGizmoPlugin : public EditorNode3DGizmoPlugin {
|
||||
|
|
|
@ -6863,7 +6863,7 @@ void Node3DEditor::_register_all_gizmos() {
|
|||
add_gizmo_plugin(Ref<Camera3DGizmoPlugin>(memnew(Camera3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<Light3DGizmoPlugin>(memnew(Light3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<AudioStreamPlayer3DGizmoPlugin>(memnew(AudioStreamPlayer3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<Listener3DGizmoPlugin>(memnew(Listener3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<AudioListener3DGizmoPlugin>(memnew(AudioListener3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<MeshInstance3DGizmoPlugin>(memnew(MeshInstance3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<OccluderInstance3DGizmoPlugin>(memnew(OccluderInstance3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<SoftDynamicBody3DGizmoPlugin>(memnew(SoftDynamicBody3DGizmoPlugin)));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* listener_2d.cpp */
|
||||
/* audio_listener_2d.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,9 +28,9 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "listener_2d.h"
|
||||
#include "audio_listener_2d.h"
|
||||
|
||||
bool Listener2D::_set(const StringName &p_name, const Variant &p_value) {
|
||||
bool AudioListener2D::_set(const StringName &p_name, const Variant &p_value) {
|
||||
if (p_name == "current") {
|
||||
if (p_value.operator bool()) {
|
||||
make_current();
|
||||
|
@ -43,7 +43,7 @@ bool Listener2D::_set(const StringName &p_name, const Variant &p_value) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Listener2D::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
bool AudioListener2D::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (p_name == "current") {
|
||||
if (is_inside_tree() && get_tree()->is_node_being_edited(this)) {
|
||||
r_ret = current;
|
||||
|
@ -56,11 +56,11 @@ bool Listener2D::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Listener2D::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
void AudioListener2D::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::BOOL, "current"));
|
||||
}
|
||||
|
||||
void Listener2D::_notification(int p_what) {
|
||||
void AudioListener2D::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
if (!get_tree()->is_node_being_edited(this) && current) {
|
||||
|
@ -80,33 +80,33 @@ void Listener2D::_notification(int p_what) {
|
|||
}
|
||||
}
|
||||
|
||||
void Listener2D::make_current() {
|
||||
void AudioListener2D::make_current() {
|
||||
current = true;
|
||||
if (!is_inside_tree()) {
|
||||
return;
|
||||
}
|
||||
get_viewport()->_listener_2d_set(this);
|
||||
get_viewport()->_audio_listener_2d_set(this);
|
||||
}
|
||||
|
||||
void Listener2D::clear_current() {
|
||||
void AudioListener2D::clear_current() {
|
||||
current = false;
|
||||
if (!is_inside_tree()) {
|
||||
return;
|
||||
}
|
||||
get_viewport()->_listener_2d_remove(this);
|
||||
get_viewport()->_audio_listener_2d_remove(this);
|
||||
}
|
||||
|
||||
bool Listener2D::is_current() const {
|
||||
bool AudioListener2D::is_current() const {
|
||||
if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) {
|
||||
return get_viewport()->get_listener_2d() == this;
|
||||
return get_viewport()->get_audio_listener_2d() == this;
|
||||
} else {
|
||||
return current;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Listener2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("make_current"), &Listener2D::make_current);
|
||||
ClassDB::bind_method(D_METHOD("clear_current"), &Listener2D::clear_current);
|
||||
ClassDB::bind_method(D_METHOD("is_current"), &Listener2D::is_current);
|
||||
void AudioListener2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("make_current"), &AudioListener2D::make_current);
|
||||
ClassDB::bind_method(D_METHOD("clear_current"), &AudioListener2D::clear_current);
|
||||
ClassDB::bind_method(D_METHOD("is_current"), &AudioListener2D::is_current);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* listener_2d.h */
|
||||
/* audio_listener_2d.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -34,8 +34,8 @@
|
|||
#include "scene/2d/node_2d.h"
|
||||
#include "scene/main/window.h"
|
||||
|
||||
class Listener2D : public Node2D {
|
||||
GDCLASS(Listener2D, Node2D);
|
||||
class AudioListener2D : public Node2D {
|
||||
GDCLASS(AudioListener2D, Node2D);
|
||||
|
||||
private:
|
||||
bool current = false;
|
|
@ -31,7 +31,7 @@
|
|||
#include "audio_stream_player_2d.h"
|
||||
|
||||
#include "scene/2d/area_2d.h"
|
||||
#include "scene/2d/listener_2d.h"
|
||||
#include "scene/2d/audio_listener_2d.h"
|
||||
#include "scene/main/window.h"
|
||||
|
||||
void AudioStreamPlayer2D::_notification(int p_what) {
|
||||
|
@ -156,7 +156,7 @@ void AudioStreamPlayer2D::_update_panning() {
|
|||
Vector2 relative_to_listener;
|
||||
|
||||
//screen in global is used for attenuation
|
||||
Listener2D *listener = vp->get_listener_2d();
|
||||
AudioListener2D *listener = vp->get_audio_listener_2d();
|
||||
if (listener) {
|
||||
listener_in_global = listener->get_global_position();
|
||||
relative_to_listener = global_pos - listener_in_global;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* listener_3d.cpp */
|
||||
/* audio_listener_3d.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,18 +28,18 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "listener_3d.h"
|
||||
#include "audio_listener_3d.h"
|
||||
|
||||
#include "scene/main/viewport.h"
|
||||
|
||||
void Listener3D::_update_audio_listener_state() {
|
||||
void AudioListener3D::_update_audio_listener_state() {
|
||||
}
|
||||
|
||||
void Listener3D::_request_listener_update() {
|
||||
void AudioListener3D::_request_listener_update() {
|
||||
_update_listener();
|
||||
}
|
||||
|
||||
bool Listener3D::_set(const StringName &p_name, const Variant &p_value) {
|
||||
bool AudioListener3D::_set(const StringName &p_name, const Variant &p_value) {
|
||||
if (p_name == "current") {
|
||||
if (p_value.operator bool()) {
|
||||
make_current();
|
||||
|
@ -53,7 +53,7 @@ bool Listener3D::_set(const StringName &p_name, const Variant &p_value) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Listener3D::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
bool AudioListener3D::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (p_name == "current") {
|
||||
if (is_inside_tree() && get_tree()->is_node_being_edited(this)) {
|
||||
r_ret = current;
|
||||
|
@ -67,20 +67,20 @@ bool Listener3D::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Listener3D::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
void AudioListener3D::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::BOOL, "current"));
|
||||
}
|
||||
|
||||
void Listener3D::_update_listener() {
|
||||
void AudioListener3D::_update_listener() {
|
||||
if (is_inside_tree() && is_current()) {
|
||||
get_viewport()->_listener_transform_3d_changed_notify();
|
||||
}
|
||||
}
|
||||
|
||||
void Listener3D::_notification(int p_what) {
|
||||
void AudioListener3D::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_WORLD: {
|
||||
bool first_listener = get_viewport()->_listener_3d_add(this);
|
||||
bool first_listener = get_viewport()->_audio_listener_3d_add(this);
|
||||
if (!get_tree()->is_node_being_edited(this) && (current || first_listener)) {
|
||||
make_current();
|
||||
}
|
||||
|
@ -99,41 +99,41 @@ void Listener3D::_notification(int p_what) {
|
|||
}
|
||||
}
|
||||
|
||||
get_viewport()->_listener_3d_remove(this);
|
||||
get_viewport()->_audio_listener_3d_remove(this);
|
||||
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
Transform3D Listener3D::get_listener_transform() const {
|
||||
Transform3D AudioListener3D::get_listener_transform() const {
|
||||
return get_global_transform().orthonormalized();
|
||||
}
|
||||
|
||||
void Listener3D::make_current() {
|
||||
void AudioListener3D::make_current() {
|
||||
current = true;
|
||||
|
||||
if (!is_inside_tree()) {
|
||||
return;
|
||||
}
|
||||
|
||||
get_viewport()->_listener_3d_set(this);
|
||||
get_viewport()->_audio_listener_3d_set(this);
|
||||
}
|
||||
|
||||
void Listener3D::clear_current() {
|
||||
void AudioListener3D::clear_current() {
|
||||
current = false;
|
||||
if (!is_inside_tree()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_viewport()->get_listener_3d() == this) {
|
||||
get_viewport()->_listener_3d_set(nullptr);
|
||||
get_viewport()->_listener_3d_make_next_current(this);
|
||||
if (get_viewport()->get_audio_listener_3d() == this) {
|
||||
get_viewport()->_audio_listener_3d_set(nullptr);
|
||||
get_viewport()->_audio_listener_3d_make_next_current(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool Listener3D::is_current() const {
|
||||
bool AudioListener3D::is_current() const {
|
||||
if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) {
|
||||
return get_viewport()->get_listener_3d() == this;
|
||||
return get_viewport()->get_audio_listener_3d() == this;
|
||||
} else {
|
||||
return current;
|
||||
}
|
||||
|
@ -141,16 +141,16 @@ bool Listener3D::is_current() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
void Listener3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("make_current"), &Listener3D::make_current);
|
||||
ClassDB::bind_method(D_METHOD("clear_current"), &Listener3D::clear_current);
|
||||
ClassDB::bind_method(D_METHOD("is_current"), &Listener3D::is_current);
|
||||
ClassDB::bind_method(D_METHOD("get_listener_transform"), &Listener3D::get_listener_transform);
|
||||
void AudioListener3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("make_current"), &AudioListener3D::make_current);
|
||||
ClassDB::bind_method(D_METHOD("clear_current"), &AudioListener3D::clear_current);
|
||||
ClassDB::bind_method(D_METHOD("is_current"), &AudioListener3D::is_current);
|
||||
ClassDB::bind_method(D_METHOD("get_listener_transform"), &AudioListener3D::get_listener_transform);
|
||||
}
|
||||
|
||||
Listener3D::Listener3D() {
|
||||
AudioListener3D::AudioListener3D() {
|
||||
set_notify_transform(true);
|
||||
}
|
||||
|
||||
Listener3D::~Listener3D() {
|
||||
AudioListener3D::~AudioListener3D() {
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* listener_3d.h */
|
||||
/* audio_listener_3d.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -33,8 +33,8 @@
|
|||
|
||||
#include "scene/3d/node_3d.h"
|
||||
|
||||
class Listener3D : public Node3D {
|
||||
GDCLASS(Listener3D, Node3D);
|
||||
class AudioListener3D : public Node3D {
|
||||
GDCLASS(AudioListener3D, Node3D);
|
||||
|
||||
private:
|
||||
bool force_change = false;
|
||||
|
@ -66,8 +66,8 @@ public:
|
|||
void set_visible_layers(uint32_t p_layers);
|
||||
uint32_t get_visible_layers() const;
|
||||
|
||||
Listener3D();
|
||||
~Listener3D();
|
||||
AudioListener3D();
|
||||
~AudioListener3D();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -31,8 +31,8 @@
|
|||
#include "audio_stream_player_3d.h"
|
||||
|
||||
#include "scene/3d/area_3d.h"
|
||||
#include "scene/3d/audio_listener_3d.h"
|
||||
#include "scene/3d/camera_3d.h"
|
||||
#include "scene/3d/listener_3d.h"
|
||||
#include "scene/main/viewport.h"
|
||||
|
||||
// Based on "A Novel Multichannel Panning Method for Standard and Arbitrary Loudspeaker Configurations" by Ramy Sadek and Chris Kyriakakis (2004)
|
||||
|
@ -391,7 +391,7 @@ Vector<AudioFrame> AudioStreamPlayer3D::_update_panning() {
|
|||
bool listener_is_camera = true;
|
||||
Node3D *listener_node = camera;
|
||||
|
||||
Listener3D *listener = vp->get_listener_3d();
|
||||
AudioListener3D *listener = vp->get_audio_listener_3d();
|
||||
if (listener) {
|
||||
listener_node = listener;
|
||||
listener_is_camera = false;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
void Viewport::set_as_audio_listener_3d(bool p_enable) {
|
||||
if (p_enable == audio_listener_3d) {
|
||||
return;
|
||||
}
|
||||
|
||||
audio_listener_3d = p_enable;
|
||||
_update_listener_3d();
|
||||
}
|
||||
|
||||
bool Viewport::is_audio_listener_3d() const {
|
||||
AudioListener3D *Viewport::get_audio_listener_3d() const {
|
||||
return audio_listener_3d;
|
||||
}
|
||||
|
||||
void Viewport::_update_listener_3d() {
|
||||
void Viewport::set_as_audio_listener_3d(bool p_enable) {
|
||||
if (p_enable == is_audio_listener_3d_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
is_audio_listener_3d_enabled = p_enable;
|
||||
_update_audio_listener_3d();
|
||||
}
|
||||
|
||||
bool Viewport::is_audio_listener_3d() const {
|
||||
return is_audio_listener_3d_enabled;
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "core/os/os.h"
|
||||
#include "scene/2d/animated_sprite_2d.h"
|
||||
#include "scene/2d/area_2d.h"
|
||||
#include "scene/2d/audio_listener_2d.h"
|
||||
#include "scene/2d/audio_stream_player_2d.h"
|
||||
#include "scene/2d/back_buffer_copy.h"
|
||||
#include "scene/2d/camera_2d.h"
|
||||
|
@ -49,7 +50,6 @@
|
|||
#include "scene/2d/light_2d.h"
|
||||
#include "scene/2d/light_occluder_2d.h"
|
||||
#include "scene/2d/line_2d.h"
|
||||
#include "scene/2d/listener_2d.h"
|
||||
#include "scene/2d/mesh_instance_2d.h"
|
||||
#include "scene/2d/multimesh_instance_2d.h"
|
||||
#include "scene/2d/navigation_agent_2d.h"
|
||||
|
@ -205,6 +205,7 @@
|
|||
|
||||
#ifndef _3D_DISABLED
|
||||
#include "scene/3d/area_3d.h"
|
||||
#include "scene/3d/audio_listener_3d.h"
|
||||
#include "scene/3d/audio_stream_player_3d.h"
|
||||
#include "scene/3d/bone_attachment_3d.h"
|
||||
#include "scene/3d/camera_3d.h"
|
||||
|
@ -217,7 +218,6 @@
|
|||
#include "scene/3d/light_3d.h"
|
||||
#include "scene/3d/lightmap_gi.h"
|
||||
#include "scene/3d/lightmap_probe.h"
|
||||
#include "scene/3d/listener_3d.h"
|
||||
#include "scene/3d/mesh_instance_3d.h"
|
||||
#include "scene/3d/multimesh_instance_3d.h"
|
||||
#include "scene/3d/navigation_agent_3d.h"
|
||||
|
@ -445,7 +445,7 @@ void register_scene_types() {
|
|||
GDREGISTER_VIRTUAL_CLASS(GeometryInstance3D);
|
||||
GDREGISTER_CLASS(Camera3D);
|
||||
GDREGISTER_CLASS(ClippedCamera3D);
|
||||
GDREGISTER_CLASS(Listener3D);
|
||||
GDREGISTER_CLASS(AudioListener3D);
|
||||
GDREGISTER_CLASS(XRCamera3D);
|
||||
GDREGISTER_CLASS(XRController3D);
|
||||
GDREGISTER_CLASS(XRAnchor3D);
|
||||
|
@ -672,7 +672,7 @@ void register_scene_types() {
|
|||
OS::get_singleton()->yield(); //may take time to init
|
||||
|
||||
GDREGISTER_CLASS(Camera2D);
|
||||
GDREGISTER_CLASS(Listener2D);
|
||||
GDREGISTER_CLASS(AudioListener2D);
|
||||
GDREGISTER_VIRTUAL_CLASS(Joint2D);
|
||||
GDREGISTER_CLASS(PinJoint2D);
|
||||
GDREGISTER_CLASS(GrooveJoint2D);
|
||||
|
@ -920,7 +920,7 @@ void register_scene_types() {
|
|||
ClassDB::add_compatibility_class("KinematicCollision", "KinematicCollision3D");
|
||||
ClassDB::add_compatibility_class("Light", "Light3D");
|
||||
ClassDB::add_compatibility_class("LineShape2D", "WorldBoundaryShape2D");
|
||||
ClassDB::add_compatibility_class("Listener", "Listener3D");
|
||||
ClassDB::add_compatibility_class("Listener", "AudioListener3D");
|
||||
ClassDB::add_compatibility_class("MeshInstance", "MeshInstance3D");
|
||||
ClassDB::add_compatibility_class("MultiMeshInstance", "MultiMeshInstance3D");
|
||||
ClassDB::add_compatibility_class("NavigationAgent", "NavigationAgent3D");
|
||||
|
|
Loading…
Reference in a new issue