guiNavEditorCtrl.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  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. dd.clear();
  332. mMesh->renderTileData(dd, mTile);
  333. }
  334. }
  335. if(mMode == mTestMode)
  336. {
  337. // Spawn new character
  338. if(ctrl)
  339. {
  340. if(gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  341. spawnPlayer(ri.point);
  342. }
  343. // Deselect character
  344. else if(shift)
  345. {
  346. mPlayer = NULL;
  347. Con::executef(this, "onPlayerDeselected");
  348. }
  349. // Select/move character
  350. else
  351. {
  352. if(gServerContainer.castRay(startPnt, endPnt, PlayerObjectType | VehicleObjectType, &ri))
  353. {
  354. if(ri.object)
  355. {
  356. mPlayer = ri.object;
  357. #ifdef TORQUE_NAVIGATION_ENABLED
  358. AIPlayer* asAIPlayer = dynamic_cast<AIPlayer*>(mPlayer.getPointer());
  359. if (asAIPlayer) //try direct
  360. {
  361. Con::executef(this, "onPlayerSelected", Con::getIntArg(asAIPlayer->mLinkTypes.getFlags()));
  362. }
  363. else
  364. {
  365. ShapeBase* sbo = dynamic_cast<ShapeBase*>(mPlayer.getPointer());
  366. if (sbo->getAIController())
  367. {
  368. if (sbo->getAIController()->mControllerData)
  369. Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags()));
  370. }
  371. else
  372. {
  373. #endif
  374. Con::executef(this, "onPlayerSelected");
  375. }
  376. #ifdef TORQUE_NAVIGATION_ENABLED
  377. }
  378. }
  379. #endif
  380. }
  381. else if (!mPlayer.isNull() && gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  382. {
  383. AIPlayer* asAIPlayer = dynamic_cast<AIPlayer*>(mPlayer.getPointer());
  384. if (asAIPlayer) //try direct
  385. {
  386. #ifdef TORQUE_NAVIGATION_ENABLED
  387. asAIPlayer->setPathDestination(ri.point);
  388. #else
  389. asAIPlayer->setMoveDestination(ri.point,false);
  390. #endif
  391. }
  392. else
  393. {
  394. ShapeBase* sbo = dynamic_cast<ShapeBase*>(mPlayer.getPointer());
  395. if (sbo->getAIController())
  396. {
  397. if (sbo->getAIController()->mControllerData)
  398. sbo->getAIController()->getNav()->setPathDestination(ri.point, true);
  399. }
  400. }
  401. }
  402. }
  403. }
  404. }
  405. void GuiNavEditorCtrl::on3DMouseUp(const Gui3DMouseEvent & event)
  406. {
  407. // Keep the Gizmo up to date.
  408. mGizmo->on3DMouseUp(event);
  409. mouseUnlock();
  410. }
  411. void GuiNavEditorCtrl::on3DMouseMove(const Gui3DMouseEvent & event)
  412. {
  413. //if(mSelRiver != NULL && mSelNode != -1)
  414. //mGizmo->on3DMouseMove(event);
  415. Point3F startPnt = event.pos;
  416. Point3F endPnt = event.pos + event.vec * 1000.0f;
  417. RayInfo ri;
  418. if(mMode == mLinkMode && !mMesh.isNull())
  419. {
  420. if(gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  421. {
  422. U32 link = mMesh->getLink(ri.point);
  423. if(link != -1)
  424. {
  425. if(link != mLink)
  426. {
  427. if(mCurLink != -1)
  428. mMesh->selectLink(mCurLink, false);
  429. mMesh->selectLink(link, true, true);
  430. }
  431. mCurLink = link;
  432. }
  433. else
  434. {
  435. if(mCurLink != mLink)
  436. mMesh->selectLink(mCurLink, false);
  437. mCurLink = -1;
  438. }
  439. }
  440. else
  441. {
  442. mMesh->selectLink(mCurLink, false);
  443. mCurLink = -1;
  444. }
  445. }
  446. // Select a tile from our current NavMesh.
  447. if(mMode == mTileMode && !mMesh.isNull())
  448. {
  449. if(gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
  450. mCurTile = mMesh->getTile(ri.point);
  451. else
  452. mCurTile = -1;
  453. }
  454. if(mMode == mTestMode)
  455. {
  456. if(gServerContainer.castRay(startPnt, endPnt, PlayerObjectType | VehicleObjectType, &ri))
  457. mCurPlayer = ri.object;
  458. else
  459. mCurPlayer = NULL;
  460. }
  461. }
  462. void GuiNavEditorCtrl::on3DMouseDragged(const Gui3DMouseEvent & event)
  463. {
  464. mGizmo->on3DMouseDragged(event);
  465. if(mGizmo->isDirty())
  466. {
  467. Point3F scale = mGizmo->getScale();
  468. const MatrixF &mat = mGizmo->getTransform();
  469. VectorF normal;
  470. mat.getColumn(2, &normal);
  471. //mSelRiver->setNode(pos, scale.x, scale.z, normal, mSelNode);
  472. mIsDirty = true;
  473. }
  474. }
  475. void GuiNavEditorCtrl::on3DMouseEnter(const Gui3DMouseEvent & event)
  476. {
  477. }
  478. void GuiNavEditorCtrl::on3DMouseLeave(const Gui3DMouseEvent & event)
  479. {
  480. }
  481. void GuiNavEditorCtrl::updateGuiInfo()
  482. {
  483. }
  484. void GuiNavEditorCtrl::onRender(Point2I offset, const RectI &updateRect)
  485. {
  486. PROFILE_SCOPE(GuiNavEditorCtrl_OnRender);
  487. Parent::onRender(offset, updateRect);
  488. return;
  489. }
  490. static void renderBoxOutline(const Box3F &box, const ColorI &col)
  491. {
  492. if(box != Box3F::Invalid)
  493. {
  494. GFXStateBlockDesc desc;
  495. desc.setCullMode(GFXCullNone);
  496. desc.setFillModeSolid();
  497. desc.setZReadWrite(true, false);
  498. desc.setBlend(true);
  499. GFX->getDrawUtil()->drawCube(desc, box, ColorI(col, 20));
  500. desc.setFillModeWireframe();
  501. desc.setBlend(false);
  502. GFX->getDrawUtil()->drawCube(desc, box, ColorI(col, 255));
  503. }
  504. }
  505. void GuiNavEditorCtrl::renderScene(const RectI & updateRect)
  506. {
  507. GFX->setStateBlock(mZDisableSB);
  508. // get the projected size...
  509. GameConnection* connection = GameConnection::getConnectionToServer();
  510. if(!connection)
  511. return;
  512. // Grab the camera's transform
  513. MatrixF mat;
  514. connection->getControlCameraTransform(0, &mat);
  515. // Get the camera position
  516. Point3F camPos;
  517. mat.getColumn(3,&camPos);
  518. if(mMode == mLinkMode)
  519. {
  520. if(mLinkStart != Point3F::Max)
  521. {
  522. GFXStateBlockDesc desc;
  523. desc.setBlend(false);
  524. desc.setZReadWrite(true ,true);
  525. MatrixF linkMat(true);
  526. linkMat.setPosition(mLinkStart);
  527. Point3F scale(0.8f, 0.8f, 0.8f);
  528. GFX->getDrawUtil()->drawTransform(desc, linkMat, &scale);
  529. }
  530. }
  531. if(mMode == mTileMode && !mMesh.isNull())
  532. {
  533. renderBoxOutline(mMesh->getTileBox(mCurTile), ColorI::BLUE);
  534. renderBoxOutline(mMesh->getTileBox(mTile), ColorI::GREEN);
  535. if(Con::getBoolVariable("$Nav::Editor::renderVoxels", false)) dd.renderGroup(0);
  536. if(Con::getBoolVariable("$Nav::Editor::renderInput", false))
  537. {
  538. dd.depthMask(false);
  539. dd.renderGroup(1);
  540. dd.depthMask(true);
  541. }
  542. }
  543. if(mMode == mTestMode)
  544. {
  545. if(!mCurPlayer.isNull())
  546. renderBoxOutline(mCurPlayer->getWorldBox(), ColorI::BLUE);
  547. if(!mPlayer.isNull())
  548. renderBoxOutline(mPlayer->getWorldBox(), ColorI::GREEN);
  549. }
  550. duDebugDrawTorque d;
  551. if(!mMesh.isNull())
  552. mMesh->renderLinks(d);
  553. d.render();
  554. // Now draw all the 2d stuff!
  555. GFX->setClipRect(updateRect);
  556. }
  557. bool GuiNavEditorCtrl::getStaticPos(const Gui3DMouseEvent & event, Point3F &tpos)
  558. {
  559. // Find clicked point on the terrain
  560. Point3F startPnt = event.pos;
  561. Point3F endPnt = event.pos + event.vec * 1000.0f;
  562. RayInfo ri;
  563. bool hit;
  564. hit = gServerContainer.castRay(startPnt, endPnt, StaticShapeObjectType, &ri);
  565. tpos = ri.point;
  566. return hit;
  567. }
  568. void GuiNavEditorCtrl::setMode(String mode, bool sourceShortcut = false)
  569. {
  570. mMode = mode;
  571. Con::executef(this, "onModeSet", mode);
  572. if(sourceShortcut)
  573. Con::executef(this, "paletteSync", mode);
  574. }
  575. void GuiNavEditorCtrl::submitUndo(const UTF8 *name)
  576. {
  577. // Grab the mission editor undo manager.
  578. UndoManager *undoMan = NULL;
  579. if(!Sim::findObject("EUndoManager", undoMan))
  580. {
  581. Con::errorf("GuiNavEditorCtrl::submitUndo() - EUndoManager not found!");
  582. return;
  583. }
  584. // Setup the action.
  585. GuiNavEditorUndoAction *action = new GuiNavEditorUndoAction(name);
  586. action->mNavEditor = this;
  587. undoMan->addAction(action);
  588. }
  589. void GuiNavEditorCtrl::_prepRenderImage(SceneManager* sceneGraph, const SceneRenderState* state)
  590. {
  591. /*if(isAwake() && River::smEditorOpen && mSelRiver)
  592. {
  593. ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>();
  594. ri->type = RenderPassManager::RIT_Editor;
  595. ri->renderDelegate.bind(this, &GuiNavEditorCtrl::_renderSelectedRiver);
  596. ri->defaultKey = 100;
  597. state->getRenderPass()->addInst(ri);
  598. }*/
  599. }
  600. DefineEngineMethod(GuiNavEditorCtrl, getMode, const char*, (), , "")
  601. {
  602. return object->getMode();
  603. }
  604. DefineEngineMethod(GuiNavEditorCtrl, setMode, void, (String mode),, "setMode(String mode)")
  605. {
  606. object->setMode(mode);
  607. }
  608. #endif