Merge pull request #1528 from marauder2k9-torque/Recast-Update

Recast refactor
This commit is contained in:
Brian Roberts 2025-08-04 08:50:11 -05:00 committed by GitHub
commit c7d966c0de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 3812 additions and 1639 deletions

View file

@ -4,3 +4,58 @@ datablock ItemData(PrototypeItemData)
ShapeAsset = "Prototyping:TorusPrimitive_shape";
cameraMaxDist = "0.75";
};
datablock PlayerData( ProtoPlayer ) {
// Third person shape
ShapeAsset = "Prototyping:Playerbot_shape";
controlMap = "playerKeyMap";
AIControllerData = "aiPlayerControl";
};
datablock WheeledVehicleTire(ProtoCarTire)
{
// Tires act as springs and generate lateral and longitudinal
// forces to move the vehicle. These distortion/spring forces
// are what convert wheel angular velocity into forces that
// act on the rigid body.
shapeAsset = "Prototyping:carwheel_shape";
staticFriction = 1;
kineticFriction = 4.2;
// Spring that generates lateral tire forces
lateralForce = 150000;
lateralDamping = 30000;
lateralRelaxation = 0.1;
// Spring that generates longitudinal tire forces
longitudinalForce = 600;
longitudinalDamping = 1600;
longitudinalRelaxation = 0.1;
};
datablock WheeledVehicleSpring(ProtoCarSpring)
{
// Wheel suspension properties
length = "0.6"; // Suspension travel
force = 3600; // Spring force
damping = 2800; // Spring damping
antiSwayForce = 300; // Lateral anti-sway force
};
datablock WheeledVehicleData(ProtoCar)
{
category = "Vehicles";
shapeAsset = "Prototyping:car_shape";
collisionMul = 0;
impactMul = 0;
controlMap = "vehicleKeyMap";
AIControllerData = "aiCarControl";
cameraMaxDist = "2.81993";
ShapeFile = "data/Prototyping/shapes/Vehicles/car.dae";
mass = "1000";
originalAssetName = "ProtoCar";
massCenter = "0 0.75 0";
dragForce = "0.1";
};

View file

@ -0,0 +1,47 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// 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.
//-----------------------------------------------------------------------------
// This file contains script methods unique to the WheeledVehicle class. All
// other necessary methods are contained in "../server/scripts/vehicle.cs" in
// which the "generic" Vehicle class methods that are shared by all vehicles,
// (flying, hover, and wheeled) can be found.
function ProtoCar::onAdd(%this, %obj)
{
Parent::onAdd(%this, %obj);
// Setup the car with some tires & springs
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--)
{
%obj.setWheelTire(%i, ProtoCarTire);
%obj.setWheelSpring(%i, ProtoCarSpring);
%obj.setWheelPowered(%i, false);
}
// Steer with the front tires
%obj.setWheelSteering(0, 1);
%obj.setWheelSteering(1, 1);
// Only power the two rear wheels... assuming there are only 4 wheels.
%obj.setWheelPowered(2, true);
%obj.setWheelPowered(3, true);
}

View file

