Octree.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. //
  2. // Copyright (c) 2008-2013 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include "Precompiled.h"
  23. #include "Context.h"
  24. #include "DebugRenderer.h"
  25. #include "Profiler.h"
  26. #include "Octree.h"
  27. #include "Scene.h"
  28. #include "SceneEvents.h"
  29. #include "Sort.h"
  30. #include "WorkQueue.h"
  31. #include "DebugNew.h"
  32. #ifdef _MSC_VER
  33. #pragma warning(disable:4355)
  34. #endif
  35. namespace Urho3D
  36. {
  37. static const float DEFAULT_OCTREE_SIZE = 1000.0f;
  38. static const int DEFAULT_OCTREE_LEVELS = 8;
  39. static const int RAYCASTS_PER_WORK_ITEM = 4;
  40. void RaycastDrawablesWork(const WorkItem* item, unsigned threadIndex)
  41. {
  42. Octree* octree = reinterpret_cast<Octree*>(item->aux_);
  43. Drawable** start = reinterpret_cast<Drawable**>(item->start_);
  44. Drawable** end = reinterpret_cast<Drawable**>(item->end_);
  45. const RayOctreeQuery& query = *octree->rayQuery_;
  46. PODVector<RayQueryResult>& results = octree->rayQueryResults_[threadIndex];
  47. while (start != end)
  48. {
  49. Drawable* drawable = *start;
  50. drawable->ProcessRayQuery(query, results);
  51. ++start;
  52. }
  53. }
  54. void UpdateDrawablesWork(const WorkItem* item, unsigned threadIndex)
  55. {
  56. const FrameInfo& frame = *(reinterpret_cast<FrameInfo*>(item->aux_));
  57. WeakPtr<Drawable>* start = reinterpret_cast<WeakPtr<Drawable>*>(item->start_);
  58. WeakPtr<Drawable>* end = reinterpret_cast<WeakPtr<Drawable>*>(item->end_);
  59. while (start != end)
  60. {
  61. Drawable* drawable = *start;
  62. if (drawable)
  63. {
  64. drawable->Update(frame);
  65. drawable->updateQueued_ = false;
  66. }
  67. ++start;
  68. }
  69. }
  70. inline bool CompareRayQueryResults(const RayQueryResult& lhs, const RayQueryResult& rhs)
  71. {
  72. return lhs.distance_ < rhs.distance_;
  73. }
  74. Octant::Octant(const BoundingBox& box, unsigned level, Octant* parent, Octree* root, unsigned index) :
  75. worldBoundingBox_(box),
  76. level_(level),
  77. numDrawables_(0),
  78. parent_(parent),
  79. root_(root),
  80. index_(index)
  81. {
  82. center_ = worldBoundingBox_.Center();
  83. halfSize_ = worldBoundingBox_.Size() * 0.5f;
  84. cullingBox_ = BoundingBox(worldBoundingBox_.min_ - halfSize_, worldBoundingBox_.max_ + halfSize_);
  85. for (unsigned i = 0; i < NUM_OCTANTS; ++i)
  86. children_[i] = 0;
  87. }
  88. Octant::~Octant()
  89. {
  90. Release();
  91. }
  92. Octant* Octant::GetOrCreateChild(unsigned index)
  93. {
  94. if (children_[index])
  95. return children_[index];
  96. Vector3 newMin = worldBoundingBox_.min_;
  97. Vector3 newMax = worldBoundingBox_.max_;
  98. Vector3 oldCenter = worldBoundingBox_.Center();
  99. if (index & 1)
  100. newMin.x_ = oldCenter.x_;
  101. else
  102. newMax.x_ = oldCenter.x_;
  103. if (index & 2)
  104. newMin.y_ = oldCenter.y_;
  105. else
  106. newMax.y_ = oldCenter.y_;
  107. if (index & 4)
  108. newMin.z_ = oldCenter.z_;
  109. else
  110. newMax.z_ = oldCenter.z_;
  111. children_[index] = new Octant(BoundingBox(newMin, newMax), level_ + 1, this, root_, index);
  112. return children_[index];
  113. }
  114. void Octant::DeleteChild(unsigned index)
  115. {
  116. delete children_[index];
  117. children_[index] = 0;
  118. }
  119. void Octant::DeleteChild(Octant* octant)
  120. {
  121. assert(octant && octant->index_ < NUM_OCTANTS);
  122. DeleteChild(octant->index_);
  123. }
  124. void Octant::InsertDrawable(Drawable* drawable, const Vector3& boxCenter, const Vector3& boxSize)
  125. {
  126. // If size OK or outside, stop recursion & insert here. Also, if drawable is not occluded, must stay in the root octant
  127. // so that hierarchic octant occlusion does not erroneously hide the drawable
  128. if ((!drawable->IsOccludee() && this == root_) || CheckDrawableSize(boxSize) ||
  129. cullingBox_.IsInside(drawable->GetWorldBoundingBox()) != INSIDE)
  130. {
  131. Octant* oldOctant = drawable->octant_;
  132. if (oldOctant != this)
  133. {
  134. // Add first, then remove, because drawable count going to zero deletes the octree branch in question
  135. AddDrawable(drawable);
  136. if (oldOctant)
  137. oldOctant->RemoveDrawable(drawable, false);
  138. }
  139. return;
  140. }
  141. unsigned x = boxCenter.x_ < center_.x_ ? 0 : 1;
  142. unsigned y = boxCenter.y_ < center_.y_ ? 0 : 2;
  143. unsigned z = boxCenter.z_ < center_.z_ ? 0 : 4;
  144. GetOrCreateChild(x + y + z)->InsertDrawable(drawable, boxCenter, boxSize);
  145. }
  146. bool Octant::CheckDrawableSize(const Vector3& boxSize) const
  147. {
  148. // If max split level, size always OK
  149. if (level_ != root_->GetNumLevels())
  150. return boxSize.x_ >= halfSize_.x_ || boxSize.y_ >= halfSize_.y_ || boxSize.z_ >= halfSize_.z_;
  151. else
  152. return true;
  153. }
  154. void Octant::ResetRoot()
  155. {
  156. root_ = 0;
  157. // The whole octree is being destroyed, just detach the drawables
  158. for (PODVector<Drawable*>::Iterator i = drawables_.Begin(); i != drawables_.End(); ++i)
  159. (*i)->SetOctant(0);
  160. for (unsigned i = 0; i < NUM_OCTANTS; ++i)
  161. {
  162. if (children_[i])
  163. children_[i]->ResetRoot();
  164. }
  165. }
  166. void Octant::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
  167. {
  168. if (debug && debug->IsInside(worldBoundingBox_))
  169. {
  170. debug->AddBoundingBox(worldBoundingBox_, Color(0.25f, 0.25f, 0.25f), depthTest);
  171. for (unsigned i = 0; i < NUM_OCTANTS; ++i)
  172. {
  173. if (children_[i])
  174. children_[i]->DrawDebugGeometry(debug, depthTest);
  175. }
  176. }
  177. }
  178. void Octant::GetDrawablesInternal(OctreeQuery& query, bool inside) const
  179. {
  180. if (this != root_)
  181. {
  182. Intersection res = query.TestOctant(cullingBox_, inside);
  183. if (res == INSIDE)
  184. inside = true;
  185. else if (res == OUTSIDE)
  186. {
  187. // Fully outside, so cull this octant, its children & drawables
  188. return;
  189. }
  190. }
  191. if (drawables_.Size())
  192. {
  193. Drawable** start = const_cast<Drawable**>(&drawables_[0]);
  194. Drawable** end = start + drawables_.Size();
  195. query.TestDrawables(start, end, inside);
  196. }
  197. for (unsigned i = 0; i < NUM_OCTANTS; ++i)
  198. {
  199. if (children_[i])
  200. children_[i]->GetDrawablesInternal(query, inside);
  201. }
  202. }
  203. void Octant::GetDrawablesInternal(RayOctreeQuery& query) const
  204. {
  205. float octantDist = query.ray_.HitDistance(cullingBox_);
  206. if (octantDist > query.maxDistance_)
  207. return;
  208. if (drawables_.Size())
  209. {
  210. Drawable** start = const_cast<Drawable**>(&drawables_[0]);
  211. Drawable** end = start + drawables_.Size();
  212. while (start != end)
  213. {
  214. Drawable* drawable = *start++;
  215. if (drawable->IsVisible() && (drawable->GetDrawableFlags() & query.drawableFlags_) &&
  216. (drawable->GetViewMask() & query.viewMask_))
  217. drawable->ProcessRayQuery(query, query.result_);
  218. }
  219. }
  220. for (unsigned i = 0; i < NUM_OCTANTS; ++i)
  221. {
  222. if (children_[i])
  223. children_[i]->GetDrawablesInternal(query);
  224. }
  225. }
  226. void Octant::GetDrawablesOnlyInternal(RayOctreeQuery& query, PODVector<Drawable*>& drawables) const
  227. {
  228. float octantDist = query.ray_.HitDistance(cullingBox_);
  229. if (octantDist > query.maxDistance_)
  230. return;
  231. if (drawables_.Size())
  232. {
  233. Drawable** start = const_cast<Drawable**>(&drawables_[0]);
  234. Drawable** end = start + drawables_.Size();
  235. while (start != end)
  236. {
  237. Drawable* drawable = *start++;
  238. if (drawable->IsVisible() && (drawable->GetDrawableFlags() & query.drawableFlags_) &&
  239. (drawable->GetViewMask() & query.viewMask_))
  240. drawables.Push(drawable);
  241. }
  242. }
  243. for (unsigned i = 0; i < NUM_OCTANTS; ++i)
  244. {
  245. if (children_[i])
  246. children_[i]->GetDrawablesOnlyInternal(query, drawables);
  247. }
  248. }
  249. void Octant::Release()
  250. {
  251. if (root_)
  252. {
  253. // Remove the drawables (if any) from this octant to the root octant
  254. for (PODVector<Drawable*>::Iterator i = drawables_.Begin(); i != drawables_.End(); ++i)
  255. {
  256. (*i)->SetOctant(root_);
  257. root_->drawables_.Push(*i);
  258. root_->QueueReinsertion(*i);
  259. }
  260. drawables_.Clear();
  261. numDrawables_ = 0;
  262. }
  263. for (unsigned i = 0; i < NUM_OCTANTS; ++i)
  264. DeleteChild(i);
  265. }
  266. OBJECTTYPESTATIC(Octree);
  267. Octree::Octree(Context* context) :
  268. Component(context),
  269. Octant(BoundingBox(-DEFAULT_OCTREE_SIZE, DEFAULT_OCTREE_SIZE), 0, 0, this),
  270. numLevels_(DEFAULT_OCTREE_LEVELS)
  271. {
  272. // Resize threaded ray query intermediate result vector according to number of worker threads
  273. rayQueryResults_.Resize(GetSubsystem<WorkQueue>()->GetNumThreads() + 1);
  274. }
  275. Octree::~Octree()
  276. {
  277. // Reset root pointer from all child octants now so that they do not move their drawables to root
  278. ResetRoot();
  279. }
  280. void Octree::RegisterObject(Context* context)
  281. {
  282. context->RegisterFactory<Octree>();
  283. Vector3 defaultBoundsMin = Vector3::ONE * DEFAULT_OCTREE_SIZE;
  284. Vector3 defaultBoundsMax = -Vector3::ONE * DEFAULT_OCTREE_SIZE;
  285. ATTRIBUTE(Octree, VAR_VECTOR3, "Bounding Box Min", worldBoundingBox_.min_, defaultBoundsMin, AM_DEFAULT);
  286. ATTRIBUTE(Octree, VAR_VECTOR3, "Bounding Box Max", worldBoundingBox_.max_, defaultBoundsMax, AM_DEFAULT);
  287. ATTRIBUTE(Octree, VAR_INT, "Number of Levels", numLevels_, DEFAULT_OCTREE_LEVELS, AM_DEFAULT);
  288. }
  289. void Octree::OnSetAttribute(const AttributeInfo& attr, const Variant& src)
  290. {
  291. // If any of the (size) attributes change, resize the octree
  292. Component::OnSetAttribute(attr, src);
  293. Resize(worldBoundingBox_, numLevels_);
  294. }
  295. void Octree::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
  296. {
  297. if (debug)
  298. {
  299. PROFILE(OctreeDrawDebug);
  300. Octant::DrawDebugGeometry(debug, depthTest);
  301. }
  302. }
  303. void Octree::Resize(const BoundingBox& box, unsigned numLevels)
  304. {
  305. PROFILE(ResizeOctree);
  306. numLevels = Max((int)numLevels, 1);
  307. // If drawables exist, they are temporarily moved to the root
  308. for (unsigned i = 0; i < NUM_OCTANTS; ++i)
  309. DeleteChild(i);
  310. Vector3 halfSize = box.Size() * 0.5f;
  311. worldBoundingBox_ = box;
  312. cullingBox_ = BoundingBox(worldBoundingBox_.min_ - halfSize, worldBoundingBox_.max_ + halfSize);
  313. numDrawables_ = drawables_.Size();
  314. numLevels_ = numLevels;
  315. }
  316. void Octree::Update(const FrameInfo& frame)
  317. {
  318. UpdateDrawables(frame);
  319. // Notify drawable update being finished. Custom animation (eg. IK) can be done at this point
  320. Scene* scene = GetScene();
  321. if (scene)
  322. {
  323. using namespace SceneDrawableUpdateFinished;
  324. VariantMap eventData;
  325. eventData[P_SCENE] = (void*)scene;
  326. eventData[P_TIMESTEP] = frame.timeStep_;
  327. scene->SendEvent(E_SCENEDRAWABLEUPDATEFINISHED, eventData);
  328. }
  329. ReinsertDrawables(frame);
  330. }
  331. void Octree::AddManualDrawable(Drawable* drawable)
  332. {
  333. if (!drawable || drawable->GetOctant())
  334. return;
  335. AddDrawable(drawable);
  336. }
  337. void Octree::RemoveManualDrawable(Drawable* drawable)
  338. {
  339. if (!drawable)
  340. return;
  341. Octant* octant = drawable->GetOctant();
  342. if (octant && octant->GetRoot() == this)
  343. octant->RemoveDrawable(drawable);
  344. }
  345. void Octree::GetDrawables(OctreeQuery& query) const
  346. {
  347. query.result_.Clear();
  348. GetDrawablesInternal(query, false);
  349. }
  350. void Octree::Raycast(RayOctreeQuery& query) const
  351. {
  352. PROFILE(Raycast);
  353. query.result_.Clear();
  354. WorkQueue* queue = GetSubsystem<WorkQueue>();
  355. // If no worker threads or no triangle-level testing, do not create work items
  356. if (!queue->GetNumThreads() || query.level_ < RAY_TRIANGLE)
  357. GetDrawablesInternal(query);
  358. else
  359. {
  360. // Threaded ray query: first get the drawables
  361. rayQuery_ = &query;
  362. rayQueryDrawables_.Clear();
  363. GetDrawablesOnlyInternal(query, rayQueryDrawables_);
  364. // Check that amount of drawables is large enough to justify threading
  365. if (rayQueryDrawables_.Size() > RAYCASTS_PER_WORK_ITEM)
  366. {
  367. for (unsigned i = 0; i < rayQueryResults_.Size(); ++i)
  368. rayQueryResults_[i].Clear();
  369. WorkItem item;
  370. item.workFunction_ = RaycastDrawablesWork;
  371. item.aux_ = const_cast<Octree*>(this);
  372. PODVector<Drawable*>::Iterator start = rayQueryDrawables_.Begin();
  373. while (start != rayQueryDrawables_.End())
  374. {
  375. PODVector<Drawable*>::Iterator end = rayQueryDrawables_.End();
  376. if (end - start > RAYCASTS_PER_WORK_ITEM)
  377. end = start + RAYCASTS_PER_WORK_ITEM;
  378. item.start_ = &(*start);
  379. item.end_ = &(*end);
  380. queue->AddWorkItem(item);
  381. start = end;
  382. }
  383. // Merge per-thread results
  384. queue->Complete();
  385. for (unsigned i = 0; i < rayQueryResults_.Size(); ++i)
  386. query.result_.Insert(query.result_.End(), rayQueryResults_[i].Begin(), rayQueryResults_[i].End());
  387. }
  388. else
  389. {
  390. for (PODVector<Drawable*>::Iterator i = rayQueryDrawables_.Begin(); i != rayQueryDrawables_.End(); ++i)
  391. (*i)->ProcessRayQuery(query, query.result_);
  392. }
  393. }
  394. Sort(query.result_.Begin(), query.result_.End(), CompareRayQueryResults);
  395. }
  396. void Octree::RaycastSingle(RayOctreeQuery& query) const
  397. {
  398. PROFILE(Raycast);
  399. query.result_.Clear();
  400. rayQueryDrawables_.Clear();
  401. GetDrawablesOnlyInternal(query, rayQueryDrawables_);
  402. // Sort by increasing hit distance to AABB
  403. for (PODVector<Drawable*>::Iterator i = rayQueryDrawables_.Begin(); i != rayQueryDrawables_.End(); ++i)
  404. {
  405. Drawable* drawable = *i;
  406. drawable->SetSortValue(query.ray_.HitDistance(drawable->GetWorldBoundingBox()));
  407. }
  408. Sort(rayQueryDrawables_.Begin(), rayQueryDrawables_.End(), CompareDrawables);
  409. // Then do the actual test according to the query, and early-out as possible
  410. float closestHit = M_INFINITY;
  411. for (PODVector<Drawable*>::Iterator i = rayQueryDrawables_.Begin(); i != rayQueryDrawables_.End(); ++i)
  412. {
  413. Drawable* drawable = *i;
  414. if (drawable->GetSortValue() <= Min(closestHit, query.maxDistance_))
  415. {
  416. unsigned oldSize = query.result_.Size();
  417. drawable->ProcessRayQuery(query, query.result_);
  418. if (query.result_.Size() > oldSize)
  419. closestHit = Min(closestHit, query.result_.Back().distance_);
  420. }
  421. else
  422. break;
  423. }
  424. if (query.result_.Size() > 1)
  425. {
  426. Sort(query.result_.Begin(), query.result_.End(), CompareRayQueryResults);
  427. query.result_.Resize(1);
  428. }
  429. }
  430. void Octree::QueueUpdate(Drawable* drawable)
  431. {
  432. drawableUpdates_.Push(WeakPtr<Drawable>(drawable));
  433. drawable->updateQueued_ = true;
  434. }
  435. void Octree::QueueReinsertion(Drawable* drawable)
  436. {
  437. Scene* scene = GetScene();
  438. if (scene && scene->IsThreadedUpdate())
  439. {
  440. MutexLock lock(octreeMutex_);
  441. drawableReinsertions_.Push(WeakPtr<Drawable>(drawable));
  442. }
  443. else
  444. drawableReinsertions_.Push(WeakPtr<Drawable>(drawable));
  445. drawable->reinsertionQueued_ = true;
  446. }
  447. void Octree::DrawDebugGeometry(bool depthTest)
  448. {
  449. DebugRenderer* debug = GetComponent<DebugRenderer>();
  450. DrawDebugGeometry(debug, depthTest);
  451. }
  452. void Octree::UpdateDrawables(const FrameInfo& frame)
  453. {
  454. // Let drawables update themselves before reinsertion
  455. if (drawableUpdates_.Empty())
  456. return;
  457. PROFILE(AnimateDrawables);
  458. Scene* scene = GetScene();
  459. WorkQueue* queue = GetSubsystem<WorkQueue>();
  460. scene->BeginThreadedUpdate();
  461. WorkItem item;
  462. item.workFunction_ = UpdateDrawablesWork;
  463. item.aux_ = const_cast<FrameInfo*>(&frame);
  464. Vector<WeakPtr<Drawable> >::Iterator start = drawableUpdates_.Begin();
  465. while (start != drawableUpdates_.End())
  466. {
  467. Vector<WeakPtr<Drawable> >::Iterator end = drawableUpdates_.End();
  468. if (end - start > DRAWABLES_PER_WORK_ITEM)
  469. end = start + DRAWABLES_PER_WORK_ITEM;
  470. item.start_ = &(*start);
  471. item.end_ = &(*end);
  472. queue->AddWorkItem(item);
  473. start = end;
  474. }
  475. queue->Complete();
  476. scene->EndThreadedUpdate();
  477. drawableUpdates_.Clear();
  478. }
  479. void Octree::ReinsertDrawables(const FrameInfo& frame)
  480. {
  481. if (drawableReinsertions_.Empty())
  482. return;
  483. PROFILE(ReinsertToOctree);
  484. // Reinsert drawables into the octree
  485. for (Vector<WeakPtr<Drawable> >::Iterator i = drawableReinsertions_.Begin(); i != drawableReinsertions_.End(); ++i)
  486. {
  487. Drawable* drawable = *i;
  488. if (!drawable)
  489. continue;
  490. Octant* octant = drawable->GetOctant();
  491. if (!octant)
  492. continue;
  493. const BoundingBox& box = drawable->GetWorldBoundingBox();
  494. Vector3 boxCenter = box.Center();
  495. Vector3 boxSize = box.Size();
  496. if (octant == this)
  497. {
  498. // Handle root octant as special case: if outside the root, do not reinsert
  499. if (GetCullingBox().IsInside(box) == INSIDE && !CheckDrawableSize(boxSize))
  500. InsertDrawable(drawable, boxCenter, boxSize);
  501. }
  502. else
  503. {
  504. // Break if drawable no longer belongs to this octree (could theoretically happen as we do not explicitly clean up
  505. // drawables from the reinsertion list as they leave the octree)
  506. if (octant->GetRoot() != this)
  507. continue;
  508. // Otherwise reinsert if outside current octant or if size does not fit octant size
  509. if (octant->GetCullingBox().IsInside(box) != INSIDE || !octant->CheckDrawableSize(boxSize))
  510. InsertDrawable(drawable, boxCenter, boxSize);
  511. }
  512. drawable->reinsertionQueued_ = false;
  513. }
  514. drawableReinsertions_.Clear();
  515. }
  516. }