Compare commits

..

No commits in common. "7fc1c372580afff44c1da59bc18a8bb11d7675b6" and "5436b98f3b945aa13b8df9549470bc95a0d65419" have entirely different histories.

16 changed files with 201 additions and 170 deletions

11
.gitignore vendored
View File

@ -49,14 +49,3 @@ appimage-build/
# libs # libs
/libs/ /libs/
/vcpkg_installed/ /vcpkg_installed/
CMakeCache.txt
cmake_install.cmake
CMakeFiles/
Makefile
compile_commands.json
VoxelEngine
libVoxelEngineSrc.a
vctest
.vctest/settings.toml

View File

@ -1,6 +1,6 @@
# 0.30 - 2025.11.27 # 0.29 - 2025.09.20
[Documentation](https://github.com/MihailRis/VoxelEngine-Cpp/tree/release-0.30/doc/en/main-page.md) for 0.30 [Documentation](https://github.com/MihailRis/VoxelEngine-Cpp/tree/release-0.29/doc/en/main-page.md) for 0.29
Table of contents: Table of contents:
@ -11,132 +11,121 @@ Table of contents:
## Added ## Added
- audio recording - pathfinding
- in-memory filesystems - components:
- `:block` placement (generator) - core:pathfinding
- `on_block_present`, `on_block_removed` events - core:player
- debugging server - core:mob
- `rotate` and `origin` vcm modifiers (rotation)
- custom audio streams in lua (audio.PCMStream class)
- add I16view, I32view, U16view, I32view lua classes
- libraries: - libraries:
- compression - random
- audio.input - gfx.skeletons
- editing atlas textures feature - (documented) assets
- add non_reset_packs argument to app.reset_content - udp support
- freeze debug panel values on cursor unlock - schedules
- project:content content source - events:
- project start application script - on_physics_update (components)
- uinode.exists property - on_block_tick(x, y, z, tps) (blocks)
- uinode events: - custom hand controller
- `onrightclick` - http headers
- `onmouseover` - named pipes
- `onmouseout` - optimizations:
- frameless window mode - speed up block.set
- settings: - speed up vectors
- `display.adaptive-menu-fps` experimental flag - items description
- `graphics.soft-lighting` - item properties methods
- command-line arguments: - tab + shift+tab
- `--tps` command line argument for headless mode - blocks, items tags
- `--dbg-server` command line argument - pack dependencies versions
- added error callback argument to network.tcp_connect - ~~allow to disable autospawn position~~ use player.set_spawnpoint
- go back in menu on Escape pressed - entity.spawn command
- publish `hud.exchange-slot` element - project script
- add `istoplevel` argument to input.add_callback - gui.root document
- engine pause mode (debugging) - time.schedules.world.common: Schedule
- rebuild mip-maps on texture reload
- documentation:
- documented player.set_camera and related
- documented `on_hud_render` event
- update app library docs
- updated content-packs docs (added full pack structure)
### Changes ### Changes
- optimization: - app.sleep_until - added 'timeout argument'
- fixed major chunks loading performance issue - network.get / post - added 'data' argument to error callback
- reduced headless mode chunks memory consumption - autorefresh model preview
- vecn functions optimization is not experimental now - move player controls to lua
- pass pack environment to menu page script - move hand control to lua
- canvas element autoresize
- disable mouse camera control if non-standard camera used
- events without prefix are forbidden now
- player.* functions now throw exception in headless mode if player id not specified
### Functions ### Functions
- app.create_memory_device - block.model_name
- app.focus - block.has_tag
- app.get_content_sources - item.has_tag
- app.open_url - item.description
- app.set_content_sources - base64.encode_urlsafe
- app.start_debug_instance - base64.decode_urlsafe
- assets.to_canvas - vec2.rotate
- audio.get_all_input_devices_names - vecn.distance
- audio.get_input_info - vecn.mix
- audio.input.fetch - rigidbody:get_vdamping
- audio.input.request_open - rigidbody:set_vdamping
- canvas:add - entity:require_component
- canvas:encode - network.udp_connect
- canvas:get_data - random.random
- canvas:mul - random.bytes
- canvas:rect - random.uuid
- canvas:sub - Random:random
- canvas:unbind_texture - Random:seed
- Canvas.decode - hud.hand_controller
- compression.decode - inventory.get_caption
- compression.encode - inventory.set_caption
- debug.get_pack_by_frame - inventory.get_description
- file.create_memory_device - inventory.set_description
- gui.ask - pathfinding.create_agent
- gui.set_syntax_styles - pathfinding.remove_agent
- gui.show_message - pathfinding.set_enabled
- hud.is_open - pathfinding.is_enabled
- input.get_mouse_delta - pathfinding.make_route
- network.find_free_port - pathfinding.make_route_async
- PCMStream:create_sound - pathfinding.pull_route
- PCMStream:feed - pathfinding.set_max_visited
- PCMStream:share - pathfinding.avoid_tag
- player.get_all - gfx.skeletons.get
- player.get_all_in_radius - Skeleton:index
- player.get_dir - Skeleton:get_model
- player.get_interaction_distance - Skeleton:set_model
- player.get_nearest - Skeleton:get_matrix
- player.set_interaction_distance - Skeleton:set_matrix
- socket:is_nodelay - Skeleton:get_texture
- socket:recv_async - Skeleton:set_texture
- socket:set_nodelay - Skeleton:is_visible
- string.escape_xml - Skeleton:set_visible
- textbox:indexByPos - Skeleton:get_color
- textbox:lineY - Skeleton:set_color
- utf8.escape_xml - Schedule:set_timeout(time_ms, callback)
- Schedule:set_interval(interval_ms, callback, [optional] repetions): int
- Schedule:remove_interval(id)
- ScheduleGroup:publish(schedule: Schedule)
## Fixes ## Fixes
- [fix: "Bytearray expected, got function"](https://github.com/MihailRis/voxelcore/commit/2d1c69ee7e7248d8e86e00c4a2f5cead490cd278) - fix 3d text position / culling
- [fix zero frames texture animation fatal error](https://github.com/MihailRis/voxelcore/commit/e9222976efa67e2fe541962aabb6485363a12354) - fix fragment:place rotation (#593)
- [fix non-local players interpolation and head direction](https://github.com/MihailRis/voxelcore/commit/75ef603df0b1958e0c9eb95c2474dc7f3ec34057) - fix server socket creation in macos
- [fix std::bad_alloc caused by corrupted regions](https://github.com/MihailRis/voxelcore/commit/47cdc0213723c74be3e41b39702b656a2db0448d) - fix: base packs not scanned for app scripts
- [fix 'align' ui property reading](https://github.com/MihailRis/voxelcore/commit/c8ba5b5dbb7980a6576444fed9f7ea66ae1ed32a) - fix lua::getfield and events registering
- [fix incorrect textbox horizontal scroll](https://github.com/MihailRis/voxelcore/commit/bc86a3d8da4301ea6ce94c52715bd7cf863b0c37) - fix UIDocument::rebuildIndices
- [fix: wrong environment used in modules imported by require(...)](https://github.com/MihailRis/voxelcore/commit/5626163f17a252212607dc63bfcd726df44bf290) - fix input library in headless mode
- [fix: some container attributes not available in panel](https://github.com/MihailRis/voxelcore/commit/8a858beeb421495247a8dfae064672bcf6eb4190) - fix rigidbody:set_gravity_scale
- [fix generation.load_fragment](https://github.com/MihailRis/voxelcore/commit/b4ba2da95524025991f07be87b61ecc015f12656) - fix extended blocks destruction particles spawn spread, offset
- [fix: byteutil.unpack 'b' is equivalent of 'B'](https://github.com/MihailRis/voxelcore/commit/2a9507b54e58f852b558d7bc9b2cc88397d37a34) - fix shaders recompiling
- [fix: missing yaml null literals](https://github.com/MihailRis/voxelcore/commit/5755c616f35cc1c1fc5e94ecbc9c38a5a7f52275) - fix: C++ vecn functions precision loss
- [fix yaml array parsing](https://github.com/MihailRis/voxelcore/commit/026ae756cf4ad4a4febbef58ce2f007b2a0fc974) - fix coroutines errors handling
- [fix mouse click textbox caret set](https://github.com/MihailRis/voxelcore/commit/a1f0c2c2527b91d3a1d4f47eb2c043ebdef60119) - fix: viewport size on toggle fullscreen
- [fix wrapped textbox selection render](https://github.com/MihailRis/voxelcore/commit/76b54a890c35b6edb6d5018078c865f31e966965) - fix: fullscreen monitor refresh rate
- [fix broken dependencies management](https://github.com/MihailRis/voxelcore/commit/ee6f006b797d1a560baa9e333c99ee0181f548b6) - fix: content menu panel height
- [fix assets.parse_model with 'xml' format](https://github.com/MihailRis/voxelcore/commit/ec94abccbc4604e5d945d2bb8d1a63561797092b) - fix generation.create_fragment (#596)
- [fix correct line generation algorithm and bounds calculation](https://github.com/MihailRis/voxelcore/commit/ed9cf8800aea07c169719a3efddae7020e6be7e9) - fix bytearray:insert (#594)
- [fix enable per-variant custom model caching](https://github.com/MihailRis/voxelcore/commit/2a1d2f9354ee2ab623aca9d0059c0a676395d6d0) - fix: script overriding
- [fix: stream stops and dies on underflow](https://github.com/MihailRis/voxelcore/commit/cf561e78a81810fcb70975c7b785938af37b4b64) - fix: hud.close after hud.show_overlay bug
- [fix Schedule:set_timeout](https://github.com/MihailRis/voxelcore/commit/1e16ab5464b80d258fd955cf0485ebf596298ab3) - fix: 'cannot resume dead coroutine' (#569)
- [fix major chunks loading performance issue](https://github.com/MihailRis/voxelcore/commit/957f9f59983790583fb57c9e9a3661631f380153) - fix: skybox is not visible behind translucent blocks
- [fix: undo/redo also available when textbox is not editable](https://github.com/MihailRis/voxelcore/commit/0df5684adf3117f4018e4b34868f6c41ee7125e3) - fix: sampler arrays inbdexed with non-constant / uniform-based expressions are forbidden
- [fix player library docs](https://github.com/MihailRis/voxelcore/commit/51f07450d89781ce35bd630e07ea8cf33b912b93) - fix initial weather intensity
- [fix: root node id overriding](https://github.com/MihailRis/voxelcore/commit/91cb5ab7d8ca5376d87e1ad69b8f2cb05278d73d) - fix drop count (560)
- [fix extended block placement across chunk borders](https://github.com/MihailRis/voxelcore/commit/b85c5e367a2adea57ab0c3111e3d3b0cc924322b) - fix BasicParser::parseNumber() out of range (560)
- [fix modelviewer fbo creation](https://github.com/MihailRis/voxelcore/commit/be6710bc831f700bd9099860c704b3571d1d90fa) - fix rotation interpolation (#557)
- [fix: panel width differs to size specified in xml](https://github.com/MihailRis/voxelcore/commit/8cc51a107e27e1cb5ae8343fa0151db9c9a66852)

View File

@ -3,7 +3,7 @@
## Latest release ## Latest release
- [Download](https://github.com/MihailRis/VoxelCore/releases/latest) | [Скачать](https://github.com/MihailRis/VoxelCore/releases/latest) - [Download](https://github.com/MihailRis/VoxelCore/releases/latest) | [Скачать](https://github.com/MihailRis/VoxelCore/releases/latest)
- [Documentation](https://github.com/MihailRis/VoxelCore/blob/release-0.30/doc/en/main-page.md) | [Документация](https://github.com/MihailRis/VoxelCore/blob/release-0.30/doc/ru/main-page.md) - [Documentation](https://github.com/MihailRis/VoxelCore/blob/release-0.29/doc/en/main-page.md) | [Документация](https://github.com/MihailRis/VoxelCore/blob/release-0.29/doc/ru/main-page.md)
--- ---

View File

@ -2,6 +2,9 @@
Documentation for 0.30. Documentation for 0.30.
> [!WARNING]
> Version is in development. Proceed to [Documentation for 0.29.](https://github.com/MihailRis/voxelcore/blob/release-0.29/doc/en/main-page.md)
## Sections ## Sections
- [Assets preloading](assets-preload.md) - [Assets preloading](assets-preload.md)

View File

@ -2,6 +2,9 @@
Документация версии 0.30. Документация версии 0.30.
> [!WARNING]
> Версия находится в разработке. Перейдите к [документации для 0.29.](https://github.com/MihailRis/voxelcore/blob/release-0.29/doc/ru/main-page.md)
## Разделы ## Разделы
- [XML разметка интерфейса](xml-ui-layouts.md) - [XML разметка интерфейса](xml-ui-layouts.md)

View File

@ -45,7 +45,7 @@ local canvas_ffi_buffer_size = 0
local _ffi = ffi local _ffi = ffi
function __vc_Canvas_set_data(self, data) function __vc_Canvas_set_data(self, data)
if type(data) == "cdata" then if type(data) == "cdata" then
self:_set_data(tostring(_ffi.cast("uintptr_t", data.bytes)), data.size) self:_set_data(tostring(_ffi.cast("uintptr_t", data)))
end end
local width = self.width local width = self.width
local height = self.height local height = self.height
@ -60,7 +60,7 @@ function __vc_Canvas_set_data(self, data)
for i=0, size - 1 do for i=0, size - 1 do
canvas_ffi_buffer[i] = data[i + 1] canvas_ffi_buffer[i] = data[i + 1]
end end
self:_set_data(tostring(_ffi.cast("uintptr_t", canvas_ffi_buffer)), data.size) self:_set_data(tostring(_ffi.cast("uintptr_t", canvas_ffi_buffer)))
end end
local ipairs_mt_supported = false local ipairs_mt_supported = false

View File

@ -12,7 +12,7 @@
#include "logic/scripting/scripting.hpp" #include "logic/scripting/scripting.hpp"
#include "core_defs.hpp" #include "core_defs.hpp"
static void load_configs(Input* input, const io::path& root) { static void load_configs(Input& input, const io::path& root) {
auto configFolder = root / "config"; auto configFolder = root / "config";
} }
@ -26,7 +26,7 @@ static std::vector<io::path> default_content_sources {
ContentControl::ContentControl( ContentControl::ContentControl(
const Project& project, const Project& project,
EnginePaths& paths, EnginePaths& paths,
Input* input, Input& input,
std::function<void()> postContent std::function<void()> postContent
) )
: paths(paths), : paths(paths),

View File

@ -19,7 +19,7 @@ public:
ContentControl( ContentControl(
const Project& project, const Project& project,
EnginePaths& paths, EnginePaths& paths,
Input* input, Input& input,
std::function<void()> postContent std::function<void()> postContent
); );
~ContentControl(); ~ContentControl();
@ -49,7 +49,7 @@ public:
const std::vector<io::path>& getContentSources() const; const std::vector<io::path>& getContentSources() const;
private: private:
EnginePaths& paths; EnginePaths& paths;
Input* input; Input& input;
std::unique_ptr<Content> content; std::unique_ptr<Content> content;
std::function<void()> postContent; std::function<void()> postContent;
std::vector<std::string> basePacks; std::vector<std::string> basePacks;

View File

@ -10,7 +10,7 @@
#include "coders/toml.hpp" #include "coders/toml.hpp"
// All in-game definitions (blocks, items, etc..) // All in-game definitions (blocks, items, etc..)
void corecontent::setup(Input* input, ContentBuilder& builder) { void corecontent::setup(Input& input, ContentBuilder& builder) {
{ {
Block& block = builder.blocks.create(CORE_AIR); Block& block = builder.blocks.create(CORE_AIR);
block.replaceable = true; block.replaceable = true;
@ -28,8 +28,8 @@ void corecontent::setup(Input* input, ContentBuilder& builder) {
} }
auto bindsFile = "res:bindings.toml"; auto bindsFile = "res:bindings.toml";
if (input && io::is_regular_file(bindsFile)) { if (io::is_regular_file(bindsFile)) {
input->getBindings().read( input.getBindings().read(
toml::parse(bindsFile, io::read_string(bindsFile)), BindType::BIND toml::parse(bindsFile, io::read_string(bindsFile)), BindType::BIND
); );
} }

View File

@ -32,5 +32,5 @@ class Input;
class ContentBuilder; class ContentBuilder;
namespace corecontent { namespace corecontent {
void setup(Input* input, ContentBuilder& builder); void setup(Input& input, ContentBuilder& builder);
} }

View File

@ -163,9 +163,9 @@ void Engine::initialize(CoreParameters coreParameters) {
langs::locale_by_envlocale(platform::detect_locale()) langs::locale_by_envlocale(platform::detect_locale())
); );
} }
content = std::make_unique<ContentControl>( content = std::make_unique<ContentControl>(*project, *paths, *input, [this]() {
*project, *paths, input.get(), [this]() { onContentLoad(); } onContentLoad();
); });
scripting::initialize(this); scripting::initialize(this);
if (!isHeadless()) { if (!isHeadless()) {

View File

@ -3,6 +3,7 @@
#include <GL/glew.h> #include <GL/glew.h>
#include "Texture.hpp" #include "Texture.hpp"
#include "debug/Logger.hpp" #include "debug/Logger.hpp"
#include "gl_util.hpp"
static debug::Logger logger("gl-framebuffer"); static debug::Logger logger("gl-framebuffer");
@ -19,21 +20,35 @@ Framebuffer::Framebuffer(uint fbo, uint depth, std::unique_ptr<Texture> texture)
} }
static std::unique_ptr<Texture> create_texture(int width, int height, int format) { static std::unique_ptr<Texture> create_texture(int width, int height, int format) {
GLuint tex; GLuint texture;
glGenTextures(1, &tex); glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, tex); glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr); glTexImage2D(
GL_TEXTURE_2D,
0,
format,
width,
height,
0,
format,
GL_UNSIGNED_BYTE,
nullptr
);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0); glFramebufferTexture2D(
return std::make_unique<Texture>(tex, width, height); GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0
);
return std::make_unique<Texture>(texture, width, height);
} }
Framebuffer::Framebuffer(uint width, uint height, bool alpha) Framebuffer::Framebuffer(uint width, uint height, bool alpha)
: width(width), height(height) : width(width), height(height)
{ {
width = std::max<uint>(1, width);
height = std::max<uint>(1, height);
glGenFramebuffers(1, &fbo); glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo);
@ -45,11 +60,17 @@ Framebuffer::Framebuffer(uint width, uint height, bool alpha)
// Setup depth attachment // Setup depth attachment
glGenRenderbuffers(1, &depth); glGenRenderbuffers(1, &depth);
glBindRenderbuffer(GL_RENDERBUFFER, depth); glBindRenderbuffer(GL_RENDERBUFFER, depth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); glFramebufferRenderbuffer(
GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depth
);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
logger.error() << "framebuffer is not complete!"; if (status != GL_FRAMEBUFFER_COMPLETE) {
auto logLine = logger.error();
logLine << "framebuffer is not complete: ";
logLine << gl::to_string(status);
logLine << " (" << status << ")";
} }
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
@ -78,7 +99,7 @@ void Framebuffer::resize(uint width, uint height) {
glBindFramebuffer(GL_FRAMEBUFFER, fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glBindRenderbuffer(GL_RENDERBUFFER, depth); glBindRenderbuffer(GL_RENDERBUFFER, depth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, 0); glBindRenderbuffer(GL_RENDERBUFFER, 0);
texture = create_texture(width, height, format); texture = create_texture(width, height, format);

View File

@ -45,4 +45,40 @@ namespace gl {
} }
return 0; return 0;
} }
/// TODO: extend
inline const char* to_string(GLenum item) {
switch (item) {
case GL_INVALID_ENUM:
return "invalid enum";
case GL_INVALID_VALUE:
return "invalid value";
case GL_INVALID_OPERATION:
return "invalid operation";
case GL_STACK_OVERFLOW:
return "stack overflow";
case GL_STACK_UNDERFLOW:
return "stack underflow";
case GL_OUT_OF_MEMORY:
return "out of memory";
case GL_INVALID_FRAMEBUFFER_OPERATION:
return "invalid framebuffer operation";
case GL_FRAMEBUFFER_UNDEFINED:
return "framebuffer undefined";
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
return "framebuffer incomplete attachment";
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
return "framebuffer incomplete missing attachment";
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
return "framebuffer incomplete draw buffer";
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
return "framebuffer incomplete read buffer";
case GL_FRAMEBUFFER_UNSUPPORTED:
return "framebuffer unsupported";
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
return "framebuffer incomplete multisample";
default:
return "unknown";
}
}
} }

View File

@ -22,6 +22,6 @@ void gui::Canvas::draw(const DrawContext& pctx, const Assets& assets) {
void gui::Canvas::setSize(const glm::vec2& size) { void gui::Canvas::setSize(const glm::vec2& size) {
UINode::setSize(size); UINode::setSize(size);
data->extend(std::max<int>(1, size.x), std::max<int>(1, size.y)); data->extend(size.x, size.y);
texture->reload(*data); texture->reload(*data);
} }

View File

@ -220,14 +220,6 @@ static int l_set_data(State* L) {
if (lua::isstring(L, 2)) { if (lua::isstring(L, 2)) {
auto ptr = reinterpret_cast<ubyte*>(std::stoull(lua::tostring(L, 2))); auto ptr = reinterpret_cast<ubyte*>(std::stoull(lua::tostring(L, 2)));
int len = lua::touinteger(L, 3);
if (len < image.getDataSize()) {
throw std::runtime_error(
"data size mismatch expected " +
std::to_string(image.getDataSize()) + ", got " +
std::to_string(len)
);
}
std::memcpy(data, ptr, image.getDataSize()); std::memcpy(data, ptr, image.getDataSize());
return 0; return 0;
} }

View File

@ -91,7 +91,7 @@ static inline void generate_pole(
voxel* voxels, voxel* voxels,
int x, int z int x, int z
) { ) {
uint y = std::min<uint>(top, CHUNK_H - 1); uint y = top;
uint layerExtension = 0; uint layerExtension = 0;
for (const auto& layer : layers.layers) { for (const auto& layer : layers.layers) {
// skip layer if can't be generated under sea level // skip layer if can't be generated under sea level
@ -106,9 +106,7 @@ static inline void generate_pole(
} else { } else {
layerHeight += layerExtension; layerHeight += layerExtension;
} }
layerHeight = std::min( layerHeight = std::min(static_cast<uint>(layerHeight), y+1);
static_cast<uint>(layerHeight), std::min<uint>(CHUNK_H - 1, y + 1)
);
for (uint i = 0; i < layerHeight; i++, y--) { for (uint i = 0; i < layerHeight; i++, y--) {
voxels[vox_index(x, y, z)].id = layer.rt.id; voxels[vox_index(x, y, z)].id = layer.rt.id;