Page 2 of 2

Posted: 15 Jun 2005 18:19
by Patchman
therax wrote:Exactly what I ran into. Depot sorting got weird (roofs), as did rail fences and particularly the "build-on-slopes" tiles. I haven't looked into these in detail because of time constraints, but I have a sneaking suspicion these are from bad Z coordinate bounds for these sprites.
That's odd, because those sprites can't overlap. TTD takes great care to never allow overlapping sprites by using some fake boxes, only the new stuff that isn't possible in TTD can have overlapping sprite boxes. For example, the depot bounding box for the front sprite is just a 1x1 box at the front corner (IIRC). Maybe there's a bug in the part of your code that checks whether sprites overlap?

I tried changing shorter vehicles so that the sprite boxes are smaller, but that gave other problems. Ideally, the sorter should support boxes at a 45⁰ angle too, or else vehicles moving diagonally across the grid won't have the right boxes. I looked into that briefly but couldn't find a simple yet efficient algorithm without using a z-buffer, which isn't useful for TTD unless you give the sprites themselves a z layer. Using a z-buffer would probably be the most reliable solution, but then you'd have to go through every single sprite and add z information to it, which just isn't feasible, particularly with the new graphics sets that have thousands of sprites each.

I did write a few working sprite sorters (you probably saw the code commented out), and they get the sorting right but break because TTD cheats with the bounding boxes and I didn't feel like fixing all those boxes (bridges, depots, stations, electrified railways). Besides, it would've broken many of the new station sets, because they all hardcode the sprite layout assuming TTD's sprite sorter.

Posted: 15 Jun 2005 19:35
by therax
Patchman wrote:That's odd, because those sprites can't overlap. TTD takes great care to never allow overlapping sprites by using some fake boxes, only the new stuff that isn't possible in TTD can have overlapping sprite boxes. For example, the depot bounding box for the front sprite is just a 1x1 box at the front corner (IIRC). Maybe there's a bug in the part of your code that checks whether sprites overlap?
Patchman wrote:I did write a few working sprite sorters (you probably saw the code commented out), and they get the sorting right but break because TTD cheats with the bounding boxes and I didn't feel like fixing all those boxes (bridges, depots, stations, electrified railways). Besides, it would've broken many of the new station sets, because they all hardcode the sprite layout assuming TTD's sprite sorter.
This is actually the case I was referring to. When I experimented with a single sorter, bridges, depots, etc. all break because of their strange bounding boxes.

To my knowledge, when using the overlap checking everything works just as well as TTDPatch in my testing, as it ought to since it's just a decompilation from the fixmisc.asm assembly. :) Since OTTD doesn't yet support new stations or the electrified rail sprites, I can't verify those cases, but they Ought-To-Work (tm).

On a side note, looks like hackykid commited this to r2440, so it should already be in the nightlies.

Posted: 15 Jun 2005 22:02
by Killer 11
yay if you will get it working there will be no graphical gliches with long wehicles like George's long busses and trucks :D