Re: More height levels
Posted: 20 Sep 2014 12:13
I got some feedback on this set of patches, see the attached diff.
The place to talk about Transport Tycoon
https://www.tt-forums.net/
Thank you very much for the comments. I will have a detailed look on them shortly.Rubidium wrote:I got some feedback on this set of patches, see the attached diff.
Basically, the thing about rows is that there is no closed formular for determining (given a particular column) which is the top and the bottommost affected row. This is then the binary interval search.The old painting algorithm repainted an area in the size of the worst
case regarding heightlevels. I.e. it looked how high a mountain could
be in the worst case, and repainted accordingly. This approach is not
feasible if mountains can have height 255*16 pixels.
The new painting algorithm works using a concept of rows and columns.
Each tile coordinate on the isometric map can be expressed by a
coordinate consisting of one row and one column. Rows go from west to
east, whereas columns from north to south. The painting algorithm
first determines the leftmost and rightmost column being affected by
the repainting activities. Then, it inspects the landscape inside the
area to be repainted, and for each column, it determines the top and
bottom row to the repainted. Based on this information, it then
repaints an area being as small as possible.
In the new painting algorithm, the area outside map is painted the
same way as the area inside map, just using the completely black tiles
from patch 30_PaintingVoidTiles. To make this work, a concept of
landscape geometry outside map is used. In this concept, outside map
landscape descends to height zero as fast as the general assumptions
about map geometry in OpenTTD allow (with general assumptions the
maximum height differences between neighbor tiles are meant). Of
course, those tiles outside map are not saved explicitely, they only
exist as concept in code when dealing with the edges of the map.
That is not going to happen in this patch, sorry.Gigigonzalez wrote: Very interesting stuff, but this should definately coincide with desert height patch included!
Im working on a map and so far i have loaded a new map 500 times and no issue![]()
Code: Select all
@@ -103,6 +104,7 @@
- Point sxy = this->ComputeScroll(pt.x / TILE_SIZE, pt.y / TILE_SIZE, max(0, (int)wid->current_x / 2 - 2), wid->current_y / 2, &sub);
+ Point sxy = this->ComputeScroll(pt_with_height.x, pt_with_height.y,
+ max(0, (int)wid->current_x / 2 - 2), wid->current_y / 2, &sub);
+#### needless change?
this->SetNewScroll(sxy.x, sxy.y, sub);
this->SetDirty();
}
I perfectly agree, the only reason why I didn´t yet switch to 999 is that at least some weeks ago, 999 needed a recompile of a patched nforenum. As soon as the infrastructure is in a state that allows a 999 patch being applied and successfully compiled without problems, I happily switch to 999.+#### I like 999 much better. Especially because this way is going to break horribly when adding sprites to openttd.grf, because it reduces the number of GRFs that can be loaded by one, and finally because it's a blob without source and a few Linux distro's want to build everything from source. If not, then it's deemed 'non-free'.
I try to explain a bit more about this here:I'm missing a complete picture here. Columns, rows, regions and some other words are used, but I'm not really getting what they mean exactly when reading this. What is the basic meaning of those words, and what is the basic idea of the drawing algorithm?
Probably you are right, I thought about something similar in the last few days already. I will have detailed look on that.+#### Can't maximum_height_level be used as well? On 4kx4k map at tile 0,0 I doubt you need to search till 4k,4k. If maximum_height_level = 32, then I'd expect it to be at most a 32x32. This should shave off a couple of iterations on average.
It indeed looks duplicated, unfortunately aircrafts and disaster vehicles don´t have a common superclass where the variables this code relies on could be defined. Thus IMHO, the answer is No, there is nothing to unify sensefully.+### Can't this logic be shared with aircraft? It looks duplicated.
I have just dived into three-years-old forum posts. See e.g.+#### Why a cheat and not a setting?
I see the problem. Probably, I can do something by indeed inspecting all visible columns. I can restrict that calculation to the case that one is beyound the usual map border at height zero. Just code will become a bit more complicate than when I compare just with a constant value.+#### Don't you know the 'column' and as such the tile height there? Can't that be used to calculate the max scroll outside of map? I fear that this way gets people into a black screen; it even took me a while to scroll out of this blackness when being zoomed in fully. As such, I think this will cause some bug reports of new users that are lost in a black screen.
There shouldn't be anything left from those. There is plenty left from others that I'm going to merge in just a while (wait at least till the savegame bump before amending).ic111 wrote:Just to get sure I didn´t miss anything: Based on your changes to trunk, I removed patches 020_GeometryOutsideMap, 030_PaintingVoidTiles, 090_Aircrafts, and 999_PaintingVoidTilesImproved. If there is any change in one of those patches still pending, please object.
Code: Select all
+/**
+ * Desired maximum height - indexed by _settings_game.difficulty.terrain_type and the map size.
+ *
+ * Sense of indexing by mapsize too:
+ * Below, h_max_new is calculated as min(map_size_x, map_size_y) / the constant defined here.
+ * Later, for calculating the height of some individual tile, the formula:
+ * h_max_new * (h - h_waterlevel) / (h_max - h_waterlevel), where h_max is the maximal heightlevel
+ * existing anywhere on the map at the time of that computation step.
+ * So, to summarize:
+ * For mapsize 64x64, the above division gives 1. And, h - h_waterlevel is always
+ * smaller than h_max - h_waterlevel. So, the result is a map consisting just of water
+ * - i.e. at heightlevel 0 :-/.
+ * My conclusion was:
+ * Indexing this setting by the mapsize is a good thing, as one gains much more
+ * control on the heightlevel distribution of maps now and small maps work at all.
+ * The n-th value of the second component is for log(min(map_size_x, map_size_y)) - 6, so
+ * index 0 is for map size 64, whereas index 8 is for map size 8192.
+ */
+static const int _max_height[7][9] = {
+ {32, 48, 72, 170, 340, 680, 1360, 2720, 5440}, ///< Extremely flat
+ {21, 40, 50, 64, 128, 380, 760, 1520, 3040}, ///< Very flat
+ {16, 27, 38, 51, 102, 204, 408, 916, 1832}, ///< Flat
+ {12, 21, 30, 39, 60, 120, 240, 480, 960}, ///< Bumpy
+ {10, 13, 17, 20, 33, 66, 132, 264, 528}, ///< Hilly
+ {9, 10, 11, 12, 13, 24, 48, 96, 192}, ///< Mountainous
+ {5, 6, 7, 7, 7, 12, 24, 48, 96} ///< Alpinist
};