Wow this whole thing gets quite interesting. It is seriously drawing me away from what i should be actually doing.
Hybrid Dog wrote:I would test along the curve until a different height is found. The known positions with the same height then are near each other, whereas when testing line by line instead of using the curve, less positions would be found and they'd rather form a line.
I think if you go along the curve and test with a height difference threshold, e.g. 2, more positions are found, you can then take away the positions with different height than the one from the start position and get a strangely delimited flat area. You could also set the threshold depending on the position, e.g. the distance to the start position.
Ah, i see. So you would end up with multiple lists that contain node-positions of areas with same/close to same height. I could sort these lists by size to get the largest flat area then. And if i take the largest and smallest X and Z values in one list, i can define a rectangle that confines that area.
The question is now, how do i find the largest rectangle that is confined in that area? (Maybe the same method Sokomine used)
That is really good to know.
Unfortunately i'm not good enough at c++ to transfer that to lua myself. Also does this work for every mapgen?
Sokomine wrote:I'm not sure if pathfinding is the best way to go here (speed?).
Well, most certainly not. I was just hoping to offload some processing into a built-in function. While testing it felt quite slow. Sometimes i reached the border of the generated map and had to wait a bit until mapgen caught up. When testing longer paths (distance 80 blocks) i even crashed minetest.
And eventually all you get is a note that the center of a mapchunk is probably rather flat.
Sokomine wrote: I like your connected-component labeling idea more as it might be more versatile.
...
If you take the heightmap and locate connected areas, you can modifiy the terrain so that it will still look good afterwards. Paramats highlandpools mod might also profit from such a height analysis method.
Yes, i completely agree. But Hybrid Dogs hilbert-curve method loks promising, too.
Sokomine wrote:Segmentation according to Deadlocks algorithm (=colors) plus a very simple and fast detection of potential candidates for houses of a size of 5x5 (marked with mese; note that many of the candidates are not really small enough; the goal was to reduce their amount, not a perfect list yet):
That image looks amazing.
Did you write a function for that? If so, can you share it? Please!
Sokomine wrote:
Back when I wrote the integration of the villages into the landscape, I did consider using the hightmap. It was pretty new back then and didn't always work in all combinations. But mostly, entire villages consume too much space to truely be integrated into existing landscapes.
The situation is quite diffrent for individual houses placed randomly on the map. My random_buildings mod (now deprecated) more or less created a few walls as a socket for a lumberjack house. That did work to a degree. The lone houses in mg_villages use the same method as the villages do. Some houses are on too steep hills, while others lie in deep holes - neither of which looks particulary realistic on that scale. Of course quite a lot of houses are placed in an acceptable way as well.
I came to the same conclusion.
The amount and type of information you need, depends heavily on your goals.
Placing smaller things will probably benefit from something like connected-component labeling.
If you need larger spaces, you're better of remodeling an area which is loosely matching your demands; the pathfinding-method is a rather poor example of that.
Anyway, i think it would be great for the modding-community to have a selection of map analysizing functions.
I'll continue to try around.