mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 05:21:49 +00:00
add debug world generator visualization
This commit is contained in:
parent
88752806e6
commit
75d66b644b
11 changed files with 116 additions and 9 deletions
|
|
@ -355,3 +355,21 @@ void WorldGenerator::generate(voxel* voxels, int chunkX, int chunkZ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
WorldGenDebugInfo WorldGenerator::createDebugInfo() const {
|
||||
const auto& area = surroundMap.getArea();
|
||||
const auto& levels = area.getBuffer();
|
||||
auto values = std::make_unique<ubyte[]>(area.getWidth()*area.getHeight());
|
||||
|
||||
for (uint i = 0; i < levels.size(); i++) {
|
||||
values[i] = levels[i];
|
||||
}
|
||||
|
||||
return WorldGenDebugInfo {
|
||||
area.getOffsetX(),
|
||||
area.getOffsetY(),
|
||||
static_cast<uint>(area.getWidth()),
|
||||
static_cast<uint>(area.getHeight()),
|
||||
std::move(values)
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,14 @@ struct ChunkPrototype {
|
|||
std::vector<StructurePlacement> structures;
|
||||
};
|
||||
|
||||
struct WorldGenDebugInfo {
|
||||
int areaOffsetX;
|
||||
int areaOffsetY;
|
||||
uint areaWidth;
|
||||
uint areaHeight;
|
||||
std::unique_ptr<ubyte[]> areaLevels;
|
||||
};
|
||||
|
||||
/// @brief High-level world generation controller
|
||||
class WorldGenerator {
|
||||
/// @param def generator definition
|
||||
|
|
@ -80,5 +88,8 @@ public:
|
|||
/// @param z chunk position Y divided by CHUNK_D
|
||||
void generate(voxel* voxels, int x, int z);
|
||||
|
||||
WorldGenDebugInfo createDebugInfo() const;
|
||||
|
||||
/// @brief Default generator name // TODO: move to config
|
||||
inline static std::string DEFAULT = "core:default";
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue