guiNavEditorCtrl.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2014 Daniel Buckmaster
  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
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell 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
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "torqueConfig.h"
  23. #ifdef TORQUE_TOOLS
  24. #include "platform/platform.h"
  25. #include "guiNavEditorCtrl.h"
  26. #include "duDebugDrawTorque.h"
  27. #include "console/engineAPI.h"
  28. #include "console/consoleTypes.h"
  29. #include "math/util/frustum.h"
  30. #include "math/mathUtils.h"
  31. #include "gfx/primBuilder.h"
  32. #include "gfx/gfxDrawUtil.h"
  33. #include "scene/sceneRenderState.h"
  34. #include "scene/sceneManager.h"
  35. #include "gui/core/guiCanvas.h"
  36. #include "gui/buttons/guiButtonCtrl.h"
  37. #include "gui/worldEditor/undoActions.h"
  38. #include "T3D/gameBase/gameConnection.h"
  39. #include "T3D/AI/AIController.h"
  40. IMPLEMENT_CONOBJECT(GuiNavEditorCtrl);
  41. ConsoleDocClass(GuiNavEditorCtrl,
  42. "@brief GUI tool that makes up the Navigation Editor\n\n"
  43. "Editor use only.\n\n"
  44. "@internal"
  45. );
  46. // Each of the mode names directly correlates with the Nav Editor's tool palette.
  47. const String GuiNavEditorCtrl::mSelectMode = "SelectMode";
  48. const String GuiNavEditorCtrl::mLinkMode = "LinkMode";
  49. const String GuiNavEditorCtrl::mCoverMode = "CoverMode";
  50. const String GuiNavEditorCtrl::mTileMode = "TileMode";
  51. const String GuiNavEditorCtrl::mTestMode = "TestMode";
  52. GuiNavEditorCtrl::GuiNavEditorCtrl()
  53. {
  54. mMode = mSelectMode;
  55. mIsDirty = false;
  56. mStartDragMousePoint = InvalidMousePoint;
  57. mMesh = NULL;
  58. mCurTile = mTile = -1;
  59. mPlayer = mCurPlayer = NULL;
  60. mSpawnClass = mSpawnDatablock = "";
  61. mLinkStart = Point3F::Max;
  62. mLink = mCurLink = -1;
  63. }
  64. GuiNavEditorCtrl::~GuiNavEditorCtrl()
  65. {
  66. }
  67. void GuiNavEditorUndoAction::undo()
  68. {
  69. }
  70. bool GuiNavEditorCtrl::onAdd()
  71. {
  72. if(!Parent::onAdd())
  73. return false;
  74. GFXStateBlockDesc desc;
  75. desc.fillMode = GFXFillSolid;
  76. desc.setBlend(false);
  77. desc.setZReadWrite(false, false);
  78. desc.setCullMode(GFXCullNone);
  79. mZDisableSB = GFX->createStateBlock(desc);
  80. desc.setZReadWrite(true, true);
  81. mZEnableSB = GFX->createStateBlock(desc);
  82. SceneManager::getPreRenderSignal().notify(this, &GuiNavEditorCtrl::_prepRenderImage);
  83. return true;
  84. }
  85. void GuiNavEditorCtrl::initPersistFields()
  86. {
  87. docsURL;
  88. addField("isDirty", TypeBool, Offset(mIsDirty, GuiNavEditorCtrl));
  89. addField("spawnClass", TypeRealString, Offset(mSpawnClass, GuiNavEditorCtrl),
  90. "Class of object to spawn in test mode.");
  91. addField("spawnDatablock", TypeRealString, Offset(mSpawnDatablock, GuiNavEditorCtrl),
  92. "Datablock to give new objects in test mode.");
  93. Parent::initPersistFields();
  94. }
  95. void GuiNavEditorCtrl::onSleep()
  96. {
  97. Parent::onSleep();
  98. //mMode = mSelectMode;
  99. }
  100. void GuiNavEditorCtrl::selectMesh(NavMesh *mesh)
  101. {
  102. mesh->setSelected(true);
  103. mMesh = mesh;
  104. }
  105. DefineEngineMethod(GuiNavEditorCtrl, selectMesh, void, (S32 id),,
  106. "@brief Select a NavMesh object.")
  107. {
  108. NavMesh *obj;
  109. if(Sim::findObject(id, obj))
  110. object->selectMesh(obj);
  111. }
  112. S32 GuiNavEditorCtrl::getMeshId()
  113. {
  114. return mMesh.isNull() ? 0 : mMesh->getId();
  115. }
  116. DefineEngineMethod(GuiNavEditorCtrl, getMesh, S32, (),,
  117. "@brief Select a NavMesh object.")
  118. {
  119. return object->getMeshId();
  120. }
  121. S32 GuiNavEditorCtrl::getPlayerId()
  122. {
  123. return mPlayer.isNull() ? 0 : mPlayer->getId();
  124. }
  125. DefineEngineMethod(GuiNavEditorCtrl, getPlayer, S32, (),,
  126. "@brief Select a NavMesh object.")
  127. {
  128. return object->getPlayerId();
  129. }
  130. void GuiNavEditorCtrl::deselect()
  131. {
  132. if(!mMesh.isNull())
  133. mMesh->setSelected(false);
  134. mMesh = NULL;
  135. mPlayer = mCurPlayer = NULL;
  136. mCurTile = mTile = -1;
  137. mLinkStart = Point3F::Max;
  138. mLink = mCurLink = -1;
  139. }
  140. DefineEngineMethod(GuiNavEditorCtrl, deselect, void, (),,
  141. "@brief Deselect whatever is currently selected in the editor.")
  142. {
  143. object->deselect();
  144. }
  145. void GuiNavEditorCtrl::deleteLink()
  146. {
  147. if(!mMesh.isNull() && mLink != -1)
  148. {
  149. mMesh->selectLink(mLink, false);
  150. mMesh->deleteLink(mLink);
  151. mLink = -1;
  152. Con::executef(this, "onLinkDeselected");
  153. }
  154. }
  155. DefineEngineMethod(GuiNavEditorCtrl, deleteLink, void, (),,
  156. "@brief Delete the currently selected link.")
  157. {
  158. object->deleteLink();
  159. }
  160. void GuiNavEditorCtrl::setLinkFlags(const LinkData &d)
  161. {
  162. if(mMode == mLinkMode && !mMesh.isNull() && mLink != -1)
  163. {
  164. mMesh->setLinkFlags(mLink, d);
  165. }
  166. }
  167. DefineEngineMethod(GuiNavEditorCtrl, setLinkFlags, void, (U32 flags),,
  168. "@Brief Set jump and drop properties of the selected link.")
  169. {
  170. object->setLinkFlags(LinkData(flags));
  171. }
  172. void GuiNavEditorCtrl::buildTile()
  173. {
  174. if(!mMesh.isNull() && mTile != -1)
  175. mMesh->buildTile(mTile);
  176. }
  177. DefineEngineMethod(GuiNavEditorCtrl, buildTile, void, (),,
  178. "@brief Build the currently selected tile.")
  179. {
  180. object->buildTile();
  181. }
  182. void GuiNavEditorCtrl::spawnPlayer(const Point3F &pos)
  183. {
  184. SceneObject *obj = (SceneObject*)Sim::spawnObject(mSpawnClass, mSpawnDatablock);
  185. if(obj)
  186. {
  187. MatrixF mat(true);
  188. mat.setPosition(pos);
  189. obj->setTransform(mat);
  190. SimObject* cleanup = Sim::findObject("MissionCleanup");
  191. if(cleanup)
  192. {
  193. SimGroup* missionCleanup = dynamic_cast<SimGroup*>(cleanup);
  194. missionCleanup->addObject(obj);
  195. }
  196. mPlayer = obj;
  197. #ifdef TORQUE_NAVIGATION_ENABLED
  198. AIPlayer* asAIPlayer = dynamic_cast<AIPlayer*>(obj);
  199. if (asAIPlayer) //try direct
  200. {
  201. Con::executef(this, "onPlayerSelected", Con::getIntArg(asAIPlayer->mLinkTypes.getFlags()));
  202. }
  203. else
  204. {
  205. ShapeBase* sbo = dynamic_cast<ShapeBase*>(obj);
  206. if (sbo->getAIController())
  207. {
  208. if (sbo->getAIController()->mControllerData)
  209. Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags()));
  210. }
  211. else
  212. {
  213. #endif
  214. Con::executef(this, "onPlayerSelected");
  215. #ifdef TORQUE_NAVIGATION_ENABLED
  216. }
  217. }
  218. #endif
  219. }
  220. }
  221. DefineEngineMethod(GuiNavEditorCtrl, spawnPlayer, void, (),,
  222. "@brief Spawn an AIPlayer at the centre of the screen.")
  223. {
  224. Point3F c;
  225. if(object->get3DCentre(c))
  226. object->spawnPlayer(c);
  227. }
  228. void GuiNavEditorCtrl::get3DCursor(GuiCursor *&cursor,
  229. bool &visible,
  230. const Gui3DMouseEvent &event_)
  231. {
  232. //cursor = mAddNodeCursor;
  233. //visible = false;
  234. cursor = NULL;
  235. visible = false;
  236. GuiCanvas *root = getRoot();
  237. if(!root)
  238. return;
  239. S32 currCursor = PlatformCursorController::curArrow;
  240. if(root->mCursorChanged == currCursor)
  241. return;
  242. PlatformWindow *window = root->getPlatformWindow();
  243. PlatformCursorController *controller = window->getCursorController();
  244. // We've already changed the cursor,
  245. // so set it back before we change it again.
  246. if(root->mCursorChanged != -1)
  247. controller->popCursor();
  248. // Now change the cursor shape
  249. controller->pushCursor(currCursor);
  250. root->mCursorChanged = currCursor;
  251. }
  252. bool GuiNavEditorCtrl::get3DCentre(Point3F &pos)
  253. {
  254. Point3F screen, start, end;
  255. screen.set(getExtent().x / 2, getExtent().y / 2, 0);
  256. unproject(screen, &start);
  257. screen.z = 1.0f;
  258. unproject(screen, &end);
  259. RayInfo ri;
  260. if(gServerContainer.castRay(start, end, StaticObjectType, &ri))
  261. {
  262. pos = ri.point;
  263. return true;
  264. }
  265. return false;
  266. }
  267. void GuiNavEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
  268. {
  269. mGizmo->on3DMouseDown(event);
  270. if(!isFirstResponder())
  271. setFirstResponder();
  272. mouseLock();
  273. // Construct a LineSegment from the camera position to 1000 meters away in
  274. // the direction clicked.
  275. // If that segment hits the terrain, truncate the ray to only be that length.
  276. Point3F startPnt = event.pos;
  277. Point3F endPnt = event.pos + event.vec * 1000.0f;
  278. RayInfo ri;
  279. U8 keys = Input::getModifierKeys();
  280. bool shift = keys & SI_LSHIFT;
  281. bool ctrl = keys & SI_LCTRL;
  282. if(mMode == mLinkMode && !mMesh.isNull())
  283. {
  284. if(gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  285. {
  286. U32 link = mMesh->getLink(ri.point);
  287. if(link != -1)
  288. {
  289. if(mLink != -1)
  290. mMesh->selectLink(mLink, false);
  291. mMesh->selectLink(link, true, false);
  292. mLink = link;
  293. LinkData d = mMesh->getLinkFlags(mLink);
  294. Con::executef(this, "onLinkSelected", Con::getIntArg(d.getFlags()));
  295. }
  296. else
  297. {
  298. if(mLink != -1)
  299. {
  300. mMesh->selectLink(mLink, false);
  301. mLink = -1;
  302. Con::executef(this, "onLinkDeselected");
  303. }
  304. else
  305. {
  306. if(mLinkStart != Point3F::Max)
  307. {
  308. mMesh->addLink(mLinkStart, ri.point);
  309. if(!shift)
  310. mLinkStart = Point3F::Max;
  311. }
  312. else
  313. {
  314. mLinkStart = ri.point;
  315. }
  316. }
  317. }
  318. }
  319. else
  320. {
  321. mMesh->selectLink(mLink, false);
  322. mLink = -1;
  323. Con::executef(this, "onLinkDeselected");
  324. }
  325. }
  326. if(mMode == mTileMode && !mMesh.isNull())
  327. {
  328. if(gServerContainer.castRay(startPnt, endPnt, StaticShapeObjectType, &ri))
  329. {
  330. mTile = mMesh->getTile(ri.point);
  331. mMesh->renderTileData(dd, mTile);
  332. }
  333. }
  334. if(mMode == mTestMode)
  335. {
  336. // Spawn new character
  337. if(ctrl)
  338. {
  339. if(gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  340. spawnPlayer(ri.point);
  341. }
  342. // Deselect character
  343. else if(shift)
  344. {
  345. mPlayer = NULL;
  346. Con::executef(this, "onPlayerDeselected");
  347. }
  348. // Select/move character
  349. else
  350. {
  351. if(gServerContainer.castRay(startPnt, endPnt, PlayerObjectType | VehicleObjectType, &ri))
  352. {
  353. if(ri.object)
  354. {
  355. mPlayer = ri.object;
  356. #ifdef TORQUE_NAVIGATION_ENABLED
  357. AIPlayer* asAIPlayer = dynamic_cast<AIPlayer*>(mPlayer.getPointer());
  358. if (asAIPlayer) //try direct
  359. {
  360. Con::executef(this, "onPlayerSelected", Con::getIntArg(asAIPlayer->mLinkTypes.getFlags()));
  361. }
  362. else
  363. {
  364. ShapeBase* sbo = dynamic_cast<ShapeBase*>(mPlayer.getPointer());
  365. if (sbo->getAIController())
  366. {
  367. if (sbo->getAIController()->mControllerData)
  368. Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags()));
  369. }
  370. else
  371. {
  372. #endif
  373. Con::executef(this, "onPlayerSelected");
  374. }
  375. #ifdef TORQUE_NAVIGATION_ENABLED
  376. }
  377. }
  378. #endif
  379. }
  380. else if (!mPlayer.isNull() && gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  381. {
  382. AIPlayer* asAIPlayer = dynamic_cast<AIPlayer*>(mPlayer.getPointer());
  383. if (asAIPlayer) //try direct
  384. {
  385. #ifdef TORQUE_NAVIGATION_ENABLED
  386. asAIPlayer->setPathDestination(ri.point);
  387. #else
  388. asAIPlayer->setMoveDestination(ri.point,false);
  389. #endif
  390. }
  391. else
  392. {
  393. ShapeBase* sbo = dynamic_cast<ShapeBase*>(mPlayer.getPointer());
  394. if (sbo->getAIController())
  395. {
  396. if (sbo->getAIController()->mControllerData)
  397. sbo->getAIController()->getNav()->setPathDestination(ri.point, true);
  398. }
  399. }
  400. }
  401. }
  402. }
  403. }
  404. void GuiNavEditorCtrl::on3DMouseUp(const Gui3DMouseEvent & event)
  405. {
  406. // Keep the Gizmo up to date.
  407. mGizmo->on3DMouseUp(event);
  408. mouseUnlock();
  409. }
  410. void GuiNavEditorCtrl::on3DMouseMove(const Gui3DMouseEvent & event)
  411. {
  412. //if(mSelRiver != NULL && mSelNode != -1)
  413. //mGizmo->on3DMouseMove(event);
  414. Point3F startPnt = event.pos;
  415. Point3F endPnt = event.pos + event.vec * 1000.0f;
  416. RayInfo ri;
  417. if(mMode == mLinkMode && !mMesh.isNull())
  418. {
  419. if(gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  420. {
  421. U32 link = mMesh->getLink(ri.point);
  422. if(link != -1)
  423. {
  424. if(link != mLink)
  425. {
  426. if(mCurLink != -1)
  427. mMesh->selectLink(mCurLink, false);
  428. mMesh->selectLink(link, true, true);
  429. }
  430. mCurLink = link;
  431. }
  432. else
  433. {
  434. if(mCurLink != mLink)
  435. mMesh->selectLink(mCurLink, false);
  436. mCurLink = -1;
  437. }
  438. }
  439. else
  440. {
  441. mMesh->selectLink(mCurLink, false);
  442. mCurLink = -1;
  443. }
  444. }
  445. // Select a tile from our current NavMesh.
  446. if(mMode == mTileMode && !mMesh.isNull())
  447. {
  448. if(gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  449. mCurTile = mMesh->getTile(ri.point);
  450. else
  451. mCurTile = -1;
  452. }
  453. if(mMode == mTestMode)
  454. {
  455. if(gServerContainer.castRay(startPnt, endPnt, PlayerObjectType | VehicleObjectType, &ri))
  456. mCurPlayer = ri.object;
  457. else
  458. mCurPlayer = NULL;
  459. }
  460. }
  461. void GuiNavEditorCtrl::on3DMouseDragged(const Gui3DMouseEvent & event)
  462. {
  463. mGizmo->on3DMouseDragged(event);
  464. if(mGizmo->isDirty())
  465. {
  466. Point3F scale = mGizmo->getScale();
  467. const MatrixF &mat = mGizmo->getTransform();
  468. VectorF normal;
  469. mat.getColumn(2, &normal);
  470. //mSelRiver->setNode(pos, scale.x, scale.z, normal, mSelNode);
  471. mIsDirty = true;
  472. }
  473. }
  474. void GuiNavEditorCtrl::on3DMouseEnter(const Gui3DMouseEvent & event)
  475. {
  476. }
  477. void GuiNavEditorCtrl::on3DMouseLeave(const Gui3DMouseEvent & event)
  478. {
  479. }
  480. void GuiNavEditorCtrl::updateGuiInfo()
  481. {
  482. }
  483. void GuiNavEditorCtrl::onRender(Point2I offset, const RectI &updateRect)
  484. {
  485. PROFILE_SCOPE(GuiNavEditorCtrl_OnRender);
  486. Parent::onRender(offset, updateRect);
  487. return;
  488. }
  489. static void renderBoxOutline(const Box3F &box, const ColorI &col)
  490. {
  491. if(box != Box3F::Invalid)
  492. {
  493. GFXStateBlockDesc desc;
  494. desc.setCullMode(GFXCullNone);
  495. desc.setFillModeSolid();
  496. desc.setZReadWrite(true, false);
  497. desc.setBlend(true);
  498. GFX->getDrawUtil()->drawCube(desc, box, ColorI(col, 20));
  499. desc.setFillModeWireframe();
  500. desc.setBlend(false);
  501. GFX->getDrawUtil()->drawCube(desc, box, ColorI(col, 255));
  502. }
  503. }
  504. void GuiNavEditorCtrl::renderScene(const RectI & updateRect)
  505. {
  506. GFX->setStateBlock(mZDisableSB);
  507. // get the projected size...
  508. GameConnection* connection = GameConnection::getConnectionToServer();
  509. if(!connection)
  510. return;
  511. // Grab the camera's transform
  512. MatrixF mat;
  513. connection->getControlCameraTransform(0, &mat);
  514. // Get the camera position
  515. Point3F camPos;
  516. mat.getColumn(3,&camPos);
  517. if(mMode == mLinkMode)
  518. {
  519. if(mLinkStart != Point3F::Max)
  520. {
  521. GFXStateBlockDesc desc;
  522. desc.setBlend(false);
  523. desc.setZReadWrite(true ,true);
  524. MatrixF linkMat(true);
  525. linkMat.setPosition(mLinkStart);
  526. Point3F scale(0.8f, 0.8f, 0.8f);
  527. GFX->getDrawUtil()->drawTransform(desc, linkMat, &scale);
  528. }
  529. }
  530. if(mMode == mTileMode && !mMesh.isNull())
  531. {
  532. renderBoxOutline(mMesh->getTileBox(mCurTile), ColorI::BLUE);
  533. renderBoxOutline(mMesh->getTileBox(mTile), ColorI::GREEN);
  534. /*if (Con::getBoolVariable("$Nav::Editor::renderVoxels", false)) dd.renderGroup(0);
  535. if (Con::getBoolVariable("$Nav::Editor::renderInput", false))
  536. {
  537. dd.depthMask(false);
  538. dd.renderGroup(1);
  539. dd.depthMask(true);
  540. }*/
  541. }
  542. if(mMode == mTestMode)
  543. {
  544. if(!mCurPlayer.isNull())
  545. renderBoxOutline(mCurPlayer->getWorldBox(), ColorI::BLUE);
  546. if(!mPlayer.isNull())
  547. renderBoxOutline(mPlayer->getWorldBox(), ColorI::GREEN);
  548. }
  549. duDebugDrawTorque d;
  550. if(!mMesh.isNull())
  551. mMesh->renderLinks(d);
  552. // Now draw all the 2d stuff!
  553. GFX->setClipRect(updateRect);
  554. }
  555. bool GuiNavEditorCtrl::getStaticPos(const Gui3DMouseEvent & event, Point3F &tpos)
  556. {
  557. // Find clicked point on the terrain
  558. Point3F startPnt = event.pos;
  559. Point3F endPnt = event.pos + event.vec * 1000.0f;
  560. RayInfo ri;
  561. bool hit;
  562. hit = gServerContainer.castRay(startPnt, endPnt, StaticShapeObjectType, &ri);
  563. tpos = ri.point;
  564. return hit;
  565. }
  566. void GuiNavEditorCtrl::setMode(String mode, bool sourceShortcut = false)
  567. {
  568. mMode = mode;
  569. Con::executef(this, "onModeSet", mode);
  570. if(sourceShortcut)
  571. Con::executef(this, "paletteSync", mode);
  572. }
  573. void GuiNavEditorCtrl::submitUndo(const UTF8 *name)
  574. {
  575. // Grab the mission editor undo manager.
  576. UndoManager *undoMan = NULL;
  577. if(!Sim::findObject("EUndoManager", undoMan))
  578. {
  579. Con::errorf("GuiNavEditorCtrl::submitUndo() - EUndoManager not found!");
  580. return;
  581. }
  582. // Setup the action.
  583. GuiNavEditorUndoAction *action = new GuiNavEditorUndoAction(name);
  584. action->mNavEditor = this;
  585. undoMan->addAction(action);
  586. }
  587. void GuiNavEditorCtrl::_prepRenderImage(SceneManager* sceneGraph, const SceneRenderState* state)
  588. {
  589. /*if(isAwake() && River::smEditorOpen && mSelRiver)
  590. {
  591. ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>();
  592. ri->type = RenderPassManager::RIT_Editor;
  593. ri->renderDelegate.bind(this, &GuiNavEditorCtrl::_renderSelectedRiver);
  594. ri->defaultKey = 100;
  595. state->getRenderPass()->addInst(ri);
  596. }*/
  597. }
  598. DefineEngineMethod(GuiNavEditorCtrl, getMode, const char*, (), , "")
  599. {
  600. return object->getMode();
  601. }
  602. DefineEngineMethod(GuiNavEditorCtrl, setMode, void, (String mode),, "setMode(String mode)")
  603. {
  604. object->setMode(mode);
  605. }
  606. #endif