mapgen_v7.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. Minetest
  3. Copyright (C) 2014-2020 paramat
  4. Copyright (C) 2013-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2.1 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License along
  14. with this program; if not, write to the Free Software Foundation, Inc.,
  15. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. */
  17. #pragma once
  18. #include "mapgen.h"
  19. ///////////// Mapgen V7 flags
  20. #define MGV7_MOUNTAINS 0x01
  21. #define MGV7_RIDGES 0x02
  22. #define MGV7_FLOATLANDS 0x04
  23. #define MGV7_CAVERNS 0x08
  24. #define MGV7_BIOMEREPEAT 0x10 // Now unused
  25. class BiomeManager;
  26. extern FlagDesc flagdesc_mapgen_v7[];
  27. struct MapgenV7Params : public MapgenParams {
  28. s16 mount_zero_level = 0;
  29. s16 floatland_ymin = 1024;
  30. s16 floatland_ymax = 4096;
  31. s16 floatland_taper = 256;
  32. float float_taper_exp = 2.0f;
  33. float floatland_density = -0.6f;
  34. s16 floatland_ywater = -31000;
  35. float cave_width = 0.09f;
  36. s16 large_cave_depth = -33;
  37. u16 small_cave_num_min = 0;
  38. u16 small_cave_num_max = 0;
  39. u16 large_cave_num_min = 0;
  40. u16 large_cave_num_max = 2;
  41. float large_cave_flooded = 0.5f;
  42. s16 cavern_limit = -256;
  43. s16 cavern_taper = 256;
  44. float cavern_threshold = 0.7f;
  45. s16 dungeon_ymin = -31000;
  46. s16 dungeon_ymax = 31000;
  47. NoiseParams np_terrain_base;
  48. NoiseParams np_terrain_alt;
  49. NoiseParams np_terrain_persist;
  50. NoiseParams np_height_select;
  51. NoiseParams np_filler_depth;
  52. NoiseParams np_mount_height;
  53. NoiseParams np_ridge_uwater;
  54. NoiseParams np_mountain;
  55. NoiseParams np_ridge;
  56. NoiseParams np_floatland;
  57. NoiseParams np_cavern;
  58. NoiseParams np_cave1;
  59. NoiseParams np_cave2;
  60. NoiseParams np_dungeons;
  61. MapgenV7Params();
  62. ~MapgenV7Params() = default;
  63. void readParams(const Settings *settings);
  64. void writeParams(Settings *settings) const;
  65. void setDefaultSettings(Settings *settings);
  66. };
  67. class MapgenV7 : public MapgenBasic {
  68. public:
  69. MapgenV7(MapgenV7Params *params, EmergeParams *emerge);
  70. ~MapgenV7();
  71. virtual MapgenType getType() const { return MAPGEN_V7; }
  72. virtual void makeChunk(BlockMakeData *data);
  73. int getSpawnLevelAtPoint(v2s16 p);
  74. float baseTerrainLevelAtPoint(s16 x, s16 z);
  75. float baseTerrainLevelFromMap(int index);
  76. bool getMountainTerrainAtPoint(s16 x, s16 y, s16 z);
  77. bool getMountainTerrainFromMap(int idx_xyz, int idx_xz, s16 y);
  78. bool getRiverChannelFromMap(int idx_xyz, int idx_xz, s16 y);
  79. bool getFloatlandTerrainFromMap(int idx_xyz, float float_offset);
  80. int generateTerrain();
  81. private:
  82. s16 mount_zero_level;
  83. s16 floatland_ymin;
  84. s16 floatland_ymax;
  85. s16 floatland_taper;
  86. float float_taper_exp;
  87. float floatland_density;
  88. s16 floatland_ywater;
  89. float *float_offset_cache = nullptr;
  90. Noise *noise_terrain_base;
  91. Noise *noise_terrain_alt;
  92. Noise *noise_terrain_persist;
  93. Noise *noise_height_select;
  94. Noise *noise_mount_height;
  95. Noise *noise_ridge_uwater;
  96. Noise *noise_mountain;
  97. Noise *noise_ridge;
  98. Noise *noise_floatland;
  99. };