Octree.cpp 19 KB

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