From 85955479c8db761c6cf0b9e569980a98b887ed2f Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 23 Oct 2024 17:50:07 -0500 Subject: [PATCH 1/4] 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 --- .../source/gui/worldEditor/terrainActions.cpp | 29 ++++ .../source/gui/worldEditor/terrainActions.h | 2 +- .../worldEditor/gui/TerrainEditToolbar.ed.gui | 161 +++++++++++++++++- .../gui/TerrainPainterToolbar.ed.gui | 21 +++ .../worldEditor/scripts/EditorGui.ed.tscript | 25 ++- 5 files changed, 230 insertions(+), 8 deletions(-) diff --git a/Engine/source/gui/worldEditor/terrainActions.cpp b/Engine/source/gui/worldEditor/terrainActions.cpp index f6ca18c13c..08b8c5c003 100644 --- a/Engine/source/gui/worldEditor/terrainActions.cpp +++ b/Engine/source/gui/worldEditor/terrainActions.cpp @@ -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; diff --git a/Engine/source/gui/worldEditor/terrainActions.h b/Engine/source/gui/worldEditor/terrainActions.h index 2d965c6434..c59451717c 100644 --- a/Engine/source/gui/worldEditor/terrainActions.h +++ b/Engine/source/gui/worldEditor/terrainActions.h @@ -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); } diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui index 688cee4f8e..5549b36d13 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui @@ -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"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui index 2425cf813f..d0c668ee87 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui @@ -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) diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript index 0dcbaddca9..7d9d98eb68 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript @@ -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); } //------------------------------------------------------------------------------------ From 24933a1cc7ecd8872c32b4fc3560034aaf47886f Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 24 Oct 2024 13:37:45 -0500 Subject: [PATCH 2/4] add min/max tile height entrys to painter, apply those to the general isvalid check for a given tile alteration. apply that to more brushes. --- .../source/gui/worldEditor/terrainActions.cpp | 61 ++-- .../source/gui/worldEditor/terrainEditor.cpp | 34 +++ Engine/source/gui/worldEditor/terrainEditor.h | 2 + .../worldEditor/gui/TerrainEditToolbar.ed.gui | 2 +- .../gui/TerrainPainterToolbar.ed.gui | 263 ++++++++++++++++-- .../worldEditor/scripts/EditorGui.ed.tscript | 14 + 6 files changed, 328 insertions(+), 48 deletions(-) diff --git a/Engine/source/gui/worldEditor/terrainActions.cpp b/Engine/source/gui/worldEditor/terrainActions.cpp index 08b8c5c003..bc4cfba7a4 100644 --- a/Engine/source/gui/worldEditor/terrainActions.cpp +++ b/Engine/source/gui/worldEditor/terrainActions.cpp @@ -51,6 +51,9 @@ bool TerrainAction::isValid(GridInfo tile) norm.z < maxSlope) return false; } + if (tile.mHeight < mTerrainEditor->mTileMinHeight || tile.mHeight > mTerrainEditor->mTileMaxHeight) + return false; + return true; } @@ -226,32 +229,13 @@ void PaintMaterialAction::process(Selection * sel, const Gui3DMouseEvent &, bool if ( !selChanged || mat < 0 ) return; - 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; - for( U32 i = 0; i < sel->size(); i++ ) { GridInfo &inf = (*sel)[i]; - if ( slopeLimit ) - { - p.x = inf.mGridPoint.gridPos.x * squareSize; - p.y = inf.mGridPoint.gridPos.y * squareSize; - if ( !terrain->getNormal( p, &norm, true ) ) - continue; - - if ( norm.z > minSlope || - norm.z < maxSlope ) - continue; - } + if (!isValid(inf)) + continue; // If grid is already set to our material, or it is an // empty grid spot, then skip painting. @@ -324,6 +308,9 @@ void RaiseHeightAction::process( Selection *sel, const Gui3DMouseEvent &evt, boo for ( U32 i = 0; i < sel->size(); i++ ) { + if (!isValid((*sel)[i])) + continue; + mTerrainEditor->getUndoSel()->add((*sel)[i]); if ( (*sel)[i].mHeight < maxHeight ) { @@ -370,6 +357,9 @@ void LowerHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool s for(U32 i = 0; i < sel->size(); i++) { + if (!isValid((*sel)[i])) + continue; + mTerrainEditor->getUndoSel()->add((*sel)[i]); if((*sel)[i].mHeight > maxHeight) { @@ -391,6 +381,9 @@ void SetHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool sel { for(U32 i = 0; i < sel->size(); i++) { + if (!isValid((*sel)[i])) + continue; + mTerrainEditor->getUndoSel()->add((*sel)[i]); (*sel)[i].mHeight = mTerrainEditor->mSetHeightVal; mTerrainEditor->setGridInfo((*sel)[i]); @@ -470,6 +463,9 @@ void ScaleHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool s { for(U32 i = 0; i < sel->size(); i++) { + if (!isValid((*sel)[i])) + continue; + mTerrainEditor->getUndoSel()->add((*sel)[i]); (*sel)[i].mHeight *= mTerrainEditor->mScaleVal; mTerrainEditor->setGridInfo((*sel)[i]); @@ -529,6 +525,9 @@ void BrushAdjustHeightAction::process(Selection * sel, const Gui3DMouseEvent & e // and record the starting heights for(U32 i = 0; i < sel->size(); i++) { + if (!isValid((*sel)[i])) + continue; + mTerrainEditor->getUndoSel()->add((*sel)[i]); (*sel)[i].mStartHeight = (*sel)[i].mHeight; } @@ -608,6 +607,9 @@ void FlattenHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool // set it for(U32 i = 0; i < sel->size(); i++) { + if (!isValid((*sel)[i])) + continue; + mTerrainEditor->getUndoSel()->add((*sel)[i]); // @@ -652,6 +654,9 @@ void SmoothHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool // linear for(U32 i = 0; i < sel->size(); i++) { + if (!isValid((*sel)[i])) + continue; + (*sel)[i].mHeight += (avgHeight - (*sel)[i].mHeight) * mTerrainEditor->mSmoothFactor * (*sel)[i].mWeight; mTerrainEditor->setGridInfo((*sel)[i]); } @@ -695,7 +700,10 @@ void SmoothSlopeAction::process(Selection * sel, const Gui3DMouseEvent &, bool s F32 goalHeight; for(U32 i = 0; i < sel->size(); i++) - { + { + if (!isValid((*sel)[i])) + continue; + goalHeight = avgHeight + ((*sel)[i].mGridPoint.gridPos.x - avgPos.x)*avgSlope.x + ((*sel)[i].mGridPoint.gridPos.y - avgPos.y)*avgSlope.y; (*sel)[i].mHeight += (goalHeight - (*sel)[i].mHeight) * (*sel)[i].mWeight; @@ -723,6 +731,9 @@ void PaintNoiseAction::process(Selection * sel, const Gui3DMouseEvent &, bool se { for( U32 i = 0; i < sel->size(); i++ ) { + if (!isValid((*sel)[i])) + continue; + mTerrainEditor->getUndoSel()->add((*sel)[i]); const Point2I &gridPos = (*sel)[i].mGridPoint.gridPos; @@ -732,6 +743,12 @@ void PaintNoiseAction::process(Selection * sel, const Gui3DMouseEvent &, bool se (*sel)[i].mHeight += (noiseVal - mMinMaxNoise.y * mScale) * (*sel)[i].mWeight * mTerrainEditor->mNoiseFactor; + if ((*sel)[i].mHeight > mTerrainEditor->mTileMaxHeight) + (*sel)[i].mHeight = mTerrainEditor->mTileMaxHeight; + + if ((*sel)[i].mHeight < mTerrainEditor->mTileMinHeight) + (*sel)[i].mHeight = mTerrainEditor->mTileMinHeight; + mTerrainEditor->setGridInfo((*sel)[i]); } diff --git a/Engine/source/gui/worldEditor/terrainEditor.cpp b/Engine/source/gui/worldEditor/terrainEditor.cpp index 5a26dc1ff3..ff3ee9e303 100644 --- a/Engine/source/gui/worldEditor/terrainEditor.cpp +++ b/Engine/source/gui/worldEditor/terrainEditor.cpp @@ -745,6 +745,8 @@ TerrainEditor::TerrainEditor() : mSlopeMinAngle = 0.0f; mSlopeMaxAngle = 90.0f; + mTileMinHeight = 0; + mTileMaxHeight = 2047; } TerrainEditor::~TerrainEditor() @@ -2858,6 +2860,38 @@ DefineEngineMethod( TerrainEditor, setSlopeLimitMaxAngle, F32, (F32 angle), , "" return angle; } +DefineEngineMethod(TerrainEditor, getTileLimitMinHeight, F32, (), , "") +{ + return object->mTileMinHeight; +} + +DefineEngineMethod(TerrainEditor, setTileLimitMinHeight, F32, (F32 height), , "") +{ + if (height < 0.0f) + height = 0.0f; + + if (height > object->mTileMaxHeight) + height = object->mTileMaxHeight; + + object->mTileMinHeight = height; + return height; +} + +DefineEngineMethod(TerrainEditor, getTileLimitMaxHeight, F32, (), , "") +{ + return object->mTileMaxHeight; +} + +DefineEngineMethod(TerrainEditor, setTileLimitMaxHeight, F32, (F32 height), , "") +{ + if (height > 2047.0f) + height = 2047.0f; + if (height < object->mTileMinHeight) + height = object->mTileMinHeight; + + object->mTileMaxHeight = height; + return height; +} //------------------------------------------------------------------------------ void TerrainEditor::autoMaterialLayer( F32 mMinHeight, F32 mMaxHeight, F32 mMinSlope, F32 mMaxSlope, F32 mCoverage ) { diff --git a/Engine/source/gui/worldEditor/terrainEditor.h b/Engine/source/gui/worldEditor/terrainEditor.h index 27de51a6b6..8146a520c0 100644 --- a/Engine/source/gui/worldEditor/terrainEditor.h +++ b/Engine/source/gui/worldEditor/terrainEditor.h @@ -448,6 +448,8 @@ class TerrainEditor : public EditTSCtrl F32 mSlopeMinAngle; F32 mSlopeMaxAngle; + F32 mTileMinHeight; + F32 mTileMaxHeight; public: diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui index 5549b36d13..896bf811cb 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui @@ -447,7 +447,7 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { AnchorBottom = "0"; AnchorLeft = "1"; AnchorRight = "0"; - text = "Slope Mask: Min"; + text = "Slope Mask: Min"; maxLength = "1024"; }; new GuiTextEditCtrl() { diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui index d0c668ee87..265a9d2fd6 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui @@ -8,7 +8,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { HorizSizing = "right"; VertSizing = "bottom"; Position = "306 -3"; - Extent = "800 40"; + Extent = "1000 40"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; @@ -35,7 +35,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { HorizSizing = "right"; VertSizing = "bottom"; Position = "0 0"; - Extent = "760 40"; + Extent = "1000 40"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; @@ -223,7 +223,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { HorizSizing = "right"; VertSizing = "bottom"; Position = "245 2"; - Extent = "256 50"; + Extent = "422 50"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; @@ -237,7 +237,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { HorizSizing = "right"; VertSizing = "bottom"; Position = "21 5"; - Extent = "78 10"; + Extent = "74 10"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; @@ -250,7 +250,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { AnchorBottom = "0"; AnchorLeft = "1"; AnchorRight = "0"; - text = "Slope Mask: Min"; + text = "Slope Range"; maxLength = "1024"; }; new GuiTextEditCtrl() { @@ -260,7 +260,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { Profile = "ToolsGuiNumericDropSliderTextProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "104 2"; + Position = "97 2"; Extent = "51 18"; MinExtent = "8 2"; canSave = "1"; @@ -290,7 +290,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "137 2"; + Position = "132 2"; Extent = "18 18"; MinExtent = "8 2"; canSave = "1"; @@ -304,30 +304,154 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { bitmapAsset = "ToolsModule:dropslider_n_image"; Command = "Canvas.pushDialog(PaintBrushSlopeMinContainer);"; }; + new GuiTextEditCtrl() { + internalName = "SlopeMaxAngle"; + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiNumericDropSliderTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "150 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 = "184 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 GuiBitmapCtrl() { + Enabled = "1"; + Profile = "ToolsGuiDefaultProfile"; + position = "211 0"; + Extent = "2 26"; + MinExtent = "1 1"; + bitmapAsset = "ToolsModule:separator_h_image"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; Profile = "ToolsGuiTextProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "165 5"; - Extent = "27 10"; + Position = "221 5"; + Extent = "79 10"; MinExtent = "8 2"; - text = "Max"; - tooltip = "Max terrain angle that will be paintable"; + 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 = "Height Range"; + maxLength = "1024"; }; new GuiTextEditCtrl() { - internalName = "SlopeMaxAngle"; + internalName = "tileMinHeight"; canSaveDynamicFields = "0"; isContainer = "0"; Profile = "ToolsGuiNumericDropSliderTextProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "190 2"; + Position = "305 2"; Extent = "51 18"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; - validate = "TerrainPainterPlugin.validateSlopeMaxAngle();"; - Command = "ETerrainEditor.setSlopeLimitMaxAngle( $ThisControl.getText() );"; + validate = "TerrainPainterPlugin.validateTileMinHeight();"; + Command = "ETerrainEditor.setTileLimitMinHeight( $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 = "340 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(PaintBrushTileMinHeightContainer);"; + }; + new GuiTextEditCtrl() { + internalName = "tileMaxHeight"; + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiNumericDropSliderTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "358 2"; + Extent = "51 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + validate = "TerrainPainterPlugin.validateTileMaxHeight();"; + Command = "ETerrainEditor.setTileLimitMaxHeight( $ThisControl.getText() );"; tooltipprofile = "ToolsGuiToolTipProfile"; tooltip = "Max terrain angle that will be paintable"; hovertime = "1000"; @@ -351,7 +475,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "223 2"; + Position = "392 2"; Extent = "18 18"; MinExtent = "8 2"; canSave = "1"; @@ -363,14 +487,14 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { buttonType = "PushButton"; useMouseEvents = "0"; bitmapAsset = "ToolsModule:dropslider_n_image"; - Command = "Canvas.pushDialog(PaintBrushSlopeMaxContainer);"; + Command = "Canvas.pushDialog(PaintBrushTileMaxHeightContainer);"; }; }; new GuiBitmapCtrl() { Enabled = "1"; Profile = "ToolsGuiDefaultProfile"; - position = "498 0"; + position = "665 0"; Extent = "2 26"; MinExtent = "1 1"; bitmapAsset = "ToolsModule:separator_h_image"; @@ -382,7 +506,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { Profile = "ToolsGuiTransparentProfile"; HorizSizing = "right"; VertSizing = "bottom"; - position = "510 2"; + position = "676 2"; Extent = "120 50"; MinExtent = "8 2"; canSave = "1"; @@ -397,7 +521,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { HorizSizing = "right"; VertSizing = "bottom"; position = "0 5"; - Extent = "47 10"; + Extent = "53 10"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; @@ -418,8 +542,8 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { profile="ToolsGuiNumericDropSliderTextProfile"; HorizSizing = "right"; VertSizing = "bottom"; - position = "49 2"; - Extent = "42 16"; + position = "55 2"; + Extent = "51 16"; MinExtent = "8 16"; canSave = "1"; Visible = "1"; @@ -439,7 +563,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "83 2"; + Position = "89 2"; Extent = "18 18"; MinExtent = "8 2"; canSave = "1"; @@ -458,14 +582,14 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { new GuiBitmapCtrl() { Enabled = "1"; Profile = "ToolsGuiDefaultProfile"; - position = "618 0"; + position = "786 0"; Extent = "2 26"; MinExtent = "1 1"; bitmapAsset = "ToolsModule:separator_h_image"; }; new GuiControl(TerrainTextureSettingsButtonContainer,EditorGuiGroup) { - position = "628 4"; + position = "796 4"; extent = "90 18"; minExtent = "8 2"; horizSizing = "right"; @@ -693,3 +817,92 @@ new GuiMouseEventCtrl(PaintBrushSoftnessSliderCtrlContainer,EditorGuiGroup) { }; }; +new GuiMouseEventCtrl(PaintBrushTileMinHeightContainer,EditorGuiGroup) { + horizSizing = "right"; + vertSizing = "bottom"; + position = "0 0"; + extent = "1024 768"; + minExtent = "8 8"; + visible = "1"; + helpTag = "0"; + class = "EditorDropdownSliderContainer"; + + new GuiSliderCtrl() { + canSaveDynamicFields = "0"; + internalName = "slider"; + isContainer = "0"; + Profile = "ToolsGuiSliderBoxProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "0 0"; + Extent = "112 20"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + AltCommand = "PaintBrushSlopeControl-->tileMinHeight.setValue(mFloatLength( ($ThisControl.getValue()), 1 )); ETerrainEditor.setTileLimitMinHeight(mFloatLength( ($ThisControl.getValue()), 1 ));TerrainPainterPlugin.validateTileMinHeight();"; + range = "0 2047"; + ticks = "0"; + value = "0"; + }; +}; + +function PaintBrushTileMinHeightContainer::onWake(%this) +{ + %this-->slider.setValue(PaintBrushSlopeControl-->tileMinHeight.getText()); + %this-->slider.AltCommand = "PaintBrushSlopeControl-->tileMinHeight.setValue(mFloatLength( ($ThisControl.getValue()), 1 )); ETerrainEditor.setTileLimitMinHeight(mFloatLength( ($ThisControl.getValue()), 1 ));TerrainPainterPlugin.validateTileMinHeight();"; + + %pos = PaintBrushSlopeControl-->tileMinHeight.getGlobalPosition(); + + if (PaintBrushSlopeControlTE.isAwake()) + { + %pos = PaintBrushSlopeControlTE-->tileMinHeight.getGlobalPosition(); + %this-->slider.AltCommand = "PaintBrushSlopeControlTE-->tileMinHeight.setValue(mFloatLength( ($ThisControl.getValue()), 1 )); ETerrainEditor.setTileLimitMinHeight(mFloatLength( ($ThisControl.getValue()), 1 ));TerrainPainterPlugin.validateTileMinHeight();"; + + } + %this-->slider.setPositionGlobal(%pos.x, %pos.y + 25); +} + +new GuiMouseEventCtrl(PaintBrushTileMaxHeightContainer,EditorGuiGroup) { + horizSizing = "right"; + vertSizing = "bottom"; + position = "0 0"; + extent = "1024 768"; + minExtent = "8 8"; + visible = "1"; + helpTag = "0"; + class = "EditorDropdownSliderContainer"; + + new GuiSliderCtrl() { + canSaveDynamicFields = "0"; + internalName = "slider"; + isContainer = "0"; + Profile = "ToolsGuiSliderBoxProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "0 0"; + Extent = "112 20"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + AltCommand = "PaintBrushSlopeControl-->tileMaxHeight.setValue(mFloatLength( ($ThisControl.getValue()), 1 )); ETerrainEditor.setTileLimitMaxHeight(mFloatLength( ($ThisControl.getValue()), 1 ));TerrainPainterPlugin.validateTileMaxHeight();"; + range = "0 2047"; + ticks = "0"; + value = "0"; + }; +}; + +function PaintBrushTileMaxHeightContainer::onWake(%this) +{ + %this-->slider.setValue(PaintBrushSlopeControl-->tileMaxHeight.getText()); + %this-->slider.AltCommand = "PaintBrushSlopeControl-->tileMaxHeight.setValue(mFloatLength( ($ThisControl.getValue()), 1 )); ETerrainEditor.setTileLimitMaxHeight(mFloatLength( ($ThisControl.getValue()), 1 ));TerrainPainterPlugin.validateTileMaxHeight();"; + + %pos = PaintBrushSlopeControl-->tileMaxHeight.getGlobalPosition(); + + if (PaintBrushSlopeControlTE.isAwake()) + { + %pos = PaintBrushSlopeControlTE-->tileMaxHeight.getGlobalPosition(); + %this-->slider.AltCommand = "PaintBrushSlopeControlTE-->TileMaxHeight.setValue(mFloatLength( ($ThisControl.getValue()), 1 )); ETerrainEditor.setTileLimitMaxHeight(mFloatLength( ($ThisControl.getValue()), 1 ));TerrainPainterPlugin.validateTileMaxHeight();"; + + } + %this-->slider.setPositionGlobal(%pos.x, %pos.y + 25); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript index 7d9d98eb68..0f6bdb2c4b 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript @@ -1431,6 +1431,20 @@ function TerrainPainterPlugin::validateSlopeMinAngle( %this ) PaintBrushSlopeControlTE-->SlopeMinAngle.setText(%minval); } +function TerrainPainterPlugin::validateTileMinHeight( %this ) +{ + %maxval = ETerrainEditor.getTileLimitMinHeight(); + PaintBrushSlopeControl-->tileMinHeight.setText(%maxval); + //PaintBrushSlopeControlTE-->tileMinHeight.setText(%maxval); +} + +function TerrainPainterPlugin::validateTileMaxHeight( %this ) +{ + %minval = ETerrainEditor.getTileLimitMaxHeight(); + PaintBrushSlopeControl-->tileMaxHeight.setText(%minval); + //PaintBrushSlopeControlTE-->tileMaxHeight.setText(%minval); +} + function TerrainPainterPlugin::keyboardModifyBrushSize( %this, %amt) { %val = PaintBrushSizeTextEditContainer-->textEdit.getText(); From 149f6cc5bfe1e25b9f5a3550eeb615df98300d5b Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 24 Oct 2024 15:17:19 -0500 Subject: [PATCH 3/4] expose min/max height filters to terrain sculpting tab --- .../worldEditor/gui/TerrainEditToolbar.ed.gui | 163 ++++++++++++++++-- .../worldEditor/scripts/EditorGui.ed.tscript | 4 +- 2 files changed, 150 insertions(+), 17 deletions(-) diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui index 896bf811cb..e19e198e68 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui @@ -413,6 +413,15 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { MinExtent = "1 1"; bitmapAsset = "ToolsModule:separator_h_image"; }; + new GuiBitmapCtrl() { + Enabled = "1"; + Profile = "ToolsGuiDefaultProfile"; + position = "690 0"; + Extent = "2 26"; + MinExtent = "1 1"; + bitmapAsset = "ToolsModule:separator_h_image"; + }; + new GuiControl(PaintBrushSlopeControlTE) { canSaveDynamicFields = "0"; isContainer = "1"; @@ -420,7 +429,7 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { HorizSizing = "right"; VertSizing = "bottom"; Position = "700 2"; - Extent = "256 50"; + Extent = "422 50"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; @@ -434,7 +443,7 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { HorizSizing = "right"; VertSizing = "bottom"; Position = "21 5"; - Extent = "78 10"; + Extent = "74 10"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; @@ -447,7 +456,7 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { AnchorBottom = "0"; AnchorLeft = "1"; AnchorRight = "0"; - text = "Slope Mask: Min"; + text = "Slope Range"; maxLength = "1024"; }; new GuiTextEditCtrl() { @@ -457,7 +466,7 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { Profile = "ToolsGuiNumericDropSliderTextProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "104 2"; + Position = "97 2"; Extent = "51 18"; MinExtent = "8 2"; canSave = "1"; @@ -487,7 +496,7 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "137 2"; + Position = "132 2"; Extent = "18 18"; MinExtent = "8 2"; canSave = "1"; @@ -501,30 +510,154 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { bitmapAsset = "ToolsModule:dropslider_n_image"; Command = "Canvas.pushDialog(PaintBrushSlopeMinContainer);"; }; + new GuiTextEditCtrl() { + internalName = "SlopeMaxAngle"; + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiNumericDropSliderTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "150 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 = "184 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 GuiBitmapCtrl() { + Enabled = "1"; + Profile = "ToolsGuiDefaultProfile"; + position = "211 0"; + Extent = "2 26"; + MinExtent = "1 1"; + bitmapAsset = "ToolsModule:separator_h_image"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; Profile = "ToolsGuiTextProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "165 5"; - Extent = "27 10"; + Position = "221 5"; + Extent = "79 10"; MinExtent = "8 2"; - text = "Max"; - tooltip = "Max terrain angle that will be paintable"; + 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 = "Height Range"; + maxLength = "1024"; }; new GuiTextEditCtrl() { - internalName = "SlopeMaxAngle"; + internalName = "tileMinHeight"; canSaveDynamicFields = "0"; isContainer = "0"; Profile = "ToolsGuiNumericDropSliderTextProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "190 2"; + Position = "305 2"; Extent = "51 18"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; - validate = "TerrainPainterPlugin.validateSlopeMaxAngle();"; - Command = "ETerrainEditor.setSlopeLimitMaxAngle( $ThisControl.getText() );"; + validate = "TerrainPainterPlugin.validateTileMinHeight();"; + Command = "ETerrainEditor.setTileLimitMinHeight( $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 = "340 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(PaintBrushTileMinHeightContainer);"; + }; + new GuiTextEditCtrl() { + internalName = "tileMaxHeight"; + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiNumericDropSliderTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "358 2"; + Extent = "51 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + validate = "TerrainPainterPlugin.validateTileMaxHeight();"; + Command = "ETerrainEditor.setTileLimitMaxHeight( $ThisControl.getText() );"; tooltipprofile = "ToolsGuiToolTipProfile"; tooltip = "Max terrain angle that will be paintable"; hovertime = "1000"; @@ -548,7 +681,7 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; VertSizing = "bottom"; - Position = "223 2"; + Position = "392 2"; Extent = "18 18"; MinExtent = "8 2"; canSave = "1"; @@ -560,7 +693,7 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { buttonType = "PushButton"; useMouseEvents = "0"; bitmapAsset = "ToolsModule:dropslider_n_image"; - Command = "Canvas.pushDialog(PaintBrushSlopeMaxContainer);"; + Command = "Canvas.pushDialog(PaintBrushTileMaxHeightContainer);"; }; }; new GuiControl(TerrainSetHeightTextEditContainer) { diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript index 0f6bdb2c4b..d683ec1785 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript @@ -1435,14 +1435,14 @@ function TerrainPainterPlugin::validateTileMinHeight( %this ) { %maxval = ETerrainEditor.getTileLimitMinHeight(); PaintBrushSlopeControl-->tileMinHeight.setText(%maxval); - //PaintBrushSlopeControlTE-->tileMinHeight.setText(%maxval); + PaintBrushSlopeControlTE-->tileMinHeight.setText(%maxval); } function TerrainPainterPlugin::validateTileMaxHeight( %this ) { %minval = ETerrainEditor.getTileLimitMaxHeight(); PaintBrushSlopeControl-->tileMaxHeight.setText(%minval); - //PaintBrushSlopeControlTE-->tileMaxHeight.setText(%minval); + PaintBrushSlopeControlTE-->tileMaxHeight.setText(%minval); } function TerrainPainterPlugin::keyboardModifyBrushSize( %this, %amt) From 218caea9e8004523876e2dc7a98da0129a78b2bb Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 28 Oct 2024 09:39:02 -0500 Subject: [PATCH 4/4] remove filtes on misbehaving brushes. correct range defaults --- Engine/source/gui/worldEditor/terrainActions.cpp | 9 --------- .../game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui | 2 +- .../tools/worldEditor/gui/TerrainPainterToolbar.ed.gui | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Engine/source/gui/worldEditor/terrainActions.cpp b/Engine/source/gui/worldEditor/terrainActions.cpp index bc4cfba7a4..2552a4d786 100644 --- a/Engine/source/gui/worldEditor/terrainActions.cpp +++ b/Engine/source/gui/worldEditor/terrainActions.cpp @@ -525,9 +525,6 @@ void BrushAdjustHeightAction::process(Selection * sel, const Gui3DMouseEvent & e // and record the starting heights for(U32 i = 0; i < sel->size(); i++) { - if (!isValid((*sel)[i])) - continue; - mTerrainEditor->getUndoSel()->add((*sel)[i]); (*sel)[i].mStartHeight = (*sel)[i].mHeight; } @@ -654,9 +651,6 @@ void SmoothHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool // linear for(U32 i = 0; i < sel->size(); i++) { - if (!isValid((*sel)[i])) - continue; - (*sel)[i].mHeight += (avgHeight - (*sel)[i].mHeight) * mTerrainEditor->mSmoothFactor * (*sel)[i].mWeight; mTerrainEditor->setGridInfo((*sel)[i]); } @@ -701,9 +695,6 @@ void SmoothSlopeAction::process(Selection * sel, const Gui3DMouseEvent &, bool s F32 goalHeight; for(U32 i = 0; i < sel->size(); i++) { - if (!isValid((*sel)[i])) - continue; - goalHeight = avgHeight + ((*sel)[i].mGridPoint.gridPos.x - avgPos.x)*avgSlope.x + ((*sel)[i].mGridPoint.gridPos.y - avgPos.y)*avgSlope.y; (*sel)[i].mHeight += (goalHeight - (*sel)[i].mHeight) * (*sel)[i].mWeight; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui index e19e198e68..95e023be46 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui @@ -667,7 +667,7 @@ $guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { AnchorBottom = "0"; AnchorLeft = "1"; AnchorRight = "0"; - text = "90.0"; + text = "2047"; maxLength = "4"; historySize = "0"; password = "0"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui index 265a9d2fd6..1b3edf239e 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui @@ -461,7 +461,7 @@ $guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { AnchorBottom = "0"; AnchorLeft = "1"; AnchorRight = "0"; - text = "90.0"; + text = "2047"; maxLength = "4"; historySize = "0"; password = "0";