Skip to content

1330 add active component for all kinds of disabling purposes - #1357

Open
RodrigoVintem wants to merge 5 commits into
mainfrom
1330-add-active-component-for-all-kinds-of-disabling-purposes
Open

1330 add active component for all kinds of disabling purposes#1357
RodrigoVintem wants to merge 5 commits into
mainfrom
1330-add-active-component-for-all-kinds-of-disabling-purposes

Conversation

@RodrigoVintem

@RodrigoVintem RodrigoVintem commented Oct 29, 2024

Copy link
Copy Markdown
Contributor

Description

add active component for all kinds of disabling purposes

Checklist

  • Self-review changes.
  • Evaluate impact on the documentation.
  • Ensure test coverage.
  • Write new samples.
  • Add entry to the changelog's unreleased section.

@github-actions

github-actions Bot commented Oct 29, 2024

Copy link
Copy Markdown
Contributor
PR Preview Action v1.4.8
🚀 Deployed preview to https://GameDevTecnico.github.io/cubos/preview/pr-1357/
on branch gh-pages at 2024-11-12 15:09 UTC

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/2)

Comment thread engine/include/cubos/engine/render/active_component/active_component.hpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated
Comment thread engine/include/cubos/engine/render/active_component/active_component.hpp Outdated
Comment thread engine/src/render/camera/plugin.cpp Outdated
Comment thread engine/src/render/camera/plugin.cpp Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (2/2)

Comment thread engine/src/render/active_component/plugin.cpp Outdated
Comment thread engine/include/cubos/engine/render/active_component/active_component.hpp Outdated
Comment thread engine/src/render/active_component/active_component.cpp Outdated
Comment thread engine/src/render/active_component/active_component.cpp Outdated
Comment thread engine/include/cubos/engine/render/active_component/active_component.hpp Outdated
Comment thread engine/include/cubos/engine/render/active_component/active_component.hpp Outdated
Comment thread engine/include/cubos/engine/render/active_component/active_component.hpp Outdated
Comment thread engine/include/cubos/engine/render/active_component/active_component.hpp Outdated
Comment thread engine/include/cubos/engine/render/active_component/active_component.hpp Outdated
Comment thread engine/CMakeLists.txt Outdated
Comment thread engine/src/render/active_component/active_component.cpp Outdated
Comment thread engine/src/render/active_component/plugin.cpp Outdated
Comment thread engine/src/render/active_component/plugin.cpp Outdated
Comment thread engine/src/render/camera/camera.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

Comment thread engine/src/render/camera/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

Comment thread engine/src/render/camera/plugin.cpp Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

Comment thread engine/src/render/camera/plugin.cpp Outdated
Comment thread engine/src/render/camera/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

Comment thread engine/src/render/lights/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated
Comment thread engine/src/render/lights/plugin.cpp Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

Comment thread engine/src/render/g_buffer_rasterizer/plugin.cpp Outdated
Comment thread engine/src/render/g_buffer_rasterizer/plugin.cpp Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

Comment thread engine/src/render/g_buffer_rasterizer/plugin.cpp
Comment thread engine/src/render/g_buffer_rasterizer/plugin.cpp

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

Comment thread engine/src/render/g_buffer_rasterizer/plugin.cpp Outdated
@RodrigoVintem
RodrigoVintem force-pushed the 1330-add-active-component-for-all-kinds-of-disabling-purposes branch from 04d3499 to b2b2d03 Compare November 6, 2024 17:17
@codecov

codecov Bot commented Nov 8, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 148 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.89%. Comparing base (8d1d78c) to head (6a10308).
⚠️ Report is 303 commits behind head on main.

Files with missing lines Patch % Lines
.../render/cascaded_shadow_maps_rasterizer/plugin.cpp 0.00% 73 Missing ⚠️
engine/src/render/lights/plugin.cpp 0.00% 22 Missing ⚠️
engine/src/render/deferred_shading/plugin.cpp 0.00% 11 Missing ⚠️
engine/src/render/camera/plugin.cpp 0.00% 8 Missing ⚠️
engine/src/render/cascaded_shadow_maps/plugin.cpp 0.00% 8 Missing ⚠️
engine/src/tools/debug_camera/plugin.cpp 0.00% 6 Missing ⚠️
engine/src/render/shadow_atlas/plugin.cpp 0.00% 4 Missing ⚠️
engine/src/render/split_screen/plugin.cpp 0.00% 4 Missing ⚠️
engine/src/render/active/plugin.cpp 0.00% 3 Missing ⚠️
...gine/src/render/shadow_atlas_rasterizer/plugin.cpp 0.00% 3 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1357      +/-   ##
==========================================
- Coverage   41.95%   41.89%   -0.07%     
==========================================
  Files         441      443       +2     
  Lines       33115    33163      +48     
  Branches     3870     3881      +11     
==========================================
  Hits        13893    13893              
- Misses      19222    19270      +48     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RodrigoVintem
RodrigoVintem marked this pull request as ready for review November 10, 2024 12:56
@RodrigoVintem
RodrigoVintem requested review from a team and tomas7770 as code owners November 10, 2024 12:56
@RodrigoVintem
RodrigoVintem requested review from RiscadoA, SrGesus and mkuritsu and removed request for a team November 10, 2024 12:56
@RodrigoVintem
RodrigoVintem force-pushed the 1330-add-active-component-for-all-kinds-of-disabling-purposes branch from 6b21468 to b3ce57a Compare November 10, 2024 13:33

