Skip to content

Commit

Permalink
Traktor: Reflection probe component visible state fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed Feb 20, 2025
1 parent 890fb5a commit 431817a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
28 changes: 17 additions & 11 deletions code/World/Entity/ProbeComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand All @@ -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)
{
}

Expand All @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions code/World/Entity/ProbeComponent.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -43,15 +43,16 @@ class T_DLLCLASS ProbeComponent : public IEntityComponent
const Aabb3& volume,
bool local,
bool capture,
bool dirty
);
bool dirty);

virtual void destroy() override final;

virtual void setOwner(Entity* owner) override final;

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;
Expand All @@ -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; }
Expand All @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion code/World/Shared/Passes/ReflectionsPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion code/World/Shared/WorldRendererShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 431817a

Please sign in to comment.