Bug #01: Black line appears between tiles from certain camera positions
This one I believe I may have fixed already by hacking around. I haven't got a formal fix in place yet though as I'm still investigating, but here's what I think is the problem so far.
Code: Select all
rounded_x_offset = FloorToFloatMultiple(_camera->x_offset, x_pixel_length);
rounded_y_offset = FloorToFloatMultiple(_camera->y_offset, x_pixel_length); // TODO: Change back
camera_x = static_cast<float>(_camera->x_position) + rounded_x_offset;
camera_y = static_cast<float>(_camera->y_position) + rounded_y_offset;
The code snippet above is from void MapMode::_CalculateMapFrame() in map.cpp around line 562. What this block does is re-adjust the position of the camera so that it is aligned to a specific pixel. What do I mean by this? Well, the game usually runs in a 1024x768 screen resolution, and the coordinate system for the map is set so that the width of the screen is 16 tiles and the height is 12 tiles (each tile is 32x32 pixels). We use collision grid coordinates for the screen though (which are 16x16 pixel units) so our true screen coordinates are 32x24. Therefore, each pixel represents a certain fraction of that space. The dimensions for a single pixel are: 0.03125x0.03125(32/1024) and (24/768). I believe the code above is supposed to align the camera position's offset (its decimal portion) to be a factor of 0.03125. However, the GetPixelSize function returns pixel size values of: [0.025000, 0.023438], which is very odd (first of all that they are not what I expected, second of all that the x and y values are unequal).
What I did for my hack to make this black line go away was to use the pixel x value of 0.025 for both x and y. I haven't been able to reproduce this since. So perhaps the cause of this problem is the GetPixelSize() function is buggy and returning inaccurate results.
Bug #02: Grey outlines appear around certain objects and tiles
This is an eyesore. See all those ugly grey outlines appearing around walls and other objects? This is not something that is wrong with map mode, but with the video engine. We've done some looking into this and believe it has something to do with the texture properties we set, either the scaling interpretation (GL_linear?) or something to do with mipmapping. We'll need someone to dive into OpenGL to figure this one out. This bug shows up in the editor too, by the way, since the editor uses the video engine to render the map.
Bug #03: Tile alignment issues
Simply put, tiles are not matching up correctly and I'm not sure why. Its painfully obvious where the "grid" of tiles lies because they don't stitch together nicely. Its almost like a line in the tiles is duplicated or missing or something. I'm not sure why this problem happens because the drawing code for tiles is pretty simple. It starts from the top left, then draws each tile across the screen to the end before going down and starting on the next line. We increment the same distance of the draw cursor for each tile we draw.
I was looking into this earlier and, as an experiment, tried adding a small additional distance between each horizontal tile that was drawn on the lower layer (middle and upper layer tiles were unaffected). The value I used was 0.02f (each tile is 2.0f across). Look at the screenshot below. There's a small black gap between most tiles, which is what I expected. But sometimes there's no gap at all! So if the draw position of each tile isn't persistent, its only natural that the type of problems I am describing would occur.
I'll do what I can to investigate here, but I think we're going to need some OpenGL expertise to really nail these suckers. I could look through the OpenGL docs if I really need to, but I'd rather not work on these problems alone...