|
|
@@ -93,6 +93,8 @@ bool Scene::Load(Deserializer& source)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ LOGINFO("Loading scene from " + source.GetName());
|
|
|
+
|
|
|
// Load the whole scene, then perform post-load if successfully loaded
|
|
|
if (Node::Load(source))
|
|
|
{
|
|
|
@@ -112,6 +114,10 @@ bool Scene::Save(Serializer& dest)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ Deserializer* ptr = dynamic_cast<Deserializer*>(&dest);
|
|
|
+ if (ptr)
|
|
|
+ LOGINFO("Saving scene to " + ptr->GetName());
|
|
|
+
|
|
|
return Node::Save(dest);
|
|
|
}
|
|
|
|
|
|
@@ -130,44 +136,6 @@ bool Scene::LoadXML(const XMLElement& source)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-void Scene::Update(float timeStep)
|
|
|
-{
|
|
|
- if (asyncLoading_)
|
|
|
- {
|
|
|
- UpdateAsyncLoading();
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- PROFILE(UpdateScene);
|
|
|
-
|
|
|
- using namespace SceneUpdate;
|
|
|
-
|
|
|
- VariantMap eventData;
|
|
|
- eventData[P_SCENE] = (void*)this;
|
|
|
- eventData[P_TIMESTEP] = timeStep;
|
|
|
-
|
|
|
- // Update variable timestep logic
|
|
|
- SendEvent(E_SCENEUPDATE, eventData);
|
|
|
-
|
|
|
- // Update scene subsystems. If a physics world is present, it will be updated, triggering fixed timestep logic updates
|
|
|
- SendEvent(E_SCENESUBSYSTEMUPDATE, eventData);
|
|
|
-
|
|
|
- // Post-update variable timestep logic
|
|
|
- SendEvent(E_SCENEPOSTUPDATE, eventData);
|
|
|
-
|
|
|
- // Update smoothing if enabled (network client scenes)
|
|
|
- if (IsSmoothed())
|
|
|
- {
|
|
|
- PROFILE(UpdateSmoothing);
|
|
|
-
|
|
|
- float constant = 1.0f - Clamp(powf(2.0f, -timeStep * smoothingConstant_), 0.0f, 1.0f);
|
|
|
- float squaredSnapThreshold = snapThreshold_ * snapThreshold_;
|
|
|
-
|
|
|
- for (Map<unsigned, Node*>::ConstIterator i = allNodes_.Begin(); i != allNodes_.End() && i->first_ < FIRST_LOCAL_ID; ++i)
|
|
|
- i->second_->UpdateSmoothing(constant, squaredSnapThreshold);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
bool Scene::LoadXML(Deserializer& source)
|
|
|
{
|
|
|
StopAsyncLoading();
|
|
|
@@ -176,6 +144,8 @@ bool Scene::LoadXML(Deserializer& source)
|
|
|
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()))
|
|
|
{
|
|
|
@@ -193,6 +163,10 @@ bool Scene::SaveXML(Serializer& dest)
|
|
|
if (!SaveXML(rootElem))
|
|
|
return false;
|
|
|
|
|
|
+ Deserializer* ptr = dynamic_cast<Deserializer*>(&dest);
|
|
|
+ if (ptr)
|
|
|
+ LOGINFO("Saving scene to " + ptr->GetName());
|
|
|
+
|
|
|
return xml->Save(dest);
|
|
|
}
|
|
|
|
|
|
@@ -213,6 +187,8 @@ bool Scene::LoadAsync(File* file)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ LOGINFO("Loading scene from " + file->GetName());
|
|
|
+
|
|
|
// Clear the previous scene and load the root level components first
|
|
|
Clear();
|
|
|
if (!Node::Load(*file, false))
|
|
|
@@ -243,6 +219,8 @@ bool Scene::LoadAsyncXML(File* file)
|
|
|
if (!xmlFile->Load(*file))
|
|
|
return false;
|
|
|
|
|
|
+ LOGINFO("Loading scene from " + file->GetName());
|
|
|
+
|
|
|
// Clear the previous scene and load the root level components first
|
|
|
Clear();
|
|
|
XMLElement rootElement = xmlFile->GetRoot();
|
|
|
@@ -284,6 +262,46 @@ void Scene::Clear()
|
|
|
checksum_ = 0;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+void Scene::Update(float timeStep)
|
|
|
+{
|
|
|
+ if (asyncLoading_)
|
|
|
+ {
|
|
|
+ UpdateAsyncLoading();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ PROFILE(UpdateScene);
|
|
|
+
|
|
|
+ using namespace SceneUpdate;
|
|
|
+
|
|
|
+ VariantMap eventData;
|
|
|
+ eventData[P_SCENE] = (void*)this;
|
|
|
+ eventData[P_TIMESTEP] = timeStep;
|
|
|
+
|
|
|
+ // Update variable timestep logic
|
|
|
+ SendEvent(E_SCENEUPDATE, eventData);
|
|
|
+
|
|
|
+ // Update scene subsystems. If a physics world is present, it will be updated, triggering fixed timestep logic updates
|
|
|
+ SendEvent(E_SCENESUBSYSTEMUPDATE, eventData);
|
|
|
+
|
|
|
+ // Post-update variable timestep logic
|
|
|
+ SendEvent(E_SCENEPOSTUPDATE, eventData);
|
|
|
+
|
|
|
+ // Update smoothing if enabled (network client scenes)
|
|
|
+ if (IsSmoothed())
|
|
|
+ {
|
|
|
+ PROFILE(UpdateSmoothing);
|
|
|
+
|
|
|
+ float constant = 1.0f - Clamp(powf(2.0f, -timeStep * smoothingConstant_), 0.0f, 1.0f);
|
|
|
+ float squaredSnapThreshold = snapThreshold_ * snapThreshold_;
|
|
|
+
|
|
|
+ for (Map<unsigned, Node*>::ConstIterator i = allNodes_.Begin(); i != allNodes_.End() && i->first_ < FIRST_LOCAL_ID; ++i)
|
|
|
+ i->second_->UpdateSmoothing(constant, squaredSnapThreshold);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void Scene::SetActive(bool enable)
|
|
|
{
|
|
|
active_ = enable;
|