mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
add a pasteUp and pasteDown pallet
This commit is contained in:
parent
561c201b88
commit
25ea164a1f
5 changed files with 118 additions and 5 deletions
|
|
@ -858,6 +858,23 @@ void HydraulicErosionAction::process(Selection* sel, const Gui3DMouseEvent&, boo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TerrainScratchPad::addTile(F32 height, U8 material)
|
||||||
|
{
|
||||||
|
mContents.push_back(new gridStub(height, material));
|
||||||
|
|
||||||
|
mBottom = mMin(height, mBottom);
|
||||||
|
mTop = mMax(height, mTop);
|
||||||
|
};
|
||||||
|
|
||||||
|
void TerrainScratchPad::clear()
|
||||||
|
{
|
||||||
|
for (U32 i = 0; i < mContents.size(); i++)
|
||||||
|
delete(mContents[i]);
|
||||||
|
mContents.clear();
|
||||||
|
mBottom = F32_MAX;
|
||||||
|
mTop = F32_MIN;
|
||||||
|
}
|
||||||
|
|
||||||
void copyAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChanged, Type type)
|
void copyAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChanged, Type type)
|
||||||
{
|
{
|
||||||
gTerrainScratchPad.clear();
|
gTerrainScratchPad.clear();
|
||||||
|
|
@ -872,6 +889,15 @@ void copyAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChanged
|
||||||
|
|
||||||
void pasteAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChanged, Type type)
|
void pasteAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChanged, Type type)
|
||||||
{
|
{
|
||||||
|
if (gTerrainScratchPad.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (gTerrainScratchPad.size() != sel->size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (type != Begin)
|
||||||
|
return;
|
||||||
|
|
||||||
for (U32 i = 0; i < sel->size(); i++)
|
for (U32 i = 0; i < sel->size(); i++)
|
||||||
{
|
{
|
||||||
if (isValid((*sel)[i]))
|
if (isValid((*sel)[i]))
|
||||||
|
|
@ -886,6 +912,66 @@ void pasteAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChange
|
||||||
mTerrainEditor->scheduleMaterialUpdate();
|
mTerrainEditor->scheduleMaterialUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pasteUpAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChanged, Type type)
|
||||||
|
{
|
||||||
|
if (gTerrainScratchPad.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (gTerrainScratchPad.size() != sel->size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (type != Begin)
|
||||||
|
return;
|
||||||
|
F32 floor = F32_MAX;
|
||||||
|
for (U32 i = 0; i < sel->size(); i++)
|
||||||
|
{
|
||||||
|
floor = mMin((*sel)[i].mHeight, floor);
|
||||||
|
}
|
||||||
|
for (U32 i = 0; i < sel->size(); i++)
|
||||||
|
{
|
||||||
|
if (isValid((*sel)[i]))
|
||||||
|
{
|
||||||
|
mTerrainEditor->getUndoSel()->add((*sel)[i]);
|
||||||
|
(*sel)[i].mHeight = gTerrainScratchPad[i]->mHeight - gTerrainScratchPad.mBottom + floor;
|
||||||
|
(*sel)[i].mMaterial = gTerrainScratchPad[i]->mMaterial;
|
||||||
|
mTerrainEditor->setGridInfo((*sel)[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mTerrainEditor->scheduleGridUpdate();
|
||||||
|
mTerrainEditor->scheduleMaterialUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void pasteDownAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChanged, Type type)
|
||||||
|
{
|
||||||
|
if (gTerrainScratchPad.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (gTerrainScratchPad.size() != sel->size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (type != Begin)
|
||||||
|
return;
|
||||||
|
|
||||||
|
F32 ceiling = F32_MIN;
|
||||||
|
for (U32 i = 0; i < sel->size(); i++)
|
||||||
|
{
|
||||||
|
ceiling = mMax((*sel)[i].mHeight, ceiling);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (U32 i = 0; i < sel->size(); i++)
|
||||||
|
{
|
||||||
|
if (isValid((*sel)[i]))
|
||||||
|
{
|
||||||
|
mTerrainEditor->getUndoSel()->add((*sel)[i]);
|
||||||
|
(*sel)[i].mHeight = gTerrainScratchPad[i]->mHeight - gTerrainScratchPad.mTop + ceiling;
|
||||||
|
(*sel)[i].mMaterial = gTerrainScratchPad[i]->mMaterial;
|
||||||
|
mTerrainEditor->setGridInfo((*sel)[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mTerrainEditor->scheduleGridUpdate();
|
||||||
|
mTerrainEditor->scheduleMaterialUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
IMPLEMENT_CONOBJECT( TerrainSmoothAction );
|
IMPLEMENT_CONOBJECT( TerrainSmoothAction );
|
||||||
|
|
||||||
ConsoleDocClass( TerrainSmoothAction,
|
ConsoleDocClass( TerrainSmoothAction,
|
||||||
|
|
|
||||||
|
|
@ -354,9 +354,10 @@ public:
|
||||||
class TerrainScratchPad
|
class TerrainScratchPad
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TerrainScratchPad() {};
|
F32 mBottom, mTop;
|
||||||
|
TerrainScratchPad(): mBottom(FLT_MAX), mTop(F32_MIN){};
|
||||||
~TerrainScratchPad() { mContents.clear(); };
|
~TerrainScratchPad() { mContents.clear(); };
|
||||||
void clear() { for (U32 i = 0; i < mContents.size(); i++) delete(mContents[i]); mContents.clear(); };
|
void clear();
|
||||||
class gridStub
|
class gridStub
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -364,7 +365,8 @@ public:
|
||||||
F32 mHeight;
|
F32 mHeight;
|
||||||
U8 mMaterial;
|
U8 mMaterial;
|
||||||
};
|
};
|
||||||
void addTile(F32 height, U8 material) { mContents.push_back(new gridStub(height, material)); };
|
void addTile(F32 height, U8 material);
|
||||||
|
U32 size() { return(mContents.size()); };
|
||||||
gridStub* operator [](U32 index) { return mContents[index]; };
|
gridStub* operator [](U32 index) { return mContents[index]; };
|
||||||
private:
|
private:
|
||||||
Vector<gridStub*> mContents;
|
Vector<gridStub*> mContents;
|
||||||
|
|
@ -392,6 +394,27 @@ public:
|
||||||
void process(Selection* sel, const Gui3DMouseEvent& event, bool selChanged, Type type);
|
void process(Selection* sel, const Gui3DMouseEvent& event, bool selChanged, Type type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class pasteUpAction : public TerrainAction
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
pasteUpAction(TerrainEditor* editor)
|
||||||
|
: TerrainAction(editor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
StringTableEntry getName() { return("pasteUp"); }
|
||||||
|
void process(Selection* sel, const Gui3DMouseEvent& event, bool selChanged, Type type);
|
||||||
|
};
|
||||||
|
|
||||||
|
class pasteDownAction : public TerrainAction
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
pasteDownAction(TerrainEditor* editor)
|
||||||
|
: TerrainAction(editor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
StringTableEntry getName() { return("pasteDown"); }
|
||||||
|
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
|
||||||
|
|
|
||||||
|
|
@ -716,7 +716,9 @@ TerrainEditor::TerrainEditor() :
|
||||||
mActions.push_back(new HydraulicErosionAction(this));
|
mActions.push_back(new HydraulicErosionAction(this));
|
||||||
mActions.push_back(new copyAction(this));
|
mActions.push_back(new copyAction(this));
|
||||||
mActions.push_back(new pasteAction(this));
|
mActions.push_back(new pasteAction(this));
|
||||||
|
mActions.push_back(new pasteUpAction(this));
|
||||||
|
mActions.push_back(new pasteDownAction(this));
|
||||||
|
|
||||||
|
|
||||||
// set the default action
|
// set the default action
|
||||||
mCurrentAction = mActions[0];
|
mCurrentAction = mActions[0];
|
||||||
|
|
|
||||||
|
|
@ -1259,6 +1259,8 @@ function EditorGui::SetTerrainPalletBar()
|
||||||
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("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.addButton("Paste", "ToolsModule:setHeight_n_image", "ETerrainEditor.switchAction( paste );", "", "paste", "ctrl v");
|
||||||
|
EWToolsPaletteWindow.addButton("pasteUp", "ToolsModule:setHeight_n_image", "ETerrainEditor.switchAction( pasteUp );", "", "pasteUp", "ctrl b");
|
||||||
|
EWToolsPaletteWindow.addButton("PasteDown", "ToolsModule:setHeight_n_image", "ETerrainEditor.switchAction( pasteDown );", "", "pasteDown", "ctrl n");
|
||||||
EWToolsPaletteWindow.refresh();
|
EWToolsPaletteWindow.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ function ButtonPalette::refresh(%this)
|
||||||
variable = getField(%buttonInfo, 3);
|
variable = getField(%buttonInfo, 3);
|
||||||
};
|
};
|
||||||
|
|
||||||
%extents.y += 23;
|
%extents.y += 25;
|
||||||
|
|
||||||
if(isObject(%this.actionMap))
|
if(isObject(%this.actionMap))
|
||||||
%this.actionMap.bindCmd( keyboard, getField(%buttonInfo, 5), %paletteButton @ ".performClick();", "" );
|
%this.actionMap.bindCmd( keyboard, getField(%buttonInfo, 5), %paletteButton @ ".performClick();", "" );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue