diff --git a/Engine/source/navigation/duDebugDrawTorque.cpp b/Engine/source/navigation/duDebugDrawTorque.cpp index 637c483b2..570908c8f 100644 --- a/Engine/source/navigation/duDebugDrawTorque.cpp +++ b/Engine/source/navigation/duDebugDrawTorque.cpp @@ -73,6 +73,11 @@ void duDebugDrawTorque::depthMask(bool state, bool isOverride) mOverrideState = isOverride; } +void duDebugDrawTorque::blend(bool blend) +{ + mDesc.setBlend(true); +} + void duDebugDrawTorque::texture(bool state) { // need a checker texture?...... if(state is true) then set first slot to that texture. diff --git a/Engine/source/navigation/duDebugDrawTorque.h b/Engine/source/navigation/duDebugDrawTorque.h index a1c69ac4f..ba7a0c9dd 100644 --- a/Engine/source/navigation/duDebugDrawTorque.h +++ b/Engine/source/navigation/duDebugDrawTorque.h @@ -68,6 +68,8 @@ public: /// Set to true to override any future changes. void depthMask(bool state, bool isOverride); + void blend(bool blend); + /// Begin drawing primitives. /// @param prim [in] primitive type to draw, one of rcDebugDrawPrimitives. /// @param size [in] size of a primitive, applies to point size and line width only. diff --git a/Engine/source/navigation/guiNavEditorCtrl.cpp b/Engine/source/navigation/guiNavEditorCtrl.cpp index 74418ddf5..d01470817 100644 --- a/Engine/source/navigation/guiNavEditorCtrl.cpp +++ b/Engine/source/navigation/guiNavEditorCtrl.cpp @@ -178,9 +178,6 @@ bool GuiNavEditorCtrl::get3DCentre(Point3F &pos) void GuiNavEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event) { - if (!mMesh) - return; - mGizmo->on3DMouseDown(event); if (mTool) @@ -193,9 +190,6 @@ void GuiNavEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event) void GuiNavEditorCtrl::on3DMouseUp(const Gui3DMouseEvent & event) { - if (!mMesh) - return; - // Keep the Gizmo up to date. mGizmo->on3DMouseUp(event); @@ -207,9 +201,6 @@ void GuiNavEditorCtrl::on3DMouseUp(const Gui3DMouseEvent & event) void GuiNavEditorCtrl::on3DMouseMove(const Gui3DMouseEvent & event) { - if (!mMesh) - return; - if (mTool) mTool->on3DMouseMove(event); diff --git a/Engine/source/navigation/navMesh.cpp b/Engine/source/navigation/navMesh.cpp index 1591d82ae..f1476e3e3 100644 --- a/Engine/source/navigation/navMesh.cpp +++ b/Engine/source/navigation/navMesh.cpp @@ -1582,7 +1582,12 @@ void NavMesh::renderToDrawer() m_drawMode == DRAWMODE_NAVMESH_INVIS)) { if (m_drawMode != DRAWMODE_NAVMESH_INVIS) + { + if (m_drawMode == DRAWMODE_NAVMESH_TRANS) + mDbgDraw.blend(true); duDebugDrawNavMeshWithClosedList(&mDbgDraw, *n->nm, *n->mQuery, 0); + mDbgDraw.blend(false); + } if(m_drawMode == DRAWMODE_NAVMESH_BVTREE) duDebugDrawNavMeshBVTree(&mDbgDraw, *n->nm); if(m_drawMode == DRAWMODE_NAVMESH_PORTALS) diff --git a/Engine/source/navigation/navMeshTools/coverTool.cpp b/Engine/source/navigation/navMeshTools/coverTool.cpp new file mode 100644 index 000000000..fda36ba8d --- /dev/null +++ b/Engine/source/navigation/navMeshTools/coverTool.cpp @@ -0,0 +1,40 @@ +#include "coverTool.h" + +IMPLEMENT_CONOBJECT(CoverTool); + +CoverTool::CoverTool() +{ +} + +void CoverTool::onActivated(const Gui3DMouseEvent& evt) +{ + Con::executef(this, "onActivated"); +} + +void CoverTool::onDeactivated() +{ + Con::executef(this, "onDeactivated"); +} + +void CoverTool::on3DMouseDown(const Gui3DMouseEvent& evt) +{ + if (mNavMesh.isNull()) + return; +} + +void CoverTool::on3DMouseMove(const Gui3DMouseEvent& evt) +{ + if (mNavMesh.isNull()) + return; +} + +void CoverTool::onRender3D() +{ + if (mNavMesh.isNull()) + return; +} + +bool CoverTool::updateGuiInfo() +{ + return false; +} diff --git a/Engine/source/navigation/navMeshTools/coverTool.h b/Engine/source/navigation/navMeshTools/coverTool.h new file mode 100644 index 000000000..73978a26c --- /dev/null +++ b/Engine/source/navigation/navMeshTools/coverTool.h @@ -0,0 +1,33 @@ +#ifndef _COVERTOOL_H_ +#define _COVERTOOL_H_ + +#ifndef _NAVMESH_TOOL_H_ +#include "navigation/navMeshTool.h" +#endif + +#ifndef _NAVPATH_H_ +#include "navigation/navPath.h" +#endif + +class CoverTool : public NavMeshTool +{ + typedef NavMeshTool Parent; +public: + DECLARE_CONOBJECT(CoverTool); + + CoverTool(); + + virtual ~CoverTool() {} + + void onActivated(const Gui3DMouseEvent& evt) override; + void onDeactivated() override; + + void on3DMouseDown(const Gui3DMouseEvent& evt) override; + void on3DMouseMove(const Gui3DMouseEvent& evt) override; + void onRender3D() override; + + bool updateGuiInfo() override; +}; + +#endif // !_COVERTOOL_H_ + diff --git a/Engine/source/navigation/navMeshTools/navMeshSelectTool.cpp b/Engine/source/navigation/navMeshTools/navMeshSelectTool.cpp index a51c614b5..2081a3335 100644 --- a/Engine/source/navigation/navMeshTools/navMeshSelectTool.cpp +++ b/Engine/source/navigation/navMeshTools/navMeshSelectTool.cpp @@ -44,7 +44,7 @@ void NavMeshSelectTool::on3DMouseDown(const Gui3DMouseEvent& evt) Point3F endPnt = evt.pos + evt.vec * 1000.0f; RayInfo ri; - if (gServerContainer.castRay(startPnt, endPnt, MarkerObjectType, &ri)) + if (gServerContainer.collideBox(startPnt, endPnt, MarkerObjectType, &ri)) { if (!ri.object) return; @@ -53,6 +53,8 @@ void NavMeshSelectTool::on3DMouseDown(const Gui3DMouseEvent& evt) if (selNavMesh) { mCurEditor->selectMesh(selNavMesh); + mSelMesh = selNavMesh; + Con::executef(this, "onNavMeshSelected"); return; } } @@ -68,7 +70,7 @@ void NavMeshSelectTool::on3DMouseMove(const Gui3DMouseEvent& evt) Point3F endPnt = evt.pos + evt.vec * 1000.0f; RayInfo ri; - if (gServerContainer.castRay(startPnt, endPnt, MarkerObjectType, &ri)) + if (gServerContainer.collideBox(startPnt, endPnt, MarkerObjectType, &ri)) { NavMesh* selNavMesh = dynamic_cast(ri.object); if (selNavMesh) @@ -90,6 +92,8 @@ void NavMeshSelectTool::onRender3D() { if (!mCurMesh.isNull()) renderBoxOutline(mCurMesh->getWorldBox(), ColorI::LIGHT); + if (!mSelMesh.isNull()) + renderBoxOutline(mSelMesh->getWorldBox(), ColorI::LIGHT); } bool NavMeshSelectTool::updateGuiInfo() diff --git a/Engine/source/navigation/navMeshTools/navMeshSelectTool.h b/Engine/source/navigation/navMeshTools/navMeshSelectTool.h index 6497d1648..ff2ad8769 100644 --- a/Engine/source/navigation/navMeshTools/navMeshSelectTool.h +++ b/Engine/source/navigation/navMeshTools/navMeshSelectTool.h @@ -11,6 +11,7 @@ class NavMeshSelectTool : public NavMeshTool typedef NavMeshTool Parent; protected: SimObjectPtr mCurMesh; + SimObjectPtr mSelMesh; public: DECLARE_CONOBJECT(NavMeshSelectTool); diff --git a/Templates/BaseGame/game/tools/navEditor/main.tscript b/Templates/BaseGame/game/tools/navEditor/main.tscript index f444bbded..65c107376 100644 --- a/Templates/BaseGame/game/tools/navEditor/main.tscript +++ b/Templates/BaseGame/game/tools/navEditor/main.tscript @@ -73,11 +73,11 @@ function initializeNavEditor() buttonImage = "ToolsModule:nav_link_n_image"; }; - new NavMeshTestTool() + new CoverTool() { - internalName = "TestTool"; - toolTip = "PathFinding Test tool"; - buttonImage = "ToolsModule:3rd_person_camera_n_image"; + internalName = "NavCoverTool"; + toolTip = "Cover Tool"; + buttonImage = "ToolsModule:nav_cover_n_image"; }; new TileTool() @@ -86,6 +86,13 @@ function initializeNavEditor() toolTip = "Tile selection tool"; buttonImage = "ToolsModule:select_bounds_n_image"; }; + + new NavMeshTestTool() + { + internalName = "TestTool"; + toolTip = "PathFinding Test tool"; + buttonImage = "ToolsModule:3rd_person_camera_n_image"; + }; }; // Bind shortcuts for the nav editor. @@ -151,8 +158,8 @@ function EditorGui::SetNavPalletBar() //Adds a button to the pallete stack //Name Icon Click Command Tooltip text Keybind EWToolsPaletteWindow.addButton("EditMode", "ToolsModule:visibility_toggle_n_image", "NavEditorGui.setActiveTool(NavMeshTools->SelectTool);", "", "Edit NavMesh", "1"); - EWToolsPaletteWindow.addButton("LinkMode", "ToolsModule:nav_link_n_image", "NavEditorGui.setActiveTool(NavMeshTools->LinkTool);", "", "Create off-mesh links", "2"); - // EWToolsPaletteWindow.addButton("CoverMode", "ToolsModule:nav_cover_n_image", "NavEditorGui.setMode(\"CoverMode\");", "","Edit cover", "3"); + EWToolsPaletteWindow.addButton("LinkMode", "ToolsModule:nav_link_n_image", "NavEditorGui.setActiveTool(NavMeshTools->LinkTool);", "", "Create off-mesh links", "2"); + EWToolsPaletteWindow.addButton("CoverMode","ToolsModule:nav_cover_n_image", "NavEditorGui.setActiveTool(NavMeshTools->NavCoverTool);", "", "Create Cover Points.", "3"); EWToolsPaletteWindow.addButton("TileMode", "ToolsModule:select_bounds_n_image", "NavEditorGui.setActiveTool(NavMeshTools->TileTool);" , "", "View and Edit Tiles", "4"); EWToolsPaletteWindow.addButton("TestMode", "ToolsModule:3rd_person_camera_n_image", "NavEditorGui.setActiveTool(NavMeshTools->TestTool);", "", "Test pathfinding", "5"); EWToolsPaletteWindow.refresh(); diff --git a/Templates/BaseGame/game/tools/navEditor/navEditor.tscript b/Templates/BaseGame/game/tools/navEditor/navEditor.tscript index 3b3a5a03b..228338e72 100644 --- a/Templates/BaseGame/game/tools/navEditor/navEditor.tscript +++ b/Templates/BaseGame/game/tools/navEditor/navEditor.tscript @@ -297,7 +297,7 @@ function NavEditorGui::showSidePanel() } //------------------------------------------------------ -// NAVMESHTESTTOOL +// NAVMESHSELECTTOOL //------------------------------------------------------ function NavMeshSelectTool::onActivated(%this) @@ -317,6 +317,18 @@ function NavMeshSelectTool::onDeactivated(%this) %actions->SelectActions.setVisible(false); } +function NavMeshSeletTool::onNavMeshSelected(%this) +{ + %obj = NavEditorGui.getMesh(); + // we set the naveditorgui navmesh in source so just get it + // and update here. + NavInspector.inspect(NavEditorGui.getMesh()); + + NavTreeView.clearSelection(); + if(isObject(%obj)) + NavTreeView.selectItem(%obj); +} + //------------------------------------------------------ // OffMeshConnectionTool //------------------------------------------------------ @@ -416,6 +428,22 @@ function NavMeshLinkBiDirection::onClick(%this) NavMeshTools->LinkTool.updateLinkFlags(); } +//------------------------------------------------------ +// CoverTool +//------------------------------------------------------ + +function CoverTool::onActivated(%this) +{ + %actions = NavEditorOptionsWindow->ActionsBox; + %actions->CoverActions.setVisible(true); +} + +function CoverTool::onDeactivated(%this) +{ + %actions = NavEditorOptionsWindow->ActionsBox; + %actions->CoverActions.setVisible(false); +} + //------------------------------------------------------ // NAVMESHTESTTOOL //------------------------------------------------------ @@ -573,71 +601,11 @@ function TileTool::onDeactivated(%this) %properties->TileProperties.setVisible(false); } -//------------------------------------------------------ - -function NavEditorGui::onModeSet(%this, %mode) -{ - // Callback when the nav editor changes mode. Set the appropriate dynamic - // GUI contents in the properties/actions boxes. - NavInspector.setVisible(false); - - %actions = NavEditorOptionsWindow->ActionsBox; - %actions->SelectActions.setVisible(false); - %actions->LinkActions.setVisible(false); - %actions->CoverActions.setVisible(false); - %actions->TileActions.setVisible(false); - %actions->TestActions.setVisible(false); - - %properties = NavEditorOptionsWindow->PropertiesBox; - %properties->LinkProperties.setVisible(false); - %properties->TileProperties.setVisible(false); - %properties->TestProperties.setVisible(false); - - switch$(%mode) - { - case "SelectMode": - NavInspector.setVisible(true); - %actions->SelectActions.setVisible(true); - case "LinkMode": - %actions->LinkActions.setVisible(true); - %properties->LinkProperties.setVisible(true); - case "CoverMode": - // - %actions->CoverActions.setVisible(true); - case "TileMode": - %actions->TileActions.setVisible(true); - %properties->TileProperties.setVisible(true); - case "TestMode": - %actions->TestActions.setVisible(true); - %properties->TestProperties.setVisible(true); - } -} - function NavEditorGui::onEscapePressed(%this) { return false; } -function NavEditorGui::selectObject(%this, %obj) -{ - NavTreeView.clearSelection(); - if(isObject(%obj)) - NavTreeView.selectItem(%obj); - %this.onObjectSelected(%obj); -} - -function NavEditorGui::onObjectSelected(%this, %obj) -{ - if(isObject(%this.selectedObject)) - %this.deselect(); - %this.selectedObject = %obj; - if(isObject(%obj)) - { - %this.selectMesh(%obj); - NavInspector.inspect(%obj); - } -} - function NavEditorGui::deleteMesh(%this) { if(isObject(%this.selectedObject)) @@ -732,7 +700,6 @@ function NavTreeView::onInspect(%this, %obj) function NavTreeView::onSelect(%this, %obj) { NavInspector.inspect(%obj); - NavEditorGui.onObjectSelected(%obj); } function NavEditorGui::prepSelectionMode(%this) diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/NavEditorPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/NavEditorPalette.ed.gui index b099f5835..499b433d9 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/NavEditorPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/NavEditorPalette.ed.gui @@ -11,7 +11,6 @@ $paletteId = new GuiControl(NavEditorPalette,EditorGuiGroup) { canSave = "1"; Visible = "1"; hovertime = "1000"; - new GuiBitmapButtonCtrl(ENavEditorSelectModeBtn) { canSaveDynamicFields = "1"; class = ENavEditorPaletteButton; @@ -26,9 +25,9 @@ $paletteId = new GuiControl(NavEditorPalette,EditorGuiGroup) { MinExtent = "8 2"; canSave = "1"; Visible = "1"; - Command = "NavEditorGui.prepSelectionMode();"; + Command = "NavEditorGui.setActiveTool(NavMeshTools->SelectTool);"; tooltipprofile = "GuiToolTipProfile"; - ToolTip = "View NavMesh (1)."; + ToolTip = "Edit NavMesh (1)."; DetailedDesc = ""; hovertime = "1000"; bitmapAsset = "ToolsModule:visibility_toggle_n_image"; @@ -49,10 +48,10 @@ $paletteId = new GuiControl(NavEditorPalette,EditorGuiGroup) { MinExtent = "8 2"; canSave = "1"; Visible = "1"; - Command = "NavEditorGui.setMode(\"LinkMode\");"; + Command = "NavEditorGui.setActiveTool(NavMeshTools->LinkTool);"; tooltipprofile = "GuiToolTipProfile"; - ToolTip = "Create off-mesh links (2)."; - DetailedDesc = "Click to select/add. Shift-click to add multiple end points."; + ToolTip = "Edit Links (2)."; + DetailedDesc = ""; hovertime = "1000"; bitmapAsset = "ToolsModule:nav_link_n_image"; buttonType = "RadioButton"; @@ -72,7 +71,7 @@ $paletteId = new GuiControl(NavEditorPalette,EditorGuiGroup) { MinExtent = "8 2"; canSave = "1"; Visible = "1"; - Command = "NavEditorGui.setMode(\"CoverMode\");"; + Command = "NavEditorGui.setActiveTool(NavMeshTools->NavCoverTool);"; tooltipprofile = "GuiToolTipProfile"; ToolTip = "Edit cover (3)."; DetailedDesc = ""; @@ -95,7 +94,7 @@ $paletteId = new GuiControl(NavEditorPalette,EditorGuiGroup) { MinExtent = "8 2"; canSave = "1"; Visible = "1"; - Command = "NavEditorGui.setMode(\"TileMode\");"; + Command = "NavEditorGui.setActiveTool(NavMeshTools->TileTool);"; tooltipprofile = "GuiToolTipProfile"; ToolTip = "View tiles (4)."; DetailedDesc = "Click to select."; @@ -118,7 +117,7 @@ $paletteId = new GuiControl(NavEditorPalette,EditorGuiGroup) { MinExtent = "8 2"; canSave = "1"; Visible = "1"; - Command = "NavEditorGui.setMode(\"TestMode\");"; + Command = "NavEditorGui.setActiveTool(NavMeshTools->TestTool);"; tooltipprofile = "GuiToolTipProfile"; ToolTip = "Test pathfinding (5)."; DetailedDesc = "Click to select/move character, CTRL-click to spawn, SHIFT-click to deselect.";