NikolaiVChr / flightgear-saab-ja-37-viggen

Saab 37 Viggen for Flightgear flight simulator
http://wiki.flightgear.org/Saab_37_Viggen
GNU General Public License v2.0
26 stars 15 forks source link

Some TI map tiles are broken #179

Closed NikolaiVChr closed 1 year ago

NikolaiVChr commented 1 year ago

Each tile is 256 x 256 But when they "cross" zero using setTranslation() at line 5822 they only get assigned 255 size (both x and y has that issue).

I suspect is has to do with int() essentially being a trunc() operation and not a floor(). Not sure.

It seems to be my code, I don't really remember that code however. I will try to look at it, unless Colin beat me to it.

colingeniet commented 1 year ago

How does it manifest visually?

NikolaiVChr commented 1 year ago

That some tiles will overlap by 1 pixel

NikolaiVChr commented 1 year ago

I fixed it in f16 by replacing int() with math.floor() for both x and y on that line. Floor or ceil does not matter, as we either have to be on one or the other side of the pixel we are in.

I expanded the comment above it to this, for the future so its easier to understand the code:

        # 3x3 example: (same for both canvas-tiles and map-tiles)
        #  *************************
        #  * -1,-1 *  0,-1 *  1,-1 *
        #  *************************
        #  * -1, 0 *  0, 0 *  1, 0 *
        #  *************************
        #  * -1, 1 *  0, 1 *  1, 1 *
        #  *************************
        #
        # x goes from -180 lon to +180 lon (zero to me.n)
        # y goes from +85.0511 lat to -85.0511 lat (zero to me.n)
        #
        # me.center_tile_float is always positives, it denotes where we are in x,y (floating points)
        # me.center_tile_int is the x,y tile that we are in (integers)
        # me.center_tile_fraction is where in that tile we are located (normalized)
        # me.tile_offset is the negative buffer so that we show tiles all around us instead of only in x,y positive direction
colingeniet commented 1 year ago

Okay, I will change that, and check the other instances of int() too.