[patch] Polyline track building tool

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [patch] Polyline track building tool

Post by adf88 »

Patch updated, version 9 (for OpenTTD r26405/1.4.X).
- removed the double-click-ends-line feature
_dp_ wrote:when I place segment with autorail and then can't remove it with polyrail (in one click). It just jumps from one end to other
You can use drag-dropping to deal with this kind of problems, that's the point of this feature.
Firstly select proper snap point and line direction by moving mouse pointer (not clicking yet). Then press mouse button down and adjust length of the line by dragging.
:] don't worry, be happy and checkout my patches
MeSaber
Engineer
Engineer
Posts: 1
Joined: 03 Sep 2014 08:34

Re: [patch] Polyline track building tool

Post by MeSaber »

http://i.imgur.com/C5PS4Pd.png

This happens very often when doing diagonal lines. 90 degree poly turns when most servers doesnt accept 90 degree turns. Could there be an option or something to disable 90 degree poly turns?

//Saber @ Novapolis.net
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [patch] Polyline track building tool

Post by adf88 »

Forbid 90-degree turns? What about 135 and 180 turns? Forbid too? The tool lets you to create any layout, even "impossible" one and making any restrictions is not a good idea.

You can:
- use drag-dropping (hover to choose right angle, press mouse button down and drag-drop to adjust line length)
- place the turn in two steps (firstly place few tracks of the first 45-degree turn, then place the rest)
:] don't worry, be happy and checkout my patches
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: [patch] Polyline track building tool

Post by HackaLittleBit »

Here a suggestion to give the thing a more natural feel.;-)
Polyline behavior stops when deleting track.
+
A click on existing track stops the polyline behavior.
See if you like it.
Attachments
Stop_polyline_r27117.patch
(1.29 KiB) Downloaded 105 times
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [patch] Polyline track building tool

Post by adf88 »

HackaLittleBit wrote:to give the thing a more natural feel.;-)
That's quite laconic explanation. Could you give some rationale? What's the actual problem? What can we gain? Because I'm not getting it.

For now I can say that disabling polyline while removing tracks is not a good idea at all. With polyline you can easily remove tracks. No matter if a track is bended many times - removing it is just few clicks, without need of precise pointing.
:] don't worry, be happy and checkout my patches
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: [patch] Polyline track building tool

Post by HackaLittleBit »

Ok here we go.
You are right I should have explained better.
I was trying your patch and I had some difficulties.
In order to explain better I needed some time to ponder.
I just show you in the picture one of the problems I encountered.

Image

I used the polyline tool (from now on PLT) to delete a piece of track.
After that I wanted to continue the line, as you can see in the second picture.
I was not able to do this immediately.
I first have to choose an other track building tool to tell the PLT were to start.
Even when I want to start at a random place the PLT keeps on insisting to start from the last ending point.
Sometimes painting half a map with polyline.;-)
This is just one example.

For me this is not desired behavior.
A noob to which I include myself should not get in panic when using the tool.
The tool is imposing too much its behavior on the player.

My patch stops the polyline when rail is removed or overbuild.
It was to show you a more gentile behavior.
A better way in my opinion is the moment an other track building tool is chosen or more explicit when the button
of the PLT goes up or disappears it should forget were it was.
It is not much effort to start a new round of polylining from a new, or from the last starting point.
Also the PLT could easily replace the autorail button.
It does the job much better.....

Hope this helps

Regards.
Attachments
poly.png
poly.png (87.94 KiB) Viewed 728 times
Honza_
Engineer
Engineer
Posts: 120
Joined: 29 Aug 2010 10:29

Re: [patch] Polyline track building tool

Post by Honza_ »

HackaLittleBit's suggestions make sense.

From my experience, when I connect track with PLT, I want it to ended. So currently I have to cancel it and launch it again. If it ended and became immidiatelly ready for new placement, it could be improvement I guess. This is also natural feature of printed circuit board routing programs.

