mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Fixed NavMesh auto sizing.
This commit is contained in:
parent
d315b1fa5a
commit
c1419d28d1
4 changed files with 112 additions and 40 deletions
|
|
@ -32,7 +32,7 @@
|
||||||
anchorLeft = "1";
|
anchorLeft = "1";
|
||||||
anchorRight = "0";
|
anchorRight = "0";
|
||||||
position = "283 240";
|
position = "283 240";
|
||||||
extent = "200 151";
|
extent = "200 176";
|
||||||
minExtent = "8 2";
|
minExtent = "8 2";
|
||||||
horizSizing = "right";
|
horizSizing = "right";
|
||||||
vertSizing = "bottom";
|
vertSizing = "bottom";
|
||||||
|
|
@ -201,11 +201,11 @@
|
||||||
canSave = "1";
|
canSave = "1";
|
||||||
canSaveDynamicFields = "0";
|
canSaveDynamicFields = "0";
|
||||||
};
|
};
|
||||||
new GuiCheckBoxCtrl() {
|
new GuiCheckBoxCtrl(MeshMissionBounds) {
|
||||||
text = " Fit NavMesh to mission area?";
|
text = " Fit NavMesh to mission area";
|
||||||
groupNum = "-1";
|
groupNum = "-1";
|
||||||
buttonType = "ToggleButton";
|
buttonType = "ToggleButton";
|
||||||
useMouseEvents = "0";
|
useMouseEvents = "1";
|
||||||
position = "22 99";
|
position = "22 99";
|
||||||
extent = "159 15";
|
extent = "159 15";
|
||||||
minExtent = "8 2";
|
minExtent = "8 2";
|
||||||
|
|
@ -218,7 +218,26 @@
|
||||||
tooltip = "Positions and scales the NavMesh so it includes all your mission objects.";
|
tooltip = "Positions and scales the NavMesh so it includes all your mission objects.";
|
||||||
hovertime = "1000";
|
hovertime = "1000";
|
||||||
isContainer = "0";
|
isContainer = "0";
|
||||||
internalName = "MeshMissionBounds";
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "0";
|
||||||
|
};
|
||||||
|
new GuiCheckBoxCtrl(MeshTerrainBounds) {
|
||||||
|
text = " Include terrain";
|
||||||
|
groupNum = "-1";
|
||||||
|
buttonType = "ToggleButton";
|
||||||
|
useMouseEvents = "0";
|
||||||
|
position = "22 121";
|
||||||
|
extent = "159 15";
|
||||||
|
minExtent = "8 2";
|
||||||
|
horizSizing = "right";
|
||||||
|
vertSizing = "bottom";
|
||||||
|
profile = "GuiCheckBoxProfile";
|
||||||
|
visible = "1";
|
||||||
|
active = "0";
|
||||||
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
tooltip = "Consider terrain when calculating NavMesh bounds.";
|
||||||
|
hovertime = "1000";
|
||||||
|
isContainer = "0";
|
||||||
canSave = "1";
|
canSave = "1";
|
||||||
canSaveDynamicFields = "0";
|
canSaveDynamicFields = "0";
|
||||||
};
|
};
|
||||||
|
|
@ -227,7 +246,7 @@
|
||||||
groupNum = "-1";
|
groupNum = "-1";
|
||||||
buttonType = "PushButton";
|
buttonType = "PushButton";
|
||||||
useMouseEvents = "0";
|
useMouseEvents = "0";
|
||||||
position = "12 121";
|
position = "12 146";
|
||||||
extent = "87 19";
|
extent = "87 19";
|
||||||
minExtent = "8 2";
|
minExtent = "8 2";
|
||||||
horizSizing = "right";
|
horizSizing = "right";
|
||||||
|
|
@ -247,7 +266,7 @@
|
||||||
groupNum = "-1";
|
groupNum = "-1";
|
||||||
buttonType = "PushButton";
|
buttonType = "PushButton";
|
||||||
useMouseEvents = "0";
|
useMouseEvents = "0";
|
||||||
position = "104 121";
|
position = "104 146";
|
||||||
extent = "84 19";
|
extent = "84 19";
|
||||||
minExtent = "8 2";
|
minExtent = "8 2";
|
||||||
horizSizing = "right";
|
horizSizing = "right";
|
||||||
|
|
@ -271,6 +290,8 @@ function CreateNewNavMeshDlg::onWake(%this)
|
||||||
%this-->MeshName.setText("Nav");
|
%this-->MeshName.setText("Nav");
|
||||||
%this-->MeshPosition.setText("0 0 0");
|
%this-->MeshPosition.setText("0 0 0");
|
||||||
%this-->MeshScale.setText("50 50 20");
|
%this-->MeshScale.setText("50 50 20");
|
||||||
|
MeshMissionBounds.setStateOn(false);
|
||||||
|
MeshTerrainBounds.setStateOn(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MissionBoundsExtents(%group)
|
function MissionBoundsExtents(%group)
|
||||||
|
|
@ -278,21 +299,31 @@ function MissionBoundsExtents(%group)
|
||||||
%box = "0 0 0 0 0 0";
|
%box = "0 0 0 0 0 0";
|
||||||
foreach(%obj in %group)
|
foreach(%obj in %group)
|
||||||
{
|
{
|
||||||
// Skip LevelInfos. Need a way to detect other non-SceneObjects.
|
|
||||||
// Also skip GroundPlanes. They're too big.
|
|
||||||
%cls = %obj.getClassName();
|
%cls = %obj.getClassName();
|
||||||
if(%cls $= "LevelInfo" || %cls $= "GroundPlane" || %cls $= "GroundCover")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Get world box - might have to recurse into nested SimGroups.
|
|
||||||
%wbox = "0 0 0 0 0 0";
|
|
||||||
if(%cls $= "SimGroup" || %cls $= "SimSet" || %cls $= "Path")
|
if(%cls $= "SimGroup" || %cls $= "SimSet" || %cls $= "Path")
|
||||||
|
{
|
||||||
|
// Need to recursively check grouped objects.
|
||||||
%wbox = MissionBoundsExtents(%obj);
|
%wbox = MissionBoundsExtents(%obj);
|
||||||
else if(%obj.getType() & $TypeMasks::StaticObjectType &&
|
}
|
||||||
!(%obj.getType() & $TypeMasks::EnvironmentObjectType))
|
|
||||||
%wbox = %obj.getWorldBox();
|
|
||||||
else
|
else
|
||||||
continue;
|
{
|
||||||
|
// Skip objects that are too big and shouldn't really be considered
|
||||||
|
// part of the scene, or are global bounds and we therefore can't get
|
||||||
|
// any sensible information out of them.
|
||||||
|
if(%cls $= "LevelInfo")
|
||||||
|
continue;
|
||||||
|
if(!MeshTerrainBounds.isStateOn() && %cls $= "TerrainBlock")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(!(%obj.getType() & $TypeMasks::StaticObjectType) ||
|
||||||
|
%obj.getType() & $TypeMasks::EnvironmentObjectType)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(%obj.isGlobalBounds())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
%wbox = %obj.getWorldBox();
|
||||||
|
}
|
||||||
|
|
||||||
// Update min point.
|
// Update min point.
|
||||||
for(%j = 0; %j < 3; %j++)
|
for(%j = 0; %j < 3; %j++)
|
||||||
|
|
@ -321,7 +352,7 @@ function CreateNewNavMeshDlg::create(%this)
|
||||||
|
|
||||||
%mesh = 0;
|
%mesh = 0;
|
||||||
|
|
||||||
if(%this-->MeshMissionBounds.isStateOn())
|
if(MeshMissionBounds.isStateOn())
|
||||||
{
|
{
|
||||||
if(!isObject(MissionGroup))
|
if(!isObject(MissionGroup))
|
||||||
{
|
{
|
||||||
|
|
@ -354,3 +385,8 @@ function CreateNewNavMeshDlg::create(%this)
|
||||||
|
|
||||||
Canvas.popDialog(CreateNewNavMeshDlg);
|
Canvas.popDialog(CreateNewNavMeshDlg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function MeshMissionBounds::onClick(%this)
|
||||||
|
{
|
||||||
|
MeshTerrainBounds.setActive(%this.isStateOn());
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ function NavEditorPlugin::onActivated(%this)
|
||||||
new SimSet(ServerNavMeshSet);
|
new SimSet(ServerNavMeshSet);
|
||||||
if(ServerNavMeshSet.getCount() == 0)
|
if(ServerNavMeshSet.getCount() == 0)
|
||||||
MessageBoxYesNo("No NavMesh", "There is no NavMesh in this level. Would you like to create one?" SPC
|
MessageBoxYesNo("No NavMesh", "There is no NavMesh in this level. Would you like to create one?" SPC
|
||||||
"If not, please use the World Editor to create a new NavMesh.",
|
"If not, please use the Nav Editor to create a new NavMesh.",
|
||||||
"Canvas.pushDialog(CreateNewNavMeshDlg);");
|
"Canvas.pushDialog(CreateNewNavMeshDlg);");
|
||||||
NavTreeView.open(ServerNavMeshSet, true);
|
NavTreeView.open(ServerNavMeshSet, true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
anchorLeft = "1";
|
anchorLeft = "1";
|
||||||
anchorRight = "0";
|
anchorRight = "0";
|
||||||
position = "283 240";
|
position = "283 240";
|
||||||
extent = "200 151";
|
extent = "200 176";
|
||||||
minExtent = "8 2";
|
minExtent = "8 2";
|
||||||
horizSizing = "right";
|
horizSizing = "right";
|
||||||
vertSizing = "bottom";
|
vertSizing = "bottom";
|
||||||
|
|
@ -201,11 +201,11 @@
|
||||||
canSave = "1";
|
canSave = "1";
|
||||||
canSaveDynamicFields = "0";
|
canSaveDynamicFields = "0";
|
||||||
};
|
};
|
||||||
new GuiCheckBoxCtrl() {
|
new GuiCheckBoxCtrl(MeshMissionBounds) {
|
||||||
text = " Fit NavMesh to mission area?";
|
text = " Fit NavMesh to mission area";
|
||||||
groupNum = "-1";
|
groupNum = "-1";
|
||||||
buttonType = "ToggleButton";
|
buttonType = "ToggleButton";
|
||||||
useMouseEvents = "0";
|
useMouseEvents = "1";
|
||||||
position = "22 99";
|
position = "22 99";
|
||||||
extent = "159 15";
|
extent = "159 15";
|
||||||
minExtent = "8 2";
|
minExtent = "8 2";
|
||||||
|
|
@ -218,7 +218,26 @@
|
||||||
tooltip = "Positions and scales the NavMesh so it includes all your mission objects.";
|
tooltip = "Positions and scales the NavMesh so it includes all your mission objects.";
|
||||||
hovertime = "1000";
|
hovertime = "1000";
|
||||||
isContainer = "0";
|
isContainer = "0";
|
||||||
internalName = "MeshMissionBounds";
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "0";
|
||||||
|
};
|
||||||
|
new GuiCheckBoxCtrl(MeshTerrainBounds) {
|
||||||
|
text = " Include terrain";
|
||||||
|
groupNum = "-1";
|
||||||
|
buttonType = "ToggleButton";
|
||||||
|
useMouseEvents = "0";
|
||||||
|
position = "22 121";
|
||||||
|
extent = "159 15";
|
||||||
|
minExtent = "8 2";
|
||||||
|
horizSizing = "right";
|
||||||
|
vertSizing = "bottom";
|
||||||
|
profile = "GuiCheckBoxProfile";
|
||||||
|
visible = "1";
|
||||||
|
active = "0";
|
||||||
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
tooltip = "Consider terrain when calculating NavMesh bounds.";
|
||||||
|
hovertime = "1000";
|
||||||
|
isContainer = "0";
|
||||||
canSave = "1";
|
canSave = "1";
|
||||||
canSaveDynamicFields = "0";
|
canSaveDynamicFields = "0";
|
||||||
};
|
};
|
||||||
|
|
@ -227,7 +246,7 @@
|
||||||
groupNum = "-1";
|
groupNum = "-1";
|
||||||
buttonType = "PushButton";
|
buttonType = "PushButton";
|
||||||
useMouseEvents = "0";
|
useMouseEvents = "0";
|
||||||
position = "12 121";
|
position = "12 146";
|
||||||
extent = "87 19";
|
extent = "87 19";
|
||||||
minExtent = "8 2";
|
minExtent = "8 2";
|
||||||
horizSizing = "right";
|
horizSizing = "right";
|
||||||
|
|
@ -247,7 +266,7 @@
|
||||||
groupNum = "-1";
|
groupNum = "-1";
|
||||||
buttonType = "PushButton";
|
buttonType = "PushButton";
|
||||||
useMouseEvents = "0";
|
useMouseEvents = "0";
|
||||||
position = "104 121";
|
position = "104 146";
|
||||||
extent = "84 19";
|
extent = "84 19";
|
||||||
minExtent = "8 2";
|
minExtent = "8 2";
|
||||||
horizSizing = "right";
|
horizSizing = "right";
|
||||||
|
|
@ -271,6 +290,8 @@ function CreateNewNavMeshDlg::onWake(%this)
|
||||||
%this-->MeshName.setText("Nav");
|
%this-->MeshName.setText("Nav");
|
||||||
%this-->MeshPosition.setText("0 0 0");
|
%this-->MeshPosition.setText("0 0 0");
|
||||||
%this-->MeshScale.setText("50 50 20");
|
%this-->MeshScale.setText("50 50 20");
|
||||||
|
MeshMissionBounds.setStateOn(false);
|
||||||
|
MeshTerrainBounds.setStateOn(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MissionBoundsExtents(%group)
|
function MissionBoundsExtents(%group)
|
||||||
|
|
@ -278,21 +299,31 @@ function MissionBoundsExtents(%group)
|
||||||
%box = "0 0 0 0 0 0";
|
%box = "0 0 0 0 0 0";
|
||||||
foreach(%obj in %group)
|
foreach(%obj in %group)
|
||||||
{
|
{
|
||||||
// Skip LevelInfos. Need a way to detect other non-SceneObjects.
|
|
||||||
// Also skip GroundPlanes. They're too big.
|
|
||||||
%cls = %obj.getClassName();
|
%cls = %obj.getClassName();
|
||||||
if(%cls $= "LevelInfo" || %cls $= "GroundPlane" || %cls $= "GroundCover")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Get world box - might have to recurse into nested SimGroups.
|
|
||||||
%wbox = "0 0 0 0 0 0";
|
|
||||||
if(%cls $= "SimGroup" || %cls $= "SimSet" || %cls $= "Path")
|
if(%cls $= "SimGroup" || %cls $= "SimSet" || %cls $= "Path")
|
||||||
|
{
|
||||||
|
// Need to recursively check grouped objects.
|
||||||
%wbox = MissionBoundsExtents(%obj);
|
%wbox = MissionBoundsExtents(%obj);
|
||||||
else if(%obj.getType() & $TypeMasks::StaticObjectType &&
|
}
|
||||||
!(%obj.getType() & $TypeMasks::EnvironmentObjectType))
|
|
||||||
%wbox = %obj.getWorldBox();
|
|
||||||
else
|
else
|
||||||
continue;
|
{
|
||||||
|
// Skip objects that are too big and shouldn't really be considered
|
||||||
|
// part of the scene, or are global bounds and we therefore can't get
|
||||||
|
// any sensible information out of them.
|
||||||
|
if(%cls $= "LevelInfo")
|
||||||
|
continue;
|
||||||
|
if(!MeshTerrainBounds.isStateOn() && %cls $= "TerrainBlock")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(!(%obj.getType() & $TypeMasks::StaticObjectType) ||
|
||||||
|
%obj.getType() & $TypeMasks::EnvironmentObjectType)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(%obj.isGlobalBounds())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
%wbox = %obj.getWorldBox();
|
||||||
|
}
|
||||||
|
|
||||||
// Update min point.
|
// Update min point.
|
||||||
for(%j = 0; %j < 3; %j++)
|
for(%j = 0; %j < 3; %j++)
|
||||||
|
|
@ -321,7 +352,7 @@ function CreateNewNavMeshDlg::create(%this)
|
||||||
|
|
||||||
%mesh = 0;
|
%mesh = 0;
|
||||||
|
|
||||||
if(%this-->MeshMissionBounds.isStateOn())
|
if(MeshMissionBounds.isStateOn())
|
||||||
{
|
{
|
||||||
if(!isObject(MissionGroup))
|
if(!isObject(MissionGroup))
|
||||||
{
|
{
|
||||||
|
|
@ -354,3 +385,8 @@ function CreateNewNavMeshDlg::create(%this)
|
||||||
|
|
||||||
Canvas.popDialog(CreateNewNavMeshDlg);
|
Canvas.popDialog(CreateNewNavMeshDlg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function MeshMissionBounds::onClick(%this)
|
||||||
|
{
|
||||||
|
MeshTerrainBounds.setActive(%this.isStateOn());
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ function NavEditorPlugin::onActivated(%this)
|
||||||
new SimSet(ServerNavMeshSet);
|
new SimSet(ServerNavMeshSet);
|
||||||
if(ServerNavMeshSet.getCount() == 0)
|
if(ServerNavMeshSet.getCount() == 0)
|
||||||
MessageBoxYesNo("No NavMesh", "There is no NavMesh in this level. Would you like to create one?" SPC
|
MessageBoxYesNo("No NavMesh", "There is no NavMesh in this level. Would you like to create one?" SPC
|
||||||
"If not, please use the World Editor to create a new NavMesh.",
|
"If not, please use the Nav Editor to create a new NavMesh.",
|
||||||
"Canvas.pushDialog(CreateNewNavMeshDlg);");
|
"Canvas.pushDialog(CreateNewNavMeshDlg);");
|
||||||
NavTreeView.open(ServerNavMeshSet, true);
|
NavTreeView.open(ServerNavMeshSet, true);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue