Torque3D/Engine/source/navigation/guiNavEditorCtrl.h
marauder2k7 d1771756c2 updated drawmodes and rendering
DebugDraw for recast now caches the results
We now have a drawmode dropdown selector
drawmode changes come from the gui itself no longer from console values
all recast drawmodes are supported with the exception of drawmodes that add abilities like navqueries until the nav tester tool is imlpemented.
2025-07-24 14:25:02 +01:00

191 lines
4.6 KiB
C++

//-----------------------------------------------------------------------------
// Copyright (c) 2014 Daniel Buckmaster
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _GUINAVEDITORCTRL_H_
#define _GUINAVEDITORCTRL_H_
#include "torqueConfig.h"
#ifdef TORQUE_TOOLS
#ifndef _EDITTSCTRL_H_
#include "gui/worldEditor/editTSCtrl.h"
#endif
#ifndef _UNDO_H_
#include "util/undo.h"
#endif
#ifndef _GIZMO_H_
#include "gui/worldEditor/gizmo.h"
#endif
#ifndef _NAVMESH_TOOL_H_
#include "navigation/navMeshTool.h"
#endif
#include "navMesh.h"
#include "T3D/aiPlayer.h"
struct ObjectRenderInst;
class SceneManager;
class SceneRenderState;
class BaseMatInstance;
class GuiNavEditorCtrl : public EditTSCtrl
{
typedef EditTSCtrl Parent;
friend class GuiNavEditorUndoAction;
public:
static const String mSelectMode;
static const String mLinkMode;
static const String mCoverMode;
static const String mTestMode;
GuiNavEditorCtrl();
~GuiNavEditorCtrl();
DECLARE_CONOBJECT(GuiNavEditorCtrl);
/// @name SimObject
/// @{
bool onAdd() override;
static void initPersistFields();
/// @}
/// @name GuiControl
/// @{
void onSleep() override;
void onRender(Point2I offset, const RectI &updateRect) override;
/// @}
/// @name EditTSCtrl
/// @{
void get3DCursor(GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_) override;
bool get3DCentre(Point3F &pos);
void on3DMouseDown(const Gui3DMouseEvent & event) override;
void on3DMouseUp(const Gui3DMouseEvent & event) override;
void on3DMouseMove(const Gui3DMouseEvent & event) override;
void on3DMouseDragged(const Gui3DMouseEvent & event) override;
void on3DMouseEnter(const Gui3DMouseEvent & event) override;
void on3DMouseLeave(const Gui3DMouseEvent & event) override;
void updateGuiInfo() override;
void renderScene(const RectI & updateRect) override;
/// @}
/// @name GuiNavEditorCtrl
/// @{
bool getStaticPos(const Gui3DMouseEvent & event, Point3F &tpos);
void setMode(String mode, bool sourceShortcut);
String getMode() { return mMode; }
void selectMesh(NavMesh *mesh);
void deselect();
S32 getMeshId();
S32 getPlayerId();
String mSpawnClass;
String mSpawnDatablock;
void deleteLink();
void setLinkFlags(const LinkData &d);
void spawnPlayer(const Point3F &pos);
/// @}
void setActiveTool(NavMeshTool* tool);
void setDrawMode(S32 id);
protected:
void _prepRenderImage(SceneManager* sceneGraph, const SceneRenderState* sceneState);
void submitUndo(const UTF8 *name = "Action");
GFXStateBlockRef mZDisableSB;
GFXStateBlockRef mZEnableSB;
bool mIsDirty;
String mMode;
/// Currently-selected NavMesh.
SimObjectPtr<NavMesh> mMesh;
/// The active tool in used by the editor.
SimObjectPtr<NavMeshTool> mTool;
/// @name Link mode
/// @{
Point3F mLinkStart;
S32 mCurLink;
S32 mLink;
/// @}
/// @name Tile mode
/// @{
duDebugDrawTorque dd;
/// @}
/// @name Test mode
/// @{
SimObjectPtr<SceneObject> mPlayer;
SimObjectPtr<SceneObject> mCurPlayer;
/// @}
Gui3DMouseEvent mLastMouseEvent;
#define InvalidMousePoint Point2I(-100,-100)
Point2I mStartDragMousePoint;
};
class GuiNavEditorUndoAction : public UndoAction
{
public:
GuiNavEditorUndoAction(const UTF8* actionName) : UndoAction(actionName), mNavEditor(NULL), mObjId(0)
{
}
GuiNavEditorCtrl *mNavEditor;
SimObjectId mObjId;
void undo() override;
void redo() override { undo(); }
};
#endif
#endif