Skip to main content

SceneMemberVisibilitySystem.ixx File

Builds per-frame scene-member visibility data per viewport. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine
namespacescene
namespacesystems

Classes Index

classSceneMemberVisibilitySystem<TOwnerHandle, TMemberHandle, TCullingStrategy, TRenderModes>

Computes visibility for scene members and stores the frame snapshot. More...

Macro Definitions Index

#defineHELIOS_LOG_SCOPE   "helios::engine::scene::systems::SceneRenderSystem"

Description

Builds per-frame scene-member visibility data per viewport.

Macro Definitions

HELIOS_LOG_SCOPE

#define HELIOS_LOG_SCOPE   "helios::engine::scene::systems::SceneRenderSystem"

Definition at line 66 of file SceneMemberVisibilitySystem.ixx.

66#define HELIOS_LOG_SCOPE "helios::engine::scene::systems::SceneRenderSystem"

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7#include <concepts>
8#include <cassert>
9#include <optional>
10#include <tuple>
11#include <vector>
12
14
15export module helios.engine.scene.systems.SceneMemberVisibilitySystem;
16
17import helios.engine.rendering.viewport.concepts.IsViewportHandle;
18
19import helios.engine.scene.SceneMemberVisibilityRegistry;
20import helios.engine.scene.types;
21import helios.engine.scene.components;
22import helios.engine.scene.concepts.IsFrustumCullerLike;
23
24import helios.engine.rendering.common.components;
25import helios.engine.rendering.common.commands;
26import helios.engine.rendering.common.types;
27
28import helios.engine.rendering.renderTarget.components.RenderTargetBindingComponent;
29
30import helios.engine.spatial.components;
31
32import helios.engine.rendering.viewport.ViewportEntity;
33
34import helios.engine.runtime.world.UpdateContext;
35import helios.engine.runtime.messaging.command.NullCommandBuffer;
36import helios.engine.runtime.messaging.command.concepts.IsCommandBufferLike;
37import helios.engine.runtime.world.tags.SystemRole;
38
39import helios.ecs.components.Active;
40
41
42import helios.engine.util.log;
43
44import helios.math;
45import helios.engine.core.types.ComponentTypeTags;
46
47using namespace helios::engine::core::types;
48using namespace helios::engine::scene;
49using namespace helios::engine::scene::types;
50using namespace helios::engine::scene::concepts;
52using namespace helios::ecs::components;
54using namespace helios::engine::rendering::viewport::concepts;
57using namespace helios::engine::scene::types;
58using namespace helios::engine::runtime::messaging::command::concepts;
65
66#define HELIOS_LOG_SCOPE "helios::engine::scene::systems::SceneRenderSystem"
67export namespace helios::engine::scene::systems {
68
69
82 template<
83 typename TOwnerHandle,
84 typename TMemberHandle,
85 typename TCullingStrategy,
86 typename ... TRenderModes
87 >
90 std::same_as<typename TCullingStrategy::MemberHandle_type, TMemberHandle>
92
96 TCullingStrategy cullingStrategy_;
97
99
104
105
118 template<typename TSubmissionMode>
119 void processMembers(
122 const SceneHandle sceneHandle,
125 ) {
126
127 for (auto [
129 smc,
130 rpc,
134 ] : updateContext.view<
141 >().whereEnabled()) {
142
143 cullingContext.bounds = boundsWorld->value();
144 cullingContext.handle = memberEntity.handle();
145
147 memberEntity.handle(),
148 renderTargetBindingComponent.targetHandle(),
149 viewportEntity.handle(),
150 sceneHandle,
151 transformWorld->value()
152 };
153
154 visibilityRegistry_.addSceneRenderContext({
155 renderTargetBindingComponent.targetHandle(), viewportEntity.handle(), sceneHandle
156 });
157
158
159 if (smc->targetHandle() == sceneHandle && cullingStrategy_.shouldRender(cullingContext)) {
160 visibilityRegistry_.template addVisibleMember<TSubmissionMode>(viewportEntity.handle(), std::move(memberContext));
161 } else {
162 visibilityRegistry_.template addCulledMember<TSubmissionMode>(viewportEntity.handle(), std::move(memberContext));
163 }
164 }
165 }
166
167
168
169 public:
170
175
176
183 : cullingStrategy_(std::move(cullingStrategy)), visibilityRegistry_(visibilityRegistry) {
184 }
185
186
197
198 visibilityRegistry_.clear();
199
206 >().whereEnabled()) {
207
208 const auto sceneHandle = sbc->targetHandle();
209 const auto cameraHandle = cbc->targetHandle();
210
212 if (!camera) {
213 assert(false && "Camera not found");
214 logger_.error("Camera not found");
215 continue;
216 }
218 if (!pmc) {
219 assert(pmc && "Camera had no ProjectionMatrixComponent");
220 logger_.error("Camera had no ProjectionMatrixComponent");
221 continue;
222 }
224 if (!lac) {
225 assert(lac && "Camera had no ViewMatrixComponent");
226 logger_.error("Camera had no ViewMatrixComponent");
227 continue;
228 }
229
231 auto frustumPlanes = helios::math::frustumPlanes(
232 pcc->fovY(), pcc->aspectRatio(), pcc->zNear(), pcc->zFar(), lac->value()
233 );
234
235 auto cullingContext = CullingContext<TMemberHandle>{frustumPlanes, pmc->value(), lac->value()};
236
241 }
242
243 }
244
245 };
246
247}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.