Adjustments for #3338

This commit is contained in:
Wojtek Figat
2025-10-12 23:24:34 +02:00
parent 12decc3320
commit 7dfc37f652
6 changed files with 58 additions and 21 deletions

View File

@@ -4,8 +4,6 @@
#include "Config.h"
#include "Types.h"
#include "Engine/Core/Math/Vector3.h"
#include "Engine/Core/Types/BaseTypes.h"
/// <summary>
@@ -85,8 +83,7 @@ public:
FORCE_INLINE static void VelocityChanged(const Vector3& velocity)
{
if (!velocity.IsNanOrInfinity())
Instance->Listener_VelocityChanged(velocity);
Instance->Listener_VelocityChanged(velocity);
}
FORCE_INLINE static void TransformChanged(const Vector3& position, const Quaternion& orientation)

View File

@@ -23,11 +23,11 @@ void AudioListener::Update()
{
// Update the velocity
const Vector3 pos = GetPosition();
const float dt = Time::Update.UnscaledDeltaTime.GetTotalSeconds();
const float dt = Math::Max(Time::Update.UnscaledDeltaTime.GetTotalSeconds(), 0.00001f);
const auto prevVelocity = _velocity;
_velocity = (pos - _prevPos) / dt;
_prevPos = pos;
if (_velocity != prevVelocity)
if (_velocity != prevVelocity && !_velocity.IsNanOrInfinity())
{
AudioBackend::Listener::VelocityChanged(_velocity);
}