Plasma Engine  2.0
Loading...
Searching...
No Matches
View.h
1#pragma once
2
3#include <Foundation/Strings/HashedString.h>
4#include <Foundation/Threading/DelegateTask.h>
5#include <Foundation/Types/SharedPtr.h>
6#include <Foundation/Types/TagSet.h>
7#include <RendererCore/Pipeline/RenderPipeline.h>
8#include <RendererCore/Pipeline/RenderPipelineNode.h>
9#include <RendererCore/Pipeline/RenderPipelineResource.h>
10#include <RendererCore/Pipeline/ViewData.h>
11#include <RendererFoundation/Device/SwapChain.h>
12#include <RendererFoundation/Resources/RenderTargetSetup.h>
13
14class plFrustum;
15class plWorld;
17
20class PL_RENDERERCORE_DLL plView : public plRenderPipelineNode
21{
22 PL_ADD_DYNAMIC_REFLECTION(plView, plRenderPipelineNode);
23
24private:
26 plView();
27 ~plView();
28
29public:
30 plViewHandle GetHandle() const;
31
32 void SetName(plStringView sName);
33 plStringView GetName() const;
34
35 void SetWorld(plWorld* pWorld);
36 plWorld* GetWorld();
37 const plWorld* GetWorld() const;
38
42 void SetSwapChain(plGALSwapChainHandle hSwapChain);
43 plGALSwapChainHandle GetSwapChain() const;
44
47 void SetRenderTargets(const plGALRenderTargets& renderTargets);
48 const plGALRenderTargets& GetRenderTargets() const;
49
51 const plGALRenderTargets& GetActiveRenderTargets() const;
52
53 void SetRenderPipelineResource(plRenderPipelineResourceHandle hPipeline);
54 plRenderPipelineResourceHandle GetRenderPipelineResource() const;
55
56 void SetCamera(plCamera* pCamera);
57 plCamera* GetCamera();
58 const plCamera* GetCamera() const;
59
60 void SetCullingCamera(const plCamera* pCamera);
61 const plCamera* GetCullingCamera() const;
62
63 void SetLodCamera(const plCamera* pCamera);
64 const plCamera* GetLodCamera() const;
65
67 plEnum<plCameraUsageHint> GetCameraUsageHint() const;
70 void SetCameraUsageHint(plEnum<plCameraUsageHint> val);
71
72 void SetViewRenderMode(plEnum<plViewRenderMode> value);
73 plEnum<plViewRenderMode> GetViewRenderMode() const;
74
75 void SetViewport(const plRectFloat& viewport);
76 const plRectFloat& GetViewport() const;
77
79 void ForceUpdate();
80
81 const plViewData& GetData() const;
82
83 bool IsValid() const;
84
86 void ExtractData();
87
89 const plSharedPtr<plTask>& GetExtractTask();
90
91
96 plResult ComputePickingRay(float fScreenPosX, float fScreenPosY, plVec3& out_vRayStartPos, plVec3& out_vRayDir) const;
97
98 plResult ComputeScreenSpacePos(const plVec3& vPoint, plVec3& out_vScreenPos) const;
99
101 const plMat4& GetProjectionMatrix(plCameraEye eye) const;
102
104 const plMat4& GetInverseProjectionMatrix(plCameraEye eye) const;
105
107 const plMat4& GetViewMatrix(plCameraEye eye) const;
108
110 const plMat4& GetInverseViewMatrix(plCameraEye eye) const;
111
113 const plMat4& GetViewProjectionMatrix(plCameraEye eye) const;
114
116 const plMat4& GetInverseViewProjectionMatrix(plCameraEye eye) const;
117
119 void ComputeCullingFrustum(plFrustum& out_frustum) const;
120
121 void SetShaderPermutationVariable(const char* szName, const char* szValue);
122
123 void SetRenderPassProperty(const char* szPassName, const char* szPropertyName, const plVariant& value);
124 void SetExtractorProperty(const char* szPassName, const char* szPropertyName, const plVariant& value);
125
126 void ResetRenderPassProperties();
127 void ResetExtractorProperties();
128
129 void SetRenderPassReadBackProperty(const char* szPassName, const char* szPropertyName, const plVariant& value);
130 plVariant GetRenderPassReadBackProperty(const char* szPassName, const char* szPropertyName);
131 bool IsRenderPassReadBackPropertyExisting(const char* szPassName, const char* szPropertyName) const;
132
137 void UpdateViewData(plUInt32 uiDataIndex);
138
139 plTagSet m_IncludeTags;
140 plTagSet m_ExcludeTags;
141
142private:
143 friend class plRenderWorld;
144 friend class plMemoryUtils;
145
146 plViewId m_InternalId;
147 plHashedString m_sName;
148
149 plSharedPtr<plTask> m_pExtractTask;
150
151 plWorld* m_pWorld = nullptr;
152
153 plRenderPipelineResourceHandle m_hRenderPipeline;
154 plUInt32 m_uiRenderPipelineResourceDescriptionCounter = 0;
155 plSharedPtr<plRenderPipeline> m_pRenderPipeline;
156 plCamera* m_pCamera = nullptr;
157 const plCamera* m_pCullingCamera = nullptr;
158 const plCamera* m_pLodCamera = nullptr;
159
160
161private:
162 plRenderPipelineNodeInputPin m_PinRenderTarget0;
163 plRenderPipelineNodeInputPin m_PinRenderTarget1;
164 plRenderPipelineNodeInputPin m_PinRenderTarget2;
165 plRenderPipelineNodeInputPin m_PinRenderTarget3;
166 plRenderPipelineNodeInputPin m_PinDepthStencil;
167
168private:
169 void UpdateCachedMatrices() const;
170
172 void EnsureUpToDate();
173
174 mutable plUInt32 m_uiLastCameraSettingsModification = 0;
175 mutable plUInt32 m_uiLastCameraOrientationModification = 0;
176 mutable float m_fLastViewportAspectRatio = 1.0f;
177
178 mutable plViewData m_Data;
179
180 plInternal::RenderDataCache* m_pRenderDataCache = nullptr;
181
182 plDynamicArray<plPermutationVar> m_PermutationVars;
183 bool m_bPermutationVarsDirty = false;
184
185 void ApplyPermutationVars();
186
187 struct PropertyValue
188 {
189 plString m_sObjectName;
190 plString m_sPropertyName;
191 plVariant m_DefaultValue;
192 plVariant m_CurrentValue;
193 bool m_bIsValid;
194 bool m_bIsDirty;
195 };
196
197 void SetProperty(plMap<plString, PropertyValue>& map, const char* szPassName, const char* szPropertyName, const plVariant& value);
198 void SetReadBackProperty(plMap<plString, PropertyValue>& map, const char* szPassName, const char* szPropertyName, const plVariant& value);
199
200 void ReadBackPassProperties();
201
202 void ResetAllPropertyStates(plMap<plString, PropertyValue>& map);
203
204 void ApplyRenderPassProperties();
205 void ApplyExtractorProperties();
206
207 void ApplyProperty(plReflectedClass* pObject, PropertyValue& data, const char* szTypeName);
208
209 plMap<plString, PropertyValue> m_PassProperties;
210 plMap<plString, PropertyValue> m_PassReadBackProperties;
211 plMap<plString, PropertyValue> m_ExtractorProperties;
212};
213
214#include <RendererCore/Pipeline/Implementation/View_inl.h>
A camera class that stores the orientation and some basic camera settings.
Definition Camera.h:41
Definition DynamicArray.h:81
Represents the frustum of some camera and can be used for culling objects.
Definition Frustum.h:32
Definition RendererFoundationDLL.h:397
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
Definition Map.h:408
This class provides functions to work on raw memory.
Definition MemoryUtils.h:26
All classes that should be dynamically reflectable, need to be derived from this base class.
Definition DynamicRTTI.h:86
Definition RenderPipeline.h:20
Definition RenderPipelineNode.h:79
Definition RenderWorld.h:40
A Shared ptr manages a shared object and destroys that object when no one references it anymore....
Definition SharedPtr.h:10
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A dynamic collection of tags featuring fast lookups.
Definition TagSet.h:23
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
Definition Declarations.h:64
Encapsulates a view on the given world through the given camera and rendered with the specified Rende...
Definition View.h:21
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Definition RenderTargetSetup.h:9
Definition RenderPipelineNode.h:44
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Holds view data like the viewport, view and projection matrices.
Definition ViewData.h:11