Pathfinding and Map Wrapping rants 2

I forgot that Planet Earth is a sphere...so the map wrap for Y coords is wrong, the intersection of equator and prime meridian divides meridian projection(tile map) into 4 "areas" like this:

Y Max
Y Min

So when your whatever moving object hits Y Max in [NW] area, your ship should reappear at [NE] area with Y Max minus 1..Hitting is Y Min in [SW] is similar except it's Y Min plus 1, also X coords is mirrored when your hit Y Max or Y Min:

X Min[NW][NE]X Max
X Min[SW][SE]X Max

Lets say we have a ship at X(100), Y(MAX-1) on 1000x1000 map(starting index 0):
[NW]'s X coords range would be 0-499
[NE]'s X coords range would be 500-999

When ship moves towards Y axis positively(north) by one, the ship reappears at X(999 - 100), Y(MAX-1)...It's very confusing, even on papers, in game the renderer needs to flip all tiles that have been "Y wrapped"(the "wrapped" tiles are on the other side of the sphere, so they are upside down and mirrored.It needs to draw from right to left and swap point 1,2 with 3,4 on quads...)

Though i will ignore this issue for now, since it's tolerable and in 1500's no ship could reach max Y(northpole) or min Y(southpole) intact... =o


Devil said...

flip the ship directions and leave the map orientation as it is. e.g. if you go northwards of japan you might arrive at alaska going southwards.

magick panda said...

Changing the ship's movement direction and orientation/facing is easy, though drawing the screen area(viewport) that contains both unwrapped tiles and wrapped tiles will not be a trivial task, the tiles below "MAX Y line" must be left<->right mirrored and flipped vertically by 180 degree's, and the whole screen needs to flipped vertically when the wrapped tiles are greater than unwrapped ones..(ship's movement direction might be relative, but the screen/map orientation has to be absolute) The problem can only be solved by exhaustive trial and error I guess, so I will have to ignore the issue for now =/