|
|
@@ -93,6 +93,8 @@ void Scene::RegisterObject(Context* context)
|
|
|
|
|
|
bool Scene::Load(Deserializer& source)
|
|
|
{
|
|
|
+ PROFILE(LoadScene);
|
|
|
+
|
|
|
StopAsyncLoading();
|
|
|
|
|
|
// Check ID
|
|
|
@@ -116,6 +118,8 @@ bool Scene::Load(Deserializer& source)
|
|
|
|
|
|
bool Scene::Save(Serializer& dest)
|
|
|
{
|
|
|
+ PROFILE(SaveScene);
|
|
|
+
|
|
|
// Write ID first
|
|
|
if (!dest.WriteFileID("USCN"))
|
|
|
{
|
|
|
@@ -132,6 +136,8 @@ bool Scene::Save(Serializer& dest)
|
|
|
|
|
|
bool Scene::LoadXML(const XMLElement& source)
|
|
|
{
|
|
|
+ PROFILE(LoadSceneXML);
|
|
|
+
|
|
|
StopAsyncLoading();
|
|
|
|
|
|
// Load the whole scene, then perform post-load if successfully loaded
|
|
|
@@ -147,26 +153,19 @@ bool Scene::LoadXML(const XMLElement& source)
|
|
|
|
|
|
bool Scene::LoadXML(Deserializer& source)
|
|
|
{
|
|
|
- StopAsyncLoading();
|
|
|
-
|
|
|
SharedPtr<XMLFile> xml(new XMLFile(context_));
|
|
|
if (!xml->Load(source))
|
|
|
return false;
|
|
|
|
|
|
LOGINFO("Loading scene from " + source.GetName());
|
|
|
|
|
|
- // Load the whole scene, then perform post-load if successfully loaded
|
|
|
- if (Node::LoadXML(xml->GetRoot()))
|
|
|
- {
|
|
|
- FinishLoading(&source);
|
|
|
- return true;
|
|
|
- }
|
|
|
- else
|
|
|
- return false;
|
|
|
+ return LoadXML(xml->GetRoot());
|
|
|
}
|
|
|
|
|
|
bool Scene::SaveXML(Serializer& dest)
|
|
|
{
|
|
|
+ PROFILE(SaveSceneXML);
|
|
|
+
|
|
|
SharedPtr<XMLFile> xml(new XMLFile(context_));
|
|
|
XMLElement rootElem = xml->CreateRoot("scene");
|
|
|
if (!SaveXML(rootElem))
|
|
|
@@ -276,6 +275,8 @@ void Scene::StopAsyncLoading()
|
|
|
|
|
|
Node* Scene::Instantiate(Deserializer& source, const Vector3& position, const Quaternion& rotation, CreateMode mode)
|
|
|
{
|
|
|
+ PROFILE(Instantiate);
|
|
|
+
|
|
|
SceneResolver resolver;
|
|
|
unsigned nodeID = source.ReadInt();
|
|
|
// Rewrite IDs when instantiating
|
|
|
@@ -295,17 +296,10 @@ Node* Scene::Instantiate(Deserializer& source, const Vector3& position, const Qu
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-Node* Scene::InstantiateXML(Deserializer& source, const Vector3& position, const Quaternion& rotation, CreateMode mode)
|
|
|
-{
|
|
|
- SharedPtr<XMLFile> xml(new XMLFile(context_));
|
|
|
- if (!xml->Load(source))
|
|
|
- return false;
|
|
|
-
|
|
|
- return InstantiateXML(xml->GetRoot(), position, rotation, mode);
|
|
|
-}
|
|
|
-
|
|
|
Node* Scene::InstantiateXML(const XMLElement& source, const Vector3& position, const Quaternion& rotation, CreateMode mode)
|
|
|
{
|
|
|
+ PROFILE(InstantiateXML);
|
|
|
+
|
|
|
SceneResolver resolver;
|
|
|
unsigned nodeID = source.GetInt("id");
|
|
|
// Rewrite IDs when instantiating
|
|
|
@@ -325,6 +319,15 @@ Node* Scene::InstantiateXML(const XMLElement& source, const Vector3& position, c
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+Node* Scene::InstantiateXML(Deserializer& source, const Vector3& position, const Quaternion& rotation, CreateMode mode)
|
|
|
+{
|
|
|
+ SharedPtr<XMLFile> xml(new XMLFile(context_));
|
|
|
+ if (!xml->Load(source))
|
|
|
+ return false;
|
|
|
+
|
|
|
+ return InstantiateXML(xml->GetRoot(), position, rotation, mode);
|
|
|
+}
|
|
|
+
|
|
|
void Scene::Clear()
|
|
|
{
|
|
|
StopAsyncLoading();
|