diff --git a/README.md b/README.md index 9fb3ca43..07df50e1 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ The long-term goal of this project is to provide a viable alternative to Minecra ## Project status -This list is non complete. +This list is not complete. See also the roadmap for 1.0.0 [here](https://github.com/Unarelith/OpenMiner/wiki/Roadmap). diff --git a/external/gamekit b/external/gamekit index f0285a38..c664d115 160000 --- a/external/gamekit +++ b/external/gamekit @@ -1 +1 @@ -Subproject commit f0285a38170f3f59963b56bbb3347a6321f7e064 +Subproject commit c664d1150ffd59f6899738e26b0cabb8af608254 diff --git a/mods/default/textures/gui/furnace.png b/mods/default/textures/gui/furnace.png index 9418bcba..298c4fdc 100644 Binary files a/mods/default/textures/gui/furnace.png and b/mods/default/textures/gui/furnace.png differ diff --git a/source/common/core/EngineConfig.hpp b/source/common/core/EngineConfig.hpp index 584cad7c..2d5bd555 100644 --- a/source/common/core/EngineConfig.hpp +++ b/source/common/core/EngineConfig.hpp @@ -36,7 +36,7 @@ namespace { constexpr unsigned char VERSION_MAJOR = 0; constexpr unsigned char VERSION_MINOR = 0; constexpr unsigned char VERSION_PATCH = 10; - constexpr const char *VERSION_SUFFIX = "pre5"; + constexpr const char *VERSION_SUFFIX = "pre6"; constexpr float DIST_NEAR = 0.1f; constexpr float DIST_FAR = 1000.0f; diff --git a/source/common/world/Heightmap.cpp b/source/common/world/Heightmap.cpp new file mode 100644 index 00000000..c9823462 --- /dev/null +++ b/source/common/world/Heightmap.cpp @@ -0,0 +1,63 @@ +/* + * ===================================================================================== + * + * OpenMiner + * + * Copyright (C) 2018-2020 Unarelith, Quentin Bazin + * Copyright (C) 2019-2020 the OpenMiner contributors (see CONTRIBUTORS.md) + * + * This file is part of OpenMiner. + * + * OpenMiner is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * OpenMiner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with OpenMiner; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * ===================================================================================== + */ +#include "FastNoise.hpp" +#include "Heightmap.hpp" + +void HeightmapChunk::generate() { + FastNoise noise; + noise.SetNoiseType(FastNoise::NoiseType::SimplexFractal); + noise.SetFrequency(1 / 256.0f); + noise.SetFractalOctaves(4); + + for(int y = 0 ; y < CHUNK_DEPTH ; y++) { + for(int x = 0 ; x < CHUNK_WIDTH ; x++) { + double n = noise.GetNoise(-x - m_x * CHUNK_WIDTH, y + m_y * CHUNK_DEPTH); + m_map[y][x] = 10 + n * 20; + } + } +} + +s32 HeightmapChunk::landHeightAt(s8 x, s8 y) const { + return m_map[y][x]; +} + +HeightmapChunk &Heightmap::getOrCreateChunk(s32 x, s32 y) { + HeightmapChunk *chunk = nullptr; + + auto it = m_chunks.find({x, y}); + if (it == m_chunks.end()) { + m_chunks.emplace(gk::Vector2i{x, y}, HeightmapChunk{x, y}); + + chunk = &m_chunks.at({x, y}); + chunk->generate(); + } + else + chunk = &it->second; + + return *chunk; +} + diff --git a/source/common/world/Heightmap.hpp b/source/common/world/Heightmap.hpp new file mode 100644 index 00000000..79dc512c --- /dev/null +++ b/source/common/world/Heightmap.hpp @@ -0,0 +1,61 @@ +/* + * ===================================================================================== + * + * OpenMiner + * + * Copyright (C) 2018-2020 Unarelith, Quentin Bazin + * Copyright (C) 2019-2020 the OpenMiner contributors (see CONTRIBUTORS.md) + * + * This file is part of OpenMiner. + * + * OpenMiner is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * OpenMiner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with OpenMiner; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * ===================================================================================== + */ +#ifndef HEIGHTMAP_HPP_ +#define HEIGHTMAP_HPP_ + +#include + +#include +#include + +#include "EngineConfig.hpp" + +class HeightmapChunk { + public: + HeightmapChunk(s32 x, s32 y) + : m_x(x), m_y(y) {} + + void generate(); + + s32 landHeightAt(s8 x, s8 y) const; + + private: + s32 m_x = 0; + s32 m_y = 0; + + s32 m_map[CHUNK_DEPTH][CHUNK_WIDTH]; +}; + +class Heightmap { + public: + HeightmapChunk &getOrCreateChunk(s32 x, s32 y); + + private: + std::unordered_map m_chunks; +}; + +#endif // HEIGHTMAP_HPP_ diff --git a/source/server/lua/LuaMod.hpp b/source/server/lua/LuaMod.hpp index 2de1faf4..a861e436 100644 --- a/source/server/lua/LuaMod.hpp +++ b/source/server/lua/LuaMod.hpp @@ -97,8 +97,8 @@ class LuaMod { LuaSkyLoader m_skyLoader{*this}; LuaBiomeLoader m_biomeLoader{*this}; LuaDimensionLoader m_dimensionLoader{*this}; - LuaEntityLoader m_entityLoader{*this, m_worldController}; LuaKeyLoader m_keyLoader{*this}; + LuaEntityLoader m_entityLoader{*this, m_worldController}; }; #endif // LUAMOD_HPP_ diff --git a/source/server/world/ServerWorld.hpp b/source/server/world/ServerWorld.hpp index 4bef39e0..2fbe0c5a 100644 --- a/source/server/world/ServerWorld.hpp +++ b/source/server/world/ServerWorld.hpp @@ -49,7 +49,7 @@ class ServerWorld : public World { public: ServerWorld(PlayerList &players, const Dimension &dimension, gk::GameClock &clock) - : m_players(players), m_dimension(dimension), m_terrainGenerator(dimension), m_clock(clock), m_scene(players) {} + : m_players(players), m_dimension(dimension), m_terrainGenerator(m_heightmap, dimension), m_clock(clock), m_scene(players) {} void update(bool doTick); @@ -80,6 +80,7 @@ class ServerWorld : public World { ChunkMap m_chunks; + Heightmap m_heightmap; TerrainGenerator m_terrainGenerator; ServerCommandHandler *m_server = nullptr; diff --git a/source/server/world/TerrainGenerator.cpp b/source/server/world/TerrainGenerator.cpp index 852f041f..8e574bc9 100644 --- a/source/server/world/TerrainGenerator.cpp +++ b/source/server/world/TerrainGenerator.cpp @@ -38,10 +38,7 @@ void TerrainGenerator::generate(ServerChunk &chunk) const { } void TerrainGenerator::fastNoiseGeneration(ServerChunk &chunk) const { - FastNoise noise; - noise.SetNoiseType(FastNoise::NoiseType::SimplexFractal); - noise.SetFrequency(1 / 256.0f); - noise.SetFractalOctaves(4); + HeightmapChunk &heightmap = m_heightmap.getOrCreateChunk(chunk.x(), chunk.y()); Random_t rand; rand.seed(chunk.x() + chunk.y() * CHUNK_WIDTH + chunk.z() * CHUNK_WIDTH * CHUNK_HEIGHT + 1337); @@ -53,11 +50,7 @@ void TerrainGenerator::fastNoiseGeneration(ServerChunk &chunk) const { const Biome &biome = Registry::getInstance().getBiome(biomeIndex); // Land height - double n = noise.GetNoise(-x - chunk.x() * CHUNK_WIDTH, y + chunk.y() * CHUNK_DEPTH); - double h = 10 + n * 20; - - // double n = noise2d((x + chunk.x() * CHUNK_WIDTH) / 256.0, (y + chunk.y() * CHUNK_DEPTH) / 256.0, 4, 0.5) * 4; - // double h = 10 + n * 2; + double h = heightmap.landHeightAt(x, y); // Land blocks for(int z = 0 ; z < CHUNK_HEIGHT ; z++) { diff --git a/source/server/world/TerrainGenerator.hpp b/source/server/world/TerrainGenerator.hpp index a4dfa144..6b5f2ca7 100644 --- a/source/server/world/TerrainGenerator.hpp +++ b/source/server/world/TerrainGenerator.hpp @@ -33,6 +33,7 @@ #include +#include "Heightmap.hpp" #include "TerrainBiomeSampler.hpp" using Random_t = effolkronium::random_local; @@ -43,7 +44,8 @@ class ServerChunk; class TerrainGenerator { public: - TerrainGenerator(const Dimension &dimension) : m_biomeSampler(dimension) {} + TerrainGenerator(Heightmap &heightmap, const Dimension &dimension) + : m_biomeSampler(dimension), m_heightmap(heightmap) {} void generate(ServerChunk &chunk) const; @@ -64,6 +66,8 @@ class TerrainGenerator { static float noise3d_abs(double x, double y, double z, int octaves, float persistence); TerrainBiomeSampler m_biomeSampler; + + Heightmap &m_heightmap; }; #endif // TERRAINGENERATOR_HPP_ diff --git a/texturepacks/minecraft/gui/furnace.png b/texturepacks/minecraft/gui/furnace.png index f40de39d..298c4fdc 100644 Binary files a/texturepacks/minecraft/gui/furnace.png and b/texturepacks/minecraft/gui/furnace.png differ