1#include "SceneSystem.h"
2#include "Components/Core/RenderComponent.h"
4#include "Foundation/ComponentModel/Entity.h"
11 bool updateHierarchy =
false;
15 for (
const auto & sceneComponent :
pool) {
16 if (!sceneComponent.isActive())
continue;
17 if (!sceneComponent.hasChanged())
continue;
21 sceneComponent.getContainer()->getComponents(renderComponents);
23 for (
auto & renderComponent : renderComponents) {
28 if (!sceneComponent.children.empty()) {
32 updateHierarchy =
true;
36 if (updateHierarchy) {
37 for (
auto & sceneComponent :
pool) {
38 if (sceneComponent.parent || sceneComponent.children.empty()) {
43 std::function<void(
SceneComponent &,
bool,
bool)> updateChildren = [&](
SceneComponent & component,
bool parentVisible,
bool parentPickable)
45 for (
const auto & child : component.
children) {
46 child->getComponents(renderComponents);
48 for (
auto & childComponent : renderComponents) {
55 if (childSceneComponent) {
57 updateChildren(*childSceneComponent, parentVisible && childSceneComponent->visible, parentPickable && childSceneComponent->pickable);
62 updateChildren(sceneComponent, sceneComponent.visible, sceneComponent.pickable);
69 if (!needsPost)
return;
76 if (sceneComponent.
parent) {
78 auto parentState = getSceneState(*parentSceneComponent);
86void Cogs::Core::SceneSystem::updateState(SceneComponent & sceneComponent)
88 auto parentState = sceneComponent.parent ? getSceneState(*sceneComponent.parent.resolveComponent<SceneComponent>()) : SceneState{ true, true };
90 ComponentModel::ComponentCollection<RenderComponent> collection;
91 sceneComponent.getContainer()->getComponents(collection);
93 for (
auto & component : collection) {
Typed collection of components.
void postUpdate()
Perform post update logic in the system.
void update()
Updates the system state to that of the current frame.
ComponentPool< SceneComponent > pool
Pool of components managed by the system.
ComponentHandle getHandle(const SceneComponent *component)
Get a handle to the given Component instance.
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Contains information on how the entity behaves in the scene.
std::vector< EntityPtr > children
Contains all child entities owned by this component.
bool visible
If the entity this component is a member of should be visible.
ComponentModel::ComponentHandle parent
Handle to the scene component of the parent entity.
bool pickable
If the entity this component is a member of should be pickable.
@ ParentVisibility
Parent visibility, used by the SceneSystem to toggle child entity visibility on/off.
@ ParentPickable
Parent pickable, used by the SceneSystem to toggle child entity pickable on/off.
@ SelfVisibility
Self visibility, used by the SceneSystem to toggle entity visibility on/off.
@ SelfPickable
Self pickable, used by the SceneSystem to toggle entity pickable on/off.
ComponentType * resolveComponent() const