// Copyright (C) 2021 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_GRAPHICS_SYSTEMS_RENDERSYSTEM_HPP #define NAZARA_GRAPHICS_SYSTEMS_RENDERSYSTEM_HPP #include #include #include #include #include #include #include #include namespace Nz { class CommandBufferBuilder; class FramePipeline; class RenderFrame; class UploadPool; class NAZARA_GRAPHICS_API RenderSystem { public: RenderSystem(entt::registry& registry); RenderSystem(const RenderSystem&) = delete; RenderSystem(RenderSystem&&) = delete; ~RenderSystem(); void Render(entt::registry& registry, RenderFrame& renderFrame); RenderSystem& operator=(const RenderSystem&) = delete; RenderSystem& operator=(RenderSystem&&) = delete; private: void OnCameraDestroy(entt::registry& registry, entt::entity entity); void OnGraphicsDestroy(entt::registry& registry, entt::entity entity); void OnNodeDestroy(entt::registry& registry, entt::entity entity); void UpdateInstances(entt::registry& registry); void UpdateVisibility(entt::registry& registry); struct CameraEntity { NazaraSlot(Node, OnNodeInvalidation, onNodeInvalidation); }; struct GraphicsEntity { NazaraSlot(GraphicsComponent, OnRenderableAttached, onRenderableAttached); NazaraSlot(GraphicsComponent, OnRenderableDetach, onRenderableDetach); NazaraSlot(GraphicsComponent, OnVisibilityUpdate, onVisibilityUpdate); NazaraSlot(Node, OnNodeInvalidation, onNodeInvalidation); }; entt::connection m_cameraDestroyConnection; entt::connection m_graphicsDestroyConnection; entt::connection m_nodeDestroyConnection; entt::observer m_cameraConstructObserver; entt::observer m_graphicsConstructObserver; std::set m_invalidatedCameraNode; std::set m_invalidatedWorldNode; std::unique_ptr m_pipeline; std::unordered_map m_cameraEntities; std::unordered_map m_graphicsEntities; std::unordered_set m_newlyHiddenEntities; std::unordered_set m_newlyVisibleEntities; }; } #include #endif // NAZARA_GRAPHICS_SYSTEMS_RENDERSYSTEM_HPP