Plasma Engine  2.0
Loading...
Searching...
No Matches
EngineProcessDocumentContext.h
1#pragma once
2
3#include <EditorEngineProcessFramework/EditorEngineProcessFrameworkDLL.h>
4#include <EditorEngineProcessFramework/EngineProcess/WorldRttiConverterContext.h>
5#include <Foundation/Types/Uuid.h>
6#include <RendererFoundation/Device/SwapChain.h>
7#include <RendererFoundation/Resources/RenderTargetSetup.h>
8
17struct plResourceEvent;
18
20{
21 using StorageType = plUInt8;
22
23 enum Enum
24 {
25 None = 0,
26 CreateWorld = PL_BIT(0),
27 Default = None
28 };
29
30 struct Bits
31 {
32 StorageType CreateWorld : 1;
33 };
34};
35PL_DECLARE_FLAGS_OPERATORS(plEngineProcessDocumentContextFlags);
36
41class PL_EDITORENGINEPROCESSFRAMEWORK_DLL plEngineProcessDocumentContext : public plReflectedClass
42{
43 PL_ADD_DYNAMIC_REFLECTION(plEngineProcessDocumentContext, plReflectedClass);
44
45public:
48
49 virtual void Initialize(const plUuid& documentGuid, const plVariant& metaData, plEngineProcessCommunicationChannel* pIPC, plStringView sDocumentType);
50 void Deinitialize();
51
53 plStringView GetDocumentType() const { return m_sDocumentType; }
54
55 void SendProcessMessage(plProcessMessage* pMsg = nullptr);
56 virtual void HandleMessage(const plEditorEngineDocumentMsg* pMsg);
57
58 static plEngineProcessDocumentContext* GetDocumentContext(plUuid guid);
59 static void AddDocumentContext(plUuid guid, const plVariant& metaData, plEngineProcessDocumentContext* pView, plEngineProcessCommunicationChannel* pIPC, plStringView sDocumentType);
60 static bool PendingOperationsInProgress();
61 static void UpdateDocumentContexts();
62 static void DestroyDocumentContext(plUuid guid);
63
64 // \brief Returns the bounding box of the objects in the world.
65 plBoundingBoxSphere GetWorldBounds(plWorld* pWorld);
66
67 void ProcessEditorEngineSyncObjectMsg(const plEditorEngineSyncObjectMsg& msg);
68
69 const plUuid& GetDocumentGuid() const { return m_DocumentGuid; }
70
71 virtual void Reset();
72 void ClearExistingObjects();
73
75 plWorldRttiConverterContext m_Context; // TODO: Move actual context into the EngineProcessDocumentContext
76 virtual plWorldRttiConverterContext& GetContext() { return m_Context; }
77 virtual const plWorldRttiConverterContext& GetContext() const { return m_Context; }
78
79 plWorld* GetWorld() const { return m_pWorld; }
80
82 virtual plGameObjectHandle ResolveStringToGameObjectHandle(const void* pString, plComponentHandle hThis, plStringView sProperty) const;
83
84protected:
85 virtual void OnInitialize();
86 virtual void OnDeinitialize();
87
92
95 virtual bool PendingOperationInProgress() const;
96
102 virtual void UpdateDocumentContext();
103
105 virtual plStatus ExportDocument(const plExportDocumentMsgToEngine* pMsg);
106 void UpdateSyncObjects();
107
109 void CreateThumbnailViewContext(const plCreateThumbnailMsgToEngine* pMsg);
110
112 void DestroyThumbnailViewContext();
113
121 virtual bool UpdateThumbnailViewContext(plEngineProcessViewContext* pThumbnailViewContext);
122
126 virtual void OnThumbnailViewContextCreated();
128 virtual void OnDestroyThumbnailViewContext();
129
130 plWorld* m_pWorld = nullptr;
131
133 void SetTagOnObject(const plUuid& object, const char* szTag, bool bSet, bool recursive);
134
136 void SetTagRecursive(plGameObject* pObject, const plTag& tag);
138 void ClearTagRecursive(plGameObject* pObject, const plTag& tag);
139
140protected:
141 const plEngineProcessViewContext* GetViewContext(plUInt32 uiView) const
142 {
143 return uiView >= m_ViewContexts.GetCount() ? nullptr : m_ViewContexts[uiView];
144 }
145
146private:
147 friend class plEditorEngineSyncObject;
148
149 void AddSyncObject(plEditorEngineSyncObject* pSync);
150 void RemoveSyncObject(plEditorEngineSyncObject* pSync);
151 plEditorEngineSyncObject* FindSyncObject(const plUuid& guid);
152
153
154private:
155 void ClearViewContexts();
156
157 // Maps a document guid to the corresponding context that handles that document on the engine side
159
161 void CleanUpContextSyncObjects();
162
163protected:
165 plUuid m_DocumentGuid;
166 plVariant m_MetaData;
167
168 plEngineProcessCommunicationChannel* m_pIPC = nullptr;
170
172
173private:
174 enum Constants
175 {
176 ThumbnailSuperscaleFactor =
177 2,
178 ThumbnailConvergenceFramesTarget = 4
179 };
180
181 plUInt8 m_uiThumbnailConvergenceFrames = 0;
182 plUInt16 m_uiThumbnailWidth = 0;
183 plUInt16 m_uiThumbnailHeight = 0;
184 plEngineProcessViewContext* m_pThumbnailViewContext = nullptr;
185 plGALRenderTargets m_ThumbnailRenderTargets;
186 plGALTextureHandle m_hThumbnailColorRT;
187 plGALTextureHandle m_hThumbnailDepthRT;
188 bool m_bWorldSimStateBeforeThumbnail = false;
189 plString m_sDocumentType;
190
192 // GameObject reference resolution
193private:
194 struct GoReferenceTo
195 {
196 plStringView m_sComponentProperty;
197 plUuid m_ReferenceToGameObject;
198 };
199
200 struct GoReferencedBy
201 {
202 plStringView m_sComponentProperty;
203 plUuid m_ReferencedByComponent;
204 };
205
206 // Components reference GameObjects
207 mutable plMap<plUuid, plHybridArray<GoReferenceTo, 4>> m_GoRef_ReferencesTo;
208
209 // GameObjects referenced by Components
210 mutable plMap<plUuid, plHybridArray<GoReferencedBy, 4>> m_GoRef_ReferencedBy;
211
212 void WorldRttiConverterContextEventHandler(const plWorldRttiConverterContext::Event& e);
213};
Definition EngineProcessMessages.h:330
Base class for all messages that are tied to some document.
Definition EngineProcessMessages.h:151
Definition SyncObject.h:11
Definition EngineProcessMessages.h:461
Definition EngineProcessCommunicationChannel.h:6
A document context is the counter part to an editor document on the engine side.
Definition EngineProcessDocumentContext.h:42
plStringView GetDocumentType() const
Returns the document type for which this context was created. Useful in case a context may be used fo...
Definition EngineProcessDocumentContext.h:53
virtual plEngineProcessViewContext * CreateViewContext()=0
Needs to be implemented to create a view context used for windows and thumbnails rendering.
virtual void DestroyViewContext(plEngineProcessViewContext *pContext)=0
Needs to be implemented to destroy the view context created in CreateViewContext.
virtual void OnThumbnailViewContextRequested()
Called before a thumbnail context is created.
Definition EngineProcessDocumentContext.h:124
Represents the view/window on the engine process side, holds all data necessary for rendering.
Definition EngineProcessViewContext.h:54
Definition EngineProcessMessages.h:307
Definition RendererFoundationDLL.h:411
This class represents an object inside the world.
Definition GameObject.h:32
Definition HashTable.h:333
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
An object mirror that mirrors across IPC to the engine process.
Definition IPCObjectMirrorEngine.h:11
Definition Map.h:408
Base class for IPC messages transmitted by plIpcChannel.
Definition RemoteMessage.h:64
All classes that should be dynamically reflectable, need to be derived from this base class.
Definition DynamicRTTI.h:86
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
The tag class stores the necessary lookup information for a single tag which can be used in conjuncti...
Definition Tag.h:16
This data type is the abstraction for 128-bit Uuid (also known as GUID) instances.
Definition Uuid.h:11
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
The world rtti converter context tracks created objects and is capable of also handling components / ...
Definition WorldRttiConverterContext.h:14
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
A handle to a component.
Definition Declarations.h:138
Definition EngineProcessDocumentContext.h:31
Definition EngineProcessDocumentContext.h:20
Definition RenderTargetSetup.h:9
A handle to a game object.
Definition Declarations.h:76
These events may be sent by a specific plResource or by the plResourceManager.
Definition Declarations.h:22
An plResult with an additional message for the reason of failure.
Definition Status.h:12
Definition WorldRttiConverterContext.h:40