Scene.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #include "Precompiled.h"
  24. #include "Component.h"
  25. #include "Context.h"
  26. #include "CoreEvents.h"
  27. #include "File.h"
  28. #include "Log.h"
  29. #include "PackageFile.h"
  30. #include "Profiler.h"
  31. #include "Scene.h"
  32. #include "SceneEvents.h"
  33. #include "WorkQueue.h"
  34. #include "XMLFile.h"
  35. static const int ASYNC_LOAD_MIN_FPS = 50;
  36. static const int ASYNC_LOAD_MAX_MSEC = (int)(1000.0f / ASYNC_LOAD_MIN_FPS);
  37. static const float DEFAULT_SMOOTHING_CONSTANT = 50.0f;
  38. static const float DEFAULT_SNAP_THRESHOLD = 1.0f;
  39. static const String emptyVarName;
  40. OBJECTTYPESTATIC(Scene);
  41. Scene::Scene(Context* context) :
  42. Node(context),
  43. replicatedNodeID_(FIRST_REPLICATED_ID),
  44. replicatedComponentID_(FIRST_REPLICATED_ID),
  45. localNodeID_(FIRST_LOCAL_ID),
  46. localComponentID_(FIRST_LOCAL_ID),
  47. smoothingConstant_(DEFAULT_SMOOTHING_CONSTANT),
  48. snapThreshold_(DEFAULT_SNAP_THRESHOLD),
  49. checksum_(0),
  50. active_(true),
  51. asyncLoading_(false),
  52. threadedUpdate_(false)
  53. {
  54. // Assign an ID to self so that nodes can refer to this node as a parent
  55. SetID(GetFreeNodeID(REPLICATED));
  56. NodeAdded(this);
  57. SubscribeToEvent(E_UPDATE, HANDLER(Scene, HandleUpdate));
  58. }
  59. Scene::~Scene()
  60. {
  61. // Remove scene reference and owner from all nodes that still exist
  62. for (Map<unsigned, Node*>::Iterator i = allNodes_.Begin(); i != allNodes_.End(); ++i)
  63. {
  64. i->second_->SetScene(0);
  65. i->second_->SetOwner(0);
  66. }
  67. }
  68. void Scene::RegisterObject(Context* context)
  69. {
  70. context->RegisterFactory<Scene>();
  71. REF_ACCESSOR_ATTRIBUTE(Scene, VAR_STRING, "Name", GetName, SetName, String, String(), AM_DEFAULT);
  72. REF_ACCESSOR_ATTRIBUTE(Scene, VAR_VECTOR3, "Position", GetPosition, SetPosition, Vector3, Vector3::ZERO, AM_DEFAULT | AM_LATESTDATA);
  73. REF_ACCESSOR_ATTRIBUTE(Scene, VAR_QUATERNION, "Rotation", GetRotation, SetRotation, Quaternion, Quaternion::IDENTITY, AM_FILE);
  74. REF_ACCESSOR_ATTRIBUTE(Scene, VAR_VECTOR3, "Scale", GetScale, SetScale, Vector3, Vector3::ONE, AM_DEFAULT);
  75. ACCESSOR_ATTRIBUTE(Scene, VAR_FLOAT, "Smoothing Constant", GetSmoothingConstant, SetSmoothingConstant, float, DEFAULT_SMOOTHING_CONSTANT, AM_DEFAULT);
  76. ACCESSOR_ATTRIBUTE(Scene, VAR_FLOAT, "Snap Threshold", GetSnapThreshold, SetSnapThreshold, float, DEFAULT_SNAP_THRESHOLD, AM_DEFAULT);
  77. ATTRIBUTE(Scene, VAR_INT, "Next Replicated Node ID", replicatedNodeID_, FIRST_REPLICATED_ID, AM_FILE | AM_NOEDIT);
  78. ATTRIBUTE(Scene, VAR_INT, "Next Replicated Component ID", replicatedComponentID_, FIRST_REPLICATED_ID, AM_FILE | AM_NOEDIT);
  79. ATTRIBUTE(Scene, VAR_INT, "Next Local Node ID", localNodeID_, FIRST_LOCAL_ID, AM_FILE | AM_NOEDIT);
  80. ATTRIBUTE(Scene, VAR_INT, "Next Local Component ID", localComponentID_, FIRST_LOCAL_ID, AM_FILE | AM_NOEDIT);
  81. ATTRIBUTE(Scene, VAR_VARIANTMAP, "Variables", vars_, VariantMap(), AM_FILE); // Network replication of vars uses custom data
  82. ACCESSOR_ATTRIBUTE(Scene, VAR_STRING, "Variable Names", GetVarNamesAttr, SetVarNamesAttr, String, String(), AM_FILE | AM_NOEDIT);
  83. REF_ACCESSOR_ATTRIBUTE(Scene, VAR_BUFFER, "Network Rotation", GetNetRotationAttr, SetNetRotationAttr, PODVector<unsigned char>, PODVector<unsigned char>(), AM_NET | AM_LATESTDATA | AM_NOEDIT);
  84. }
  85. bool Scene::Load(Deserializer& source)
  86. {
  87. StopAsyncLoading();
  88. // Check ID
  89. if (source.ReadFileID() != "USCN")
  90. {
  91. LOGERROR(source.GetName() + " is not a valid scene file");
  92. return false;
  93. }
  94. LOGINFO("Loading scene from " + source.GetName());
  95. // Load the whole scene, then perform post-load if successfully loaded
  96. if (Node::Load(source))
  97. {
  98. FinishLoading(&source);
  99. return true;
  100. }
  101. else
  102. return false;
  103. }
  104. bool Scene::Save(Serializer& dest)
  105. {
  106. // Write ID first
  107. if (!dest.WriteFileID("USCN"))
  108. {
  109. LOGERROR("Could not save scene, writing to stream failed");
  110. return false;
  111. }
  112. Deserializer* ptr = dynamic_cast<Deserializer*>(&dest);
  113. if (ptr)
  114. LOGINFO("Saving scene to " + ptr->GetName());
  115. return Node::Save(dest);
  116. }
  117. bool Scene::LoadXML(const XMLElement& source)
  118. {
  119. StopAsyncLoading();
  120. // Load the whole scene, then perform post-load if successfully loaded
  121. // Note: the scene filename and checksum can not be set, as we only used an XML element
  122. if (Node::LoadXML(source))
  123. {
  124. FinishLoading(0);
  125. return true;
  126. }
  127. else
  128. return false;
  129. }
  130. bool Scene::LoadXML(Deserializer& source)
  131. {
  132. StopAsyncLoading();
  133. SharedPtr<XMLFile> xml(new XMLFile(context_));
  134. if (!xml->Load(source))
  135. return false;
  136. LOGINFO("Loading scene from " + source.GetName());
  137. // Load the whole scene, then perform post-load if successfully loaded
  138. if (Node::LoadXML(xml->GetRoot()))
  139. {
  140. FinishLoading(&source);
  141. return true;
  142. }
  143. else
  144. return false;
  145. }
  146. bool Scene::SaveXML(Serializer& dest)
  147. {
  148. SharedPtr<XMLFile> xml(new XMLFile(context_));
  149. XMLElement rootElem = xml->CreateRoot("scene");
  150. if (!SaveXML(rootElem))
  151. return false;
  152. Deserializer* ptr = dynamic_cast<Deserializer*>(&dest);
  153. if (ptr)
  154. LOGINFO("Saving scene to " + ptr->GetName());
  155. return xml->Save(dest);
  156. }
  157. bool Scene::LoadAsync(File* file)
  158. {
  159. if (!file)
  160. {
  161. LOGERROR("Null file for async loading");
  162. return false;
  163. }
  164. StopAsyncLoading();
  165. // Check ID
  166. if (file->ReadFileID() != "USCN")
  167. {
  168. LOGERROR(file->GetName() + " is not a valid scene file");
  169. return false;
  170. }
  171. LOGINFO("Loading scene from " + file->GetName());
  172. Clear();
  173. // Store own old ID for resolving possible root node references
  174. unsigned nodeID = file->ReadUInt();
  175. resolver_.AddNode(nodeID, this);
  176. // Load root level components first
  177. if (!Node::Load(*file, resolver_, false))
  178. return false;
  179. // Then prepare for loading all root level child nodes in the async update
  180. asyncLoading_ = true;
  181. asyncProgress_.file_ = file;
  182. asyncProgress_.xmlFile_.Reset();
  183. asyncProgress_.xmlElement_ = XMLElement();
  184. asyncProgress_.loadedNodes_ = 0;
  185. asyncProgress_.totalNodes_ = file->ReadVLE();
  186. return true;
  187. }
  188. bool Scene::LoadAsyncXML(File* file)
  189. {
  190. if (!file)
  191. {
  192. LOGERROR("Null file for async loading");
  193. return false;
  194. }
  195. StopAsyncLoading();
  196. SharedPtr<XMLFile> xmlFile(new XMLFile(context_));
  197. if (!xmlFile->Load(*file))
  198. return false;
  199. LOGINFO("Loading scene from " + file->GetName());
  200. Clear();
  201. XMLElement rootElement = xmlFile->GetRoot();
  202. // Store own old ID for resolving possible root node references
  203. unsigned nodeID = rootElement.GetInt("id");
  204. resolver_.AddNode(nodeID, this);
  205. // Load the root level components first
  206. if (!Node::LoadXML(rootElement, resolver_, false))
  207. return false;
  208. // Then prepare for loading all root level child nodes in the async update
  209. XMLElement childNodeElement = rootElement.GetChild("node");
  210. asyncLoading_ = true;
  211. asyncProgress_.file_ = file;
  212. asyncProgress_.xmlFile_ = xmlFile;
  213. asyncProgress_.xmlElement_ = childNodeElement;
  214. asyncProgress_.loadedNodes_ = 0;
  215. asyncProgress_.totalNodes_ = 0;
  216. // Count the amount of child nodes
  217. while (childNodeElement)
  218. {
  219. ++asyncProgress_.totalNodes_;
  220. childNodeElement = childNodeElement.GetNext("node");
  221. }
  222. return true;
  223. }
  224. void Scene::StopAsyncLoading()
  225. {
  226. asyncLoading_ = false;
  227. asyncProgress_.file_.Reset();
  228. asyncProgress_.xmlFile_.Reset();
  229. asyncProgress_.xmlElement_ = XMLElement();
  230. resolver_.Reset();
  231. }
  232. void Scene::Clear()
  233. {
  234. StopAsyncLoading();
  235. RemoveAllChildren();
  236. RemoveAllComponents();
  237. fileName_ = String();
  238. checksum_ = 0;
  239. }
  240. void Scene::SetActive(bool enable)
  241. {
  242. active_ = enable;
  243. }
  244. void Scene::SetSmoothingConstant(float constant)
  245. {
  246. smoothingConstant_ = Max(constant, M_EPSILON);
  247. }
  248. void Scene::SetSnapThreshold(float threshold)
  249. {
  250. snapThreshold_ = Max(threshold, 0.0f);
  251. }
  252. void Scene::AddRequiredPackageFile(PackageFile* package)
  253. {
  254. // Do not add packages that failed to load
  255. if (!package || !package->GetNumFiles())
  256. return;
  257. requiredPackageFiles_.Push(SharedPtr<PackageFile>(package));
  258. }
  259. void Scene::ClearRequiredPackageFiles()
  260. {
  261. requiredPackageFiles_.Clear();
  262. }
  263. void Scene::ResetOwner(Connection* owner)
  264. {
  265. for (Map<unsigned, Node*>::Iterator i = allNodes_.Begin(); i != allNodes_.End(); ++i)
  266. {
  267. if (i->second_->GetOwner() == owner)
  268. i->second_->SetOwner(0);
  269. }
  270. }
  271. void Scene::RegisterVar(const String& name)
  272. {
  273. varNames_[ShortStringHash(name)] = name;
  274. }
  275. void Scene::UnregisterVar(const String& name)
  276. {
  277. varNames_.Erase(ShortStringHash(name));
  278. }
  279. void Scene::UnregisterAllVars()
  280. {
  281. varNames_.Clear();
  282. }
  283. Node* Scene::GetNode(unsigned id) const
  284. {
  285. Map<unsigned, Node*>::ConstIterator i = allNodes_.Find(id);
  286. if (i != allNodes_.End())
  287. return i->second_;
  288. else
  289. return 0;
  290. }
  291. Component* Scene::GetComponent(unsigned id) const
  292. {
  293. Map<unsigned, Component*>::ConstIterator i = allComponents_.Find(id);
  294. if (i != allComponents_.End())
  295. return i->second_;
  296. else
  297. return 0;
  298. }
  299. float Scene::GetAsyncProgress() const
  300. {
  301. if (!asyncLoading_ || !asyncProgress_.totalNodes_)
  302. return 1.0f;
  303. else
  304. return (float)asyncProgress_.loadedNodes_ / (float)asyncProgress_.totalNodes_;
  305. }
  306. const String& Scene::GetVarName(ShortStringHash hash) const
  307. {
  308. Map<ShortStringHash, String>::ConstIterator i = varNames_.Find(hash);
  309. return i != varNames_.End() ? i->second_ : emptyVarName;
  310. }
  311. void Scene::Update(float timeStep)
  312. {
  313. if (asyncLoading_)
  314. {
  315. UpdateAsyncLoading();
  316. return;
  317. }
  318. PROFILE(UpdateScene);
  319. using namespace SceneUpdate;
  320. VariantMap eventData;
  321. eventData[P_SCENE] = (void*)this;
  322. eventData[P_TIMESTEP] = timeStep;
  323. // Update variable timestep logic
  324. SendEvent(E_SCENEUPDATE, eventData);
  325. // Update scene subsystems. If a physics world is present, it will be updated, triggering fixed timestep logic updates
  326. SendEvent(E_SCENESUBSYSTEMUPDATE, eventData);
  327. // Update smoothing if enabled (network client scenes)
  328. if (IsSmoothed())
  329. {
  330. PROFILE(UpdateSmoothing);
  331. float constant = 1.0f - Clamp(powf(2.0f, -timeStep * smoothingConstant_), 0.0f, 1.0f);
  332. float squaredSnapThreshold = snapThreshold_ * snapThreshold_;
  333. for (Map<unsigned, Node*>::ConstIterator i = allNodes_.Begin(); i != allNodes_.End() && i->first_ < FIRST_LOCAL_ID; ++i)
  334. i->second_->UpdateSmoothing(constant, squaredSnapThreshold);
  335. }
  336. // Post-update variable timestep logic
  337. SendEvent(E_SCENEPOSTUPDATE, eventData);
  338. }
  339. void Scene::BeginThreadedUpdate()
  340. {
  341. // Check the work queue subsystem whether it actually has created worker threads. If not, do not enter threaded mode.
  342. if (GetSubsystem<WorkQueue>()->GetNumThreads())
  343. threadedUpdate_ = true;
  344. }
  345. void Scene::EndThreadedUpdate()
  346. {
  347. if (!threadedUpdate_)
  348. return;
  349. threadedUpdate_ = false;
  350. if (!delayedDirtyComponents_.Empty())
  351. {
  352. PROFILE(EndThreadedUpdate);
  353. for (PODVector<Component*>::ConstIterator i = delayedDirtyComponents_.Begin(); i != delayedDirtyComponents_.End(); ++i)
  354. (*i)->OnMarkedDirty((*i)->GetNode());
  355. delayedDirtyComponents_.Clear();
  356. }
  357. }
  358. void Scene::DelayedMarkedDirty(Component* component)
  359. {
  360. MutexLock lock(sceneMutex_);
  361. delayedDirtyComponents_.Push(component);
  362. }
  363. unsigned Scene::GetFreeNodeID(CreateMode mode)
  364. {
  365. if (mode == REPLICATED)
  366. {
  367. for (;;)
  368. {
  369. if (!allNodes_.Contains(replicatedNodeID_))
  370. return replicatedNodeID_;
  371. if (replicatedNodeID_ != LAST_REPLICATED_ID)
  372. ++replicatedNodeID_;
  373. else
  374. replicatedNodeID_ = FIRST_REPLICATED_ID;
  375. }
  376. }
  377. else
  378. {
  379. for (;;)
  380. {
  381. if (!allNodes_.Contains(localNodeID_))
  382. return localNodeID_;
  383. if (localNodeID_ != LAST_LOCAL_ID)
  384. ++localNodeID_;
  385. else
  386. localNodeID_ = FIRST_LOCAL_ID;
  387. }
  388. }
  389. }
  390. unsigned Scene::GetFreeComponentID(CreateMode mode)
  391. {
  392. if (mode == REPLICATED)
  393. {
  394. for (;;)
  395. {
  396. if (!allComponents_.Contains(replicatedComponentID_))
  397. return replicatedComponentID_;
  398. if (replicatedComponentID_ != LAST_REPLICATED_ID)
  399. ++replicatedComponentID_;
  400. else
  401. replicatedComponentID_ = FIRST_REPLICATED_ID;
  402. }
  403. }
  404. else
  405. {
  406. for (;;)
  407. {
  408. if (!allComponents_.Contains(localComponentID_))
  409. return localComponentID_;
  410. if (localComponentID_ != LAST_LOCAL_ID)
  411. ++localComponentID_;
  412. else
  413. localComponentID_ = FIRST_LOCAL_ID;
  414. }
  415. }
  416. }
  417. void Scene::NodeAdded(Node* node)
  418. {
  419. if (!node || node->GetScene())
  420. return;
  421. node->SetScene(this);
  422. // If we already have an existing node with the same ID, must remove the scene reference from it
  423. unsigned id = node->GetID();
  424. Map<unsigned, Node*>::Iterator i = allNodes_.Find(id);
  425. if (i != allNodes_.End() && i->second_ != node)
  426. {
  427. LOGWARNING("Overwriting node with ID " + String(id));
  428. i->second_->SetScene(0);
  429. i->second_->SetOwner(0);
  430. }
  431. allNodes_[id] = node;
  432. }
  433. void Scene::NodeRemoved(Node* node)
  434. {
  435. if (!node || node->GetScene() != this)
  436. return;
  437. allNodes_.Erase(node->GetID());
  438. node->SetID(0);
  439. node->SetScene(0);
  440. }
  441. void Scene::ComponentAdded(Component* component)
  442. {
  443. if (!component)
  444. return;
  445. unsigned id = component->GetID();
  446. Map<unsigned, Component*>::Iterator i = allComponents_.Find(id);
  447. if (i != allComponents_.End() && i->second_ != component)
  448. LOGWARNING("Overwriting component with ID " + String(id));
  449. allComponents_[id] = component;
  450. }
  451. void Scene::ComponentRemoved(Component* component)
  452. {
  453. if (!component)
  454. return;
  455. allComponents_.Erase(component->GetID());
  456. component->SetID(0);
  457. }
  458. void Scene::SetVarNamesAttr(String value)
  459. {
  460. Vector<String> varNames = value.Split(';');
  461. varNames_.Clear();
  462. for (Vector<String>::ConstIterator i = varNames.Begin(); i != varNames.End(); ++i)
  463. varNames_[ShortStringHash(*i)] = *i;
  464. }
  465. String Scene::GetVarNamesAttr() const
  466. {
  467. String ret;
  468. for (Map<ShortStringHash, String>::ConstIterator i = varNames_.Begin(); i != varNames_.End(); ++i)
  469. {
  470. if (i != varNames_.Begin())
  471. ret += ';';
  472. ret += i->second_;
  473. }
  474. return ret;
  475. }
  476. void Scene::HandleUpdate(StringHash eventType, VariantMap& eventData)
  477. {
  478. using namespace Update;
  479. if (active_)
  480. Update(eventData[P_TIMESTEP].GetFloat());
  481. }
  482. void Scene::UpdateAsyncLoading()
  483. {
  484. PROFILE(UpdateAsyncLoading);
  485. Timer asyncLoadTimer;
  486. for (;;)
  487. {
  488. if (asyncProgress_.loadedNodes_ >= asyncProgress_.totalNodes_)
  489. {
  490. FinishAsyncLoading();
  491. return;
  492. }
  493. // Read one child node with its full sub-hierarchy from either from binary or XML
  494. if (!asyncProgress_.xmlFile_)
  495. {
  496. unsigned nodeID = asyncProgress_.file_->ReadUInt();
  497. Node* newNode = CreateChild(nodeID, nodeID < FIRST_LOCAL_ID ? REPLICATED : LOCAL);
  498. resolver_.AddNode(nodeID, newNode);
  499. newNode->Load(*asyncProgress_.file_, resolver_);
  500. }
  501. else
  502. {
  503. unsigned nodeID = asyncProgress_.xmlElement_.GetInt("id");
  504. Node* newNode = CreateChild(nodeID, nodeID < FIRST_LOCAL_ID ? REPLICATED : LOCAL);
  505. resolver_.AddNode(nodeID, newNode);
  506. newNode->LoadXML(asyncProgress_.xmlElement_, resolver_);
  507. asyncProgress_.xmlElement_ = asyncProgress_.xmlElement_.GetNext("node");
  508. }
  509. ++asyncProgress_.loadedNodes_;
  510. // Break if time limit exceeded, so that we keep sufficient FPS
  511. if (asyncLoadTimer.GetMSec(false) >= ASYNC_LOAD_MAX_MSEC)
  512. break;
  513. }
  514. using namespace AsyncLoadProgress;
  515. VariantMap eventData;
  516. eventData[P_SCENE] = (void*)this;
  517. eventData[P_PROGRESS] = (float)asyncProgress_.loadedNodes_ / (float)asyncProgress_.totalNodes_;
  518. eventData[P_LOADEDNODES] = asyncProgress_.loadedNodes_;
  519. eventData[P_TOTALNODES] = asyncProgress_.totalNodes_;
  520. SendEvent(E_ASYNCLOADPROGRESS, eventData);
  521. }
  522. void Scene::FinishAsyncLoading()
  523. {
  524. resolver_.Resolve();
  525. ApplyAttributes();
  526. FinishLoading(asyncProgress_.file_);
  527. StopAsyncLoading();
  528. using namespace AsyncLoadFinished;
  529. VariantMap eventData;
  530. eventData[P_SCENE] = (void*)this;
  531. SendEvent(E_ASYNCLOADFINISHED, eventData);
  532. }
  533. void Scene::FinishLoading(Deserializer* source)
  534. {
  535. if (source)
  536. {
  537. fileName_ = source->GetName();
  538. checksum_ = source->GetChecksum();
  539. }
  540. }
  541. void RegisterSceneLibrary(Context* context)
  542. {
  543. Node::RegisterObject(context);
  544. Scene::RegisterObject(context);
  545. }