-
Notifications
You must be signed in to change notification settings - Fork 33
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
RodrigoVintem
wants to merge
5
commits into
main
Choose a base branch
from
1330-add-active-component-for-all-kinds-of-disabling-purposes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ff7aef1
feat(engine): implement active component for cameras and light
RodrigoVintem a236f4e
feat(engine): implement active component for cameras and light
RodrigoVintem c7cce47
Merge branch 'main' into 1330-add-active-component-for-all-kinds-of-d…
RodrigoVintem 48b1308
feat(engine): implement active component for cameras and light
RodrigoVintem 6a10308
Merge branch '1330-add-active-component-for-all-kinds-of-disabling-pu…
RodrigoVintem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// @file | ||
/// @brief Component @ref cubos::engine::Active | ||
/// @ingroup render-active-plugin | ||
#pragma once | ||
|
||
#include <cubos/core/reflection/reflect.hpp> | ||
|
||
namespace cubos::engine | ||
{ | ||
/// @brief Component which stores the active state for an entity. | ||
/// @note Added automatically once a specific camera or light is added. | ||
RodrigoVintem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// @ingroup render-active-plugin | ||
struct Active | ||
{ | ||
CUBOS_REFLECT; | ||
|
||
/// @brief Whether the entity is active. | ||
bool active = true; | ||
}; | ||
} // namespace cubos::engine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
RodrigoVintem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#include <cubos/engine/api.hpp> | ||
#include <cubos/engine/prelude.hpp> | ||
#include <cubos/engine/render/active/active.hpp> | ||
|
||
namespace cubos::engine | ||
{ | ||
CUBOS_ENGINE_API void activePlugin(Cubos& cubos); | ||
RodrigoVintem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <cubos/core/ecs/reflection.hpp> | ||
#include <cubos/core/reflection/external/primitives.hpp> | ||
|
||
#include <cubos/engine/render/active/active.hpp> | ||
|
||
CUBOS_REFLECT_IMPL(cubos::engine::Active) | ||
{ | ||
return core::ecs::TypeBuilder<Active>("cubos::engine::Active").withField("active", &Active::active).build(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <cubos/engine/render/active/active.hpp> | ||
#include <cubos/engine/render/active/plugin.hpp> | ||
|
||
void cubos::engine::activePlugin(Cubos& cubos) | ||
{ | ||
cubos.component<Active>(); | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
#include <cubos/core/io/window.hpp> | ||
#include <cubos/core/reflection/external/primitives.hpp> | ||
|
||
#include <cubos/engine/render/active/plugin.hpp> | ||
#include <cubos/engine/render/camera/camera.hpp> | ||
#include <cubos/engine/render/camera/plugin.hpp> | ||
#include <cubos/engine/render/cascaded_shadow_maps/plugin.hpp> | ||
|
@@ -26,9 +27,14 @@ | |
|
||
cubos.system("create cascaded shadow maps") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
.tagged(createCascadedShadowMapsTag) | ||
.call([](const Window& window, Query<DirectionalShadowCaster&> query, Query<Entity, const Camera&> cameras) { | ||
for (auto [caster] : query) | ||
.call([](const Window& window, Query<DirectionalShadowCaster&, const Active&> query, | ||
Query<Entity, const Camera&, const Active&> cameras) { | ||
for (auto [caster, active] : query) | ||
{ | ||
if (!active.active) | ||
{ | ||
continue; | ||
} | ||
// Remove shadow maps for cameras that no longer exist | ||
std::vector<Entity> removedCameras; | ||
for (auto& [cameraEntity, shadowMap] : caster.shadowMaps) | ||
|
@@ -38,9 +44,9 @@ | |
removedCameras.push_back(cameraEntity); | ||
} | ||
} | ||
for (auto [entity, camera] : cameras) | ||
for (auto [entity, camera, cameraActive] : cameras) | ||
{ | ||
if (!camera.active && caster.shadowMaps.contains(entity)) | ||
if (!cameraActive.active && caster.shadowMaps.contains(entity)) | ||
{ | ||
removedCameras.push_back(entity); | ||
} | ||
|
@@ -53,9 +59,9 @@ | |
caster.updateShadowMaps(window->renderDevice()); | ||
|
||
// Create shadow maps for new cameras | ||
for (auto [entity, camera] : cameras) | ||
for (auto [entity, camera, cameraActive] : cameras) | ||
{ | ||
if (camera.active && !caster.shadowMaps.contains(entity)) | ||
if (cameraActive.active && !caster.shadowMaps.contains(entity)) | ||
{ | ||
caster.shadowMaps[entity] = std::make_shared<DirectionalShadowCaster::ShadowMap>(); | ||
caster.shadowMaps[entity]->resize(window->renderDevice(), caster.size, | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 toactive
dir tocubos/engine/