As for delete, in some cases it would be good too, but sometimes I want to remove like one rail badly placed and continue from the removed position. If the tool ended, it would be unwanted. It's hard to distinguish which action players wants, so one direction has to be choosed and I think it's more logical the way it is.

I don't really agree that PLT imposes too much on the player. It is intuitive and easy to use. After laying one track, you will love it and never want to route rails the old way :-)
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [patch] Polyline track building tool

Post by adf88 »

New version released.
HackaLittleBit wrote:Even when I want to start at a random place the PLT keeps on insisting to start from the last ending point...
So it's all about making easier to decide whether to start a new line or to continue from previous one. I realize about the problem but I was not sure about how to design a "natural" algorithm that would cover all cases so I was sticking to a minimalistic solution. There are some goals I made:
- traditional autorail tool should be available as always was
- polyline tool should be available without messing in settings
- you should be always allowed to start a polyline from the point of the last placement
- you should be always allowed to start a new polyline
The last one was not well covered, yet. Lastly I figured out how to properly use double-clicking without troubles I had previously. This let me to move on and I designed a hopefully good system. From now on:
  • [01-improve-polyline-shape-computation]
    More natural shape computation (minor fix).
  • [02-move-polyline-snap-point-when-overbuilding]
    Polyline will follow overbuilt tracks too.
  • [03-pick-a-tile-to-snap-to-when-starting-new-polyline]
    When placing a new polyline, firstly you pick a tile to snap to (previously you had to place a track and the line was snapped to this track).
  • [04-start-new-polyline-when-double-clicking]
    When polyline tool is opened, double-clicking on a white-highlighted tile (not on a blue-highlighted tile) starts new polyline.
  • [05-choose-if-to-start-new-polyline-when-opening-the-tool]
    Allows to choose, while opening polyline tool, whether to start completely new line or connect to a previously built track. Start new line when clicking on the button or by CTRL+SHIFT+A. Connect when ctrl-clicking on the button or by CTRL+A.
Single diff having everything is available at the first page.
Patch queue with the changes is available below:
Attachments
polyline_track_tool_v10_ottd_r27095-mq.zip
(29.44 KiB) Downloaded 96 times
:] don't worry, be happy and checkout my patches
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: [patch] Polyline track building tool

Post by HackaLittleBit »

Ok, starts to look smooth.
Attached two small patches.
one is a proposal to for better behavior.(
adf88 wrote:When placing a new polyline, firstly you pick a tile to snap to (previously you had to place a track and the line was snapped to this track).
Isn't that counter intuitive?
)
With that patch applied all rail buttons build rail when location is chosen, and button is pressed down and up.
For the PLT it will continue from there on.

Then I have a small bug for you.
Click polyline tool button, build small section and try to close the polyline tool button.
You have to click twice to do so.
Also have a check when game is in paused mode.
I don't think the tool should be activated when user is not allowed to build during pause mode.

Somewhere there is a tiny bug when single clicking white line that make the tool stop.
I was not able to reproduce however.
I need to play more with this awesome tool.;-)
Attachments
trunk_3.zip
(1.81 KiB) Downloaded 112 times
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [patch] Polyline track building tool

Post by adf88 »

New version (10a) is released.
HackaLittleBit wrote:
adf88 wrote:When placing a new polyline, firstly you pick a tile to snap to (previously you had to place a track and the line was snapped to this track).
Isn't that counter intuitive?
Counter intuitive? No. But maybe not the best idea indeed. I changed the behaviour. Clicking now works like in earlier versions. Drag-dropping first line now has "polyline" style.
HackaLittleBit wrote:Then I have a small bug for you.
Click polyline tool button, build small section and try to close the polyline tool button.
You have to click twice to do so.
It was somehow intended behaviour, this first click was starting a new line. However, it feels odd at least. I changed button/hotkey handling:
  • button clicking - open the tool in non-snapping mode (new line), close the tool if it is opened
  • button ctrl-clicking - switch between snapping and non-snapping modes, open the tool in non-snapping mode if it is closed
  • CTRL+A hotkey - activate polyline tool in snapping mode, close the tool if snapping mode is already active
  • CTRL+SHIFT+A hotkey - activate polyline tool in non-snapping (new line) mode, close the tool if non-snapping mode is already active
