mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +00:00
copy paste support for terrains
This commit is contained in:
parent
262ff405fa
commit
561c201b88
4 changed files with 75 additions and 1 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include "gui/core/guiCanvas.h"
|
#include "gui/core/guiCanvas.h"
|
||||||
|
|
||||||
|
TerrainScratchPad gTerrainScratchPad;
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
bool TerrainAction::isValid(GridInfo tile)
|
bool TerrainAction::isValid(GridInfo tile)
|
||||||
{
|
{
|
||||||
|
|
@ -857,6 +858,34 @@ void HydraulicErosionAction::process(Selection* sel, const Gui3DMouseEvent&, boo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void copyAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChanged, Type type)
|
||||||
|
{
|
||||||
|
gTerrainScratchPad.clear();
|
||||||
|
for (U32 i=0;i<sel->size();i++)
|
||||||
|
{
|
||||||
|
if (isValid((*sel)[i]))
|
||||||
|
gTerrainScratchPad.addTile((*sel)[i].mHeight, (*sel)[i].mMaterial);
|
||||||
|
else
|
||||||
|
gTerrainScratchPad.addTile(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void pasteAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChanged, Type type)
|
||||||
|
{
|
||||||
|
for (U32 i = 0; i < sel->size(); i++)
|
||||||
|
{
|
||||||
|
if (isValid((*sel)[i]))
|
||||||
|
{
|
||||||
|
mTerrainEditor->getUndoSel()->add((*sel)[i]);
|
||||||
|
(*sel)[i].mHeight = gTerrainScratchPad[i]->mHeight;
|
||||||
|
(*sel)[i].mMaterial = gTerrainScratchPad[i]->mMaterial;
|
||||||
|
mTerrainEditor->setGridInfo((*sel)[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mTerrainEditor->scheduleGridUpdate();
|
||||||
|
mTerrainEditor->scheduleMaterialUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
IMPLEMENT_CONOBJECT( TerrainSmoothAction );
|
IMPLEMENT_CONOBJECT( TerrainSmoothAction );
|
||||||
|
|
||||||
ConsoleDocClass( TerrainSmoothAction,
|
ConsoleDocClass( TerrainSmoothAction,
|
||||||
|
|
|
||||||
|
|
@ -351,6 +351,47 @@ public:
|
||||||
F32 mScale;
|
F32 mScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TerrainScratchPad
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TerrainScratchPad() {};
|
||||||
|
~TerrainScratchPad() { mContents.clear(); };
|
||||||
|
void clear() { for (U32 i = 0; i < mContents.size(); i++) delete(mContents[i]); mContents.clear(); };
|
||||||
|
class gridStub
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
gridStub(F32 height, U8 material) : mHeight(height), mMaterial(material) {};
|
||||||
|
F32 mHeight;
|
||||||
|
U8 mMaterial;
|
||||||
|
};
|
||||||
|
void addTile(F32 height, U8 material) { mContents.push_back(new gridStub(height, material)); };
|
||||||
|
gridStub* operator [](U32 index) { return mContents[index]; };
|
||||||
|
private:
|
||||||
|
Vector<gridStub*> mContents;
|
||||||
|
};
|
||||||
|
|
||||||
|
class copyAction : public TerrainAction
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
copyAction(TerrainEditor* editor)
|
||||||
|
: TerrainAction(editor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
StringTableEntry getName() { return("copy"); }
|
||||||
|
void process(Selection* sel, const Gui3DMouseEvent& event, bool selChanged, Type type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class pasteAction : public TerrainAction
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
pasteAction(TerrainEditor* editor)
|
||||||
|
: TerrainAction(editor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
StringTableEntry getName() { return("paste"); }
|
||||||
|
void process(Selection* sel, const Gui3DMouseEvent& event, bool selChanged, Type type);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// An undo action used to perform terrain wide smoothing.
|
/// An undo action used to perform terrain wide smoothing.
|
||||||
class TerrainSmoothAction : public UndoAction
|
class TerrainSmoothAction : public UndoAction
|
||||||
|
|
|
||||||
|
|
@ -714,6 +714,8 @@ TerrainEditor::TerrainEditor() :
|
||||||
mActions.push_back(new PaintNoiseAction(this));
|
mActions.push_back(new PaintNoiseAction(this));
|
||||||
mActions.push_back(new ThermalErosionAction(this));
|
mActions.push_back(new ThermalErosionAction(this));
|
||||||
mActions.push_back(new HydraulicErosionAction(this));
|
mActions.push_back(new HydraulicErosionAction(this));
|
||||||
|
mActions.push_back(new copyAction(this));
|
||||||
|
mActions.push_back(new pasteAction(this));
|
||||||
|
|
||||||
|
|
||||||
// set the default action
|
// set the default action
|
||||||
|
|
|
||||||
|
|
@ -1256,7 +1256,9 @@ function EditorGui::SetTerrainPalletBar()
|
||||||
EWToolsPaletteWindow.addButton("FlattenHeight", "ToolsModule:flattenHeight_n_image", "ETerrainEditor.switchAction( flattenHeight );", "", "Flatten Height", "9");
|
EWToolsPaletteWindow.addButton("FlattenHeight", "ToolsModule:flattenHeight_n_image", "ETerrainEditor.switchAction( flattenHeight );", "", "Flatten Height", "9");
|
||||||
EWToolsPaletteWindow.addButton("SetHeight", "ToolsModule:setHeight_n_image", "ETerrainEditor.switchAction( setHeight );", "", "Set Height", "0");
|
EWToolsPaletteWindow.addButton("SetHeight", "ToolsModule:setHeight_n_image", "ETerrainEditor.switchAction( setHeight );", "", "Set Height", "0");
|
||||||
EWToolsPaletteWindow.addButton("SetEmpty", "ToolsModule:setEmpty_n_image", "ETerrainEditor.switchAction( setEmpty );", "", "Set Empty", "0");
|
EWToolsPaletteWindow.addButton("SetEmpty", "ToolsModule:setEmpty_n_image", "ETerrainEditor.switchAction( setEmpty );", "", "Set Empty", "0");
|
||||||
EWToolsPaletteWindow.addButton("ClearEmpty", "ToolsModule:clearEmpty_n_image", "ETerrainEditor.switchAction( clearEmpty );", "", "Clear Empty", "shift 0");
|
EWToolsPaletteWindow.addButton("ClearEmpty", "ToolsModule:clearEmpty_n_image", "ETerrainEditor.switchAction( clearEmpty );", "", "Clear Empty", "shift 0");
|
||||||
|
EWToolsPaletteWindow.addButton("Copy", "ToolsModule:setHeight_n_image", "ETerrainEditor.switchAction( copy );", "", "copy", "ctrl C");
|
||||||
|
EWToolsPaletteWindow.addButton("Paste", "ToolsModule:setHeight_n_image", "ETerrainEditor.switchAction( paste );", "", "paste", "ctrl v");
|
||||||
EWToolsPaletteWindow.refresh();
|
EWToolsPaletteWindow.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue