Merge pull request #25038 from GlaDos28/master
fixed AudioStreamPlayer3D::_get_attenuation_db epsilon value
This commit is contained in:
commit
a63bb3c804
1 changed files with 4 additions and 3 deletions
|
@ -33,6 +33,7 @@
|
||||||
#include "scene/3d/area.h"
|
#include "scene/3d/area.h"
|
||||||
#include "scene/3d/camera.h"
|
#include "scene/3d/camera.h"
|
||||||
#include "scene/main/viewport.h"
|
#include "scene/main/viewport.h"
|
||||||
|
|
||||||
void AudioStreamPlayer3D::_mix_audio() {
|
void AudioStreamPlayer3D::_mix_audio() {
|
||||||
|
|
||||||
if (!stream_playback.is_valid() || !active ||
|
if (!stream_playback.is_valid() || !active ||
|
||||||
|
@ -206,15 +207,15 @@ float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const {
|
||||||
float att = 0;
|
float att = 0;
|
||||||
switch (attenuation_model) {
|
switch (attenuation_model) {
|
||||||
case ATTENUATION_INVERSE_DISTANCE: {
|
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;
|
} break;
|
||||||
case ATTENUATION_INVERSE_SQUARE_DISTANCE: {
|
case ATTENUATION_INVERSE_SQUARE_DISTANCE: {
|
||||||
float d = (p_distance / unit_size);
|
float d = (p_distance / unit_size);
|
||||||
d *= d;
|
d *= d;
|
||||||
att = Math::linear2db(1.0 / (d + 0.00001));
|
att = Math::linear2db(1.0 / (d + CMP_EPSILON));
|
||||||
} break;
|
} break;
|
||||||
case ATTENUATION_LOGARITHMIC: {
|
case ATTENUATION_LOGARITHMIC: {
|
||||||
att = -20 * Math::log(p_distance / unit_size + 000001);
|
att = -20 * Math::log(p_distance / unit_size + CMP_EPSILON);
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
ERR_PRINT("Unknown attenuation type");
|
ERR_PRINT("Unknown attenuation type");
|
||||||
|
|
Loading…
Reference in a new issue