summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-01-17 10:39:08 +0100
committerGitHub <noreply@github.com>2019-01-17 10:39:08 +0100
commita63bb3c8042846b31c04def2d260e19b2d64d294 (patch)
tree4ec8d6e29a30253d41659f5bd5b160dc1ade2af8
parent9f2d98c0556e296a5ecfcbc973c6f6ef3ec10698 (diff)
parentfc086bc93d2acd7a7f4885773e6b640404400b32 (diff)
Merge pull request #25038 from GlaDos28/master
fixed AudioStreamPlayer3D::_get_attenuation_db epsilon value
-rw-r--r--scene/3d/audio_stream_player_3d.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index cad7ff47c1..0f4d0383a4 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -33,6 +33,7 @@
#include "scene/3d/area.h"
#include "scene/3d/camera.h"
#include "scene/main/viewport.h"
+
void AudioStreamPlayer3D::_mix_audio() {
if (!stream_playback.is_valid() || !active ||
@@ -206,15 +207,15 @@ float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const {
float att = 0;
switch (attenuation_model) {
case ATTENUATION_INVERSE_DISTANCE: {
- att = Math::linear2db(1.0 / ((p_distance / unit_size) + 000001));
+ att = Math::linear2db(1.0 / ((p_distance / unit_size) + CMP_EPSILON));
} break;
case ATTENUATION_INVERSE_SQUARE_DISTANCE: {
float d = (p_distance / unit_size);
d *= d;
- att = Math::linear2db(1.0 / (d + 0.00001));
+ att = Math::linear2db(1.0 / (d + CMP_EPSILON));
} break;
case ATTENUATION_LOGARITHMIC: {
- att = -20 * Math::log(p_distance / unit_size + 000001);
+ att = -20 * Math::log(p_distance / unit_size + CMP_EPSILON);
} break;
default: {
ERR_PRINT("Unknown attenuation type");