mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
terrain mask work
adds an isValid(gridinfo tile) command to prefilter out grid elements of a specified nature applies that to SetEmptyAction::process also corrects sliderbar positions for terrain painting elements, as ell as adds a min/max slope for removal potential TODOs: apply it more places pending feedback. add a min/max hieght filter as well
This commit is contained in:
parent
43501127ec
commit
85955479c8
|
|
@ -27,6 +27,32 @@
|
|||
#include "gui/core/guiCanvas.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool TerrainAction::isValid(GridInfo tile)
|
||||
{
|
||||
|
||||
const bool slopeLimit = mTerrainEditor->mSlopeMinAngle > 0.0f || mTerrainEditor->mSlopeMaxAngle < 90.0f;
|
||||
const F32 minSlope = mSin(mDegToRad(90.0f - mTerrainEditor->mSlopeMinAngle));
|
||||
const F32 maxSlope = mSin(mDegToRad(90.0f - mTerrainEditor->mSlopeMaxAngle));
|
||||
|
||||
const TerrainBlock* terrain = mTerrainEditor->getActiveTerrain();
|
||||
const F32 squareSize = terrain->getSquareSize();
|
||||
|
||||
Point2F p;
|
||||
Point3F norm;
|
||||
|
||||
if (slopeLimit)
|
||||
{
|
||||
p.x = tile.mGridPoint.gridPos.x * squareSize;
|
||||
p.y = tile.mGridPoint.gridPos.y * squareSize;
|
||||
if (!terrain->getNormal(p, &norm, true))
|
||||
return false;
|
||||
|
||||
if (norm.z > minSlope ||
|
||||
norm.z < maxSlope)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SelectAction::process(Selection * sel, const Gui3DMouseEvent & event, bool selChanged, Type type)
|
||||
{
|
||||
|
|
@ -390,6 +416,9 @@ void SetEmptyAction::process(Selection * sel, const Gui3DMouseEvent &, bool selC
|
|||
if ( inf.mMaterial == U8_MAX )
|
||||
continue;
|
||||
|
||||
if (!isValid(inf))
|
||||
continue;
|
||||
|
||||
// The change flag needs to be set on the undo
|
||||
// so that it knows to restore materials.
|
||||
inf.mMaterialChanged = true;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class TerrainAction
|
|||
End,
|
||||
Process
|
||||
};
|
||||
|
||||
bool isValid(GridInfo tile);
|
||||
//
|
||||
virtual void process(Selection * sel, const Gui3DMouseEvent & event, bool selChanged, Type type) = 0;
|
||||
virtual bool useMouseBrush() { return(true); }
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) {
|
|||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "306 0";
|
||||
Extent = "800 40";
|
||||
Extent = "1500 40";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
|
|
@ -35,7 +35,7 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) {
|
|||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "0 0";
|
||||
Extent = "760 40";
|
||||
Extent = "1500 40";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
|
|
@ -413,7 +413,156 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) {
|
|||
MinExtent = "1 1";
|
||||
bitmapAsset = "ToolsModule:separator_h_image";
|
||||
};
|
||||
new GuiControl(PaintBrushSlopeControlTE) {
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "1";
|
||||
Profile = "ToolsGuiDefaultProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "700 2";
|
||||
Extent = "256 50";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "ToolsGuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
|
||||
new GuiTextCtrl() {
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiTextProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "21 5";
|
||||
Extent = "78 10";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "ToolsGuiToolTipProfile";
|
||||
tooltip = "Allows painting on the terrain within a specified slope";
|
||||
hovertime = "1000";
|
||||
Margin = "0 0 0 0";
|
||||
Padding = "0 0 0 0";
|
||||
AnchorTop = "1";
|
||||
AnchorBottom = "0";
|
||||
AnchorLeft = "1";
|
||||
AnchorRight = "0";
|
||||
text = "Slope Mask: Min";
|
||||
maxLength = "1024";
|
||||
};
|
||||
new GuiTextEditCtrl() {
|
||||
internalName = "SlopeMinAngle";
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiNumericDropSliderTextProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "104 2";
|
||||
Extent = "51 18";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
validate = "TerrainPainterPlugin.validateSlopeMinAngle();";
|
||||
Command = "ETerrainEditor.setSlopeLimitMinAngle( $ThisControl.getText() );";
|
||||
tooltipprofile = "ToolsGuiToolTipProfile";
|
||||
tooltip = "Minimum terrain angle that will be paintable";
|
||||
hovertime = "1000";
|
||||
Margin = "0 0 0 0";
|
||||
Padding = "0 0 0 0";
|
||||
AnchorTop = "1";
|
||||
AnchorBottom = "0";
|
||||
AnchorLeft = "1";
|
||||
AnchorRight = "0";
|
||||
text = "0.0";
|
||||
maxLength = "4";
|
||||
historySize = "0";
|
||||
password = "0";
|
||||
tabComplete = "0";
|
||||
sinkAllKeyEvents = "0";
|
||||
passwordMask = "*";
|
||||
};
|
||||
new GuiBitmapButtonCtrl() {
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiDefaultProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "137 2";
|
||||
Extent = "18 18";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "ToolsGuiToolTipProfile";
|
||||
tooltip = "Minimum terrain angle that will be paintable";
|
||||
hovertime = "1000";
|
||||
groupNum = "-1";
|
||||
buttonType = "PushButton";
|
||||
useMouseEvents = "0";
|
||||
bitmapAsset = "ToolsModule:dropslider_n_image";
|
||||
Command = "Canvas.pushDialog(PaintBrushSlopeMinContainer);";
|
||||
};
|
||||
new GuiTextCtrl() {
|
||||
Profile = "ToolsGuiTextProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "165 5";
|
||||
Extent = "27 10";
|
||||
MinExtent = "8 2";
|
||||
text = "Max";
|
||||
tooltip = "Max terrain angle that will be paintable";
|
||||
};
|
||||
new GuiTextEditCtrl() {
|
||||
internalName = "SlopeMaxAngle";
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiNumericDropSliderTextProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "190 2";
|
||||
Extent = "51 18";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
validate = "TerrainPainterPlugin.validateSlopeMaxAngle();";
|
||||
Command = "ETerrainEditor.setSlopeLimitMaxAngle( $ThisControl.getText() );";
|
||||
tooltipprofile = "ToolsGuiToolTipProfile";
|
||||
tooltip = "Max terrain angle that will be paintable";
|
||||
hovertime = "1000";
|
||||
Margin = "0 0 0 0";
|
||||
Padding = "0 0 0 0";
|
||||
AnchorTop = "1";
|
||||
AnchorBottom = "0";
|
||||
AnchorLeft = "1";
|
||||
AnchorRight = "0";
|
||||
text = "90.0";
|
||||
maxLength = "4";
|
||||
historySize = "0";
|
||||
password = "0";
|
||||
tabComplete = "0";
|
||||
sinkAllKeyEvents = "0";
|
||||
passwordMask = "*";
|
||||
};
|
||||
new GuiBitmapButtonCtrl() {
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiDefaultProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "223 2";
|
||||
Extent = "18 18";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "ToolsGuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
groupNum = "-1";
|
||||
tooltip = "Max terrain angle that will be paintable";
|
||||
buttonType = "PushButton";
|
||||
useMouseEvents = "0";
|
||||
bitmapAsset = "ToolsModule:dropslider_n_image";
|
||||
Command = "Canvas.pushDialog(PaintBrushSlopeMaxContainer);";
|
||||
};
|
||||
};
|
||||
new GuiControl(TerrainSetHeightTextEditContainer) {
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "1";
|
||||
|
|
@ -510,10 +659,10 @@ new GuiMouseEventCtrl(TerrainBrushSizeSliderCtrlContainer,EditorGuiGroup) {
|
|||
internalName = "slider";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiSliderBoxProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
position = TerrainBrushSizeTextEditContainer.position.x + EWTerrainEditToolbar.position.x + 50 SPC
|
||||
TerrainBrushSizeTextEditContainer.position.y + 50;
|
||||
//HorizSizing = "right";
|
||||
//VertSizing = "bottom";
|
||||
position = TerrainBrushSizeTextEditContainer.getGlobalPosition().x + 50 SPC
|
||||
TerrainBrushSizeTextEditContainer.getGlobalPosition().y + 50;
|
||||
Extent = "112 20";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
|
|
|
|||
|
|
@ -570,6 +570,17 @@ new GuiMouseEventCtrl(PaintBrushSlopeMinContainer,EditorGuiGroup) {
|
|||
function PaintBrushSlopeMinContainer::onWake(%this)
|
||||
{
|
||||
%this-->slider.setValue(PaintBrushSlopeControl-->SlopeMinAngle.getText());
|
||||
%this-->slider.AltCommand = "PaintBrushSlopeControl-->SlopeMinAngle.setValue(mFloatLength( ($ThisControl.getValue()), 1 )); ETerrainEditor.setSlopeLimitMinAngle(mFloatLength( ($ThisControl.getValue()), 1 ));TerrainPainterPlugin.validateSlopeMinAngle();";
|
||||
|
||||
%pos = PaintBrushSlopeControl-->SlopeMinAngle.getGlobalPosition();
|
||||
|
||||
if (PaintBrushSlopeControlTE.isAwake())
|
||||
{
|
||||
%pos = PaintBrushSlopeControlTE-->SlopeMinAngle.getGlobalPosition();
|
||||
%this-->slider.AltCommand = "PaintBrushSlopeControlTE-->SlopeMinAngle.setValue(mFloatLength( ($ThisControl.getValue()), 1 )); ETerrainEditor.setSlopeLimitMinAngle(mFloatLength( ($ThisControl.getValue()), 1 ));TerrainPainterPlugin.validateSlopeMinAngle();";
|
||||
|
||||
}
|
||||
%this-->slider.setPositionGlobal(%pos.x, %pos.y + 25);
|
||||
}
|
||||
|
||||
new GuiMouseEventCtrl(PaintBrushSlopeMaxContainer,EditorGuiGroup) {
|
||||
|
|
@ -605,6 +616,16 @@ new GuiMouseEventCtrl(PaintBrushSlopeMaxContainer,EditorGuiGroup) {
|
|||
function PaintBrushSlopeMaxContainer::onWake(%this)
|
||||
{
|
||||
%this-->slider.setValue(PaintBrushSlopeControl-->SlopeMaxAngle.getText());
|
||||
%this-->slider.AltCommand = "PaintBrushSlopeControl-->SlopeMaxAngle.setValue(mFloatLength( ($ThisControl.getValue()), 1 )); ETerrainEditor.setSlopeLimitMaxAngle(mFloatLength( ($ThisControl.getValue()), 1 ));TerrainPainterPlugin.validateSlopeMaxAngle();";
|
||||
|
||||
%pos = PaintBrushSlopeControl-->SlopeMaxAngle.getGlobalPosition();
|
||||
|
||||
if (PaintBrushSlopeControlTE.isAwake())
|
||||
{
|
||||
%pos = PaintBrushSlopeControlTE-->SlopeMaxAngle.getGlobalPosition();
|
||||
%this-->slider.AltCommand = "PaintBrushSlopeControlTE-->SlopeMaxAngle.setValue(mFloatLength( ($ThisControl.getValue()), 1 )); ETerrainEditor.setSlopeLimitMaxAngle(mFloatLength( ($ThisControl.getValue()), 1 ));TerrainPainterPlugin.validateSlopeMaxAngle();";
|
||||
}
|
||||
%this-->slider.setPositionGlobal(%pos.x, %pos.y + 25);
|
||||
}
|
||||
|
||||
function PaintBrushSlopeMaxContainer::init(%this)
|
||||
|
|
|
|||
|
|
@ -1398,6 +1398,8 @@ function TerrainPainterPlugin::syncBrushInfo( %this )
|
|||
PaintBrushSizeTextEditContainer-->textEdit.text = getWord(ETerrainEditor.getBrushSize(), 0);
|
||||
PaintBrushSlopeControl-->SlopeMinAngle.text = ETerrainEditor.getSlopeLimitMinAngle();
|
||||
PaintBrushSlopeControl-->SlopeMaxAngle.text = ETerrainEditor.getSlopeLimitMaxAngle();
|
||||
PaintBrushSlopeControlTE-->SlopeMinAngle.text = ETerrainEditor.getSlopeLimitMinAngle();
|
||||
PaintBrushSlopeControlTE-->SlopeMaxAngle.text = ETerrainEditor.getSlopeLimitMaxAngle();
|
||||
PaintBrushPressureTextEditContainer-->textEdit.text = ETerrainEditor.getBrushPressure()*100;
|
||||
%brushType = ETerrainEditor.getBrushType();
|
||||
eval( "EWTerrainPainterToolbar-->" @ %brushType @ ".setStateOn(1);" );
|
||||
|
|
@ -1419,12 +1421,14 @@ function TerrainPainterPlugin::validateSlopeMaxAngle( %this )
|
|||
{
|
||||
%maxval = ETerrainEditor.getSlopeLimitMaxAngle();
|
||||
PaintBrushSlopeControl-->SlopeMaxAngle.setText(%maxval);
|
||||
PaintBrushSlopeControlTE-->SlopeMaxAngle.setText(%maxval);
|
||||
}
|
||||
|
||||
function TerrainPainterPlugin::validateSlopeMinAngle( %this )
|
||||
{
|
||||
%minval = ETerrainEditor.getSlopeLimitMinAngle();
|
||||
PaintBrushSlopeControl-->SlopeMinAngle.setText(%minval);
|
||||
PaintBrushSlopeControl-->SlopeMinAngle.setText(%minval);
|
||||
PaintBrushSlopeControlTE-->SlopeMinAngle.setText(%minval);
|
||||
}
|
||||
|
||||
function TerrainPainterPlugin::keyboardModifyBrushSize( %this, %amt)
|
||||
|
|
@ -3105,6 +3109,8 @@ function EWorldEditorStatusBarCamera::onSelect( %this, %id, %text )
|
|||
function softSnapSizeSliderCtrlContainer::onWake(%this)
|
||||
{
|
||||
%this-->slider.setValue(EWorldEditorToolbar-->softSnapSizeTextEdit.getValue());
|
||||
%pos = EWorldEditorToolbar-->softSnapSizeTextEdit.getGlobalPosition();
|
||||
%this-->slider.setPositionGlobal(%pos.x, %pos.y + 25);
|
||||
}
|
||||
function softSnapSizeSliderCtrlContainer::onSliderChanged(%this)
|
||||
{
|
||||
|
|
@ -3117,16 +3123,22 @@ function PaintBrushSizeSliderCtrlContainer::onWake(%this)
|
|||
{
|
||||
%this-->slider.range = "1" SPC getWord(ETerrainEditor.maxBrushSize, 0);
|
||||
%this-->slider.setValue(PaintBrushSizeTextEditContainer-->textEdit.getValue());
|
||||
%pos = PaintBrushSizeTextEditContainer.getGlobalPosition();
|
||||
%this-->slider.setPositionGlobal(%pos.x, %pos.y + 25);
|
||||
}
|
||||
|
||||
function PaintBrushPressureSliderCtrlContainer::onWake(%this)
|
||||
{
|
||||
%this-->slider.setValue(PaintBrushPressureTextEditContainer-->textEdit.getValue() / 100);
|
||||
%pos = PaintBrushPressureTextEditContainer.getGlobalPosition();
|
||||
%this-->slider.setPositionGlobal(%pos.x, %pos.y + 25);
|
||||
}
|
||||
|
||||
function PaintBrushSoftnessSliderCtrlContainer::onWake(%this)
|
||||
{
|
||||
%this-->slider.setValue(PaintBrushSoftnessTextEditContainer-->textEdit.getValue() / 100);
|
||||
%pos = PaintBrushSoftnessTextEditContainer.getGlobalPosition();
|
||||
%this-->slider.setPositionGlobal(%pos.x, %pos.y + 25);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
|
|
@ -3135,26 +3147,37 @@ function TerrainBrushSizeSliderCtrlContainer::onWake(%this)
|
|||
{
|
||||
%this-->slider.range = "1" SPC getWord(ETerrainEditor.maxBrushSize, 0);
|
||||
%this-->slider.setValue(TerrainBrushSizeTextEditContainer-->textEdit.getValue());
|
||||
%pos = TerrainBrushSizeTextEditContainer.getGlobalPosition();
|
||||
%this-->slider.setPositionGlobal(%pos.x, %pos.y + 25);
|
||||
}
|
||||
|
||||
function TerrainBrushPressureSliderCtrlContainer::onWake(%this)
|
||||
{
|
||||
%this-->slider.setValue(TerrainBrushPressureTextEditContainer-->textEdit.getValue() / 100.0);
|
||||
%pos = TerrainBrushPressureTextEditContainer.getGlobalPosition();
|
||||
%this-->slider.setPositionGlobal(%pos.x, %pos.y + 25);
|
||||
}
|
||||
|
||||
function TerrainBrushSoftnessSliderCtrlContainer::onWake(%this)
|
||||
{
|
||||
%this-->slider.setValue(TerrainBrushSoftnessTextEditContainer-->textEdit.getValue() / 100.0);
|
||||
%pos = TerrainBrushSoftnessTextEditContainer.getGlobalPosition();
|
||||
%this-->slider.setPositionGlobal(%pos.x, %pos.y + 25);
|
||||
}
|
||||
|
||||
function TerrainSetHeightSliderCtrlContainer::onWake(%this)
|
||||
{
|
||||
%this-->slider.setValue(TerrainSetHeightTextEditContainer-->textEdit.getValue());
|
||||
%pos = TerrainSetHeightTextEditContainer.getGlobalPosition();
|
||||
%this-->slider.setPositionGlobal(%pos.x, %pos.y + 25);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
function CameraSpeedDropdownCtrlContainer::onWake(%this)
|
||||
{
|
||||
%this-->slider.setValue(CameraSpeedDropdownContainer-->textEdit.getText());
|
||||
%pos = CameraSpeedDropdownContainer.getGlobalPosition();
|
||||
%this-->slider.setPositionGlobal(%pos.x, %pos.y + 25);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue