Original trains bounding boxes displaced from track axis.

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

Post Reply
temporal8
Route Supervisor
Route Supervisor
Posts: 430
Joined: 17 May 2019 14:15

Original trains bounding boxes displaced from track axis.

Post 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 2027 times
box2.png
box2.png (221.85 KiB) Viewed 2027 times
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Original trains bounding boxes displaced from track axis.

Post 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!)
temporal8
Route Supervisor
Route Supervisor
Posts: 430
Joined: 17 May 2019 14:15

Re: Original trains bounding boxes displaced from track axis.

Post 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.
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 41 guests