From 431817ac64fd151e847d23b7decbe5431373af2f Mon Sep 17 00:00:00 2001 From: apistol78 Date: Thu, 20 Feb 2025 09:11:56 +0100 Subject: [PATCH] Traktor: Reflection probe component visible state fixed. --- code/World/Entity/ProbeComponent.cpp | 28 ++++++++++++-------- code/World/Entity/ProbeComponent.h | 10 ++++--- code/World/Shared/Passes/ReflectionsPass.cpp | 2 +- code/World/Shared/WorldRendererShared.cpp | 5 +++- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/code/World/Entity/ProbeComponent.cpp b/code/World/Entity/ProbeComponent.cpp index be119207d2..ef8e53aaad 100644 --- a/code/World/Entity/ProbeComponent.cpp +++ b/code/World/Entity/ProbeComponent.cpp @@ -6,9 +6,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#include "World/Entity.h" #include "World/Entity/ProbeComponent.h" +#include "World/Entity.h" + namespace traktor::world { @@ -20,16 +21,15 @@ ProbeComponent::ProbeComponent( const Aabb3& volume, bool local, bool capture, - bool dirty -) -: m_owner(nullptr) -, m_texture(texture) -, m_intensity(intensity) -, m_volume(volume) -, m_last(Vector4::zero()) -, m_local(local) -, m_capture(capture) -, m_dirty(dirty) + bool dirty) + : m_owner(nullptr) + , m_texture(texture) + , m_intensity(intensity) + , m_volume(volume) + , m_last(Vector4::zero()) + , m_local(local) + , m_capture(capture) + , m_dirty(dirty) { } @@ -48,6 +48,12 @@ void ProbeComponent::update(const UpdateParams& update) { } +void ProbeComponent::setState(const EntityState& state, const EntityState& mask, bool includeChildren) +{ + if (mask.visible) + m_visible = state.visible; +} + void ProbeComponent::setTransform(const Transform& transform) { if (!m_dirty && (transform.translation() - m_last).length2() > 0.001_simd) diff --git a/code/World/Entity/ProbeComponent.h b/code/World/Entity/ProbeComponent.h index 0c6ea98d69..870f158b0e 100644 --- a/code/World/Entity/ProbeComponent.h +++ b/code/World/Entity/ProbeComponent.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2025 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -43,8 +43,7 @@ class T_DLLCLASS ProbeComponent : public IEntityComponent const Aabb3& volume, bool local, bool capture, - bool dirty - ); + bool dirty); virtual void destroy() override final; @@ -52,6 +51,8 @@ class T_DLLCLASS ProbeComponent : public IEntityComponent virtual void update(const UpdateParams& update) override final; + virtual void setState(const EntityState& state, const EntityState& mask, bool includeChildren) override final; + virtual void setTransform(const Transform& transform) override final; virtual Aabb3 getBoundingBox() const override final; @@ -72,6 +73,8 @@ class T_DLLCLASS ProbeComponent : public IEntityComponent bool shouldCapture() const { return m_capture; } + bool isVisible() const { return m_visible; } + void setDirty(bool dirty) { m_dirty = dirty; } bool getDirty() const { return m_dirty; } @@ -88,6 +91,7 @@ class T_DLLCLASS ProbeComponent : public IEntityComponent Vector4 m_last = Vector4::zero(); bool m_local = false; bool m_capture = false; + bool m_visible = true; bool m_dirty = false; int32_t m_revision = 0; }; diff --git a/code/World/Shared/Passes/ReflectionsPass.cpp b/code/World/Shared/Passes/ReflectionsPass.cpp index 752b393d2f..983025f757 100644 --- a/code/World/Shared/Passes/ReflectionsPass.cpp +++ b/code/World/Shared/Passes/ReflectionsPass.cpp @@ -227,7 +227,7 @@ render::handle_t ReflectionsPass::setup( { for (auto p : gatheredView.probes) { - if (p->getLocal() && p->getTexture() != nullptr) + if (p->getLocal() && p->isVisible() && p->getTexture() != nullptr) { const Transform& transform = p->getTransform(); const Matrix44 worldView = worldRenderView.getView() * transform.toMatrix44(); diff --git a/code/World/Shared/WorldRendererShared.cpp b/code/World/Shared/WorldRendererShared.cpp index 7e99ea7585..916391b567 100644 --- a/code/World/Shared/WorldRendererShared.cpp +++ b/code/World/Shared/WorldRendererShared.cpp @@ -261,7 +261,10 @@ void WorldRendererShared::gather(const World* world, const std::function< bool(c lights.push_back(lightComponent); } else if (auto probeComponent = dynamic_type_cast< const ProbeComponent* >(component)) - m_gatheredView.probes.push_back(probeComponent); + { + if (probeComponent->isVisible()) + m_gatheredView.probes.push_back(probeComponent); + } else if (auto fogComponent = dynamic_type_cast< const FogComponent* >(component)) m_gatheredView.fog = fogComponent; }