VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
renderPassCookieRenderer.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4// Created by Arnis Lektauers on 01.10.2025.
5//
7
8namespace visutwin::canvas
9{
10 void RenderPassCookieRenderer::update(const std::vector<Light*>& lights) {
11 // Pick lights we need to update the cookies for
12 std::vector<Light*>& filteredLights = _filteredLights;
13 filteredLights.clear();
14 filter(lights, filteredLights);
15
16 // Enable / disable the pass
17 _executeEnabled = filteredLights.size() > 0;
18 }
19
20 void RenderPassCookieRenderer::filter(const std::vector<Light*>& lights, std::vector<Light*>& filteredLights)
21 {
22 for (auto* light : lights) {
23 // Skip directional lights
24 if (light->type() == LightType::LIGHTTYPE_DIRECTIONAL) {
25 continue;
26 }
27
28 // Skip clustered cookies with no assigned atlas slot
29 if (!light->atlasViewportAllocated()) {
30 continue;
31 }
32
33 // Only render cookie when the slot is reassigned (assuming the cookie texture is static)
34 if (!light->atlasSlotUpdated() && !_forceCopy) {
35 continue;
36 }
37
38 if (light->enabled() && light->cookie() && light->visibleThisFrame()) {
39 filteredLights.push_back(light);
40 }
41 }
42
43 _forceCopy = false;
44 }
45}