Fix realtime environment probes updating

#2191
This commit is contained in:
Wojtek Figat
2024-09-19 23:46:04 +02:00
parent 075c224022
commit f983be6104
2 changed files with 13 additions and 16 deletions

View File

@@ -319,6 +319,11 @@ void ProbesRendererService::Update()
// Calculate time delta since last update // Calculate time delta since last update
auto timeNow = Time::Update.UnscaledTime; auto timeNow = Time::Update.UnscaledTime;
auto timeSinceUpdate = timeNow - _lastProbeUpdate; auto timeSinceUpdate = timeNow - _lastProbeUpdate;
if (timeSinceUpdate < 0)
{
_lastProbeUpdate = timeNow;
timeSinceUpdate = 0;
}
// Check if render job is done // Check if render job is done
if (isUpdateSynced()) if (isUpdateSynced())
@@ -352,8 +357,9 @@ void ProbesRendererService::Update()
auto dt = (float)Time::Update.UnscaledDeltaTime.GetTotalSeconds(); auto dt = (float)Time::Update.UnscaledDeltaTime.GetTotalSeconds();
for (int32 i = 0; i < _probesToBake.Count(); i++) for (int32 i = 0; i < _probesToBake.Count(); i++)
{ {
_probesToBake[i].Timeout -= dt; auto& e = _probesToBake[i];
if (_probesToBake[i].Timeout <= 0) e.Timeout -= dt;
if (e.Timeout <= 0)
{ {
firstValidEntryIndex = i; firstValidEntryIndex = i;
break; break;
@@ -418,6 +424,9 @@ void ProbesRenderer::OnRender(RenderTask* task, GPUContext* context)
if (_current.Actor == nullptr) if (_current.Actor == nullptr)
{ {
// Probe has been unlinked (or deleted) // Probe has been unlinked (or deleted)
_task->Enabled = false;
_updateFrameNumber = 0;
_current.Type = EntryType::Invalid;
return; return;
} }
break; break;

View File

@@ -28,21 +28,9 @@ public:
struct Entry struct Entry
{ {
EntryType Type; EntryType Type = EntryType::Invalid;
ScriptingObjectReference<Actor> Actor; ScriptingObjectReference<Actor> Actor;
float Timeout; float Timeout = 0.0f;
Entry()
{
Type = EntryType::Invalid;
}
Entry(const Entry& other)
{
Type = other.Type;
Actor = other.Actor;
Timeout = other.Timeout;
}
bool UseTextureData() const; bool UseTextureData() const;
int32 GetResolution() const; int32 GetResolution() const;