summary refs log tree commit diff
path: root/src/World/Generation/Generator.hpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2023-07-08 03:25:44 +0200
committerMel <einebeere@gmail.com>2023-07-08 03:25:44 +0200
commitfe2baedc760c2f29e2c720f6b1132a2de33c5430 (patch)
treedfbe1c72a17805a3cab6e0d47433e9021890c9ca /src/World/Generation/Generator.hpp
parent41fbca10f6c6cdd9c1623f1347e7ecb40f5e7f59 (diff)
downloadmeowcraft-fe2baedc760c2f29e2c720f6b1132a2de33c5430.tar.zst
meowcraft-fe2baedc760c2f29e2c720f6b1132a2de33c5430.zip
Use own size types
Diffstat (limited to 'src/World/Generation/Generator.hpp')
-rw-r--r--src/World/Generation/Generator.hpp49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/World/Generation/Generator.hpp b/src/World/Generation/Generator.hpp
index c18de45..ee78dc5 100644
--- a/src/World/Generation/Generator.hpp
+++ b/src/World/Generation/Generator.hpp
@@ -1,48 +1,47 @@
 #pragma once
 
-#include <cstdint>
-
-#include "Decoration.hpp"
+#include "../../Common/Sizes.hpp"
 #include "../Chunk.hpp"
 #include "../BiomeType.hpp"
 #include "../../Math/Perlin.hpp"
 #include "../../Math/Tensor.hpp"
+#include "Decoration.hpp"
 
 namespace MC::World::Generation {
 
 class Generator {
 public:
     Generator() = default;
-    Chunk generate(int64_t chunk_x, int64_t chunk_y);
+    Chunk generate(I64 chunk_x, I64 chunk_y);
 private:
     template <typename V> using Map2D = Matrix<Chunk::Width, Chunk::Width, V>;
     template <typename V> using Map3D = Tensor<3, V, Chunk::Width, Chunk::Height, Chunk::Width>;
 
-    Map2D<float> generate_landmass_map(int64_t chunk_x, int64_t chunk_y);
-    Map2D<float> generate_hill_map(int64_t chunk_x, int64_t chunk_y);
-    Map2D<float> generate_height_map(Map2D<float>& landmass_map, Map2D<float>& hill_map);
+    Map2D<Real> generate_landmass_map(I64 chunk_x, I64 chunk_y);
+    Map2D<Real> generate_hill_map(I64 chunk_x, I64 chunk_y);
+    Map2D<Real> generate_height_map(Map2D<Real>& landmass_map, Map2D<Real>& hill_map);
 
-    Map2D<float> generate_temperature_map(int64_t chunk_x, int64_t chunk_y);
-    Map2D<float> generate_humidity_map(int64_t chunk_x, int64_t chunk_y);
+    Map2D<Real> generate_temperature_map(I64 chunk_x, I64 chunk_y);
+    Map2D<Real> generate_humidity_map(I64 chunk_x, I64 chunk_y);
 
     Map2D<BiomeType> generate_biome_map(
-        Map2D<float>& landmass_map, Map2D<float>& hill_map,
-        Map2D<float>& temperature_map, Map2D<float>& humidity_map
+        Map2D<Real>& landmass_map, Map2D<Real>& hill_map,
+        Map2D<Real>& temperature_map, Map2D<Real>& humidity_map
     );
 
-    Map3D<bool> generate_terrain(Map2D<float>& height_map, int64_t chunk_x, int64_t chunk_y);
+    Map3D<Bool> generate_terrain(Map2D<Real>& height_map, I64 chunk_x, I64 chunk_y);
 
-    void decorate_soil(Chunk& chunk, Map2D<BiomeType>& biome_map, Map3D<bool>& terrain_map);
+    void decorate_soil(Chunk& chunk, Map2D<BiomeType>& biome_map, Map3D<Bool>& terrain_map);
 
-    [[nodiscard]] float get_landmass(Vector<2> pos) const;
-    [[nodiscard]] float get_hill(Vector<2> pos) const;
+    [[nodiscard]] Real get_landmass(Vector<2> pos) const;
+    [[nodiscard]] Real get_hill(Vector<2> pos) const;
 
-    [[nodiscard]] float get_humidity(Vector<2> pos) const;
-    [[nodiscard]] float get_temperature(Vector<2> pos) const;
+    [[nodiscard]] Real get_humidity(Vector<2> pos) const;
+    [[nodiscard]] Real get_temperature(Vector<2> pos) const;
 
-    [[nodiscard]] float get_density(Vector<3> pos) const;
+    [[nodiscard]] Real get_density(Vector<3> pos) const;
 
-    static Vector<2> chunk_position_to_world_vector(int64_t chunk_x, int64_t chunk_y, uint x, uint y);
+    static Vector<2> chunk_position_to_world_vector(I64 chunk_x, I64 chunk_y, UInt x, UInt y);
 
     static inline std::vector<Decorator*> s_decorators = {
         new TreeDecorator(),
@@ -60,14 +59,14 @@ private:
     enum class LandmassSlice { Land, Beach, Ocean };
     enum class TemperatureZone { Hot, Fair, Cold };
     enum class HumidityZone { Wet, Lush, Temperate, Dry };
-    static constexpr uint HillSliceSize = (uint)HillSlice::Valley + 1;
-    static constexpr uint LandmassSliceSize = (uint)LandmassSlice::Ocean + 1;
-    static constexpr uint TemperatureZoneSize = (uint)TemperatureZone::Cold + 1;
-    static constexpr uint HumidityZoneSize = (uint)HumidityZone::Dry + 1;
+    static constexpr UInt HillSliceSize = (UInt)HillSlice::Valley + 1;
+    static constexpr UInt LandmassSliceSize = (UInt)LandmassSlice::Ocean + 1;
+    static constexpr UInt TemperatureZoneSize = (UInt)TemperatureZone::Cold + 1;
+    static constexpr UInt HumidityZoneSize = (UInt)HumidityZone::Dry + 1;
 
-    static constexpr size_t biome_lookup_table_size = (size_t)HillSliceSize * (size_t)LandmassSliceSize * (size_t)TemperatureZoneSize * (size_t)HumidityZoneSize;
+    static constexpr USize biome_lookup_table_size = (USize)HillSliceSize * (USize)LandmassSliceSize * (USize)TemperatureZoneSize * (USize)HumidityZoneSize;
     static std::array<BiomeType, biome_lookup_table_size> create_biome_lookup_table();
-    static size_t biome_lookup_table_index(HillSlice hill_slice, LandmassSlice landmass_slice, TemperatureZone temperature_zone, HumidityZone humidity_zone);
+    static USize biome_lookup_table_index(HillSlice hill_slice, LandmassSlice landmass_slice, TemperatureZone temperature_zone, HumidityZone humidity_zone);
     static BiomeType lookup_biome(HillSlice hill_slice, LandmassSlice landmass_slice, TemperatureZone temperature_zone, HumidityZone humidity_zone);
     static inline std::array<BiomeType, biome_lookup_table_size> biome_lookup_table = create_biome_lookup_table();
 };