Plasma Engine  2.0
Loading...
Searching...
No Matches
SceneDocument.h
1#pragma once
2
3#include <EditorPluginScene/EditorPluginSceneDLL.h>
4
5#include <EditorFramework/Document/GameObjectDocument.h>
6
10
12{
13 enum Enum
14 {
15 Off,
16 Simulate,
17 Play,
18 };
19};
20
21class PL_EDITORPLUGINSCENE_DLL plSceneDocument : public plGameObjectDocument
22{
23 PL_ADD_DYNAMIC_REFLECTION(plSceneDocument, plGameObjectDocument);
24
25public:
26 enum class DocumentType
27 {
28 Scene,
29 Prefab,
30 Layer
31 };
32
33public:
34 plSceneDocument(plStringView sDocumentPath, DocumentType documentType);
36
37 enum class ShowOrHide
38 {
39 Show,
40 Hide
41 };
42
43 void GroupSelection();
44
46 void DuplicateSpecial();
47
49 void DeltaTransform();
50
51
53 void SnapObjectToCamera();
54
55
57 void AttachToObject();
58
60 void DetachFromParent();
61
63 void CopyReference();
64
66 plStatus CreateEmptyObject(bool bAttachToParent, bool bAtPickedPosition);
67
68 void DuplicateSelection();
69 void ToggleHideSelectedObjects();
70 void ShowOrHideSelectedObjects(ShowOrHide action);
71 void ShowOrHideAllObjects(ShowOrHide action);
72 void HideUnselectedObjects();
73
75 bool IsPrefab() const { return m_DocumentType == DocumentType::Prefab; }
76
78 bool IsObjectEditorPrefab(const plUuid& object, plUuid* out_pPrefabAssetGuid = nullptr) const;
79
81 bool IsObjectEnginePrefab(const plUuid& object, plUuid* out_pPrefabAssetGuid = nullptr) const;
82
84 virtual bool ArePrefabsAllowed() const override { return !IsPrefab(); }
85
86
87 virtual void GetSupportedMimeTypesForPasting(plHybridArray<plString, 4>& out_mimeTypes) const override;
88 virtual bool CopySelectedObjects(plAbstractObjectGraph& out_objectGraph, plStringBuilder& out_sMimeType) const override;
89 virtual bool Paste(
90 const plArrayPtr<PasteInfo>& info, const plAbstractObjectGraph& objectGraph, bool bAllowPickedPosition, plStringView sMimeType) override;
91 bool DuplicateSelectedObjects(const plArrayPtr<PasteInfo>& info, const plAbstractObjectGraph& objectGraph, bool bSetSelected);
92 bool CopySelectedObjects(plAbstractObjectGraph& ref_graph, plMap<plUuid, plUuid>* out_pParents) const;
93 bool PasteAt(const plArrayPtr<PasteInfo>& info, const plVec3& vPos);
94 bool PasteAtOrignalPosition(const plArrayPtr<PasteInfo>& info, const plAbstractObjectGraph& objectGraph);
95
96 virtual void UpdatePrefabs() override;
97
99 virtual void UnlinkPrefabs(const plDeque<const plDocumentObject*>& selection) override;
100
101 virtual plUuid ReplaceByPrefab(
102 const plDocumentObject* pRootObject, plStringView sPrefabFile, const plUuid& prefabAsset, const plUuid& prefabSeed, bool bEnginePrefab) override;
103
105 virtual plUuid RevertPrefab(const plDocumentObject* pObject) override;
106
108 virtual void ConvertToEditorPrefab(const plDeque<const plDocumentObject*>& selection);
110 virtual void ConvertToEnginePrefab(const plDeque<const plDocumentObject*>& selection);
111
112 virtual plStatus CreatePrefabDocumentFromSelection(plStringView sFile, const plRTTI* pRootType, plDelegate<void(plAbstractObjectNode*)> adjustGraphNodeCB = {}, plDelegate<void(plDocumentObject*)> adjustNewNodesCB = {}, plDelegate<void(plAbstractObjectGraph& graph, plDynamicArray<plAbstractObjectNode*>& graphRootNodes)> finalizeGraphCB = {}) override;
113
114 GameMode::Enum GetGameMode() const { return m_GameMode; }
115
116 virtual bool CanEngineProcessBeRestarted() const override;
117
118 void StartSimulateWorld();
119 void TriggerGameModePlay(bool bUsePickedPositionAsStart);
120
122 bool StopGameMode();
123
124 plTransformStatus ExportScene(bool bCreateThumbnail);
125 void ExportSceneGeometry(
126 const char* szFile, bool bOnlySelection, int iExtractionMode /* plWorldGeoExtractionUtil::ExtractionMode */, const plMat3& mTransform);
127
128 virtual void HandleEngineMessage(const plEditorEngineDocumentMsg* pMsg) override;
129 void HandleGameModeMsg(const plGameModeMsgToEditor* pMsg);
130 void HandleObjectStateFromEngineMsg(const plPushObjectStateMsgToEditor* pMsg);
131
132 void SendObjectMsg(const plDocumentObject* pObj, plObjectTagMsgToEngine* pMsg);
133 void SendObjectMsgRecursive(const plDocumentObject* pObj, plObjectTagMsgToEngine* pMsg);
134
137
138 virtual const plDocumentObject* GetSettingsObject() const;
139 const plSceneDocumentSettingsBase* GetSettingsBase() const;
140 template <typename T>
141 const T* GetSettings() const
142 {
143 return plDynamicCast<const T*>(GetSettingsBase());
144 }
145
146 plStatus CreateExposedProperty(
147 const plDocumentObject* pObject, const plAbstractProperty* pProperty, plVariant index, plExposedSceneProperty& out_key) const;
148 plStatus AddExposedParameter(const char* szName, const plDocumentObject* pObject, const plAbstractProperty* pProperty, plVariant index);
149 plInt32 FindExposedParameter(const plDocumentObject* pObject, const plAbstractProperty* pProperty, plVariant index);
150 plStatus RemoveExposedParameter(plInt32 iIndex);
152
155
159 void StoreFavoriteCamera(plUInt8 uiSlot);
160
164 void RestoreFavoriteCamera(plUInt8 uiSlot);
165
167 plResult JumpToLevelCamera(plUInt8 uiSlot, bool bImmediate);
168
170 plResult CreateLevelCamera(plUInt8 uiSlot);
171
172 virtual plManipulatorSearchStrategy GetManipulatorSearchStrategy() const override
173 {
174 return plManipulatorSearchStrategy::ChildrenOfSelectedObject;
175 }
176
178
179protected:
180 void SetGameMode(GameMode::Enum mode);
181
182 virtual void InitializeAfterLoading(bool bFirstTimeCreation) override;
183 virtual void UpdatePrefabObject(plDocumentObject* pObject, const plUuid& PrefabAsset, const plUuid& PrefabSeed, plStringView sBasePrefab) override;
184 virtual void UpdateAssetDocumentInfo(plAssetDocumentInfo* pInfo) const override;
185
186 template <typename Func>
187 void ApplyRecursive(const plDocumentObject* pObject, Func f)
188 {
189 f(pObject);
190
191 for (auto pChild : pObject->GetChildren())
192 {
193 ApplyRecursive<Func>(pChild, f);
194 }
195 }
196
197protected:
198 void EnsureSettingsObjectExist();
199 void DocumentObjectMetaDataEventHandler(const plObjectMetaData<plUuid, plDocumentObjectMetaData>::EventData& e);
200 void EngineConnectionEventHandler(const plEditorEngineProcessConnection::Event& e);
201 void ToolsProjectEventHandler(const plToolsProjectEvent& e);
202
203 plStatus RequestExportScene(const char* szTargetFile, const plAssetFileHeader& header);
204
205 virtual plTransformStatus InternalTransformAsset(const char* szTargetFile, plStringView sOutputTag, const plPlatformProfile* pAssetProfile,
206 const plAssetFileHeader& AssetHeader, plBitflags<plTransformFlags> transformFlags) override;
207 virtual plTransformStatus InternalTransformAsset(plStreamWriter& stream, plStringView sOutputTag, const plPlatformProfile* pAssetProfile,
208 const plAssetFileHeader& AssetHeader, plBitflags<plTransformFlags> transformFlags) override;
209 plTransformStatus InternalCreateThumbnail(const ThumbnailInfo& ThumbnailInfo) override;
210
211 void SyncObjectHiddenState();
212 void SyncObjectHiddenState(plDocumentObject* pObject);
213
216 void UpdateObjectDebugTargets();
217
218 DocumentType m_DocumentType = DocumentType::Scene;
219
220 GameMode::Enum m_GameMode;
221
222 GameModeData m_GameModeData[3];
223
224 // Local mirror for settings
225 plDocumentObjectMirror m_ObjectMirror;
226 plRttiConverterContext m_Context;
227
230 virtual void OnInterDocumentMessage(plReflectedClass* pMessage, plDocument* pSender) override;
231 void GatherObjectsOfType(plDocumentObject* pRoot, plGatherObjectsOfTypeMsgInterDoc* pMsg) const;
232};
Definition AbstractObjectGraph.h:115
Definition AbstractObjectGraph.h:17
This is the base interface for all properties in the reflection system. It provides enough informatio...
Definition AbstractProperty.h:150
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
virtual void UpdateAssetDocumentInfo(plAssetDocumentInfo *pInfo) const
Override this to add custom data (e.g. additional file dependencies) to the info struct.
Definition AssetDocument.cpp:380
virtual plTransformStatus InternalTransformAsset(plStreamWriter &stream, plStringView sOutputTag, const plPlatformProfile *pAssetProfile, const plAssetFileHeader &AssetHeader, plBitflags< plTransformFlags > transformFlags)=0
Override this and write the transformed file for the given szOutputTag into the given stream.
virtual plTransformStatus InternalCreateThumbnail(const ThumbnailInfo &thumbnailInfo)
Override this function to generate a thumbnail. Only called if GetAssetFlags returns plAssetDocumentF...
Definition AssetDocument.cpp:745
Definition AssetDocumentInfo.h:7
Simple class to handle asset file headers (the very first bytes in all transformed asset files)
Definition AssetFileHeader.h:8
Definition Deque.h:270
Definition Document.h:57
virtual void OnInterDocumentMessage(plReflectedClass *pMessage, plDocument *pSender)
Called on all documents when BroadcastInterDocumentMessage() is called.
Definition Document.h:179
virtual bool CopySelectedObjects(plAbstractObjectGraph &out_objectGraph, plStringBuilder &out_sMimeType) const
Creates the abstract graph of data to be copied and returns the mime type for the clipboard to identi...
Definition Document.h:163
virtual void GetSupportedMimeTypesForPasting(plHybridArray< plString, 4 > &out_mimeTypes) const
Whether this document supports pasting the given mime format into it.
Definition Document.h:161
virtual void UnlinkPrefabs(const plDeque< const plDocumentObject * > &selection)
Removes the link between a prefab instance and its template, turning the instance into a regular obje...
Definition DocumentPrefab.cpp:39
virtual void UpdatePrefabs()
Updates ALL prefabs in the document with the latest changes. Merges the current prefab templates with...
Definition DocumentPrefab.cpp:10
virtual bool CanEngineProcessBeRestarted() const
Asks the document whether a restart of the engine process is allowed at this time.
Definition Document.h:145
Definition DocumentObjectBase.h:11
Definition DocumentObjectMirror.h:34
Definition DynamicArray.h:81
Base class for all messages that are tied to some document.
Definition EngineProcessMessages.h:151
Definition Messages.h:7
Definition EngineProcessMessages.h:549
Definition GameObjectDocument.h:95
virtual void HandleEngineMessage(const plEditorEngineDocumentMsg *pMsg) override
Handles all messages received from the corresponding plEngineProcessDocumentContext on the engine pro...
Definition GameObjectDocument.cpp:1070
Send between editor documents, such that one document can know about objects in another document.
Definition EngineProcessMessages.h:579
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Definition Map.h:408
Definition EngineProcessMessages.h:474
Definition PlatformProfile.h:25
Definition Messages.h:53
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
All classes that should be dynamically reflectable, need to be derived from this base class.
Definition DynamicRTTI.h:86
Definition RttiConverter.h:33
Definition SceneDocument.h:22
bool IsPrefab() const
Whether this document represents a prefab or a scene.
Definition SceneDocument.h:75
virtual plManipulatorSearchStrategy GetManipulatorSearchStrategy() const override
Needed by plManipulatorManager to know where to look for the manipulator attributes.
Definition SceneDocument.h:172
virtual bool ArePrefabsAllowed() const override
Nested prefabs are not allowed.
Definition SceneDocument.h:84
Definition SceneObjectManager.h:11
Interface for binary out (write) streams.
Definition Stream.h:107
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
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
Definition SceneDocument.h:12
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
A generic delegate class which supports static functions and member functions.
Definition Delegate.h:76
Definition EngineProcessConnection.h:63
Definition ObjectMetaData.h:20
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
An plResult with an additional message for the reason of failure.
Definition Status.h:12
Definition ToolsProject.h:13
Definition Declarations.h:114