@ -279,24 +279,22 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
HorizSizing = "width";
VertSizing = "bottom";
Position = "4 24";
Extent = "202 85";
Extent = "202 136";
Docking = "Top";
Margin = "3 3 3 3";
internalName = "ActionsBox";
new GuiTextCtrl(){
Profile = "EditorTextProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "5 0";
Extent = "86 18";
text = "Actions";
new GuiPopUpMenuCtrl(DrawModeSelector) {
position = "7 0";
extent = "190 20";
profile = "ToolsGuiPopUpMenuProfile";
tooltipProfile = "GuiToolTipProfile";
};
new GuiStackControl()
{
internalName = "SelectActions";
position = "7 21";
extent = "190 64";
extent = "190 136";
new GuiButtonCtrl() {
Profile = "ToolsGuiButtonProfile";
@ -372,7 +370,7 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
{
internalName = "LinkActions";
position = "7 21";
extent = "190 64";
extent = "190 136";
new GuiButtonCtrl() {
Profile = "ToolsGuiButtonProfile";
@ -388,7 +386,7 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
{
internalName = "CoverActions";
position = "7 21";
extent = "190 64";
extent = "190 136";
new GuiButtonCtrl() {
Profile = "ToolsGuiButtonProfile";
@ -413,7 +411,7 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
{
internalName = "TileActions";
position = "7 21";
extent = "190 64";
extent = "190 136";
new GuiButtonCtrl() {
Profile = "ToolsGuiButtonProfile";
@ -422,23 +420,54 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
VertSizing = "bottom";
Extent = "182 18";
text = "Rebuild tile";
command = "NavEditorGui.buildTile();";
command = "NavMeshTools->TileTool.buildTile();";
};
};
new GuiStackControl()
{
internalName = "TestActions";
position = "7 21";
extent = "190 64";
new GuiButtonCtrl() {
Profile = "ToolsGuiButtonProfile";
buttonType = "PushButton";
HorizSizing = "right";
VertSizing = "bottom";
Extent = "180 18";
text = "Spawn";
command = "NavEditorGui.spawnPlayer();";
extent = "190 136";
new GuiControl() {
profile = "GuiDefaultProfile";
Extent = "190 20";
new GuiTextCtrl(){
Profile = "EditorTextProfile";
extent = "89 20";
text = "Spawn Class";
};
new GuiTextCtrl(){
Profile = "EditorTextProfile";
Position = "100 0";
extent = "89 20";
text = "Spawn Datablock";
};
};
new GuiControl() {
profile = "GuiDefaultProfile";
Extent = "190 20";
new GuiPopUpMenuCtrl(SpawnClassSelector) {
extent = "89 20";
profile = "ToolsGuiPopUpMenuProfile";
tooltipProfile = "GuiToolTipProfile";
};
new GuiPopUpMenuCtrl(SpawnDatablockSelector) {
position = "100 0";
extent = "89 20";
profile = "ToolsGuiPopUpMenuProfile";
tooltipProfile = "GuiToolTipProfile";
};
};
new GuiControl() {
profile = "GuiDefaultProfile";
Extent = "190 20";
new GuiTextCtrl(){
Profile = "EditorTextProfile";
extent = "89 20";
text = "AI Actions";
};
};
new GuiControl() {
profile = "GuiDefaultProfile";
@ -451,7 +480,9 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
VertSizing = "bottom";
Extent = "90 18";
text = "Delete";
command = "NavEditorGui.getPlayer().delete();";
tooltipProfile = "GuiToolTipProfile";
tooltip = "Delete Selected Bot.";
command = "NavMeshTools->TestTool.getPlayer().delete();NavInspector.inspect();";
};
new GuiButtonCtrl() {
position = "100 0";
@ -460,8 +491,8 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
HorizSizing = "right";
VertSizing = "bottom";
Extent = "90 18";
text = "Find cover";
command = "NavEditorGui.findCover();";
text = "Stop";
command = "NavMeshTools->TestTool.stop();";
};
};
new GuiControl() {
@ -474,8 +505,8 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
HorizSizing = "right";
VertSizing = "bottom";
Extent = "90 18";
text = "Follow";
command = "NavEditorGui.followObject();";
text = "Select Follow";
command = "NavMeshTools->TestTool.followObject();";
};
new GuiButtonCtrl() {
position = "100 0";
@ -484,8 +515,39 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
HorizSizing = "right";
VertSizing = "bottom";
Extent = "90 18";
text = "Stop";
command = "NavEditorGui.stop();";
text = "Find cover";
command = "NavMeshTools->TestTool.findCover();";
};
};
new GuiControl() {
profile = "GuiDefaultProfile";
Extent = "190 18";
new GuiButtonCtrl() {
Profile = "ToolsGuiButtonProfile";
buttonType = "PushButton";
HorizSizing = "right";
VertSizing = "bottom";
Extent = "90 18";
text = "Toggle Follow";
command = "NavMeshTools->TestTool.toggleFollow();";
};
new GuiTextEditSliderCtrl(CoverRadius) {
position = "100 0";
extent = "90 18";
format = "%3.2f";
range = "0 1e+03";
increment = "0.1";
focusOnMouseWheel = "0";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
hovertime = "1000";
profile = "ToolsGuiTextEditProfile";
tooltipProfile = "GuiToolTipProfile";
toolTip = "The radius to search for cover";
};
};
};
@ -567,7 +629,45 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
position = "7 21";
extent = "186 64";
padding = "2 2 2 2";
new GuiTextEditSliderCtrl() {
internalName = "LinkRadius";
class = "NavMeshLinkRadius";
extent = "50 15";
format = "%3.2f";
range = "0 1e+03";
increment = "0.1";
focusOnMouseWheel = "0";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
hovertime = "1000";
profile = "ToolsGuiTextEditProfile";
tooltipProfile = "GuiToolTipProfile";
toolTip = "The radius for this link.";
AltCommand = "NavMeshTools->LinkTool.updateRadius();";
};
new GuiCheckBoxCtrl() {
internalName = "LinkBiDirection";
class = "NavMeshLinkBiDirection";
text = " Link Bi-Directional";
buttonType = "ToggleButton";
useMouseEvents = "0";
extent = "159 15";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "0";
tooltipProfile = "GuiToolTipProfile";
toolTip = "This link is bidirectional.";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
internalName = "LinkWalkFlag";
class = "NavMeshLinkFlagButton";
@ -732,194 +832,6 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
variable = "$Nav::Editor::renderVoxels";
};
};
new GuiStackControl() {
internalName = "TestProperties";
position = "7 21";
extent = "186 64";
padding = "2 2 2 2";
new GuiTextCtrl() {
text = "Cover";
profile = "ToolsGuiTextProfile";
extent = "180 20";
minExtent = "8 2";
visible = "1";
};
new GuiTextEditCtrl() {
internalName = "CoverRadius";
text = "10";
profile = "ToolsGuiTextEditProfile";
extent = "40 20";
minExtent = "8 2";
visible = "1";
tooltipProfile = "GuiToolTipProfile";
toolTip = "Radius for cover-finding.";
};
new GuiTextEditCtrl() {
internalName = "CoverPosition";
text = "LocalClientConnection.getControlObject().getPosition();";
profile = "ToolsGuiTextEditProfile";
extent = "140 20";
minExtent = "8 2";
visible = "1";
tooltipProfile = "GuiToolTipProfile";
toolTip = "Position to find cover from.";
};
new GuiTextCtrl() {
text = "Follow";
profile = "ToolsuiTextProfile";
extent = "180 20";
minExtent = "8 2";
visible = "1";
};
new GuiTextEditCtrl() {
internalName = "FollowRadius";
text = "1";
profile = "ToolsGuiTextEditProfile";
extent = "40 20";
minExtent = "8 2";
visible = "1";
tooltipProfile = "GuiToolTipProfile";
toolTip = "Radius for following.";
};
new GuiTextEditCtrl() {
internalName = "FollowObject";
text = "LocalClientConnection.player";
profile = "ToolsGuiTextEditProfile";
extent = "140 20";
minExtent = "8 2";
visible = "1";
tooltipProfile = "GuiToolTipProfile";
toolTip = "Object to follow.";
};
new GuiTextCtrl() {
text = "Movement";
profile = "ToolsGuiTextProfile";
extent = "180 20";
minExtent = "8 2";
visible = "1";
};
new GuiCheckBoxCtrl() {
internalName = "LinkWalkFlag";
class = "NavMeshTestFlagButton";
text = " Walk";
buttonType = "ToggleButton";
useMouseEvents = "0";
extent = "159 15";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "0";
tooltipProfile = "GuiToolTipProfile";
toolTip = "Can this character walk on ground?";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
internalName = "LinkJumpFlag";
class = "NavMeshTestFlagButton";
text = " Jump";
buttonType = "ToggleButton";
useMouseEvents = "0";
extent = "159 15";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "0";
tooltipProfile = "GuiToolTipProfile";
toolTip = "Can this character jump?";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
internalName = "LinkDropFlag";
class = "NavMeshTestFlagButton";
text = " Drop";
buttonType = "ToggleButton";
useMouseEvents = "0";
extent = "159 15";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "0";
tooltipProfile = "GuiToolTipProfile";
toolTip = "Can this character drop over edges?";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
internalName = "LinkLedgeFlag";
class = "NavMeshTestFlagButton";
text = " Ledge";
buttonType = "ToggleButton";
useMouseEvents = "0";
extent = "159 15";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "0";
tooltipProfile = "GuiToolTipProfile";
toolTip = "Can this character jump from ledges?";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
internalName = "LinkClimbFlag";
class = "NavMeshTestFlagButton";
text = " Climb";
buttonType = "ToggleButton";
useMouseEvents = "0";
extent = "159 15";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "0";
tooltipProfile = "GuiToolTipProfile";
toolTip = "Can this character climb?";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
internalName = "LinkTeleportFlag";
class = "NavMeshTestFlagButton";
text = " Teleport";
buttonType = "ToggleButton";
useMouseEvents = "0";
extent = "159 15";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "0";
tooltipProfile = "GuiToolTipProfile";
toolTip = "Can this character teleport?";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
};
};
new GuiMLTextCtrl(NavFieldInfoControl) {
canSaveDynamicFields = "0";

View file

@ -77,68 +77,5 @@ $guiContent = new GuiControl(NavEditorToolbar,EditorGuiGroup) {
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
text = "Mesh";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
position = "167 1";
extent = "50 30";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "1";
variable = "$Nav::Editor::renderMesh";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
internalName = "MeshButton";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
text = "Portals";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
position = "224 1";
extent = "54 30";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "1";
variable = "$Nav::Editor::renderPortals";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
internalName = "PortalButton";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
text = "BV tree";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
position = "286 1";
extent = "140 30";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "1";
variable = "$Nav::Editor::renderBVTree";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
internalName = "BVTreeButton";
canSave = "1";
canSaveDynamicFields = "0";
};
};
//--- OBJECT WRITE END ---

View file

@ -57,6 +57,44 @@ function initializeNavEditor()
editorGui = NavEditorGui;
};
new SimSet(NavMeshTools)
{
new NavMeshSelectTool()
{
internalName = "SelectTool";
toolTip = "Edit NavMesh";
buttonImage = "ToolsModule:visibility_toggle_n_image";
};
new OffMeshConnectionTool()
{
internalName = "LinkTool";
toolTip = "Link tool";
buttonImage = "ToolsModule:nav_link_n_image";
};
new CoverTool()
{
internalName = "NavCoverTool";
toolTip = "Cover Tool";
buttonImage = "ToolsModule:nav_cover_n_image";
};
new TileTool()
{
internalName = "TileTool";
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.
%map = new ActionMap();
%map.bindCmd(keyboard, "1", "ENavEditorSelectModeBtn.performClick();", "");
@ -118,12 +156,12 @@ function EditorGui::SetNavPalletBar()
EWToolsPaletteWindow.setActionMap(WorldEditorInspectorPlugin.map);
//Adds a button to the pallete stack
//Name Icon Click Command Tooltip text Keybind
EWToolsPaletteWindow.addButton("ViewNavMesh", "ToolsModule:visibility_toggle_n_image", "NavEditorGui.prepSelectionMode();", "", "View NavMesh", "1");
EWToolsPaletteWindow.addButton("LinkMode", "ToolsModule:nav_link_n_image", "NavEditorGui.setMode(\"LinkMode\");", "", "Create off-mesh links", "2");
EWToolsPaletteWindow.addButton("CoverMode", "ToolsModule:nav_cover_n_image", "NavEditorGui.setMode(\"CoverMode\");", "", "Edit cover", "3");
EWToolsPaletteWindow.addButton("TileMode", "ToolsModule:select_bounds_n_image", "NavEditorGui.setMode(\"TileMode\");", "", "View tiles", "4");
EWToolsPaletteWindow.addButton("TestMode", "ToolsModule:3rd_person_camera_n_image", "NavEditorGui.setMode(\"TestMode\");", "", "Test pathfinding", "5");
//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.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();
}
@ -135,7 +173,22 @@ function NavEditorPlugin::onActivated(%this)
$Nav::EditorOpen = true;
// Start off in Select mode.
ToolsPaletteArray->NavEditorSelectMode.performClick();
// 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);
ENavEditorSelectModeBtn.performClick();
EditorGui.bringToFront(NavEditorGui);
NavEditorGui.setVisible(true);
@ -177,6 +230,9 @@ function NavEditorPlugin::onActivated(%this)
Parent::onActivated(%this);
EditorGui.SetNavPalletBar();
DrawModeSelector.init();
DrawModeSelector.selectDefault();
}
function NavEditorPlugin::onDeactivated(%this)
@ -242,7 +298,7 @@ function NavEditorPlugin::initSettings(%this)
EditorSettings.beginGroup("NavEditor", true);
EditorSettings.setDefaultValue("SpawnClass", "AIPlayer");
EditorSettings.setDefaultValue("SpawnDatablock", "DefaultPlayerData");
EditorSettings.setDefaultValue("SpawnDatablock", "ProtoPlayer");
EditorSettings.endGroup();
}
@ -252,9 +308,6 @@ function NavEditorPlugin::readSettings(%this)
EditorSettings.beginGroup("NavEditor", true);
// Currently these are globals because of the way they are accessed in navMesh.cpp.
$Nav::Editor::renderMesh = EditorSettings.value("RenderMesh");
$Nav::Editor::renderPortals = EditorSettings.value("RenderPortals");
$Nav::Editor::renderBVTree = EditorSettings.value("RenderBVTree");
NavEditorGui.spawnClass = EditorSettings.value("SpawnClass");
NavEditorGui.spawnDatablock = EditorSettings.value("SpawnDatablock");
NavEditorGui.backgroundBuild = EditorSettings.value("BackgroundBuild");
@ -274,9 +327,6 @@ function NavEditorPlugin::writeSettings(%this)
{
EditorSettings.beginGroup("NavEditor", true);
EditorSettings.setValue("RenderMesh", $Nav::Editor::renderMesh);
EditorSettings.setValue("RenderPortals", $Nav::Editor::renderPortals);
EditorSettings.setValue("RenderBVTree", $Nav::Editor::renderBVTree);
EditorSettings.setValue("SpawnClass", NavEditorGui.spawnClass);
EditorSettings.setValue("SpawnDatablock", NavEditorGui.spawnDatablock);
EditorSettings.setValue("BackgroundBuild", NavEditorGui.backgroundBuild);

View file

@ -296,79 +296,314 @@ function NavEditorGui::showSidePanel()
%parent.panelHidden = false;
}
//------------------------------------------------------------------------------
//------------------------------------------------------
// NAVMESHSELECTTOOL
//------------------------------------------------------
function NavEditorGui::onModeSet(%this, %mode)
function NavMeshSelectTool::onActivated(%this)
{
NavInspector.setVisible(false);
%actions = NavEditorOptionsWindow->ActionsBox;
NavInspector.setVisible(true);
%actions->SelectActions.setVisible(true);
NavInspector.inspect(NavEditorGui.getMesh());
}
function NavMeshSelectTool::onDeactivated(%this)
{
NavInspector.setVisible(false);
%actions = NavEditorOptionsWindow->ActionsBox;
%actions->SelectActions.setVisible(false);
}
function NavMeshSelectTool::onNavMeshSelected(%this)
{
NavTreeView.clearSelection();
if(isObject(NavEditorGui.getMesh()))
NavTreeView.selectItem(NavEditorGui.getMesh());
// we set the naveditorgui navmesh in source so just get it
// and update here.
NavInspector.inspect(NavEditorGui.getMesh());
}
//------------------------------------------------------
// OffMeshConnectionTool
//------------------------------------------------------
function OffMeshConnectionTool::onActivated(%this)
{
// 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;
%actions->LinkActions.setVisible(true);
%properties->LinkProperties.setVisible(true);
}
function OffMeshConnectionTool::onDeactivated(%this)
{
NavInspector.setVisible(false);
%actions = NavEditorOptionsWindow->ActionsBox;
%actions->LinkActions.setVisible(false);
%properties = NavEditorOptionsWindow->PropertiesBox;
%properties->LinkProperties.setVisible(false);
%properties->TileProperties.setVisible(false);
%properties->TestProperties.setVisible(false);
}
switch$(%mode)
function OffMeshConnectionTool::updateLinkFlags(%this)
{
%properties = NavEditorOptionsWindow-->LinkProperties;
%this.setLinkProperties(getLinkFlags(%properties), %properties->LinkBiDirection.isStateOn(), %properties->LinkRadius.getValue());
}
function updateLinkData(%control, %flags, %biDir, %radius)
{
%control->LinkRadius.setActive(true);
%control->LinkBiDirection.setActive(true);
%control->LinkWalkFlag.setActive(true);
%control->LinkJumpFlag.setActive(true);
%control->LinkDropFlag.setActive(true);
%control->LinkLedgeFlag.setActive(true);
%control->LinkClimbFlag.setActive(true);
%control->LinkTeleportFlag.setActive(true);
%control->LinkRadius.setValue(%radius);
%control->LinkBiDirection.setStateOn(%biDir);
%control->LinkWalkFlag.setStateOn(%flags & $Nav::WalkFlag);
%control->LinkJumpFlag.setStateOn(%flags & $Nav::JumpFlag);
%control->LinkDropFlag.setStateOn(%flags & $Nav::DropFlag);
%control->LinkLedgeFlag.setStateOn(%flags & $Nav::LedgeFlag);
%control->LinkClimbFlag.setStateOn(%flags & $Nav::ClimbFlag);
%control->LinkTeleportFlag.setStateOn(%flags & $Nav::TeleportFlag);
}
function getLinkFlags(%control)
{
return (%control->LinkWalkFlag.isStateOn() ? $Nav::WalkFlag : 0) |
(%control->LinkJumpFlag.isStateOn() ? $Nav::JumpFlag : 0) |
(%control->LinkDropFlag.isStateOn() ? $Nav::DropFlag : 0) |
(%control->LinkLedgeFlag.isStateOn() ? $Nav::LedgeFlag : 0) |
(%control->LinkClimbFlag.isStateOn() ? $Nav::ClimbFlag : 0) |
(%control->LinkTeleportFlag.isStateOn() ? $Nav::TeleportFlag : 0);
}
function disableLinkData(%control)
{
%control->LinkRadius.setActive(false);
%control->LinkBiDirection.setActive(false);
%control->LinkWalkFlag.setActive(false);
%control->LinkJumpFlag.setActive(false);
%control->LinkDropFlag.setActive(false);
%control->LinkLedgeFlag.setActive(false);
%control->LinkClimbFlag.setActive(false);
%control->LinkTeleportFlag.setActive(false);
}
function OffMeshConnectionTool::onLinkSelected(%this, %flags, %biDir, %radius)
{
updateLinkData(NavEditorOptionsWindow-->LinkProperties, %flags, %biDir, %radius);
}
function OffMeshConnectionTool::onLinkDeselected(%this)
{
disableLinkData(NavEditorOptionsWindow-->LinkProperties);
}
function OffMeshConnectionTool::updateRadius(%this)
{
%this.updateLinkFlags();
}
function NavMeshLinkFlagButton::onClick(%this)
{
NavMeshTools->LinkTool.updateLinkFlags();
}
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
//------------------------------------------------------
function NavMeshTestTool::onActivated(%this)
{
NavInspector.setVisible(false);
%actions = NavEditorOptionsWindow->ActionsBox;
%actions->TestActions.setVisible(true);
%classList = enumerateConsoleClasses("Player") TAB enumerateConsoleClasses("Vehicle");
//echo(%classList);
SpawnClassSelector.clear();
foreach$(%class in %classList)
{
case "SelectMode":
if(%class !$= "Vehicle") // vehicle doesnt work, purely virtual class.
SpawnClassSelector.add(%class);
}
SpawnClassSelector.setFirstSelected(true);
}
function NavMeshTestTool::onDeactivated(%this)
{
NavInspector.setVisible(false);
%actions = NavEditorOptionsWindow->ActionsBox;
%actions->TestActions.setVisible(false);
}
function NavMeshTestTool::onPlayerSelected(%this)
{
if (!isObject(%this.getPlayer().aiController))
{
%this.getPlayer().aiController = new AIController(){ ControllerData = %this.getPlayer().getDatablock().aiControllerData; };
%this.getPlayer().setAIController(%this.getPlayer().aiController);
}
if(%this.getPlayer().isMemberOfClass("AIPlayer"))
{
NavInspector.inspect(%this.getPlayer());
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);
}
else
{
NavInspector.inspect(%this.getPlayer().getDatablock().aiControllerData);
NavInspector.setVisible(true);
}
NavMeshIgnore(%this.getPlayer(), true);
%this.getPlayer().setDamageState("Enabled");
}
function NavMeshTestTool::onPlayerDeselected(%this)
{
NavInspector.inspect();
}
function NavMeshTestTool::stop(%this)
{
if (isObject(%this.getPlayer().aiController))
%this.getPlayer().aiController.stop();
else
{
%this.getPlayer().stop();
}
}
function NavMeshTestTool::toggleFollow(%this)
{
if(isObject(%this.getFollowObject()) && isObject(%this.getPlayer()))
{
%player = %this.getPlayer();
if(%player.isMemberOfClass("AIPlayer"))
%player.followObject(%this.getFollowObject(), "2.0");
else
%player.getAIController().followObject(%this.getFollowObject(), %player.getDatablock().aiControllerData.mFollowTolerance);
}
}
function NavEditorGui::paletteSync(%this, %mode)
function NavMeshTestTool::followObject(%this)
{
// Synchronise the palette (small buttons on the left) with the actual mode
// the nav editor is in.
%evalShortcut = "ToolsPaletteArray-->" @ %mode @ ".setStateOn(1);";
eval(%evalShortcut);
}
%this.followSelectMode();
}
function NavMeshTestTool::findCover(%this)
{
if(isObject(%this.getPlayer()))
{
%player = %this.getPlayer();
%pos = %player.getPosition();
if(%player.isMemberOfClass("AIPlayer"))
%player.findCover(%pos, CoverRadius.getText());
else
%player.getAIController().findCover(%pos, CoverRadius.getText());
}
}
function SpawnClassSelector::onSelect(%this, %id)
{
%className = %this.getTextById(%id);
NavMeshTools->TestTool.setSpawnClass(%className);
SpawnDatablockSelector.clear();
%classData = %className @ "Data";
if(%className $= "AIPlayer")
{
%classData = "PlayerData";
}
// add the datablocks
for(%i = 0; %i < DataBlockGroup.getCount(); %i++)
{
%obj = DataBlockGroup.getObject(%i);
if( isMemberOfClass( %obj.getClassName(), %classData ))
SpawnDatablockSelector.add(%obj.getName());
}
SpawnDatablockSelector.setFirstSelected(true);
}
function SpawnDatablockSelector::onSelect(%this, %id)
{
%className = %this.getTextById(%id);
NavMeshTools->TestTool.setSpawnDatablock(%className);
}
//------------------------------------------------------
// TILETOOL
//------------------------------------------------------
function TileTool::onActivated(%this)
{
NavInspector.setVisible(false);
%actions = NavEditorOptionsWindow->ActionsBox;
%properties = NavEditorOptionsWindow->PropertiesBox;
%actions->TileActions.setVisible(true);
%properties->TileProperties.setVisible(true);
}
function TileTool::onDeactivated(%this)
{
NavInspector.setVisible(false);
%actions = NavEditorOptionsWindow->ActionsBox;
%actions->TileActions.setVisible(false);
%properties = NavEditorOptionsWindow->PropertiesBox;
%properties->TileProperties.setVisible(false);
}
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))
@ -388,12 +623,12 @@ function NavEditorGui::deleteSelected(%this)
toolsMessageBoxYesNo("Warning",
"Are you sure you want to delete" SPC NavEditorGui.selectedObject.getName(),
"NavEditorGui.deleteMesh();");
case "TestMode":
%this.getPlayer().delete();
%this.onPlayerDeselected();
case "LinkMode":
%this.deleteLink();
%this.isDirty = true;
// case "TestMode":
// %this.getPlayer().delete();
// %this.onPlayerDeselected();
// case "LinkMode":
// %this.deleteLink();
// %this.isDirty = true;
}
}
@ -415,99 +650,6 @@ function NavEditorGui::buildLinks(%this)
}
}
function updateLinkData(%control, %flags)
{
%control->LinkWalkFlag.setActive(true);
%control->LinkJumpFlag.setActive(true);
%control->LinkDropFlag.setActive(true);
%control->LinkLedgeFlag.setActive(true);
%control->LinkClimbFlag.setActive(true);
%control->LinkTeleportFlag.setActive(true);
%control->LinkWalkFlag.setStateOn(%flags & $Nav::WalkFlag);
%control->LinkJumpFlag.setStateOn(%flags & $Nav::JumpFlag);
%control->LinkDropFlag.setStateOn(%flags & $Nav::DropFlag);
%control->LinkLedgeFlag.setStateOn(%flags & $Nav::LedgeFlag);
%control->LinkClimbFlag.setStateOn(%flags & $Nav::ClimbFlag);
%control->LinkTeleportFlag.setStateOn(%flags & $Nav::TeleportFlag);
}
function getLinkFlags(%control)
{
return (%control->LinkWalkFlag.isStateOn() ? $Nav::WalkFlag : 0) |
(%control->LinkJumpFlag.isStateOn() ? $Nav::JumpFlag : 0) |
(%control->LinkDropFlag.isStateOn() ? $Nav::DropFlag : 0) |
(%control->LinkLedgeFlag.isStateOn() ? $Nav::LedgeFlag : 0) |
(%control->LinkClimbFlag.isStateOn() ? $Nav::ClimbFlag : 0) |
(%control->LinkTeleportFlag.isStateOn() ? $Nav::TeleportFlag : 0);
}
function disableLinkData(%control)
{
%control->LinkWalkFlag.setActive(false);
%control->LinkJumpFlag.setActive(false);
%control->LinkDropFlag.setActive(false);
%control->LinkLedgeFlag.setActive(false);
%control->LinkClimbFlag.setActive(false);
%control->LinkTeleportFlag.setActive(false);
}
function NavEditorGui::onLinkSelected(%this, %flags)
{
updateLinkData(NavEditorOptionsWindow-->LinkProperties, %flags);
}
function NavEditorGui::onPlayerSelected(%this, %flags)
{
if (!isObject(%this.getPlayer().aiController) || (isObject(%this.getPlayer().aiController) && !(%this.getPlayer().isMemberOfClass("AIPlayer"))))
{
%this.getPlayer().aiController = new AIController(){ ControllerData = %this.getPlayer().getDatablock().aiControllerData; };
%this.getPlayer().setAIController(%this.getPlayer().aiController);
}
NavMeshIgnore(%this.getPlayer(), true);
%this.getPlayer().setDamageState("Enabled");
updateLinkData(NavEditorOptionsWindow-->TestProperties, %flags);
}
function NavEditorGui::updateLinkFlags(%this)
{
if(isObject(%this.getMesh()))
{
%properties = NavEditorOptionsWindow-->LinkProperties;
%this.setLinkFlags(getLinkFlags(%properties));
%this.isDirty = true;
}
}
function NavEditorGui::updateTestFlags(%this)
{
if(isObject(%this.getPlayer()))
{
%properties = NavEditorOptionsWindow-->TestProperties;
%player = %this.getPlayer();
%player.allowWwalk = %properties->LinkWalkFlag.isStateOn();
%player.allowJump = %properties->LinkJumpFlag.isStateOn();
%player.allowDrop = %properties->LinkDropFlag.isStateOn();
%player.allowLedge = %properties->LinkLedgeFlag.isStateOn();
%player.allowClimb = %properties->LinkClimbFlag.isStateOn();
%player.allowTeleport = %properties->LinkTeleportFlag.isStateOn();
%this.isDirty = true;
}
}
function NavEditorGui::onLinkDeselected(%this)
{
disableLinkData(NavEditorOptionsWindow-->LinkProperties);
}
function NavEditorGui::onPlayerDeselected(%this)
{
disableLinkData(NavEditorOptionsWindow-->TestProperties);
}
function NavEditorGui::createCoverPoints(%this)
{
if(isObject(%this.getMesh()))
@ -526,48 +668,6 @@ function NavEditorGui::deleteCoverPoints(%this)
}
}
function NavEditorGui::findCover(%this)
{
if(%this.getMode() $= "TestMode" && isObject(%this.getPlayer()))
{
%pos = LocalClientConnection.getControlObject().getPosition();
%text = NavEditorOptionsWindow-->TestProperties->CoverPosition.getText();
if(%text !$= "")
%pos = eval("return " @ %text);
%this.getPlayer().getAIController().findCover(%pos, NavEditorOptionsWindow-->TestProperties->CoverRadius.getText());
}
}
function NavEditorGui::followObject(%this)
{
if(%this.getMode() $= "TestMode" && isObject(%this.getPlayer()))
{
%obj = LocalClientConnection.player;
%text = NavEditorOptionsWindow-->TestProperties->FollowObject.getText();
if(%text !$= "")
{
%command = "return " @ %text;
if(!endsWith(%command, ";"))
%command = %command @ ";";
%obj = eval(%command);
if(!isObject(%obj))
toolsMessageBoxOk("Error", "Cannot find object" SPC %text);
}
if(isObject(%obj))
%this.getPlayer().getAIController().followObject(%obj, NavEditorOptionsWindow-->TestProperties->FollowRadius.getText());
}
}
function NavEditorGui::stop(%this)
{
if (isObject(%this.getPlayer().aiController))
%this.getPlayer().aiController.stop();
else
{
NavEditorGui.getPlayer().stop();
}
}
function NavInspector::inspect(%this, %obj)
{
%name = "";
@ -598,13 +698,13 @@ function NavTreeView::onInspect(%this, %obj)
function NavTreeView::onSelect(%this, %obj)
{
NavInspector.inspect(%obj);
NavEditorGui.onObjectSelected(%obj);
NavEditorGui.selectMesh(%obj);
}
function NavEditorGui::prepSelectionMode(%this)
{
%this.setMode("SelectMode");
ToolsPaletteArray-->NavEditorSelectMode.setStateOn(1);
NavEditorGui.setActiveTool(NavMeshTools->SelectTool);
}
//-----------------------------------------------------------------------------
@ -618,16 +718,6 @@ function ENavEditorPaletteButton::onClick(%this)
//-----------------------------------------------------------------------------
function NavMeshLinkFlagButton::onClick(%this)
{
NavEditorGui.updateLinkFlags();
}
function NavMeshTestFlagButton::onClick(%this)
{
NavEditorGui.updateTestFlags();
}
singleton GuiControlProfile(NavEditorProfile)
{
canKeyFocus = true;
@ -635,3 +725,38 @@ singleton GuiControlProfile(NavEditorProfile)
fillColor = "192 192 192 192";
category = "Editor";
};
function DrawModeSelector::init(%this)
{
%this.clear();
%this.add("Draw NavMesh", 0);
%this.add("Draw NavMesh Transparent", 1);
%this.add("Draw NavMesh BVTree", 2);
%this.add("Draw NavMesh Nodes", 3);
%this.add("Draw NavMesh Portals", 4);
%this.add("Draw NavMesh Invis", 5);
%this.add("Draw Mesh", 6);
%this.add("Draw Voxels", 7);
%this.add("Draw Walkable Voxels", 8);
%this.add("Draw Compact Heightfield", 9);
%this.add("Draw Compact Distance", 10);
%this.add("Draw Compact Regions", 11);
%this.add("Draw Region Connections", 12);
%this.add("Draw Raw Contours", 13);
%this.add("Draw Both Contours", 14);
%this.add("Draw Contours", 15);
%this.add("Draw PolyMesh", 16);
%this.add("Draw PolyMesh Detail", 17);
}
function DrawModeSelector::selectDefault(%this)
{
%this.setSelected(0);
}
function DrawModeSelector::onSelect(%this, %id)
{
NavEditorGui.setDrawMode(%id);
}

View file

@ -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.";