The International Simutrans Forum

 

Author Topic: Height map loader refactor  (Read 585 times)

0 Members and 1 Guest are viewing this topic.

Offline ceeac

  • Devotee
  • *
  • Posts: 135
Height map loader refactor
« on: October 30, 2019, 06:37:51 AM »
This patch improves the code responsible for loading height maps by hardening it against malformed/corrupted input and by doing some refactoring and cleanup.

Offline makie

  • Devotee
  • *
  • Posts: 194
    • Homepage PAK128-German
  • Languages: DE
Re: Height map loader refactor
« Reply #1 on: October 30, 2019, 09:47:48 PM »
In simutrans it is possible to set the "word_minimum_height" and the "world_maximum_height"
With world_maximum_height=100 you can build really high mountains.

Unfortunately height_map_loader_t works only with a fixed and limited range.
No support for extended "world_maximum_height" therefore you can not load a height map for this

It should better calculate the conversion so that black is "word_minimum_height" or the sea floor
and white is "world_maximum_height" or the highest mountain.

look at :
https://forum.simutrans.com/index.php/topic,19099.msg180941.html#msg180941

Offline ceeac

  • Devotee
  • *
  • Posts: 135
Re: Height map loader refactor
« Reply #2 on: May 21, 2020, 12:38:25 PM »
Unfortunately height_map_loader_t works only with a fixed and limited range.
No support for extended "world_maximum_height" therefore you can not load a height map for this
Now there is support for this. Currently there are four modes:
  • legacy (small heights): Equivalent to the previous behaviour with "maximize height levels" off.
  • legacy (large heights): Equivalent to the previous behaviour with "maximize height levels" on.
  • linear: The default mode. Linear interpolation of height values between minimum (black) and maximum (white) height.
  • clamp: With this mode, 1 greyscale level = 1 height level. "Cuts off" mountains/valleys to between minimum and maximum height.
I am not convinced whether these names are the best so I'll leave that open for discussion. This is also the reason I have not yet added the strings to base.tab for translation.

Offline makie

  • Devotee
  • *
  • Posts: 194
    • Homepage PAK128-German
  • Languages: DE
Re: Height map loader refactor
« Reply #3 on: May 21, 2020, 01:13:23 PM »
Oh this look fine.  :)
Need  8)

I am not convinced whether these names are the best so I'll leave that open for discussion. This is also the reason I have not yet added the strings to base.tab for translation.
Don't worry about best names. This can easy changed via translation.
The strings in the program should rather be seen as key into the table en.tab.

Offline ceeac

  • Devotee
  • *
  • Posts: 135
Re: Height map loader refactor
« Reply #4 on: May 26, 2020, 08:20:00 AM »
Okay, I added the strings to base.tab and fixed an error which allowed heights to be larger than world_max_height when loading height maps in legacy mode.