From ae57701e6c221c57773212b2db5bf5079d299882 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Thu, 4 Mar 2010 22:16:18 +0000 Subject: [PATCH] Generate smoother slopes at the expense of more StraightTrack --- src/Editor.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Editor.cpp b/src/Editor.cpp index cbcdb70..c12970e 100644 --- a/src/Editor.cpp +++ b/src/Editor.cpp @@ -236,18 +236,21 @@ bool Editor::drawTrackTile(Point where, track::Direction axis) bool level; Vector slope = map->slopeAt(where, axis, level); + bool bValid, aValid; + Vector slopeBefore = map->slopeBefore(where, axis, bValid); + Vector slopeAfter = map->slopeAfter(where, axis, aValid); + if (level) { - const bool flat = abs(slope.y) < 0.001f; + const bool flat = + abs(slope.y) < 0.001f + && (!bValid || abs(slopeBefore.y) < 0.001f) + && (!aValid || abs(slopeAfter.y) < 0.001); if (flat) { map->setTrackAt(where, makeStraightTrack(axis)); return true; } else { - bool bValid, aValid; - Vector slopeBefore = map->slopeBefore(where, axis, bValid); - Vector slopeAfter = map->slopeAfter(where, axis, aValid); - if (!bValid || !aValid) { warn() << "Cannot place track here"; return false; -- 2.39.2