@tomas7770 tomas7770 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's already implemented LGTM! Here's what should need to be done for the lights. (GitHub doesn't let me add comments to unchanged lines of code so I'll try to do this manually)

engine/src/render/deferred_shading/plugin.cpp

In each of the loops that initialize lights in the shader (there is one for each type of light: directional, point, spot), check if the light is active, and continue if it's not.

for (auto [lightLocalToWorld, light, lightActive, caster] : directionalLights)
{
    if (!lightActive.active)
    {
        continue;
    }
    auto& perLight = perScene.directionalLights[perScene.numDirectionalLights++];

engine/src/render/shadow_atlas/plugin.cpp

No need to reserve space in the shadow atlas for lights that aren't active.

for (auto [caster, active] : casters)
{
    if (!active.active)
    {
        continue;
    }
    bool foundSlot = false;

The entity that has the caster is the same one that has the light, so adding the Active component to the caster query allows checking if the light is active.

.call([](ShadowAtlas& atlas, Query<SpotShadowCaster&, const Active&> casters) {

engine/src/render/cascaded_shadow_maps/plugin.cpp

Same as above.

for (auto [caster, active] : query)
{
    if (!active.active)
    {
        continue;
    }
    // Remove shadow maps for cameras that no longer exist

engine/src/render/shadow_atlas_rasterizer/plugin.cpp

No need to draw shadows for lights that aren't active.

for (auto [caster, light, localToWorld, active] : lights)
{
    if (!active.active)
    {
        continue;
    }
    // Get light viewport

engine/src/render/cascaded_shadow_maps_rasterizer/plugin.cpp

Same as above.

for (auto [caster, light, localToWorld, lightActive] : lights)
{
    if (!lightActive.active)
    {
        continue;
    }
    auto& shadowMap = caster.shadowMaps.at(cameraEntity);

Little sidenote unrelated to the PR.

engine/src/render/ssao/plugin.cpp has several includes that don't seem to be used for anything, such as lights and HDR. Maybe these can be removed?

@RodrigoVintem
RodrigoVintem force-pushed the 1330-add-active-component-for-all-kinds-of-disabling-purposes branch from b3ce57a to a236f4e Compare November 11, 2024 18:24
@RodrigoVintem

Copy link
Copy Markdown
Contributor Author

Added Tomas' changes to the files related to light, that should use the Active component. Also removed the unnecessary includes mentioned by Tomas.

@SrGesus SrGesus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM!

Comment thread engine/include/cubos/engine/render/camera/camera.hpp Outdated

@mkuritsu mkuritsu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me just very small changes to maintain consistency.

Aside from that I'm just concern about some implications of this implementation.

Comment thread engine/src/render/cascaded_shadow_maps_rasterizer/plugin.cpp Outdated
Comment thread engine/src/tools/debug_camera/plugin.cpp Outdated

@tomas7770 tomas7770 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still some small things that should be changed, but otherwise looks good!

Comment thread engine/src/render/shadow_atlas/plugin.cpp
Comment thread engine/src/render/cascaded_shadow_maps/plugin.cpp Outdated
Comment thread engine/src/render/cascaded_shadow_maps/plugin.cpp Outdated
@RodrigoVintem

Copy link
Copy Markdown
Contributor Author

All the new changes proposed by the reviewers have been made.

@RiscadoA RiscadoA left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM, pointed out some details that we should sort out before merging.
Ty for working on this 😌

Comment thread engine/include/cubos/engine/render/active/active.hpp
@@ -0,0 +1,20 @@
/// @file
/// @brief Component @ref cubos::engine::Active
/// @ingroup render-active-plugin

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this plugin should be a render-plugin. It is also relevant outside it. We'll use it for audio, and probably for collisions too later on. So, it would be better to put it in engine-plugin, and move to active dir to cubos/engine/

Comment thread engine/include/cubos/engine/render/active/plugin.hpp
Comment thread engine/include/cubos/engine/render/active/plugin.hpp
@@ -26,9 +27,14 @@ void cubos::engine::cascadedShadowMapsPlugin(Cubos& cubos)

cubos.system("create cascaded shadow maps")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you also need to add cubos.depends(cameraPlugin) here, and the same goes for the other plugins.
Have you tested running the shadows sample? It probably crashes

@RiscadoA RiscadoA added this to the 0.5 milestone Nov 17, 2024
@RiscadoA RiscadoA linked an issue Nov 17, 2024 that may be closed by this pull request
@RiscadoA RiscadoA modified the milestones: 0.5, 0.6 Nov 30, 2024
@RiscadoA RiscadoA modified the milestones: 0.6, 0.7 Feb 10, 2025
@RiscadoA RiscadoA removed this from the 0.7 milestone May 1, 2025
@RiscadoA RiscadoA self-assigned this May 1, 2025
@RiscadoA RiscadoA added this to the 0.8 milestone May 1, 2025
@RiscadoA

RiscadoA commented May 1, 2025

Copy link
Copy Markdown
Member

Since this has been abandoned I will pick it up on the next milestone.

@RiscadoA RiscadoA modified the milestones: 0.8, 0.9 Jul 29, 2025
@RiscadoA RiscadoA removed this from the 0.9 milestone Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Active component for all kinds of disabling purposes

5 participants