rename generator/Structure to generator/VoxelStructure
This commit is contained in:
parent
8516cf4f7f
commit
390a16ace1
@ -4,7 +4,7 @@
|
||||
#include "files/util.hpp"
|
||||
#include "coders/binary_json.hpp"
|
||||
#include "world/Level.hpp"
|
||||
#include "world/generator/Structure.hpp"
|
||||
#include "world/generator/VoxelStructure.hpp"
|
||||
|
||||
using namespace scripting;
|
||||
|
||||
@ -17,7 +17,7 @@ static int l_save_structure(lua::State* L) {
|
||||
}
|
||||
bool saveEntities = lua::toboolean(L, 4);
|
||||
|
||||
auto structure = Structure::create(level, pointA, pointB, saveEntities);
|
||||
auto structure = VoxelStructure::create(level, pointA, pointB, saveEntities);
|
||||
auto map = structure->serialize();
|
||||
|
||||
auto bytes = json::to_binary(map.get());
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "Structure.hpp"
|
||||
#include "VoxelStructure.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <cstring>
|
||||
@ -11,7 +11,7 @@
|
||||
#include "voxels/VoxelsVolume.hpp"
|
||||
#include "world/Level.hpp"
|
||||
|
||||
std::unique_ptr<Structure> Structure::create(
|
||||
std::unique_ptr<VoxelStructure> VoxelStructure::create(
|
||||
Level* level, const glm::ivec3& a, const glm::ivec3& b, bool entities
|
||||
) {
|
||||
auto start = glm::min(a, b);
|
||||
@ -43,11 +43,11 @@ std::unique_ptr<Structure> Structure::create(
|
||||
voxels[i].id = index;
|
||||
}
|
||||
|
||||
return std::make_unique<Structure>(
|
||||
return std::make_unique<VoxelStructure>(
|
||||
size, std::move(voxels), std::move(blockNames));
|
||||
}
|
||||
|
||||
std::unique_ptr<dynamic::Map> Structure::serialize() const {
|
||||
std::unique_ptr<dynamic::Map> VoxelStructure::serialize() const {
|
||||
auto root = std::make_unique<dynamic::Map>();
|
||||
root->put("version", STRUCTURE_FORMAT_VERSION);
|
||||
root->put("size", dynamic::to_value(size));
|
||||
@ -64,7 +64,7 @@ std::unique_ptr<dynamic::Map> Structure::serialize() const {
|
||||
return root;
|
||||
}
|
||||
|
||||
void Structure::deserialize(dynamic::Map* src) {
|
||||
void VoxelStructure::deserialize(dynamic::Map* src) {
|
||||
size = glm::ivec3();
|
||||
dynamic::get_vec(src, "size", size);
|
||||
voxels.resize(size.x*size.y*size.z);
|
||||
@ -11,7 +11,7 @@ inline constexpr int STRUCTURE_FORMAT_VERSION = 1;
|
||||
class Level;
|
||||
class Content;
|
||||
|
||||
struct Structure : public Serializable {
|
||||
struct VoxelStructure : public Serializable {
|
||||
glm::ivec3 size;
|
||||
|
||||
/// @brief Structure voxels indexed different to world content
|
||||
@ -19,9 +19,9 @@ struct Structure : public Serializable {
|
||||
/// @brief Block names are used for indexing
|
||||
std::vector<std::string> blockNames;
|
||||
|
||||
Structure() : size() {}
|
||||
VoxelStructure() : size() {}
|
||||
|
||||
Structure(
|
||||
VoxelStructure(
|
||||
glm::ivec3 size,
|
||||
std::vector<voxel> voxels,
|
||||
std::vector<std::string> blockNames
|
||||
@ -33,6 +33,6 @@ struct Structure : public Serializable {
|
||||
std::unique_ptr<dynamic::Map> serialize() const override;
|
||||
void deserialize(dynamic::Map* src) override;
|
||||
|
||||
static std::unique_ptr<Structure> create(
|
||||
static std::unique_ptr<VoxelStructure> create(
|
||||
Level* level, const glm::ivec3& a, const glm::ivec3& b, bool entities);
|
||||
};
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
static debug::Logger logger("world-generator");
|
||||
|
||||
static inline constexpr uint MAX_PARAMETERS = 16;
|
||||
static inline constexpr uint MAX_PARAMETERS = 8;
|
||||
static inline constexpr uint MAX_CHUNK_PROTOTYPE_LEVELS = 8;
|
||||
|
||||
WorldGenerator::WorldGenerator(
|
||||
@ -136,7 +136,8 @@ void WorldGenerator::generateHeightmap(
|
||||
|
||||
void WorldGenerator::update(int centerX, int centerY, int loadDistance) {
|
||||
surroundMap.setCenter(centerX, centerY);
|
||||
surroundMap.resize(loadDistance + 1 /* additional safety padding */);
|
||||
// 1 is safety padding preventing ChunksController rounding problem
|
||||
surroundMap.resize(loadDistance + 1);
|
||||
surroundMap.setCenter(centerX, centerY);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user