Page 1 of 1

Original trains bounding boxes displaced from track axis.

Posted: 02 Oct 2023 09:15
by temporal8
Why are the bounding boxes of the trains offset with respect to the axis of the tracks?

I have noticed that it causes problems in the trains development, in the original trains it does not cause problems due to its small scale where the graphics of the locomotives do not coincide / overlap with the stations bounding boxes but there is a problem that all developers have , CZ, GETS, Real Trains, etc... and those displaced bounding boxes force us to create complicated setups, CZ for example uses vehicles in 3 parts but in addition to a main graphic it needs additional nose and tail graphics so that the Locomotives do not have errors with bounding boxes, something similar happens with get and Real Trains as well.

With this I say that it is not possible to use a 3-part setup made up of a central graphic + 2 invisible parts but rather it is necessary to have graphics in all 3 parts.

I think it would be best to fix those bounding boxes by aligning them with the track axe. Look closely, the graphical error on the locomotive occurs right at the point where the locomotive's bounding box ends, if it wasn't offset and aligned across this it wouldn't happen.

The expected and correct thing would be for the bounding box to match the graphics and this doesn't even happen on the original trains/locomotives in the game. If one wanted to move the game's original graphics to match the bounding boxes, they would be out of place, so what is wrong is the bounding boxes being moved outside of their natural and correct location. I imagine that there must be a reason that I don't know for this to be the case, but it seemed like a good idea to propose it anyway.

The truth is that they would make life much easier for content developers, thanks in advance.
box.png
box.png (143.72 KiB) Viewed 4084 times
box2.png
box2.png (221.85 KiB) Viewed 4084 times

Re: Original trains bounding boxes displaced from track axis.

Posted: 02 Oct 2023 12:46
by PikkaBird
The maximum length of a train vehicle in OpenTTD is 8/8, or half a tile. If you're trying to draw vehicles longer than that, you shouldn't expect it to just work.
temporal8 wrote: 02 Oct 2023 09:15 there is a problem that all developers have
No, only those developers who are trying to draw sprites significantly outside the bounding box. Why would you not expect a single sprite on the center vehicle to clip in this situation, when the vehicle is fully on the tile behind the tile that the platform sprite is on?

(FWIW the one alignment issue that the default sprites, and most NewGRFs, do have is that everything is shifted one (or 2, or 4 at extra zoom) pixel to the right, relative to the bounding boxes - I think correcting that error is something more NewGRFs (and base sets) should do!)

Re: Original trains bounding boxes displaced from track axis.

Posted: 02 Oct 2023 20:46
by temporal8
PikkaBird wrote: 02 Oct 2023 12:46 The maximum length of a train vehicle in OpenTTD is 8/8, or half a tile. If you're trying to draw vehicles longer than that, you shouldn't expect it to just work.
temporal8 wrote: 02 Oct 2023 09:15 there is a problem that all developers have
No, only those developers who are trying to draw sprites significantly outside the bounding box. Why would you not expect a single sprite on the center vehicle to clip in this situation, when the vehicle is fully on the tile behind the tile that the platform sprite is on?

(FWIW the one alignment issue that the default sprites, and most NewGRFs, do have is that everything is shifted one (or 2, or 4 at extra zoom) pixel to the right, relative to the bounding boxes - I think correcting that error is something more NewGRFs (and base sets) should do!)
Thanks for reply pal. I understand what you are saying about the central graph but In fact, in that example above, the locomotive graphic is in the front part, the first one of the 3 parts and that bug should not occur as i understand, which is why I asked about the displaced bounding boxes.


Anyway, at all zoom levels I see the original graphics of trains and tracks moved to the right, leaving the bounding box on the left, one or the other is displaced, It's not a criticism but I don't understand why it is like that.