There was also another bug. When placement was failing (e.g. out of money) polyline snap point was moved anyway. It's fixed now.
HackaLittleBit wrote:Also have a check when game is in paused mode.
I don't think the tool should be activated when user is not allowed to build during pause mode.
Why should PLT be treated in different way then other tools?


Single diff having everything is available at the first page.
Patch queue with the changes is available below:
Attachments
polyline_track_tool_v10a_ottd_r27095-mq.zip
(35.8 KiB) Downloaded 93 times
:] don't worry, be happy and checkout my patches
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: [patch] Polyline track building tool

Post by HackaLittleBit »

Why should PLT be treated in different way then other tools?
It shouldn't and it doesn't.;-)

I can't find things to complain anymore.
Very nice and smooth now.

Below is small patch to rectify some punctuations etc.

Regards.
Attachments
Minor style changes r27135.patch
(12.72 KiB) Downloaded 115 times
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [patch] Polyline track building tool

Post by adf88 »

New version (10b) is released.

Just a single bug fix. While dragging to a point where no line is highlighted and releasing mouse button in that moment, no line should be placed but some arbitrary line was being placed anyway. Now it's fixed (12-don-t-place-track-when-none-highlighted).

As usual, single diff having everything is available at the first page.
Patch queue with the latest changes is available below:
Attachments
polyline_track_tool_v10b_ottd_r27095-mq.zip
(36.34 KiB) Downloaded 141 times
:] don't worry, be happy and checkout my patches
_dp_
Transport Coordinator
Transport Coordinator
Posts: 276
Joined: 18 Dec 2013 12:32

Re: [patch] Polyline track building tool

Post by _dp_ »

Let's move it to polyline topic :) (in reply to viewtopic.php?p=1180890#p1180890)
adf88 wrote:Besides this idea is independent of the Polyline patch, I think it's impossible to conclude a behavior that would suit everyone. Moreover, some (most?) people are against aggressive/automatic thermoforming and this kind of change would never get into the trunk because of philosophical reasons. Or I misunderstood you, please explain then.
You're right, but I still think it will be a very useful feature. Like right now I can't even set servers to anything but "very flat" (or "flat" with some extra shenanigans) because it takes way too much time to build rails on hills. As for behavior I think making it so that track keeps the height if, say, Alt is pressed would be a good starting point.
adf88 wrote:
_dp_ wrote:smarter handling of slopes
No idea what you mean, totally.
Mostly this thing: http://imgur.com/a/bnTkZ. Makes no sense whatsoever.
adf88 wrote:
_dp_ wrote:support for bridges/tunnels
There is support for bridges/tunnels already..
Very basic, it doesn't even move snapping point if bridge is already there. But I'd like to be able to do smth like this in one click: http://imgur.com/a/kyEZg
adf88 wrote:
_dp_ wrote:some alignment to other tracks
There is some alignment to other tracks already - following track will be aligned to previous track. Perhaps you thought of alignment to other tracks - HOW? I don't see how could it be done, how could it be useful.
Well, yeah, this one is a bit vague, but I usually build track from both sides at the same time so I often find myself in a situation when I want to connect to other track that's not on a screen yet (I usually am zoomed in a lot when I build). And I'd like to have some indication where should I end my track to connect with that rail.
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [patch] Polyline track building tool

Post by adf88 »

New version is released (v11).

Two new features:
  • After building a rail station you can snap new rail track to it (CTRL-click the polyline button or press CTRL+A).
  • After placing a rail track at tunnel/bridge/station entrance, snapping will be carried over, up to the other end.
