Diagonal roads!

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

User avatar
lukasz1985
Route Supervisor
Route Supervisor
Posts: 436
Joined: 27 Mar 2013 08:58
Location: Poland
Contact:

Re: Diagonal roads!

Post by lukasz1985 »

Sorry for bumping this old thread, but I want to make a proposal and hear your opinions.

I will make a few points. Most importantly I want to state, that diagonal roads are - in some sense - already there, the only problem is drawing a correct NewGRF and doing some minor changes to the source code (for the basic solution). What do I mean?

The fundamental assumption of the above is that the roads will look like and work like the roads in Simutrans - if you're not familiar with this, here are some links to posts that roughly display this:
viewtopic.php?p=980809#p980809
viewtopic.php?p=149090#p149090

So what, in detail is the solution?

The first part is that - for the visuals to be correct at least four sprites - for every curved road - would have to be redrawn, what I mean is explained on the folowing image:

Image

And analogously for the 3 other curve sprites.

With the most basic implementation the existing roads NewGRFs would become obsolete, because, you guess it, the vehicles would not go aligned on the track.

And here comes the second part: the code. The basic solution will need to change one thing: the way that RV's pass through curved roads (and curved roads only). Now the path they go through looks like following:
Image

And needs to look like following:
Image

I guess this is not much of a work to do, since this is hardcoded somewhere in the source. Technically speaking the implementation would be even easier because we're speaking of 1 line segment for each direction instead of 3.

This is the most basic implementation of course. If we would like to go serious and keep the existing NewGRFs intact - the roadtypes NewGRF's would have to indicate what kind of roads in terms of diagonality they contain and the code should take appropriate actions when a vehicle enters a "curved" road.

I won't cover cons and pros of such an approach to diagonal roads, as this has been discussed all over the forums and is perhaps to some degree a matter of taste.

My actual proposal is to implement this by myself (perhaps with some help from other devs), but I would like to hear what you want. I don't know if this would go into trunk, but I might fork OTTD and implement this alone for now, so you could get a taste.

You can take a poll and vote for or against my proposal: https://poll-maker.com/poll5190243xFe0668FB-156

I'm not putting this in the development section of the forum, because this is not an in-depth technical discussion.

Have a nice day.
ImageImage
_dp_
Transport Coordinator
Transport Coordinator
Posts: 284
Joined: 18 Dec 2013 12:32

Re: Diagonal roads!

Post by _dp_ »

lukasz1985 wrote: 13 May 2024 08:24 I guess this is not much of a work to do, since this is hardcoded somewhere in the source. Technically speaking the implementation would be even easier because we're speaking of 1 line segment for each direction instead of 3.
You guessed wrong. Even if somehow make your segments longer than they should be to not disconnect articulated vehicles (current implementation needs at least 8 steps per segment). You'll still have to deal with them when converting old savegames. Also, you'll likely need some compatibility solution for vehicle newgrfs that rely on subtile coordinaties. And let me to not even start on vehicle overtaking...
User avatar
odisseus
Chief Executive
Chief Executive
Posts: 665
Joined: 01 Nov 2017 21:19

Re: Diagonal roads!

Post by odisseus »

Don't forget the changes that must be made in the acceleration model. A visual change in the vehicle's trajectory is not enough!

While travelling through a sequence of curved road pieces, the vehicle takes a 90 degree turn on every tile, which incurs a large speed penalty. If we replace curved tiles with diagonal tiles, the vehicle will be travelling in a perfectly straight path, and the speed penalty should not be incurred. Also, when the vehicle passes from a straight tile onto a diagonal tile, it will take a slight turn (45 degrees); in this case there should be a reduced speed penalty.

This is just for the most basic implementation which won't allow any diagonal movement on crossroads, sharp diagonal-to-diagonal turns, or closely spaced parallel roads. If you want to have any of that, you need to implement massive changes to the pathfinder, and also some changes to the map format.
User avatar
lukasz1985
Route Supervisor
Route Supervisor
Posts: 436
Joined: 27 Mar 2013 08:58
Location: Poland
Contact:

Re: Diagonal roads!

Post by lukasz1985 »

This solution would draw old savegames non compatible (in the basic variant, because if there was a way to choose vehicles behaviour for curves somehow - old savegames, would of course still work). I guess at least 8 steps per segment would still be intact.
ImageImage
Not In Service
Engineer
Engineer
Posts: 15
Joined: 04 Jan 2025 07:56

Re: Diagonal roads!

Post by Not In Service »

Reading this gave rise to a non-diagonal roads 'need'
odisseus wrote: 13 May 2024 10:14 Don't forget the changes that must be made in the acceleration model. ...

While travelling through a sequence of curved road pieces, the vehicle takes a 90 degree turn on every tile, which incurs a large speed penalty.
This gives rise to its own suggestion- an option sandbox-wise to somehow limit or control or remove this penalty may be needed because these curved pieces can be a way to create the roads the lack of diagonals/ round road pieces etc (as those are problematic) means you can't create, what I mean is you sometimes want to go diagonal-ish with a wavy zig zag of corners or use these for a pseudo roundabout or other road setup of a type you can't make so you sort of fake it with corner pieces. hence this penalty could be a problem in some situations. Especially if you do 'interesting' stuff like roundabouts are a no so I'll make a 'diamondabout'.

Also while I'm thinking roads it dawned on me my upcoming build would benefit from one way and pedestrian roads that the ai will build town buildings along, I think it won't along one way currently and pedestrian is absent, so maybe extend the options for these re will the ai build town buildings along them, is it able to build roads joined to them or not, and adding pedestrian roads players cannot route vehicles down, as these are useful for modeling real city layouts in scenarios. I guess there are other options like cycle lanes etc and scenic only roads such as park/countryside footpaths but these probably already exist as grfs and suggestions. I think you can allow ai road joins to one way though by having a non one way section so that already has a workaround for now.
Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 2 guests