Catenary sprites problem

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

Post Reply
User avatar
Emperor Jake
Tycoon
Tycoon
Posts: 3427
Joined: 24 Apr 2007 09:37
Skype: Discord: Emperor Jake #4106
Location: Not Actually Japan
Contact:

Catenary sprites problem

Post by Emperor Jake »

While coding some stuff, I seemingly found a problem in the order in which OpenTTD draws catenary sprites. In the \ and _ views, if the poles are at the bottom of the tracks, the game draws the wires on top of the poles. This causes graphical glitches when using taller catenary poles. The / views behave as they should. (I have adjusted the alignments to show the effects of the wrong sprite order, that's why the pole sticks out of the track)

Image
Attachments
catenary.png
catenary.png (45.59 KiB) Viewed 475 times
Last edited by Emperor Jake on 21 Feb 2015 09:18, edited 1 time in total.
User avatar
Voyager One
Tycoon
Tycoon
Posts: 11204
Joined: 28 Dec 2009 09:47
Location: Rijeka, Croatia

Re: Catenary sprites problem

Post by Voyager One »

... not to mention that these sprites place poles in the middle of tracks... see circled pole at the bottom...

Weird, I never have noticed it but I have to ask you what track set are you using? Normal OTTD rails have gray poles and they don't seem to show these problems.
Leon

Image Image Image Image
"... all I ask is a tall ship and a star to steer her by..." - John Masefield
User avatar
Emperor Jake
Tycoon
Tycoon
Posts: 3427
Joined: 24 Apr 2007 09:37
Skype: Discord: Emperor Jake #4106
Location: Not Actually Japan
Contact:

Re: Catenary sprites problem

Post by Emperor Jake »

Voyager One wrote: ... not to mention that these sprites place poles in the middle of tracks... see circled pole at the bottom...
As I said I realigned the sprites so that the problem would be clearer. I also used the brown poles so they would contrast with the wires. You can reproduce this problem with the default catenary sprites and moving them with the sprite aligner, so it's not the fault of my NewGRF. It's not apparent with the default catenary or Purno's catenary at first glance, but I noticed it when I made taller poles for my current WIP.

The sprites are from an old version of my Trains of Europe Track set, which was never officially released, but I am working on something :P
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Catenary sprites problem

Post by Eddi »

i suppose this is a problem with too small bounding boxes.
User avatar
Emperor Jake
Tycoon
Tycoon
Posts: 3427
Joined: 24 Apr 2007 09:37
Skype: Discord: Emperor Jake #4106
Location: Not Actually Japan
Contact:

Re: Catenary sprites problem

Post by Emperor Jake »

I've found an older thread documenting this same problem.

As you can see, this problem is also apparent with the zBase default catenary.
catenaryHD.png
catenaryHD.png (201.79 KiB) Viewed 2360 times
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Catenary sprites problem

Post by Eddi »

What i mean with too small bounding box:

the bounding box of the pylon is not tall enough to reach in front of the catenary, so the game treats these as two unrelated objects, which can go in any order.
Attachments
Unbenannt, 1. Jan 1925#4.png
Unbenannt, 1. Jan 1925#4.png (38.03 KiB) Viewed 2336 times
User avatar
Emperor Jake
Tycoon
Tycoon
Posts: 3427
Joined: 24 Apr 2007 09:37
Skype: Discord: Emperor Jake #4106
Location: Not Actually Japan
Contact:

Re: Catenary sprites problem

Post by Emperor Jake »

Eddi wrote:What i mean with too small bounding box:

the bounding box of the pylon is not tall enough to reach in front of the catenary, so the game treats these as two unrelated objects, which can go in any order.
That seems to make sense, but it doesn't explain why the / view is drawn properly, is it random?. Would making the bounding boxes taller fix it and how hard would that be?

Here's a preview of my work in progress; I've made the poles so that the issue is barely visible, so it's not hugely important. I'd liked to have made them taller though.
poles.PNG
poles.PNG (32.22 KiB) Viewed 2334 times
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: Catenary sprites problem

Post by frosch »

Making the bounding boxes taller may fix this, but it may also break all bridges.
Hard to predict, but you can try it: Look for BB_HEIGHT_UNDER_BRIDGE in elrail.cpp and replace it with some bigger value. But given my comment from the past, maybe that was already tried:
static const uint BB_HEIGHT_UNDER_BRIDGE = 6; ///< Everything that can be built under low bridges, must not exceed this Z height.
However, generally it is not possible to fix all glitches (you can prove that). You can only try to minimize the glitches to a few pixels. And the catenary/pylon issue is about very few pixels.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Catenary sprites problem

Post by Eddi »

uhm, but catenary is removed under low bridges? and the pylons are basically on the adjacent tile?
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: Catenary sprites problem

Post by wallyweb »

I just noticed new bounding boxes for catenary sprites.
I assume this was done to resolve some of the issues discussed above.
Now I recently noticed that the top of the poles (yellow circle) are prone to random clipping.
Would extending the bounding box to the red lines resolve this?
Attachments
NEW BOUNDING BOXES POLE TOP..png
NEW BOUNDING BOXES POLE TOP..png (8.77 KiB) Viewed 1361 times
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Catenary sprites problem

Post by Eddi »

it might solve some clipping issues, but it might as well introduce others.
Post Reply

Return to “OpenTTD Problems”

Who is online

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