Line data Source code
1 : /* Copyright (C) 2025 Wildfire Games. 2 : * This file is part of 0 A.D. 3 : * 4 : * 0 A.D. is free software: you can redistribute it and/or modify 5 : * it under the terms of the GNU General Public License as published by 6 : * the Free Software Foundation, either version 2 of the License, or 7 : * (at your option) any later version. 8 : * 9 : * 0 A.D. is distributed in the hope that it will be useful, 10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 : * GNU General Public License for more details. 13 : * 14 : * You should have received a copy of the GNU General Public License 15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 : */ 17 : 18 : #ifndef INCLUDED_SILHOUETTERENDERER 19 : #define INCLUDED_SILHOUETTERENDERER 20 : 21 : #include "graphics/Color.h" 22 : #include "graphics/Overlay.h" 23 : #include "graphics/ShaderTechniquePtr.h" 24 : #include "maths/BoundingBoxAligned.h" 25 : 26 : #include <vector> 27 : 28 : class CCamera; 29 : class CModel; 30 : class CPatch; 31 : class SceneCollector; 32 : namespace Renderer::Backend { class IDeviceCommandContext; } 33 : namespace Renderer::Backend { class IVertexInputLayout; } 34 : 35 : class SilhouetteRenderer 36 : { 37 : public: 38 : SilhouetteRenderer(); 39 : 40 : void AddOccluder(CPatch* patch); 41 : void AddOccluder(CModel* model); 42 : void AddCaster(CModel* model); 43 : 44 : void ComputeSubmissions(const CCamera& camera); 45 : void RenderSubmitOverlays(SceneCollector& collector); 46 : void RenderSubmitOccluders(SceneCollector& collector); 47 : void RenderSubmitCasters(SceneCollector& collector); 48 : 49 : void RenderDebugBounds( 50 : Renderer::Backend::IDeviceCommandContext* deviceCommandContext); 51 : void RenderDebugOverlays( 52 : Renderer::Backend::IDeviceCommandContext* deviceCommandContext); 53 : 54 : void EndFrame(); 55 : 56 : private: 57 : bool m_DebugEnabled; 58 : 59 : std::vector<CPatch*> m_SubmittedPatchOccluders; 60 : std::vector<CModel*> m_SubmittedModelOccluders; 61 : std::vector<CModel*> m_SubmittedModelCasters; 62 : 63 : std::vector<CPatch*> m_VisiblePatchOccluders; 64 : std::vector<CModel*> m_VisibleModelOccluders; 65 : std::vector<CModel*> m_VisibleModelCasters; 66 : 67 : struct DebugBounds 68 : { 69 : CColor color; 70 : CBoundingBoxAligned bounds; 71 : }; 72 : 73 0 : struct DebugRect 74 : { 75 : CColor color; 76 : float x0, y0, x1, y1; 77 : }; 78 : 79 : std::vector<DebugBounds> m_DebugBounds; 80 : std::vector<DebugRect> m_DebugRects; 81 : 82 : std::vector<SOverlaySphere> m_DebugSpheres; 83 : 84 : CShaderTechniquePtr m_ShaderTech; 85 : Renderer::Backend::IVertexInputLayout* m_VertexInputLayout = nullptr; 86 : }; 87 : 88 : #endif // INCLUDED_SILHOUETTERENDERER