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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ set(CUBOS_ENGINE_SOURCE
"src/render/shadow_atlas_rasterizer/shadow_atlas_rasterizer.cpp"
"src/render/cascaded_shadow_maps/plugin.cpp"
"src/render/cascaded_shadow_maps_rasterizer/plugin.cpp"
"src/render/active_component/plugin.cpp"
"src/render/active_component/active_component.cpp"

"src/tools/settings_inspector/plugin.cpp"
"src/tools/selection/plugin.cpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <cubos/core/reflection/reflect.hpp>

namespace cubos::engine
{
struct Active_component
RodrigoVintem marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
struct Active_component
struct ActiveComponent

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
struct Active_component
struct ActiveComponent

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
struct Active_component
struct ActiveComponent

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
struct Active_component
struct ActiveComponent

{
CUBOS_REFLECT;

bool active = true;
};
} // namespace cubos::engine
10 changes: 10 additions & 0 deletions engine/include/cubos/engine/render/active_component/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include <cubos/engine/api.hpp>
#include <cubos/engine/prelude.hpp>
#include <cubos/engine/render/active_component/active_component.hpp>

namespace cubos::engine
{
CUBOS_ENGINE_API void activePlugin(Cubos& cubos);
}
1 change: 0 additions & 1 deletion engine/include/cubos/engine/render/camera/camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace cubos::engine
CUBOS_REFLECT;

/// @brief Whether the camera is drawing to a target.
bool active{true};

/// @brief Projection matrix of the camera.
glm::mat4 projection{};
Expand Down
11 changes: 11 additions & 0 deletions engine/src/render/active_component/active_component.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <cubos/core/ecs/reflection.hpp>
#include <cubos/core/reflection/external/primitives.hpp>

#include <cubos/engine/render/active_component/active_component.hpp>

CUBOS_REFLECT_IMPL(cubos::engine::Active_component)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
CUBOS_REFLECT_IMPL(cubos::engine::Active_component)
CUBOS_REFLECT_IMPL(cubos::engine::ActiveComponent)

{
return core::ecs::TypeBuilder<Active_component>("cubos::engine::Active_component")
.withField("active", &Active_component::active)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
return core::ecs::TypeBuilder<Active_component>("cubos::engine::Active_component")
.withField("active", &Active_component::active)
return core::ecs::TypeBuilder<ActiveComponent>("cubos::engine::Active_component")
.withField("active", &ActiveComponent::active)

.build();
}
11 changes: 11 additions & 0 deletions engine/src/render/active_component/plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <cubos/engine/render/active_component/active_component.hpp>
#include <cubos/engine/render/active_component/plugin.hpp>

// Environment not included

using namespace cubos::engine;

void cubos::engine::activePlugin(Cubos& cubos)
{
cubos.component<Active_component>();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
cubos.component<Active_component>();
cubos.component<ActiveComponent>();

}
2 changes: 1 addition & 1 deletion engine/src/render/camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
CUBOS_REFLECT_IMPL(cubos::engine::Camera)
{
return core::ecs::TypeBuilder<Camera>("cubos::engine::Camera")
.withField("active", &Camera::active)
//.withField("active", &Camera::active)
.withField("projection", &Camera::projection)
.withField("zNear", &Camera::zNear)
.withField("zFar", &Camera::zFar)
Expand Down
13 changes: 13 additions & 0 deletions engine/src/render/camera/plugin.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <glm/gtc/matrix_transform.hpp>

#include <cubos/engine/render/active_component/active_component.hpp>
#include <cubos/engine/render/active_component/plugin.hpp>
#include <cubos/engine/render/camera/camera.hpp>
#include <cubos/engine/render/camera/draws_to.hpp>
#include <cubos/engine/render/camera/orthographic.hpp>
Expand All @@ -13,13 +15,24 @@ using namespace cubos::engine;
void cubos::engine::cameraPlugin(Cubos& cubos)
{
cubos.depends(renderTargetPlugin);
cubos.depends(activePlugin);

cubos.component<Camera>();
cubos.component<PerspectiveCamera>();
cubos.component<OrthographicCamera>();

cubos.relation<DrawsTo>();

cubos.observer("add active component on add Camera")
.onAdd<Camera>()
.without<Active_component>()
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
.without<Active_component>()
.without<ActiveComponent>()

.call([](Commands cmds, Query<Entity> query) {
for (auto [ent] : query)
{
cmds.add(ent, Active_component{});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
cmds.add(ent, Active_component{});
cmds.add(ent, ActiveComponent{});

}
});

cubos.observer("add Camera on add PerspectiveCamera")
.onAdd<PerspectiveCamera>()
.without<Camera>()
Expand Down
33 changes: 33 additions & 0 deletions engine/src/render/lights/plugin.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <cubos/engine/render/active_component/active_component.hpp>
#include <cubos/engine/render/active_component/plugin.hpp>
#include <cubos/engine/render/lights/directional.hpp>
#include <cubos/engine/render/lights/environment.hpp>
#include <cubos/engine/render/lights/plugin.hpp>
Expand All @@ -7,8 +9,39 @@
void cubos::engine::lightsPlugin(Cubos& cubos)
{
cubos.resource<RenderEnvironment>();
cubos.depends(activePlugin);

cubos.component<DirectionalLight>();
cubos.component<PointLight>();
cubos.component<SpotLight>();

cubos.observer("add active component on add DirectionalLight")
.onAdd<DirectionalLight>()
.without<Active_component>()
RodrigoVintem marked this conversation as resolved.
Show resolved Hide resolved
.call([](Commands cmds, Query<Entity> query) {
for (auto [ent] : query)
{
cmds.add(ent, Active_component{});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
cmds.add(ent, Active_component{});
cmds.add(ent, ActiveComponent{});

}
});

cubos.observer("add active component on add PointLight")
.onAdd<PointLight>()
.without<Active_component>()
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
.without<Active_component>()
.without<ActiveComponent>()

.call([](Commands cmds, Query<Entity> query) {
for (auto [ent] : query)
{
cmds.add(ent, Active_component{});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
cmds.add(ent, Active_component{});
cmds.add(ent, ActiveComponent{});

}
});

cubos.observer("add active component on add SpotLight")
.onAdd<SpotLight>()
.without<Active_component>()
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
.without<Active_component>()
.without<ActiveComponent>()

.call([](Commands cmds, Query<Entity> query) {
for (auto [ent] : query)
{
cmds.add(ent, Active_component{});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-identifier-naming ⚠️
invalid case style for struct Active_component

Suggested change
cmds.add(ent, Active_component{});
cmds.add(ent, ActiveComponent{});

}
});
}
Loading