Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

RodrigoVintem
Copy link
Contributor

@RodrigoVintem RodrigoVintem commented Oct 29, 2024

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.

Copy link
Contributor

github-actions bot commented Oct 29, 2024

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

Copy link
Contributor

@github-actions github-actions bot left a comment

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)

engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/camera/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/camera/plugin.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

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)

engine/CMakeLists.txt Outdated Show resolved Hide resolved
engine/src/render/active_component/active_component.cpp Outdated Show resolved Hide resolved
engine/src/render/active_component/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/active_component/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/camera/camera.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

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)

engine/src/render/camera/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

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)

engine/src/render/camera/plugin.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

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)

engine/src/render/camera/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/camera/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

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)

engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/lights/plugin.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

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)

engine/src/render/g_buffer_rasterizer/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/g_buffer_rasterizer/plugin.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

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)

Copy link
Contributor

@github-actions github-actions bot left a comment

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)

engine/src/render/g_buffer_rasterizer/plugin.cpp Outdated Show resolved Hide resolved
@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
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: 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).

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 Sentry.
📢 Have feedback on the report? Share it here.

@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
Copy link
Contributor

@tomas7770 tomas7770 left a comment

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
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.

Copy link
Contributor

@SrGesus SrGesus left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM!

engine/include/cubos/engine/render/camera/camera.hpp Outdated Show resolved Hide resolved
Copy link
Contributor

@mkuritsu mkuritsu left a comment

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.

engine/src/tools/debug_camera/plugin.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@tomas7770 tomas7770 left a comment

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!

engine/src/render/shadow_atlas/plugin.cpp Show resolved Hide resolved
engine/src/render/cascaded_shadow_maps/plugin.cpp Outdated Show resolved Hide resolved
engine/src/render/cascaded_shadow_maps/plugin.cpp Outdated Show resolved Hide resolved
@RodrigoVintem
Copy link
Contributor Author

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

Copy link
Member

@RiscadoA RiscadoA left a comment

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 😌

@@ -0,0 +1,20 @@
/// @file
/// @brief Component @ref cubos::engine::Active
/// @ingroup render-active-plugin
Copy link
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/

@@ -26,9 +27,14 @@ void cubos::engine::cascadedShadowMapsPlugin(Cubos& cubos)

cubos.system("create cascaded shadow maps")
Copy link
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
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