Files

41 lines
1.5 KiB
C++

#pragma once
#include "evo/world/coordinates.hpp"
#include <cstdint>
#include <expected>
#include <string_view>
#include <vector>
namespace evo::world {
inline constexpr std::uint32_t base_chunk_edge = 16;
inline constexpr std::uint32_t base_chunk_cells = 4096;
// Raw request, validated on every entry. No implicit upgrade to newer versions.
struct BaseDescriptor {
std::uint64_t seed{};
std::uint32_t coordinate_version{1};
std::uint32_t generator_version{1};
std::uint32_t material_version{1};
std::uint32_t edge{base_chunk_edge};
auto operator<=>(const BaseDescriptor&) const = default;
};
enum class GenerationError : std::uint8_t {
unsupported_coordinates,
unsupported_generator,
unsupported_materials,
unsupported_edge,
invalid_voxel,
invalid_chunk,
unknown_material
};
// Names carry no biological/chemical inventory or density.
[[nodiscard]] std::expected<std::string_view, GenerationError>
material_name(std::uint32_t table_version, MaterialId id) noexcept;
[[nodiscard]] std::expected<CellSample, GenerationError> base_sample(BaseDescriptor descriptor,
VoxelAddress address) noexcept;
// Bounded X-fast staging output, not resident chunk ownership or a wire record.
// Allocation exceptions propagate to the host boundary. No partial result escapes.
[[nodiscard]] std::expected<std::vector<CellSample>, GenerationError>
generate_base_chunk(BaseDescriptor descriptor, ChunkAddress address);
} // namespace evo::world