mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-28 04:11:51 +00:00
make new elevation tool more drastic + add RMB action
This was SVN commit r13684.
This commit is contained in:
@@ -181,7 +181,7 @@ TerrainSidebar::TerrainSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebar
|
||||
wxSizer* gridSizer = new wxGridSizer(4);
|
||||
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), this, _("Modify"), _T("AlterElevation")),
|
||||
_("Brush with left mouse buttons to raise terrain,\nright mouse button to lower it")), wxSizerFlags().Expand());
|
||||
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), this, _("Pike"), _T("PikeElevation")),
|
||||
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), this, _("Ridge"), _T("PikeElevation")),
|
||||
_("Brush with left mouse buttons to raise terrain,\nright mouse button to lower it")), wxSizerFlags().Expand());
|
||||
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), this, _("Smooth"), _T("SmoothElevation")),
|
||||
_("Brush with left mouse button to smooth terrain,\nright mouse button to roughen it")), wxSizerFlags().Expand());
|
||||
|
||||
@@ -28,6 +28,7 @@ class PikeElevation : public StateDrivenTool<PikeElevation>
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(PikeElevation);
|
||||
|
||||
int m_Direction; // +1 = raise, -1 = lower
|
||||
Position m_Pos;
|
||||
|
||||
public:
|
||||
@@ -55,7 +56,13 @@ public:
|
||||
if (evt.LeftDown())
|
||||
{
|
||||
obj->m_Pos = Position(evt.GetPosition());
|
||||
SET_STATE(Piking);
|
||||
SET_STATE(PikeRaising);
|
||||
return true;
|
||||
}
|
||||
else if (evt.RightDown())
|
||||
{
|
||||
obj->m_Pos = Position(evt.GetPosition());
|
||||
SET_STATE(PikeLowering);
|
||||
return true;
|
||||
}
|
||||
else if (evt.Moving())
|
||||
@@ -86,7 +93,7 @@ public:
|
||||
|
||||
bool OnMouse(PikeElevation* obj, wxMouseEvent& evt)
|
||||
{
|
||||
if (evt.LeftUp())
|
||||
if (IsMouseUp(evt))
|
||||
{
|
||||
SET_STATE(Waiting);
|
||||
return true;
|
||||
@@ -106,11 +113,27 @@ public:
|
||||
|
||||
void OnTick(PikeElevation* obj, float dt)
|
||||
{
|
||||
POST_COMMAND(PikeElevation, (obj->m_Pos, dt*4096.f*g_Brush_Elevation.GetStrength()));
|
||||
POST_COMMAND(PikeElevation, (obj->m_Pos, dt*4096.f*GetDirection()*g_Brush_Elevation.GetStrength()));
|
||||
obj->m_Pos = Position::Unchanged();
|
||||
}
|
||||
|
||||
virtual bool IsMouseUp(wxMouseEvent& evt) = 0;
|
||||
virtual int GetDirection() = 0;
|
||||
};
|
||||
|
||||
struct sPikeRaising : public sPiking
|
||||
{
|
||||
bool IsMouseUp(wxMouseEvent& evt) { return evt.LeftUp(); }
|
||||
int GetDirection() { return +1; }
|
||||
}
|
||||
Piking;
|
||||
PikeRaising;
|
||||
|
||||
struct sPikeLowering : public sPiking
|
||||
{
|
||||
bool IsMouseUp(wxMouseEvent& evt) { return evt.RightUp(); }
|
||||
int GetDirection() { return -1; }
|
||||
}
|
||||
PikeLowering;
|
||||
};
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(PikeElevation, StateDrivenTool<PikeElevation>);
|
||||
|
||||
@@ -415,7 +415,8 @@ BEGIN_COMMAND(PikeElevation)
|
||||
{
|
||||
float x = (float)dx - ((float)g_CurrentBrush.m_H - 1) / 2.f;
|
||||
float y = (float)dy - ((float)g_CurrentBrush.m_W - 1) / 2.f;
|
||||
float distance = clamp(1 - (float)sqrt(x * x + y * y) / h, 0.f, 1.f);
|
||||
float distance = clamp(1 - (float)sqrt(x * x + y * y) / h, 0.01f, 1.0f);
|
||||
distance *= distance;
|
||||
m_TerrainDelta.RaiseVertex(x0 + dx, y0 + dy, (int)(amount * distance));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user