!B (Sandbox) (CE-21795) Importing models with multisubmaterials via fbx switches...
[CRYENGINE.git] / Code / CryEngine / CrySchematyc2 / Script / ScriptSerializationUtils.h
blob07283cdb9061c7178184d31d8340500429efd626
1 // Copyright 2001-2019 Crytek GmbH / Crytek Group. All rights reserved.
3 #pragma once
5 #include "CrySerialization/BlackBox.h"
7 #include <CrySchematyc2/Script/IScriptFile.h>
8 #include <CrySchematyc2/Script/IScriptGraph.h>
9 #include <CrySchematyc2/Serialization/ISerializationContext.h>
11 namespace Schematyc2
13 namespace DocSerializationUtils
15 DECLARE_SHARED_POINTERS(IScriptElement)
17 class CDocGraphFactory // #SchematycTODO : Combine with CScriptElementFactory?
19 public:
21 IDocGraphPtr CreateGraph(IScriptFile& file, const SGUID& guid, const SGUID& scopeGUID, const char* szName, EScriptGraphType type, const SGUID& contextGUID);
24 // #SchematycTODO : Move to separate file .cpp and .h files and/or to IFramework?
25 // #SchematycTODO : Resolve disconnect between factory method used to construct elements during serialization and in place methods used when editing?
26 class CScriptElementFactory
28 public:
30 CScriptElementFactory();
32 void SetDefaultElementType(EScriptElementType defaultElementType);
33 IScriptElementPtr CreateElement(IScriptFile& file, EScriptElementType elementType);
34 IScriptElementPtr CreateElement(Serialization::IArchive& archive, const char* szName);
36 private:
38 EScriptElementType m_defaultElementType; // N.B. This is a hack to work around the fact that elements are located in discreet sections of each file. In future we should inline element type.
41 class CInputBlock
43 public:
45 typedef std::vector<size_t> DependencyIndices;
47 struct SElement
49 SElement();
51 void Serialize(Serialization::IArchive& archive);
53 IScriptElementPtr ptr;
54 Serialization::SBlackBox blackBox;
55 ESerializationPass serializationPass;
56 DependencyIndices dependencyIndices;
57 size_t sortPriority;
60 typedef std::vector<SElement> Elements;
62 public:
64 CInputBlock(IScriptFile& file);
66 void Serialize(Serialization::IArchive& archive);
67 void BuildElementHierarchy(IScriptElement& root);
68 void SortElementsByDependency();
69 Elements& GetElements();
71 private:
73 void AppendElements(Elements& dst, const Elements& src) const;
74 void EraseEmptyElements(Elements &elements) const;
75 void SortElementsByDependency(Elements &elements);
76 void VerifyElementDependencies(const Elements &elements);
78 private:
80 IScriptFile& m_file;
81 Elements m_elements;
84 extern CDocGraphFactory g_docGraphFactory;
85 extern CScriptElementFactory g_scriptElementFactory;