BsDockManager.cpp 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsDockManager.h"
  4. #include "BsEditorWidgetContainer.h"
  5. #include "BsEditorWidget.h"
  6. #include "BsEditorWidgetManager.h"
  7. #include "BsMath.h"
  8. #include "BsException.h"
  9. #include "BsMesh.h"
  10. #include "BsMaterial.h"
  11. #include "BsVector2.h"
  12. #include "BsCoreApplication.h"
  13. #include "BsRendererManager.h"
  14. #include "BsCoreRenderer.h"
  15. #include "BsSceneObject.h"
  16. #include "BsGUIManager.h"
  17. #include "BsBuiltinEditorResources.h"
  18. #include "BsCGUIWidget.h"
  19. #include "BsCCamera.h"
  20. #include "BsDragAndDropManager.h"
  21. #include "BsGUIDockSlider.h"
  22. #include "BsVertexDataDesc.h"
  23. #include "BsDockManagerLayout.h"
  24. #include "BsEditorWindow.h"
  25. #include "BsGUIPanel.h"
  26. #include "BsCoreThread.h"
  27. #include "BsRendererUtility.h"
  28. using namespace std::placeholders;
  29. namespace BansheeEngine
  30. {
  31. const UINT32 DockManager::DockContainer::SLIDER_SIZE = 3;
  32. const UINT32 DockManager::DockContainer::MIN_CHILD_SIZE = 20;
  33. DockManager::DockContainer::DockContainer(DockManager* manager)
  34. : mIsLeaf(true), mParent(nullptr), mManager(manager), mWidgets(nullptr), mSlider(nullptr), mSplitPosition(0.5f)
  35. , mIsHorizontal(false)
  36. {
  37. mChildren[0] = nullptr;
  38. mChildren[1] = nullptr;
  39. }
  40. DockManager::DockContainer::DockContainer(DockManager* manager, DockContainer* parent)
  41. : mIsLeaf(false), mParent(parent), mManager(manager), mWidgets(nullptr), mSlider(nullptr), mSplitPosition(0.5f)
  42. , mIsHorizontal(false)
  43. {
  44. mChildren[0] = nullptr;
  45. mChildren[1] = nullptr;
  46. }
  47. DockManager::DockContainer::~DockContainer()
  48. {
  49. if (mIsLeaf)
  50. {
  51. if (mWidgets != nullptr)
  52. bs_delete(mWidgets);
  53. if (mGUIWidgetSO != nullptr)
  54. mGUIWidgetSO->destroy();
  55. }
  56. if(!mIsLeaf)
  57. {
  58. if(mChildren[0] != nullptr)
  59. bs_delete(mChildren[0]);
  60. if(mChildren[1] != nullptr)
  61. bs_delete(mChildren[1]);
  62. }
  63. if(mSlider != nullptr)
  64. {
  65. GUIElement::destroy(mSlider);
  66. mSlider = nullptr;
  67. }
  68. }
  69. void DockManager::DockContainer::setArea(INT32 x, INT32 y, UINT32 width, UINT32 height)
  70. {
  71. if(mIsLeaf)
  72. {
  73. if(mWidgets != nullptr)
  74. {
  75. mWidgets->setPosition(x, y);
  76. mWidgets->setSize(width, height);
  77. }
  78. }
  79. mArea.x = x;
  80. mArea.y = y;
  81. mArea.width = width;
  82. mArea.height = height;
  83. updateChildAreas();
  84. }
  85. void DockManager::DockContainer::updateChildAreas()
  86. {
  87. if(!mIsLeaf && mChildren[0] != nullptr && mChildren[1] != nullptr)
  88. {
  89. if(mIsHorizontal)
  90. {
  91. UINT32 remainingSize = (UINT32)std::max(0, (INT32)mArea.height - (INT32)SLIDER_SIZE);
  92. UINT32 sizeTop = Math::floorToInt(remainingSize * mSplitPosition);
  93. UINT32 sizeBottom = remainingSize - sizeTop;
  94. mChildren[0]->setArea(mArea.x, mArea.y, mArea.width, sizeTop);
  95. mChildren[1]->setArea(mArea.x, mArea.y + sizeTop + SLIDER_SIZE, mArea.width, sizeBottom);
  96. mSlider->setWidth(mArea.width);
  97. mSlider->setHeight(SLIDER_SIZE);
  98. mSlider->setPosition(mArea.x, mArea.y + sizeTop);
  99. }
  100. else
  101. {
  102. UINT32 remainingSize = (UINT32)std::max(0, (INT32)mArea.width - (INT32)SLIDER_SIZE);
  103. UINT32 sizeLeft = Math::floorToInt(remainingSize * mSplitPosition);
  104. UINT32 sizeRight = remainingSize - sizeLeft;
  105. mChildren[0]->setArea(mArea.x, mArea.y, sizeLeft, mArea.height);
  106. mChildren[1]->setArea(mArea.x + sizeLeft + SLIDER_SIZE, mArea.y, sizeRight, mArea.height);
  107. mSlider->setWidth(SLIDER_SIZE);
  108. mSlider->setHeight(mArea.height);
  109. mSlider->setPosition(mArea.x + sizeLeft, mArea.y);
  110. }
  111. }
  112. }
  113. void DockManager::DockContainer::makeLeaf(EditorWindowBase* parentWindow)
  114. {
  115. mGUIWidgetSO = SceneObject::create("DockContainer", SOF_Internal | SOF_Persistent | SOF_DontSave);
  116. HGUIWidget guiWidget = mGUIWidgetSO->addComponent<CGUIWidget>(parentWindow->getGUICamera());
  117. guiWidget->setDepth(128);
  118. guiWidget->setSkin(BuiltinEditorResources::instance().getSkin());
  119. mIsLeaf = true;
  120. mWidgets = bs_new<EditorWidgetContainer>(guiWidget->_getInternal(), parentWindow);
  121. mWidgets->onWidgetClosed.connect(std::bind(&DockManager::DockContainer::widgetRemoved, this));
  122. mWidgets->onMaximized.connect(std::bind(&DockManager::DockContainer::maximizeClicked, this));
  123. if(mSlider != nullptr)
  124. {
  125. GUIElement::destroy(mSlider);
  126. mSlider = nullptr;
  127. }
  128. mWidgets->setPosition(mArea.x, mArea.y);
  129. mWidgets->setSize(mArea.width, mArea.height);
  130. }
  131. void DockManager::DockContainer::makeLeaf(const HSceneObject& guiWidgetSO, EditorWidgetContainer* existingContainer)
  132. {
  133. mIsLeaf = true;
  134. mWidgets = existingContainer;
  135. mGUIWidgetSO = guiWidgetSO;
  136. mWidgets->onWidgetClosed.connect(std::bind(&DockManager::DockContainer::widgetRemoved, this));
  137. mWidgets->onMaximized.connect(std::bind(&DockManager::DockContainer::maximizeClicked, this));
  138. if(mSlider != nullptr)
  139. {
  140. GUIElement::destroy(mSlider);
  141. mSlider = nullptr;
  142. }
  143. mWidgets->setPosition(mArea.x, mArea.y);
  144. mWidgets->setSize(mArea.width, mArea.height);
  145. }
  146. void DockManager::DockContainer::addLeft(EditorWidgetBase* widget)
  147. {
  148. if(mIsLeaf)
  149. splitContainer(false, true);
  150. mChildren[0]->addWidget(widget);
  151. }
  152. void DockManager::DockContainer::addRight(EditorWidgetBase* widget)
  153. {
  154. if(mIsLeaf)
  155. splitContainer(false, false);
  156. mChildren[1]->addWidget(widget);
  157. }
  158. void DockManager::DockContainer::addTop(EditorWidgetBase* widget)
  159. {
  160. if(mIsLeaf)
  161. splitContainer(true, true);
  162. mChildren[0]->addWidget(widget);
  163. }
  164. void DockManager::DockContainer::addBottom(EditorWidgetBase* widget)
  165. {
  166. if(mIsLeaf)
  167. splitContainer(true, false);
  168. mChildren[1]->addWidget(widget);
  169. }
  170. void DockManager::DockContainer::splitContainer(bool horizontal, bool newChildIsFirst, float splitPosition)
  171. {
  172. DockContainer* children[2];
  173. UINT32 idxA = newChildIsFirst ? 0 : 1;
  174. UINT32 idxB = (idxA + 1) % 2;
  175. children[idxA] = bs_new<DockContainer>(mManager, this);
  176. children[idxB] = bs_new<DockContainer>(mManager, this);
  177. mWidgets->onWidgetClosed.clear();
  178. mWidgets->onMaximized.clear();
  179. children[idxA]->makeLeaf(mManager->mParentWindow);
  180. children[idxB]->makeLeaf(mGUIWidgetSO, mWidgets);
  181. mWidgets = nullptr;
  182. mGUIWidgetSO = nullptr;
  183. makeSplit(children[0], children[1], horizontal, splitPosition);
  184. }
  185. void DockManager::DockContainer::makeSplit(DockManager::DockContainer* first, DockManager::DockContainer* second, bool horizontal, float splitPosition)
  186. {
  187. mChildren[0] = first;
  188. mChildren[1] = second;
  189. mIsLeaf = false;
  190. mIsHorizontal = horizontal;
  191. mSplitPosition = splitPosition;
  192. if (mWidgets != nullptr)
  193. {
  194. bs_delete(mWidgets);
  195. mWidgets = nullptr;
  196. }
  197. if (mGUIWidgetSO != nullptr)
  198. {
  199. mGUIWidgetSO->destroy(true);
  200. mGUIWidgetSO = nullptr;
  201. }
  202. if (mSlider != nullptr)
  203. {
  204. GUIElement::destroy(mSlider);
  205. mSlider = nullptr;
  206. }
  207. mSlider = GUIDockSlider::create(horizontal, "Separator");
  208. mManager->_getParentWidget()->getPanel()->addElement(mSlider);
  209. mSlider->onDragged.connect(std::bind(&DockManager::DockContainer::sliderDragged, this, _1));
  210. setArea(mArea.x, mArea.y, mArea.width, mArea.height);
  211. }
  212. void DockManager::DockContainer::addWidget(EditorWidgetBase* widget)
  213. {
  214. if(!mIsLeaf)
  215. return;
  216. mWidgets->add(*widget);
  217. }
  218. void DockManager::DockContainer::addWidget(const String& name)
  219. {
  220. if(!mIsLeaf)
  221. return;
  222. EditorWidgetManager::instance().create(name, *mWidgets);
  223. }
  224. void DockManager::DockContainer::sliderDragged(const Vector2I& delta)
  225. {
  226. if(mIsHorizontal && delta.y != 0)
  227. {
  228. UINT32 maxSize = (UINT32)std::max(MIN_CHILD_SIZE, (INT32)mArea.height - (INT32)SLIDER_SIZE - MIN_CHILD_SIZE);
  229. UINT32 remainingSize = (UINT32)std::max(0, (INT32)mArea.height - (INT32)SLIDER_SIZE);
  230. mSplitPosition = Math::clamp((UINT32)Math::floorToInt(remainingSize * mSplitPosition) + delta.y, MIN_CHILD_SIZE, maxSize) / (float)remainingSize;
  231. updateChildAreas();
  232. }
  233. else if(!mIsHorizontal && delta.x != 0)
  234. {
  235. UINT32 maxSize = (UINT32)std::max(MIN_CHILD_SIZE, (INT32)mArea.width - (INT32)SLIDER_SIZE - MIN_CHILD_SIZE);
  236. UINT32 remainingSize = (UINT32)std::max(0, (INT32)mArea.width - (INT32)SLIDER_SIZE);
  237. mSplitPosition = Math::clamp((UINT32)Math::floorToInt(remainingSize * mSplitPosition) + delta.x, MIN_CHILD_SIZE, maxSize) / (float)remainingSize;
  238. updateChildAreas();
  239. }
  240. }
  241. void DockManager::DockContainer::widgetRemoved()
  242. {
  243. assert(mIsLeaf);
  244. if(mWidgets->getNumWidgets() == 0)
  245. {
  246. if(mParent == nullptr) // We're root so we just reset ourselves, can't delete root
  247. {
  248. if (mManager->mIsMaximized)
  249. {
  250. mManager->mMaximizedContainer = this;
  251. mManager->mIsMaximized = false;
  252. }
  253. bs_delete(mWidgets);
  254. mWidgets = nullptr;
  255. mGUIWidgetSO->destroy(true);
  256. mGUIWidgetSO = nullptr;
  257. mIsLeaf = true;
  258. mSplitPosition = 0.5f;
  259. mIsHorizontal = false;
  260. }
  261. else
  262. {
  263. // Replace our parent with our sibling
  264. DockContainer* sibling = nullptr;
  265. if(mParent->mChildren[0] == this)
  266. sibling = mParent->mChildren[1];
  267. else
  268. sibling = mParent->mChildren[0];
  269. if (sibling->mIsLeaf)
  270. {
  271. sibling->mWidgets->onWidgetClosed.clear();
  272. sibling->mWidgets->onMaximized.clear();
  273. mParent->makeLeaf(sibling->mGUIWidgetSO, sibling->mWidgets);
  274. sibling->mWidgets = nullptr;
  275. sibling->mGUIWidgetSO = nullptr;
  276. }
  277. else
  278. {
  279. mParent->makeSplit(sibling->mChildren[0], sibling->mChildren[1], sibling->mIsHorizontal, sibling->mSplitPosition);
  280. sibling->mChildren[0]->mParent = mParent;
  281. sibling->mChildren[1]->mParent = mParent;
  282. sibling->mChildren[0] = nullptr;
  283. sibling->mChildren[1] = nullptr;
  284. }
  285. bs_delete(sibling);
  286. bs_delete(this);
  287. }
  288. }
  289. }
  290. void DockManager::DockContainer::maximizeClicked()
  291. {
  292. mManager->toggleMaximize(this);
  293. }
  294. DockManager::DockContainer* DockManager::DockContainer::find(EditorWidgetContainer* widgetContainer)
  295. {
  296. if(mIsLeaf)
  297. {
  298. if(mWidgets == widgetContainer)
  299. return this;
  300. else
  301. return nullptr;
  302. }
  303. else
  304. {
  305. if(mChildren[0] != nullptr)
  306. {
  307. DockContainer* foundContainer = mChildren[0]->find(widgetContainer);
  308. if (foundContainer != nullptr)
  309. return foundContainer;
  310. }
  311. if(mChildren[1] != nullptr && mChildren[1]->find(widgetContainer) != nullptr)
  312. {
  313. DockContainer* foundContainer = mChildren[1]->find(widgetContainer);
  314. if (foundContainer != nullptr)
  315. return foundContainer;
  316. }
  317. }
  318. return nullptr;
  319. }
  320. DockManager::DockContainer* DockManager::DockContainer::findAtPos(const Vector2I& pos)
  321. {
  322. if(mIsLeaf)
  323. {
  324. if(mArea.contains(pos))
  325. {
  326. return this;
  327. }
  328. }
  329. else
  330. {
  331. if (mChildren[0] != nullptr)
  332. {
  333. DockContainer* foundContainer = mChildren[0]->findAtPos(pos);
  334. if (foundContainer != nullptr)
  335. return foundContainer;
  336. }
  337. if(mChildren[1] != nullptr)
  338. {
  339. DockContainer* foundContainer = mChildren[1]->findAtPos(pos);
  340. if (foundContainer != nullptr)
  341. return foundContainer;
  342. }
  343. }
  344. return nullptr;
  345. }
  346. Rect2I DockManager::DockContainer::getContentBounds() const
  347. {
  348. if(!mIsLeaf || mWidgets == nullptr)
  349. return mArea;
  350. return mWidgets->getContentBounds();
  351. }
  352. void DockManager::DockContainer::update()
  353. {
  354. if (mIsLeaf)
  355. {
  356. if (mWidgets != nullptr)
  357. mWidgets->update();
  358. }
  359. else
  360. {
  361. if (mChildren[0] != nullptr)
  362. mChildren[0]->update();
  363. if (mChildren[1] != nullptr)
  364. mChildren[1]->update();
  365. }
  366. }
  367. DockManager::DockManager(EditorWindowBase* parentWindow, const GUIDimensions& dimensions)
  368. : GUIElementContainer(dimensions), mParentWindow(parentWindow), mRootContainer(this), mIsMaximized(false)
  369. , mMaximizedContainer(nullptr), mMouseOverContainer(nullptr), mHighlightedDropLoc(DockLocation::None)
  370. , mShowOverlay(false)
  371. {
  372. mTopDropPolygon = bs_newN<Vector2>(4);
  373. mBotDropPolygon = bs_newN<Vector2>(4);
  374. mLeftDropPolygon = bs_newN<Vector2>(4);
  375. mRightDropPolygon = bs_newN<Vector2>(4);
  376. for(UINT32 i = 0; i < 4; i++)
  377. {
  378. mTopDropPolygon[i] = Vector2::ZERO;
  379. mBotDropPolygon[i] = Vector2::ZERO;
  380. mLeftDropPolygon[i] = Vector2::ZERO;
  381. mRightDropPolygon[i] = Vector2::ZERO;
  382. }
  383. HMaterial dropOverlayMat = BuiltinEditorResources::instance().createDockDropOverlayMaterial();
  384. mCore.store(bs_new<DockOverlayRenderer>(), std::memory_order_release);
  385. gCoreAccessor().queueCommand(std::bind(&DockManager::initializeOverlayRenderer,
  386. this, dropOverlayMat->getCore()));
  387. }
  388. DockManager::~DockManager()
  389. {
  390. bs_deleteN(mTopDropPolygon, 4);
  391. bs_deleteN(mBotDropPolygon, 4);
  392. bs_deleteN(mLeftDropPolygon, 4);
  393. bs_deleteN(mRightDropPolygon, 4);
  394. gCoreAccessor().queueCommand(std::bind(&DockManager::destroyOverlayRenderer,
  395. this, mCore.load(std::memory_order_relaxed)));
  396. }
  397. void DockManager::initializeOverlayRenderer(const SPtr<MaterialCore>& initData)
  398. {
  399. mCore.load(std::memory_order_acquire)->initialize(initData);
  400. }
  401. void DockManager::destroyOverlayRenderer(DockOverlayRenderer* core)
  402. {
  403. bs_delete(core);
  404. }
  405. DockManager* DockManager::create(EditorWindowBase* parentWindow)
  406. {
  407. return new (bs_alloc<DockManager>()) DockManager(parentWindow, GUIDimensions::create());
  408. }
  409. void DockManager::update()
  410. {
  411. if(!DragAndDropManager::instance().isDragInProgress())
  412. {
  413. mHighlightedDropLoc = DockLocation::None;
  414. mShowOverlay = false;
  415. }
  416. mRootContainer.update();
  417. HCamera camera = mParentWindow->getGUICamera();
  418. DockOverlayRenderer* core = mCore.load(std::memory_order_relaxed);
  419. gCoreAccessor().queueCommand(std::bind(&DockOverlayRenderer::updateData, core, camera->_getCamera()->getCore(),
  420. mDropOverlayMesh->getCore(), mShowOverlay, mHighlightedDropLoc));
  421. }
  422. void DockManager::insert(EditorWidgetContainer* relativeTo, EditorWidgetBase* widgetToInsert, DockLocation location)
  423. {
  424. if(relativeTo != nullptr)
  425. {
  426. DockContainer* container = mRootContainer.find(relativeTo);
  427. if(container == nullptr)
  428. BS_EXCEPT(InternalErrorException, "Cannot find the wanted widget container relative to which the widget should be inserted.");
  429. switch(location)
  430. {
  431. case DockLocation::Left:
  432. container->addLeft(widgetToInsert);
  433. break;
  434. case DockLocation::Right:
  435. container->addRight(widgetToInsert);
  436. break;
  437. case DockLocation::Top:
  438. container->addTop(widgetToInsert);
  439. break;
  440. case DockLocation::Bottom:
  441. container->addBottom(widgetToInsert);
  442. break;
  443. case DockLocation::None:
  444. break;
  445. }
  446. }
  447. else
  448. {
  449. if(mRootContainer.mWidgets != nullptr)
  450. BS_EXCEPT(InternalErrorException, "Trying to insert a widget into dock manager root container but one already exists.");
  451. mRootContainer.makeLeaf(mParentWindow);
  452. mRootContainer.addWidget(widgetToInsert);
  453. }
  454. }
  455. void DockManager::setArea(INT32 x, INT32 y, UINT32 width, UINT32 height)
  456. {
  457. mRootContainer.setArea(x, y, width, height);
  458. mArea = Rect2I(x, y, width, height);
  459. updateDropOverlay(x, y, width, height);
  460. }
  461. void DockManager::closeAll()
  462. {
  463. mRootContainer = DockContainer(this);
  464. mMouseOverContainer = nullptr;
  465. }
  466. SPtr<DockManagerLayout> DockManager::getLayout() const
  467. {
  468. struct StackElem
  469. {
  470. StackElem(DockManagerLayout::Entry* layoutEntry, const DockContainer* container)
  471. :layoutEntry(layoutEntry), container(container)
  472. { }
  473. DockManagerLayout::Entry* layoutEntry;
  474. const DockContainer* container;
  475. };
  476. auto GetWidgetNamesInContainer = [&] (const DockContainer* container)
  477. {
  478. Vector<String> widgetNames;
  479. if(container->mWidgets != nullptr)
  480. {
  481. UINT32 numWidgets = container->mWidgets->getNumWidgets();
  482. for(UINT32 i = 0; i < numWidgets; i++)
  483. {
  484. EditorWidgetBase* widget = container->mWidgets->getWidget(i);
  485. widgetNames.push_back(widget->getName());
  486. }
  487. }
  488. return widgetNames;
  489. };
  490. if (mIsMaximized)
  491. {
  492. SPtr<DockManagerLayout> layout;
  493. if (mRestoredLayout != nullptr)
  494. layout = mRestoredLayout->clone();
  495. else
  496. layout = bs_shared_ptr_new<DockManagerLayout>();
  497. layout->setIsMaximized(true, GetWidgetNamesInContainer(mMaximizedContainer));
  498. return layout;
  499. }
  500. else
  501. {
  502. SPtr<DockManagerLayout> layout = bs_shared_ptr_new<DockManagerLayout>();
  503. DockManagerLayout::Entry* rootEntry = &layout->getRootEntry();
  504. if (mRootContainer.mIsLeaf)
  505. {
  506. rootEntry->isLeaf = true;
  507. rootEntry->widgetNames = GetWidgetNamesInContainer(&mRootContainer);
  508. }
  509. else
  510. {
  511. rootEntry->isLeaf = false;
  512. rootEntry->horizontalSplit = mRootContainer.mIsHorizontal;
  513. rootEntry->splitPosition = mRootContainer.mSplitPosition;
  514. rootEntry->parent = nullptr;
  515. }
  516. Stack<StackElem> todo;
  517. todo.push(StackElem(rootEntry, &mRootContainer));
  518. while (!todo.empty())
  519. {
  520. StackElem currentElem = todo.top();
  521. todo.pop();
  522. if (!currentElem.container->mIsLeaf)
  523. {
  524. for (UINT32 i = 0; i < 2; i++)
  525. {
  526. if (currentElem.container->mChildren[i] == nullptr)
  527. continue;
  528. if (currentElem.container->mChildren[i]->mIsLeaf)
  529. {
  530. Vector<String> widgetNames = GetWidgetNamesInContainer(currentElem.container->mChildren[i]);
  531. currentElem.layoutEntry->children[i] =
  532. DockManagerLayout::Entry::createLeaf(currentElem.layoutEntry, i, widgetNames);
  533. }
  534. else
  535. {
  536. currentElem.layoutEntry->children[i] =
  537. DockManagerLayout::Entry::createContainer(currentElem.layoutEntry, i,
  538. currentElem.container->mChildren[i]->mSplitPosition,
  539. currentElem.container->mChildren[i]->mIsHorizontal);
  540. todo.push(StackElem(currentElem.layoutEntry->children[i], currentElem.container->mChildren[i]));
  541. }
  542. }
  543. }
  544. }
  545. return layout;
  546. }
  547. }
  548. void DockManager::setLayout(const SPtr<DockManagerLayout>& layout)
  549. {
  550. // Undock all currently docked widgets
  551. Vector<EditorWidgetBase*> undockedWidgets;
  552. std::function<void(DockContainer*)> undockWidgets = [&](DockContainer* container)
  553. {
  554. while (!container->mIsLeaf)
  555. {
  556. // Due to the way undocking works a container can be transfromed from non-leaf to leaf
  557. // if its child container is deleted, so we need to check to that specially
  558. undockWidgets(container->mChildren[0]);
  559. }
  560. if (container->mIsLeaf)
  561. {
  562. if (container->mWidgets != nullptr)
  563. {
  564. UINT32 numWidgets = container->mWidgets->getNumWidgets();
  565. for (UINT32 i = 0; i < numWidgets; i++)
  566. {
  567. EditorWidgetBase* curWidget = container->mWidgets->getWidget(0);
  568. EditorWidgetManager::instance().close(curWidget);
  569. undockedWidgets.push_back(curWidget);
  570. }
  571. }
  572. }
  573. };
  574. undockWidgets(&mRootContainer);
  575. mRootContainer = DockContainer(this);
  576. // Load layout
  577. struct StackEntry
  578. {
  579. StackEntry(const DockManagerLayout::Entry* layoutEntry, DockContainer* container)
  580. :layoutEntry(layoutEntry), container(container)
  581. { }
  582. const DockManagerLayout::Entry* layoutEntry;
  583. DockContainer* container;
  584. };
  585. auto GetLeafEntry = [] (const DockManagerLayout::Entry* parentEntry, UINT32 childIdx) -> const DockManagerLayout::Entry*
  586. {
  587. while(true)
  588. {
  589. if(parentEntry->isLeaf)
  590. return parentEntry;
  591. parentEntry = parentEntry->children[childIdx];
  592. }
  593. return nullptr;
  594. };
  595. auto OpenWidgets = [&] (DockContainer* parent, const Vector<String>& widgetNames)
  596. {
  597. for(auto& widgetName : widgetNames)
  598. {
  599. parent->addWidget(widgetName);
  600. }
  601. };
  602. // Prune layout by removing invalid leafs (ones with no widgets, or widgets that no longer exist)
  603. layout->pruneInvalidLeaves();
  604. if (layout->isMaximized())
  605. {
  606. mRestoredLayout = layout->clone();
  607. mRestoredLayout->setIsMaximized(false, Vector<String>());
  608. const Vector<String>& maximizedWidgets = mRestoredLayout->getMaximizedWidgetNames();
  609. if (maximizedWidgets.size() > 0) // If zero, entire layout is empty
  610. {
  611. mRootContainer.makeLeaf(mParentWindow);
  612. OpenWidgets(&mRootContainer, maximizedWidgets);
  613. }
  614. }
  615. else
  616. {
  617. // Dock elements
  618. const DockManagerLayout::Entry* rootEntry = &layout->getRootEntry();
  619. const DockManagerLayout::Entry* leafEntry = GetLeafEntry(rootEntry, 0);
  620. if (leafEntry->widgetNames.size() > 0) // If zero, entire layout is empty
  621. {
  622. mRootContainer.makeLeaf(mParentWindow);
  623. OpenWidgets(&mRootContainer, leafEntry->widgetNames);
  624. if (!rootEntry->isLeaf)
  625. {
  626. Stack<StackEntry> layoutTodo;
  627. layoutTodo.push(StackEntry(rootEntry, &mRootContainer));
  628. while (!layoutTodo.empty())
  629. {
  630. StackEntry curEntry = layoutTodo.top();
  631. layoutTodo.pop();
  632. leafEntry = GetLeafEntry(curEntry.layoutEntry->children[1], 0);
  633. curEntry.container->splitContainer(curEntry.layoutEntry->horizontalSplit, false, curEntry.layoutEntry->splitPosition);
  634. DockContainer* otherChild = curEntry.container->mChildren[1];
  635. OpenWidgets(otherChild, leafEntry->widgetNames);
  636. if (!curEntry.layoutEntry->children[0]->isLeaf)
  637. layoutTodo.push(StackEntry(curEntry.layoutEntry->children[0], curEntry.container->mChildren[0]));
  638. if (!curEntry.layoutEntry->children[1]->isLeaf)
  639. layoutTodo.push(StackEntry(curEntry.layoutEntry->children[1], curEntry.container->mChildren[1]));
  640. }
  641. }
  642. }
  643. // Set container sizes
  644. {
  645. Stack<StackEntry> layoutTodo;
  646. layoutTodo.push(StackEntry(rootEntry, &mRootContainer));
  647. while (!layoutTodo.empty())
  648. {
  649. StackEntry curEntry = layoutTodo.top();
  650. layoutTodo.pop();
  651. if (!curEntry.layoutEntry->isLeaf)
  652. {
  653. layoutTodo.push(StackEntry(curEntry.layoutEntry->children[0], curEntry.container->mChildren[0]));
  654. layoutTodo.push(StackEntry(curEntry.layoutEntry->children[1], curEntry.container->mChildren[1]));
  655. }
  656. }
  657. }
  658. }
  659. // Destroy any widgets that are no longer docked anywhere
  660. for(auto& widget : undockedWidgets)
  661. {
  662. if(widget->_getParent() == nullptr)
  663. widget->close();
  664. }
  665. setArea(mArea.x, mArea.y, mArea.width, mArea.height);
  666. }
  667. void DockManager::toggleMaximize(DockContainer* container)
  668. {
  669. if (mIsMaximized)
  670. {
  671. if (mRestoredLayout != nullptr)
  672. setLayout(mRestoredLayout);
  673. mRestoredLayout = nullptr;
  674. mMaximizedContainer = nullptr;
  675. mIsMaximized = false;
  676. }
  677. else
  678. {
  679. mRestoredLayout = getLayout();
  680. mMaximizedContainer = container;
  681. Vector<String> maximizedWidgetNames;
  682. if (container->mWidgets != nullptr)
  683. {
  684. UINT32 numWidgets = container->mWidgets->getNumWidgets();
  685. for (UINT32 i = 0; i < numWidgets; i++)
  686. {
  687. EditorWidgetBase* widget = container->mWidgets->getWidget(i);
  688. maximizedWidgetNames.push_back(widget->getName());
  689. }
  690. }
  691. SPtr<DockManagerLayout> maxLayout = bs_shared_ptr_new<DockManagerLayout>();
  692. DockManagerLayout::Entry& rootEntry = maxLayout->getRootEntry();
  693. rootEntry.isLeaf = true;
  694. rootEntry.widgetNames = maximizedWidgetNames;
  695. setLayout(maxLayout);
  696. mIsMaximized = true;
  697. }
  698. }
  699. void DockManager::updateClippedBounds()
  700. {
  701. // TODO - Clipping not actually accounted for but shouldn't matter as right now DockManager is only used in one specific situation
  702. mClippedBounds = mRootContainer.mArea;
  703. }
  704. void DockManager::updateDropOverlay(INT32 x, INT32 y, UINT32 width, UINT32 height)
  705. {
  706. const static int spacing = 10;
  707. const static float innerScale = 0.15f;
  708. UINT32 outWidth = std::max(0, (INT32)width - spacing * 2);
  709. UINT32 outHeight = std::max(0, (INT32)height - spacing * 2);
  710. UINT32 innerOffset = outWidth > outHeight ? Math::floorToInt(innerScale * outHeight) : Math::floorToInt(innerScale * outWidth);
  711. UINT32 inWidth = outWidth - innerOffset;
  712. UINT32 inHeight = outHeight - innerOffset;
  713. INT32 inXOffset = Math::floorToInt((outWidth - inWidth) * 0.5f);
  714. INT32 inYOffset = Math::floorToInt((outHeight - inHeight) * 0.5f);
  715. Vector2 outTopLeft((float)x, (float)y);
  716. Vector2 outTopRight((float)(x + outWidth), (float)y);
  717. Vector2 outBotLeft((float)x, (float)(y + outHeight));
  718. Vector2 outBotRight((float)(x + outWidth), (float)(y + outHeight));
  719. Vector2 inTopLeft((float)(x + inXOffset), (float)(y + inYOffset));
  720. Vector2 inTopRight((float)(x + inXOffset + inWidth), (float)(y + inYOffset));
  721. Vector2 inBotLeft((float)(x + inXOffset), (float)(y + inYOffset + inHeight));
  722. Vector2 inBotRight((float)(x + inXOffset + inWidth), (float)(y + inYOffset + inHeight));
  723. SPtr<VertexDataDesc> vertexDesc = bs_shared_ptr_new<VertexDataDesc>();
  724. vertexDesc->addVertElem(VET_FLOAT2, VES_POSITION);
  725. vertexDesc->addVertElem(VET_COLOR, VES_COLOR);
  726. SPtr<MeshData> meshData = bs_shared_ptr_new<MeshData>(16, 24, vertexDesc);
  727. auto vertIter = meshData->getVec2DataIter(VES_POSITION);
  728. auto colIter = meshData->getDWORDDataIter(VES_COLOR);
  729. // Top
  730. Vector2 topOffset((float)spacing, 0.0f);
  731. mTopDropPolygon[0] = outTopLeft + topOffset;
  732. mTopDropPolygon[1] = outTopRight + topOffset;
  733. mTopDropPolygon[2] = inTopRight + topOffset;
  734. mTopDropPolygon[3] = inTopLeft + topOffset;
  735. vertIter.addValue(mTopDropPolygon[0]);
  736. vertIter.addValue(mTopDropPolygon[1]);
  737. vertIter.addValue(mTopDropPolygon[2]);
  738. vertIter.addValue(mTopDropPolygon[3]);
  739. Color color(1.0f, 0.0f, 0.0f, 0.0f);
  740. UINT32 color32 = color.getAsRGBA();
  741. colIter.addValue(color32);
  742. colIter.addValue(color32);
  743. colIter.addValue(color32);
  744. colIter.addValue(color32);
  745. // Bottom
  746. Vector2 botOffset((float)spacing, (float)spacing * 2.0f);
  747. mBotDropPolygon[0] = inBotLeft + botOffset;
  748. mBotDropPolygon[1] = inBotRight + botOffset;
  749. mBotDropPolygon[2] = outBotRight + botOffset;
  750. mBotDropPolygon[3] = outBotLeft + botOffset;
  751. vertIter.addValue(mBotDropPolygon[0]);
  752. vertIter.addValue(mBotDropPolygon[1]);
  753. vertIter.addValue(mBotDropPolygon[2]);
  754. vertIter.addValue(mBotDropPolygon[3]);
  755. color = Color(0.0f, 1.0f, 0.0f, 0.0f);
  756. color32 = color.getAsRGBA();
  757. colIter.addValue(color32);
  758. colIter.addValue(color32);
  759. colIter.addValue(color32);
  760. colIter.addValue(color32);
  761. // Left
  762. Vector2 leftOffset(0.0f, (float)spacing);
  763. mLeftDropPolygon[0] = outTopLeft + leftOffset;
  764. mLeftDropPolygon[1] = inTopLeft + leftOffset;
  765. mLeftDropPolygon[2] = inBotLeft + leftOffset;
  766. mLeftDropPolygon[3] = outBotLeft + leftOffset;
  767. vertIter.addValue(mLeftDropPolygon[0]);
  768. vertIter.addValue(mLeftDropPolygon[1]);
  769. vertIter.addValue(mLeftDropPolygon[2]);
  770. vertIter.addValue(mLeftDropPolygon[3]);
  771. color = Color(0.0f, 0.0f, 1.0f, 0.0f);
  772. color32 = color.getAsRGBA();
  773. colIter.addValue(color32);
  774. colIter.addValue(color32);
  775. colIter.addValue(color32);
  776. colIter.addValue(color32);
  777. // Right
  778. Vector2 rightOffset((float)spacing * 2.0f, (float)spacing);
  779. mRightDropPolygon[0] = inTopRight + rightOffset;
  780. mRightDropPolygon[1] = outTopRight + rightOffset;
  781. mRightDropPolygon[2] = outBotRight + rightOffset;
  782. mRightDropPolygon[3] = inBotRight + rightOffset;
  783. vertIter.addValue(mRightDropPolygon[0]);
  784. vertIter.addValue(mRightDropPolygon[1]);
  785. vertIter.addValue(mRightDropPolygon[2]);
  786. vertIter.addValue(mRightDropPolygon[3]);
  787. color = Color(0.0f, 0.0f, 0.0f, 1.0f);
  788. color32 = color.getAsRGBA();
  789. colIter.addValue(color32);
  790. colIter.addValue(color32);
  791. colIter.addValue(color32);
  792. colIter.addValue(color32);
  793. UINT32* indexData = meshData->getIndices32();
  794. // Top
  795. indexData[0] = 0;
  796. indexData[1] = 1;
  797. indexData[2] = 2;
  798. indexData[3] = 0;
  799. indexData[4] = 2;
  800. indexData[5] = 3;
  801. // Bottom
  802. indexData[6] = 4;
  803. indexData[7] = 5;
  804. indexData[8] = 6;
  805. indexData[9] = 4;
  806. indexData[10] = 6;
  807. indexData[11] = 7;
  808. // Left
  809. indexData[12] = 8;
  810. indexData[13] = 9;
  811. indexData[14] = 10;
  812. indexData[15] = 8;
  813. indexData[16] = 10;
  814. indexData[17] = 11;
  815. // Right
  816. indexData[18] = 12;
  817. indexData[19] = 13;
  818. indexData[20] = 14;
  819. indexData[21] = 12;
  820. indexData[22] = 14;
  821. indexData[23] = 15;
  822. mDropOverlayMesh = Mesh::create(meshData);
  823. }
  824. bool DockManager::_mouseEvent(const GUIMouseEvent& event)
  825. {
  826. if(event.getType() == GUIMouseEventType::MouseDragAndDropDragged)
  827. {
  828. if(DragAndDropManager::instance().getDragTypeId() != (UINT32)DragAndDropType::EditorWidget)
  829. return false;
  830. const Vector2I& widgetRelPos = event.getPosition();
  831. const Matrix4& worldTfrm = _getParentWidget()->getWorldTfrm();
  832. Vector4 tfrmdPos = worldTfrm.multiplyAffine(Vector4((float)widgetRelPos.x, (float)widgetRelPos.y, 0.0f, 1.0f));
  833. Vector2 windowPosVec(tfrmdPos.x, tfrmdPos.y);
  834. Vector2I windowPos(Math::roundToInt(windowPosVec.x), Math::roundToInt(windowPosVec.y));
  835. mMouseOverContainer = mRootContainer.findAtPos(windowPos);
  836. if(mMouseOverContainer == nullptr)
  837. mMouseOverContainer = &mRootContainer;
  838. Rect2I overlayBounds;
  839. if(mMouseOverContainer != nullptr)
  840. overlayBounds = mMouseOverContainer->getContentBounds();
  841. // Update mesh if needed
  842. if(mLastOverlayBounds != overlayBounds)
  843. {
  844. if(overlayBounds.width <= 0 || overlayBounds.height <= 0)
  845. mDropOverlayMesh = HMesh();
  846. else
  847. updateDropOverlay(overlayBounds.x, overlayBounds.y, overlayBounds.width, overlayBounds.height);
  848. mLastOverlayBounds = overlayBounds;
  849. }
  850. // Check if we need to highlight any drop locations
  851. if(mMouseOverContainer != nullptr)
  852. {
  853. if(insidePolygon(mTopDropPolygon, 4, windowPosVec))
  854. mHighlightedDropLoc = DockLocation::Top;
  855. else if(insidePolygon(mBotDropPolygon, 4, windowPosVec))
  856. mHighlightedDropLoc = DockLocation::Bottom;
  857. else if(insidePolygon(mLeftDropPolygon, 4, windowPosVec))
  858. mHighlightedDropLoc = DockLocation::Left;
  859. else if(insidePolygon(mRightDropPolygon, 4, windowPosVec))
  860. mHighlightedDropLoc = DockLocation::Right;
  861. else
  862. mHighlightedDropLoc = DockLocation::None;
  863. if(overlayBounds.contains(windowPos))
  864. mShowOverlay = true;
  865. else
  866. mShowOverlay = false;
  867. }
  868. else
  869. mShowOverlay = false;
  870. return false;
  871. }
  872. else if(event.getType() == GUIMouseEventType::MouseDragAndDropDropped)
  873. {
  874. if(DragAndDropManager::instance().getDragTypeId() != (UINT32)DragAndDropType::EditorWidget)
  875. return false;
  876. EditorWidgetBase* draggedWidget = reinterpret_cast<EditorWidgetBase*>(DragAndDropManager::instance().getDragData());
  877. const Vector2I& widgetRelPos = event.getPosition();
  878. const Matrix4& worldTfrm = _getParentWidget()->getWorldTfrm();
  879. Vector4 tfrmdPos = worldTfrm.multiplyAffine(Vector4((float)widgetRelPos.x, (float)widgetRelPos.y, 0.0f, 1.0f));
  880. Vector2 windowPosVec(tfrmdPos.x, tfrmdPos.y);
  881. Vector2I windowPos(Math::roundToInt(windowPosVec.x), Math::roundToInt(windowPosVec.y));
  882. DockContainer* mouseOverContainer = mRootContainer.findAtPos(windowPos);
  883. if(mouseOverContainer == nullptr)
  884. {
  885. Rect2I overlayBounds = mRootContainer.getContentBounds();
  886. if(overlayBounds.contains(windowPos))
  887. {
  888. insert(nullptr, draggedWidget, DockLocation::None);
  889. return true;
  890. }
  891. }
  892. else
  893. {
  894. if (insidePolygon(mTopDropPolygon, 4, windowPosVec))
  895. {
  896. insert(mouseOverContainer->mWidgets, draggedWidget, DockLocation::Top);
  897. return true;
  898. }
  899. else if (insidePolygon(mBotDropPolygon, 4, windowPosVec))
  900. {
  901. insert(mouseOverContainer->mWidgets, draggedWidget, DockLocation::Bottom);
  902. return true;
  903. }
  904. else if (insidePolygon(mLeftDropPolygon, 4, windowPosVec))
  905. {
  906. insert(mouseOverContainer->mWidgets, draggedWidget, DockLocation::Left);
  907. return true;
  908. }
  909. else if (insidePolygon(mRightDropPolygon, 4, windowPosVec))
  910. {
  911. insert(mouseOverContainer->mWidgets, draggedWidget, DockLocation::Right);
  912. return true;
  913. }
  914. }
  915. }
  916. return false;
  917. }
  918. // TODO - Move to a separate Polygon class?
  919. bool DockManager::insidePolygon(Vector2* polyPoints, UINT32 numPoints, Vector2 point) const
  920. {
  921. bool isInside = false;
  922. for (UINT32 i = 0, j = numPoints - 1; i < numPoints; j = i++)
  923. {
  924. float lineVal = (polyPoints[j].x - polyPoints[i].x) * (point.y - polyPoints[i].y) / (polyPoints[j].y - polyPoints[i].y) + polyPoints[i].x;
  925. if (((polyPoints[i].y > point.y) != (polyPoints[j].y > point.y)) && (point.x < lineVal))
  926. isInside = !isInside;
  927. }
  928. return isInside;
  929. }
  930. const Color DockOverlayRenderer::TINT_COLOR = Color(0.44f, 0.44f, 0.44f, 0.22f);
  931. const Color DockOverlayRenderer::HIGHLIGHT_COLOR = Color(0.44f, 0.44f, 0.44f, 0.42f);
  932. DockOverlayRenderer::DockOverlayRenderer()
  933. :mHighlightedDropLoc(DockManager::DockLocation::None), mShowOverlay(false)
  934. {
  935. }
  936. DockOverlayRenderer::~DockOverlayRenderer()
  937. {
  938. if (mCamera != nullptr)
  939. {
  940. SPtr<CoreRenderer> activeRenderer = RendererManager::instance().getActive();
  941. activeRenderer->unregisterRenderCallback(mCamera.get(), 40);
  942. }
  943. }
  944. void DockOverlayRenderer::initialize(const SPtr<MaterialCore>& material)
  945. {
  946. mMaterial = material;
  947. mParams = material->createParamsSet();
  948. }
  949. void DockOverlayRenderer::updateData(const SPtr<CameraCore>& camera, const SPtr<MeshCore>& mesh, bool active,
  950. DockManager::DockLocation location)
  951. {
  952. if (mCamera != camera)
  953. {
  954. SPtr<CoreRenderer> activeRenderer = RendererManager::instance().getActive();
  955. if (mCamera != nullptr)
  956. activeRenderer->unregisterRenderCallback(mCamera.get(), 40);
  957. if (camera != nullptr)
  958. activeRenderer->registerRenderCallback(camera.get(), 40, std::bind(&DockOverlayRenderer::render, this), true);
  959. }
  960. mCamera = camera;
  961. mMesh = mesh;
  962. mShowOverlay = active;
  963. mHighlightedDropLoc = location;
  964. }
  965. void DockOverlayRenderer::render()
  966. {
  967. THROW_IF_NOT_CORE_THREAD;
  968. if (!mShowOverlay)
  969. return;
  970. SPtr<ViewportCore> viewport = mCamera->getViewport();
  971. float invViewportWidth = 1.0f / (viewport->getWidth() * 0.5f);
  972. float invViewportHeight = 1.0f / (viewport->getHeight() * 0.5f);
  973. mMaterial->setFloat("invViewportWidth", invViewportWidth);
  974. mMaterial->setFloat("invViewportHeight", invViewportHeight);
  975. mMaterial->setColor("tintColor", TINT_COLOR);
  976. mMaterial->setColor("highlightColor", HIGHLIGHT_COLOR);
  977. Color highlightColor;
  978. switch (mHighlightedDropLoc)
  979. {
  980. case DockManager::DockLocation::Top:
  981. highlightColor = Color(1.0f, 0.0f, 0.0f, 0.0f);
  982. break;
  983. case DockManager::DockLocation::Bottom:
  984. highlightColor = Color(0.0f, 1.0f, 0.0f, 0.0f);
  985. break;
  986. case DockManager::DockLocation::Left:
  987. highlightColor = Color(0.0f, 0.0f, 1.0f, 0.0f);
  988. break;
  989. case DockManager::DockLocation::Right:
  990. highlightColor = Color(0.0f, 0.0f, 0.0f, 1.0f);
  991. break;
  992. case DockManager::DockLocation::None:
  993. highlightColor = Color(0.0f, 0.0f, 0.0f, 0.0f);
  994. break;
  995. }
  996. mMaterial->setColor("highlightActive", highlightColor);
  997. mMaterial->updateParamsSet(mParams);
  998. gRendererUtility().setPass(mMaterial);
  999. gRendererUtility().setPassParams(mParams);
  1000. gRendererUtility().draw(mMesh, mMesh->getProperties().getSubMesh(0));
  1001. }
  1002. }