_dp_: I'll answer later. Still thinking ;)
:] don't worry, be happy and checkout my patches
Patagonicus
Engineer
Engineer
Posts: 26
Joined: 24 Oct 2011 20:42

Re: [patch] Polyline track building tool

Post by Patagonicus »

Found that assertions in GetTileOwner (called by IsTileOwner) could fail. Following fix works, but please check if it looks okay:

Code: Select all

diff --git a/src/viewport.cpp b/src/viewport.cpp
index cc3d3b3..71723da 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -3668,7 +3668,7 @@ static LineSnapPoint LineSnapPointAtRailTrackEndpoint(TileIndex tile, DiagDirect
 
        /* Check whether to extend the snap point over a tunnel/bridge/station etc. */
        tile = TileAddByDiagDir(tile, exit_dir);
-       if (extended != NULL && IsTileOwner(tile, _local_company) && !IsTileType(tile, MP_RAILWAY) && !IsTileType(tile, MP_ROAD) &&
+       if (extended != NULL && !IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY) && IsTileOwner(tile, _local_company) && !IsTileType(tile, MP_RAILWAY) && !IsTileType(tile, MP_ROAD) &&
                        TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, INVALID_DIAGDIR)) == AxisToTrackBits(DiagDirToAxis(exit_dir))) {
                /* Check if this is a bridge and move the tile to the other end if so. */
                if (IsTileType(tile, MP_TUNNELBRIDGE)) tile = GetOtherTunnelBridgeEnd(tile);
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [patch] Polyline track building tool

Post by adf88 »

Thanks. Patch updated.
:] don't worry, be happy and checkout my patches
_dp_
Transport Coordinator
Transport Coordinator
Posts: 276
Joined: 18 Dec 2013 12:32

Re: [patch] Polyline track building tool

Post by _dp_ »

New version doesn't show error if there is not enough money, just moves snap point around.

P.S. Still thinking? ;)
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: [patch] Polyline track building tool

Post by adf88 »

New version (11b) is released.

Two bugs were fixed:
  • the "money limit" error was not shown on money shortage
  • snapping to non-rail bridges was possible
_dp_ wrote:
adf88 wrote:
_dp_ wrote:smarter handling of slopes (...) Mostly this thing: http://imgur.com/a/bnTkZ. Makes no sense whatsoever.
Actually this makes sense. While automatic terraforming rather won't happen, automatic fitting tracks to the landscape got my attention.
_dp_ wrote:I'd like to be able to do smth like this in one click: http://imgur.com/a/kyEZg
This could be handy. Got may attention 2. Although bridge type would have to be automatic (like when CTRL-clicking when placing bridges).
_dp_ wrote:some alignment to other tracks (...) Well, yeah, this one is a bit vague, but I usually build track from both sides at the same time so I often find myself in a situation when I want to connect to other track that's not on a screen yet (I usually am zoomed in a lot when I build). And I'd like to have some indication where should I end my track to connect with that rail.
Use the blue guideline - make sure it hits the other end. It has to be visible, sorry, no other way. Maybe open an extra viewport?
:] don't worry, be happy and checkout my patches
_dp_
Transport Coordinator
Transport Coordinator
Posts: 276
Joined: 18 Dec 2013 12:32

Re: [patch] Polyline track building tool

Post by _dp_ »

I started my own branch to make polyrail to work better on hills, you can keep track here if you want: https://bitbucket.org/citymania/cmclien ... r-polyrail
Though I'm mostly just experimenting for now, it's still far from being of any practical use.
krawco
Engineer
Engineer
Posts: 13
Joined: 07 Apr 2010 12:32

Re: [patch] Polyline track building tool

Post by krawco »

It surprises me how few people appretiate this amazing tool. Most of the problems people have with it can be solved by just using autorail.

Big thanks for creating the plugin and all the updates!
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Bing [Bot] and 13 guests