From 7f408c11de9e2cb4ef09070f17a4f5ff19b96195 Mon Sep 17 00:00:00 2001 From: boolean-false Date: Sun, 20 Sep 2026 18:55:59 +0700 Subject: [PATCH 01/91] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B2=D0=B5?= =?UTF-8?q?=D0=BB=20parse=5Fdouble=20=D0=BD=D0=B0=20from=5Fchars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/stringutil.cpp | 41 +++++++++++++++++++++++----------------- test/util/stringutil.cpp | 8 ++++++++ 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/util/stringutil.cpp b/src/util/stringutil.cpp index 8d80a82ab..a2743a8ba 100644 --- a/src/util/stringutil.cpp +++ b/src/util/stringutil.cpp @@ -1,9 +1,11 @@ -#include "stringutil.hpp" - -#include -#include -#include -#include +#include "stringutil.hpp" + +#include +#include +#include +#include +#include +#include #include #include @@ -509,17 +511,22 @@ int util::replaceAll( return replace_all(str, from, to); } -// replace it with std::from_chars in the far far future -double util::parse_double(const std::string& str) { - std::istringstream ss(str); - ss.imbue(std::locale("C")); - double d; - ss >> d; - if (ss.fail()) { - throw std::runtime_error("invalid number format"); - } - return d; -} +double util::parse_double(const std::string& str) { + const char* begin = str.data(); + const char* end = begin + str.size(); + while (begin != end && std::isspace(static_cast(*begin))) { + begin++; + } + if (begin != end && *begin == '+') { + begin++; + } + double d = 0.0; + const auto result = std::from_chars(begin, end, d); + if (result.ec != std::errc()) { + throw std::runtime_error("invalid number format"); + } + return d; +} double util::parse_double(const std::string& str, size_t offset, size_t len) { return parse_double(str.substr(offset, len)); diff --git a/test/util/stringutil.cpp b/test/util/stringutil.cpp index a057d4e69..88915c58d 100644 --- a/test/util/stringutil.cpp +++ b/test/util/stringutil.cpp @@ -68,6 +68,14 @@ TEST(stringutil, base64_urlsafe) { } } +TEST(stringutil, parse_double) { + EXPECT_DOUBLE_EQ(util::parse_double("53.125"), 53.125); + EXPECT_DOUBLE_EQ(util::parse_double("-0.25"), -0.25); + EXPECT_DOUBLE_EQ(util::parse_double(" +12.5"), 12.5); + EXPECT_DOUBLE_EQ(util::parse_double("xx1.75yy", 2, 4), 1.75); + EXPECT_THROW(util::parse_double("not-a-number"), std::runtime_error); +} + class StringParser : BasicParser { public: StringParser(std::string_view source) : BasicParser("", source) {} From b631b33b5021ca7a16a00d15ca1a63181aa35a61 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 20 Sep 2026 17:00:16 +0300 Subject: [PATCH 02/91] update CHANGELOG.md to 0.32 --- CHANGELOG.md | 419 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 265 insertions(+), 154 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 281924189..db7f72050 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ -# 0.31 - 2026.03.22 +# 0.32 - 20xx.xx.xx -[Documentation](https://github.com/MihailRis/VoxelEngine-Cpp/tree/release-0.31/doc/en/main-page.md) for 0.31 +[Documentation](https://github.com/MihailRis/VoxelEngine-Cpp/tree/release-0.32/doc/en/main-page.md) for 0.32 Table of contents: @@ -13,169 +13,280 @@ Table of contents: ## New Features -- solid entities with solid hitboxes -- rendering ui to texture with 'frame' element -- loading vector fonts support with freetype library -- defining skeletons in VCM files -- project permissions system -- executing commands from stdin ('--stdin-cmd' command line argument enables it) +- animation +- semi-transparent entities +- client-side --script, --test support +- environments +- translators +- VCA format ## Added -- added clouds, so sky is no more so deadly clear -- ui: - - added 'onmouseenter', 'onmouseleave' events - - added 'zIndex' common scripting property - - added 'inventory' scripting property to slot element - - added 'font' attribute - - added 'text-align' label attribute - - added 'frame' element - - added 'fallback' image attribute -- particles: - - added 'spawn_offset' property -- audio: - - added acoustic effects (reverb) - - added 'audio.acoustic-effects' setting - - added 'record-audio' project permission -- projects system: - - added project permissions configuration - - added 'debugging' permission -- added 'base:flat_grass' world generator -- added ssao quality setting -- added background assets loader -- vcm format: - - added 'bone' (model/skeleton node) element - - added 'tri' (triangle) element -- added 'on_inventory_interact' hud event -- added weather properties: - - 'sky_tint' - - 'clouds_tint' - - 'min_sky_light' -- added block properties: - - 'grounding-behaviour' (extended blocks) - - explicit 'solid' visual property -- added world generator parameters: - - 'player-spawn-radius' - - 'player-min-spawn-height' - - 'player-max-spawn-height' -- added 'material' entity property -- added patch number to engine build produced by release pipeline -- new functions arguments: - - added 'skeleton_name' argument to assets.parse_model - - added 'include_non_selectable' argument to block.raycast - - added 'variant_index' argument to block.get_model, block.model_name, block.get_textures - - added optional 'emission' argument to gfx.blockwraps.wrap - - added gui.load_document namespace extension table -- added freetype dependency +- events: + - main.lua script: + - on_scripts_loading + - on_content_loaded + - world.lua script: + - on_entity_spawned + - on_entity_despawned + - entity component: + - on_player_set +- libraries: + - animation + - crypto + - ctypes + - test + - vc + - xml +- new classes: + - debug.Logger + - I8view + - I64view + - U64view + - FLTview + - DBLview + - private PlayingTrack + - private Hash +- 3d text 'font' property +- documented: + - block `material` property +- defaults: + - block-material +- permissions: + - sub-instances +- `--log` command line argument +- `ladder` rotation profile +- new ui properties: + - `select` element `button` mode + - `onrightclick` + - `onmiddleclick` +- verbose parsing error messages +- content menu: pack version display +- Heightmap.normalNoise field +- content menu: filtering by pack id +- `hot-reload` VC-DBG signal +- `normal` attribute for `tri` and `rect` VCM primitives +- `lighting-mode` entity property +- vca syntax highlighting ## New Functions -- assets.request_texture -- block.get_hitbox -- entity.rigidbody:get_elasticity -- entity.rigidbody:get_mass -- entity.rigidbody:get_material -- entity.rigidbody:set_elasticity -- entity.rigidbody:set_mass -- entity.rigidbody:set_material -- entity.rigidbody:get_ground_vel -- gfx.blockwraps.set_faces -- gfx.blockwraps.set_tints -- gui.close_menu -- gui.create_frame -- gui.get_active_frame -- gui.set_active_frame -- hud.get_second_inventory -- hud.is_player_inventory_open -- mat4.perspective -- quat.from_euler -- session.get -- session.has -- session.reset +- animation.action +- animation.play +- app.get_content +- app.is_instance_alive +- app.start_background_instance +- app.terminate_instance +- assets.parse_animation +- Bytearray:copy +- Bytearray:fill +- Bytearray:move +- crypto.aes_gcm_decrypt +- crypto.aes_gcm_encrypt +- crypto.chacha20_poly1305_decrypt +- crypto.chacha20_poly1305_encrypt +- crypto.constant_time_equal +- crypto.ecdsa_keypair +- crypto.ecdsa_public +- crypto.ecdsa_sign +- crypto.ecdsa_verify +- crypto.ed25519_keypair +- crypto.ed25519_public +- crypto.ed25519_sign +- crypto.ed25519_verify +- crypto.features +- crypto.hash +- crypto.hkdf_expand +- crypto.hkdf_extract +- crypto.hmac +- crypto.md5 +- crypto.p256_keypair +- crypto.p256_public +- crypto.p256_shared +- crypto.pbkdf2 +- crypto.random_bytes +- crypto.rsa_pkcs1_verify +- crypto.rsa_pss_verify +- crypto.scrypt +- crypto.sha256 +- crypto.sha384 +- crypto.sha512 +- crypto.x25519 +- crypto.x25519_keypair +- crypto.x25519_public +- crypto.x25519_shared +- ctypes.int16 +- ctypes.int32 +- ctypes.int64 +- ctypes.int8 +- ctypes.uint16 +- ctypes.uint32 +- ctypes.uint64 +- ctypes.uint8 +- entities.def_solid +- events.remove +- file.remove_ext +- gfx.text3d.get_entity +- gfx.text3d.set_entity +- gui.screenshot +- Hash:final +- Hash:update +- Heightmap:ceil +- Heightmap:cos +- Heightmap:floor +- Heightmap:round +- Heightmap:sin +- Heightmap:tan +- input.get_mouse_scroll +- inventory.set_all_data +- io_stream:available +- io_stream:tell +- io_stream:wrap_bytearray +- math.noise +- math.noise2d +- math.sign +- network.request +- PlayingTrack:pause +- PlayingTrack:stop +- quat.mul +- quat.mul_vec3 +- rigidbody:set_selectable +- socket:as_stream +- socket:peek +- socket:peek_async +- string.url_decode +- string.url_encode +- table.keys +- test.click +- test.fill +- test.find_by_attr +- test.find_by_attr_presence +- test.find_by_text +- test.press +- time.precise_time +- time.precise_utc_time +- Tview:typesize +- vc.get_setting +- vc.get_setting_info +- vc.get_version +- vc.is_client +- vc.is_headless +- vc.str_setting +- world.raycast +- xml.parse +- xml.parse_vcd +- xml.tostring -now documented: +New overloads: -- audio.input.get_input_info -- gui.ask -- gui.show_message +- asserts.equals(Canvas) +- skeleton:set_color(int, ...) ## Changes -- minor visual restoration -- assets.parse_model now supports OBJ format -- chunks loading optimizations -- app.load_content, app.reset_content, app.reconfig_packs and app.config_packs calling limited to app script coroutine and time.post_runnable context -- debug panel updated a bit -- pass app library from standard pages loader -- skeletons are now assets +- inventory interaction enchancements [#897](https://github.com/MihailRis/voxelcore/issues/897) +- breaking: document events removed from 'events' library temporary ## Fixes -- [fix vec3 shadeless flag](https://github.com/MihailRis/voxelcore/commit/5e05b44c26c1b57aaceb5e3478ccf5f98e3f14d7) -- [fix: missing extended block size limit check](https://github.com/MihailRis/voxelcore/commit/9628177698b29488965bffc60fa305e752245c13) -- [fix extended block grounding](https://github.com/MihailRis/voxelcore/commit/0b7dc14f5512478c7b7df408bab007d06de6f9ae) -- [fix blocks variants](https://github.com/MihailRis/voxelcore/commit/0cc8c70a1704bf511635c1c1e19fe707e8477127) -- [fix fatal exception caused by empty skeleton model texture name](https://github.com/MihailRis/voxelcore/commit/fc04284b34d5dfc8afd008933b61644dda6b73c6) -- [fix blocks random tick](https://github.com/MihailRis/voxelcore/commit/9ac8406558ebe6183071545aeb8e34a968503c18) -- [fix 'attempt to compare string with number' in audio.input.fetch](https://github.com/MihailRis/voxelcore/commit/ba2546e096c93e13fc0abfcf0e0447eb1721960f) -- [fix: FFI library access from non-built-in scripts vulnerability](https://github.com/MihailRis/voxelcore/commit/a32845d083f3d2528f04eebe173ed7358cd2cf14) -- [fix non-lighted chunks saving](https://github.com/MihailRis/voxelcore/commit/5b8c2d6162092f3655e2d857fa75ee42d879e604) -- [fix: attempting to build lights in non-local players chunk matrices](https://github.com/MihailRis/voxelcore/commit/3308a61d560c2d9bbff0c81d2ed5d391103ec5d0) -- [fix extended blocks collision detection](https://github.com/MihailRis/voxelcore/commit/c8e884009bdc7b7ee8025b05cfb12284f340d0af) -- [fix: block inventory not removing in some cases](https://github.com/MihailRis/voxelcore/commit/e4d21c940be9048076180976eaba31f0138661a3) -- [fix extended blocks culling on chunk borders](https://github.com/MihailRis/voxelcore/commit/7abbe43c3cf21bbf7afa3cf392b08e52950fa163) -- [fix: player name text is still visible when suspended](https://github.com/MihailRis/voxelcore/commit/49aa7cdfba19ebc6d141dca28f7ed269c2e443fa) -- [fix: crouching falling prevention does not reset velocity & fix small hitboxes horizontal collision](https://github.com/MihailRis/voxelcore/commit/bfa8b7cf3d483b2ea3f4f7166f49b1682a471363) -- [fix: macos build pipeline uses OpenAL.Framework instead of openal-soft](https://github.com/MihailRis/voxelcore/commit/cd537cc1cbf490b614cdbd8ab38a3a26364c29f6) -- [fix: assets access attempts in headless mode leading to segfaults](https://github.com/MihailRis/voxelcore/commit/a92efe581f3b6a37f3217684a7174efb50bb6ef9) -- [fix crash in headless](https://github.com/MihailRis/voxelcore/commit/2b4c3c08f35c0ce0de85789a27b77a47ce134c53) -- [fix advanced render setting tooltip](https://github.com/MihailRis/voxelcore/commit/fcbbf4814a10b6db09ba30e90b21be7dc0c96d9f) -- [fix io_stream.write_line](https://github.com/MihailRis/voxelcore/commit/4809003aa8af28ed04d78a396f32580ee5506c39) -- [fix bytearray view classes](https://github.com/MihailRis/voxelcore/commit/3f68fc1fc4fce39328a570253583d9a796779d7d) -- [fix extra faces when dense mode is off](https://github.com/MihailRis/voxelcore/commit/89485dc592f138cd244d61ac6871d745c3e82e9d) -- [fix fatal error when skeleton is missing](https://github.com/MihailRis/voxelcore/commit/8b5261f4f14ee31894dcf5125a4836ff140de8a9) -- [fix entity skeleton name serialization](https://github.com/MihailRis/voxelcore/commit/d07c8e523429393a26dbccaaf7fc7275079fa577) -- [fix on_chunk_register_event](https://github.com/MihailRis/voxelcore/commit/d197415739f0e75369a4b14de808ce9c16c808d8) -- [fix: player entity body is active before player flight state applied](https://github.com/MihailRis/voxelcore/commit/5785060ffb85edb33c72410e0c65123c094fb3dd) -- [fix: player not spawning entity after set_suspended(pid, false)](https://github.com/MihailRis/voxelcore/commit/088bfc878efc05fdd92078581068e16d1e38f652) -- [fix incorrect 3d text preset for existing players](https://github.com/MihailRis/voxelcore/commit/d9a914ee5423ec216e216f6839785a887eb47036) -- [fix: player.set_suspend(pid, true) leaves entity in the world](https://github.com/MihailRis/voxelcore/commit/a4fc4a5044d394a8f1d054ecf76d18c6ebba0a78) -- [fix nested vcm elements](https://github.com/MihailRis/voxelcore/commit/22e0c469c006217b82b1dcac9193cd38b8072cd2) -- [fix unchecked indices buffer overflow](https://github.com/MihailRis/voxelcore/commit/336ae09f669fe734ac9a69ebcbb3550596f26a56) -- [fix gui.show_input_dialog key:escape reaction](https://github.com/MihailRis/voxelcore/commit/1644751b1a32a3ecc2b4604e4a5a1cb00c7692bd) -- [fix app.reset_content args](https://github.com/MihailRis/voxelcore/commit/43fa181398c6064fd165cd6244ed4847933cef4c) -- [fix gfx.posteffects.set_intensity](https://github.com/MihailRis/voxelcore/commit/f171d3e30844c69a0675d23db583f34abdcd4f6c) -- [fix blocks raycast filter](https://github.com/MihailRis/voxelcore/commit/ce769143f881afbaa1136ec6a0692ff2b4cc2bd4) -- [fix conditional jump or move depends on uninitialised value in GLFWWindow](https://github.com/MihailRis/voxelcore/commit/e371153288c3eb99e568fe19fb725f151d6a58ac) -- [fix debugging server creation](https://github.com/MihailRis/voxelcore/commit/72040b5dbb37c6588a53e6d7584f16e98ed0a8e2) -- [fix on_blocks_tick interval](https://github.com/MihailRis/voxelcore/commit/cd43d9545a52ca153b7548585c65af8b98bbfc7f) -- [fix: inventory interaction on "disablePlayerInventory = true"](https://github.com/MihailRis/voxelcore/commit/dba10805f8d98aedf6d7ab3f5f8d7ca5c2280e8e) -- [fix: checkbox hover color](https://github.com/MihailRis/voxelcore/commit/76d5af85cc04b6560e7dde4cb9116b8d6d638036) -- [fix a typo in the vector3:rot and duplicate vector2.\_\_eq](https://github.com/MihailRis/voxelcore/commit/334666a5615e0996fa036cc44ed94777aee76867) -- [fix gfx.blockwraps.set_texture](https://github.com/MihailRis/voxelcore/commit/e423c746280c690ab26a217b1e8668253cdd1372) -- [fix: chunk border wigth change when render block selection](https://github.com/MihailRis/voxelcore/commit/963e7d78f5f555940517e9afa4dccafbe7085d17) -- [fix block model change wrapper reaction](https://github.com/MihailRis/voxelcore/commit/6d6d38c2180ae79d69498acdd3a525399579995a) -- [fix: InventoryView: when moving one object with the right mouse button, the phantom remained](https://github.com/MihailRis/voxelcore/commit/c7da5fa5698113710dca986516372a483ebfa0c7) -- [fix: integers signs are unspecified in binary_json_spec.md](https://github.com/MihailRis/voxelcore/commit/e5f9e4d02aba96678afac533be9679523487006b) -- [fix fragment:place lights](https://github.com/MihailRis/voxelcore/commit/7a513949e94764797abd09410836f4475da8156a) -- [fix: 'shadeless' block property ignored if custom model is used](https://github.com/MihailRis/voxelcore/commit/78062e2197be750d3a6fa87d44e8079286323cdd) -- [fix custom model blocks lighting](https://github.com/MihailRis/voxelcore/commit/36f7fb759a6266edae91f2e2986882eba066bdaf) -- [fix inventory.set](https://github.com/MihailRis/voxelcore/commit/c394df4e07641b9c18dc8a4ee1bcd1c519a82f66) -- [fix fatal error on invalid item id in inventory](https://github.com/MihailRis/voxelcore/commit/180dd5051b5a7358200ae705fd20b632b0d96f72) -- [fix on_block_tick timer](https://github.com/MihailRis/voxelcore/commit/77b4382577dc9cc3a21317190290e9019355ec9b) -- [fix on_block_tick triggered while paused](https://github.com/MihailRis/voxelcore/commit/4d53eb97c359b7453209af91eedfe56b03042a6e) -- [fix hover elements lifetime](https://github.com/MihailRis/voxelcore/commit/55e4e6de02e606b756dba57cefe2fdb3574c389d) -- [fix shadeless blocks with soft lights disabled](https://github.com/MihailRis/voxelcore/commit/ea8e1301eadcc1298668bcc5d7c6d9893f916e1d) -- [fix libpng error handling](https://github.com/MihailRis/voxelcore/commit/ba405ee6fc1541c2e84f62a6a047da711a313ff4) -- [fix corrupted voxel reset](https://github.com/MihailRis/voxelcore/commit/e0b5c8457b93d2caa9d7959a28960cd456bbd61d) -- [fix overriden content units scripts overriding](https://github.com/MihailRis/voxelcore/commit/719ba6e17a995d689e2c6e4845d920b6c42856c1) -- [fix block ticks](https://github.com/MihailRis/voxelcore/commit/4a880177da63b282d0889493c4497bf81c4780ae) -- [fix nil coords passed to on_block_tick](https://github.com/MihailRis/voxelcore/commit/ee21debe520a48759af9bbe2a27de148d91b371c) -- [fix: incomplete size transform support by entities](https://github.com/MihailRis/voxelcore/commit/fefc975832685f1377736aefd8a048b1fd943130) -- [fix exception if model having invalid variable texture passed to modelviewer](https://github.com/MihailRis/voxelcore/commit/1d56d83b72d59da34ceac5cc104ce3aa278dd299) -- [fix canvas:set_data with table argument](https://github.com/MihailRis/voxelcore/commit/e678195a2ae3cfd1ddc39435dd103292806dd4bc) -- [fix generated item's script](https://github.com/MihailRis/voxelcore/commit/4df4209bc59944e97102be7a618292378dc301a4) -- [fix ui elements overriding](https://github.com/MihailRis/voxelcore/commit/c214d70f1d33785f9262c552a6f7b933b41e9125) -- [fix: pack environment not passed to components](https://github.com/MihailRis/voxelcore/commit/69cf4c1c046281106571341702c48d74c27a3788) -- [fix 'unexpected end' while parsing .obj](https://github.com/MihailRis/voxelcore/commit/31e7a4ebc0076b6fdb12f4775ffba0903a11ba4e) -- [fix: bad_alloc if canvas element size is negative](https://github.com/MihailRis/voxelcore/commit/7c74eece99e1ec52e3022803975c92b951ec11c0) +- [fix stack_vector](https://github.com/MihailRis/voxelcore/commit/1fbf16e3dcf145f322849b182be20bac1272a82b) +- [fix audio.input.request_open](https://github.com/MihailRis/voxelcore/commit/8a19c903e44b7569a38e470ec7b260a03cd4d673) +- [fix: block/item.properties not inheriting parent content unit properties](https://github.com/MihailRis/voxelcore/commit/a9d185256ae14789c17b005b27f7be94895f7dca) +- [fix: player name 3d text not updating by Decorator](https://github.com/MihailRis/voxelcore/commit/33db2633a282a9ba532143e223e3ae8b4d12fc22) +- [fix lua::toquat](https://github.com/MihailRis/voxelcore/commit/9d7e95db807f6210cd18e3e4b58d05eb5ab165d3) +- [fix: destroyed skeleton config access on skeleton reload](https://github.com/MihailRis/voxelcore/commit/9893c09fd5459eda2f013b7603fd32db18e02b98) +- [fix entity bounding box check on block place](https://github.com/MihailRis/voxelcore/commit/bb44b4186bd617281614c5f04329bd4221b08c0d) +- [fix: cursor is not hidden in wayland if previously changed by glfwSetCursor](https://github.com/MihailRis/voxelcore/commit/6896fa433ca2a5f6bfd5205072edfaded7107a42) +- [fix process_properties](https://github.com/MihailRis/voxelcore/commit/dde8c674b81835e6d7a6591bd0732a9c5c140be0) +- [fix stringutil locale-related functions](https://github.com/MihailRis/voxelcore/commit/30177b9d2a3f87955005f39418dbcf8b1c76dfca) +- [fix teleports loop on low obstacles](https://github.com/MihailRis/voxelcore/commit/e28af89de2ff4b79cbfc84515005fc3ae3074004) +- [fix entity spawn/despawn](https://github.com/MihailRis/voxelcore/commit/2dd8024b7e0f82bfc79cd6e5e389c3dd6a5a700c) +- [fix 3d text scaling in projected display mode](https://github.com/MihailRis/voxelcore/commit/736cdb0980f68f64e5b3c0135cf5962169c05349) +- [fix audio.play type checks](https://github.com/MihailRis/voxelcore/commit/6daaa4895bee30e4a92b3e769116ec8e473f2728) +- [fix app.reconfig_packs](https://github.com/MihailRis/voxelcore/commit/73837082c2f629614dd28e04880d9ca6f59908b1) +- [fix skeletons behaviour in preload.json](https://github.com/MihailRis/voxelcore/commit/acff9454924f630fb69719f868e78bcf319956e4) +- [fix LevelScreen::saveWorldPreview](https://github.com/MihailRis/voxelcore/commit/91b14f4264b57cda3779e991b426bf832fc1d9a7) +- [fix core:player component mob.set_flight call](https://github.com/MihailRis/voxelcore/commit/66796019af77d33be0577bb7bf7a0f30307246e7) +- [fix components parent environment](https://github.com/MihailRis/voxelcore/commit/dcaf87988bfac2b622eba4003ff7c52b41088601) +- [fix utf8.sub behaviour](https://github.com/MihailRis/voxelcore/commit/31478977099e501752271094802a6f057eb4f01e) +- [fix multiline textbox wrappping](https://github.com/MihailRis/voxelcore/commit/99c66c61bb4da0b8defc7aa3219088de32ae4fab) +- [fix: manually changing textbox.caret does not reset selection](https://github.com/MihailRis/voxelcore/commit/843cc3769dffe1318b32a25f1dbeb8a0390a074d) +- [fix tick intervals in headless mode](https://github.com/MihailRis/voxelcore/commit/0975fcd8193025c171acf0644babfb570e53c468) +- [fix player ticks](https://github.com/MihailRis/voxelcore/commit/47f2bf75d79f73a28afd618f52509767c0876881) +- [fix selection reset on end reached with shift pressed](https://github.com/MihailRis/voxelcore/commit/1d4abd7758db633fd389990ddd015f37c5803ed3) +- [fix textbox scrolling](https://github.com/MihailRis/voxelcore/commit/bebb5049efaa8b242b3eba25eeb8227dfb06a161) +- [fix lua syntax highlighting](https://github.com/MihailRis/voxelcore/commit/b307b5c93b6ab2d2102e81310e3441930f55e682) +- [fix controls settings panel height](https://github.com/MihailRis/voxelcore/commit/c4bddba6b73a42b7ed1da4cbc81e4c79d48b7117) +- [fix lua::bytearray_as_string](https://github.com/MihailRis/voxelcore/commit/3f81494d4b14f3a8d6be0f9e9a489f0d26c88e37) +- [particles fix](https://github.com/MihailRis/voxelcore/commit/e6ac30143c8e0ade446d61b92119ebdecb616e28) +- [blocks.fill fix](https://github.com/MihailRis/voxelcore/commit/31a90bd91172eb07923ea41c0ed18bdaee83f462) +- [lighting fix](https://github.com/MihailRis/voxelcore/commit/0bbde3a778762f7f6740cd65b494824111313c2e) +- [fix gui.load_document environment extension](https://github.com/MihailRis/voxelcore/commit/b1974405c69596edf0cfd4a4b5cd42ba0d65448e) +- [fix serialization error for specific types](https://github.com/MihailRis/voxelcore/commit/2f729bd3cbb793f20c5e060a75e38a18d0d88d0f) +- [fix vcm texture sides](https://github.com/MihailRis/voxelcore/commit/38bebac37ee2a290315c3148576e98c825efa46d) +- [fix post-runnable context in content-related functions](https://github.com/MihailRis/voxelcore/commit/0ffefddee1781389fc6e8014ea00856e09cfff1d) +- [fix: app.reconfig_packs attempts to remove indices in generator test mode](https://github.com/MihailRis/voxelcore/commit/ce189c810d13512225b82933724603781a1ecef1) +- [fix: duplicating core:chat event handlers in in-game chat](https://github.com/MihailRis/voxelcore/commit/52829023c2718876ce97bc91345b3cadfdd7d10e) +- [fix document events & breaking: document events removed from 'events' library temporary](https://github.com/MihailRis/voxelcore/commit/089bcbbb64b8009db03fb9b6ed04c491e46d6933) +- [fix uinode.parent property](https://github.com/MihailRis/voxelcore/commit/902c885fe0d72cbe5bd2ea9a95d4551516197d4a) +- [fix ui elements related things](https://github.com/MihailRis/voxelcore/commit/84b2aef81f82d46b07d9bd059540d7ac90cae3ec) +- [fix segfault on world.get_chunk_data if no world open](https://github.com/MihailRis/voxelcore/commit/4a11dd28ec9b7a0344c21a6fc4c3ab80c429eb50) +- [fix ceiling collision](https://github.com/MihailRis/voxelcore/commit/625a5caeccbce1d06a0ad1c743e56995d9b42343) +- [fix of io_stream:read_fully for binary and yield mode](https://github.com/MihailRis/voxelcore/commit/fdec2d722d2b81e7bdbdfec2209a9df28d10dde0) +- [fix of io_stream:available for non-buffered streams when "length" arg defined](https://github.com/MihailRis/voxelcore/commit/cd040cfeb47f91b29c6d138f745b442483f4cf44) +- [fix dead skeleton model references](https://github.com/MihailRis/voxelcore/commit/9d3a60328f7a44e0361a31e2e8c5b9079282810b) +- [fix maths_inline version of mat4.rotate](https://github.com/MihailRis/voxelcore/commit/87310dd38f848ca059b627fc0b6d1d2503d05071) +- [fix BasicParser power function](https://github.com/MihailRis/voxelcore/commit/c45d994216e57811b36d9463fab7ad2c7cc051c0) +- [fix exponential notation parsing (](https://github.com/MihailRis/voxelcore/commit/b024b6cddfcee9bc436d8260cdb3f1647087af96 "fix exponential notation parsing (#857)")[#857](https://github.com/MihailRis/voxelcore/pull/857)[)](https://github.com/MihailRis/voxelcore/commit/b024b6cddfcee9bc436d8260cdb3f1647087af96) +- [fix graphics settings & reduce extra GL calls](https://github.com/MihailRis/voxelcore/commit/5b868ae857b1b425a4f529c663b3dad55fcbf59a) +- [fix integer raycast filters & add simple raycast test](https://github.com/MihailRis/voxelcore/commit/39a42365534ebd4c4c0be690e9ea0646e1459a7b) +- [fix canvas:encode produces flipped images for png](https://github.com/MihailRis/voxelcore/commit/279fb92b94a0f8b8d28ed141b54b160450ec91f7) +- [fix canvas:line lines clipping](https://github.com/MihailRis/voxelcore/commit/a5596ed5cd65bc62b983ec9dff3263beeced2dd7) +- [fix newly created raycast bug](https://github.com/MihailRis/voxelcore/commit/46b4aab6dce9e7c195b5c29584168f8e5b8fbb52) +- [fix Skeleton::setConfig](https://github.com/MihailRis/voxelcore/commit/a0b7e81a94d8a4f2750fbbd507ba6bd2e688f8b4) +- [fix audio input device settings](https://github.com/MihailRis/voxelcore/commit/a99c6aa8e08d440d9b049007747ac769c2fff431) +- [fix: missing font usage produces fatal error](https://github.com/MihailRis/voxelcore/commit/420d0daf28853e1db1a985f9a74ec38f3d978ddc) +- [fix texture-faces reading](https://github.com/MihailRis/voxelcore/commit/d3eb7a10bea6825c0ff2da9f459a1b528a6a410f) +- [fix the margin](https://github.com/MihailRis/voxelcore/commit/86fdcb289b1cfa510c861c677731599b4f0f0519) +- [fix components order & add skeleton:get_matrix overload & add skeleton:reset_pose](https://github.com/MihailRis/voxelcore/commit/8242d299ed68c8f27e691e464562e43c936788da) +- [fix user component initialization exception handling & fix fatal error on uninitialized component access](https://github.com/MihailRis/voxelcore/commit/28385f236c3e3d2ccf020b116f08a8f6d33ec1a3) +- [fix projected 3d text for non-monospace fonts](https://github.com/MihailRis/voxelcore/commit/4837e1de027e738bd59c4ba9c91b654e5d866f9a) +- [fix custom model blocks render (with some conditions)](https://github.com/MihailRis/voxelcore/commit/e0be7a8d8c9f8d54d7af1b6b976fefc941ebba1f) +- [fix 3d texts antialiasing render issue](https://github.com/MihailRis/voxelcore/commit/40e73ca34b14939468f64a5d349a98400e704bbb) +- [fixing errors in rules.lua](https://github.com/MihailRis/voxelcore/commit/81af4b9e2acba5d67b5bacdb343618c686dd9d5f) +- [fix block.index() calls in grass_block.lua and export base:util.calc_loot()](https://github.com/MihailRis/voxelcore/commit/2eae8f6f275e7a41ac30309e61f8d22d8a644ac7) +- [fix fix lua version comparision](https://github.com/MihailRis/voxelcore/commit/4be73acc61f6805c9df2743e68a86ee646d43e25) +- [fix lua version compare](https://github.com/MihailRis/voxelcore/commit/9444dc0c4596bd0c1fd2710488c8d412da8aab1f) +- [fix zIndex type in docs](https://github.com/MihailRis/voxelcore/commit/c445f1a68f9bc1c9c9877cd91d010a1dd5240f0d) +- [fix double click behaviour](https://github.com/MihailRis/voxelcore/commit/9ea50148b8a02a74befbcbc618a6a7dca7643316) +- [fix horizontal panel behaviour](https://github.com/MihailRis/voxelcore/commit/2448869bf922a5773dbfd420a0a0e2cb151b0712) +- [fix: stdcomp calling non-component global functions](https://github.com/MihailRis/voxelcore/commit/64a5a74f53722aa0db17b47bd0aa9fce106a661c) +- [fix missing keys support](https://github.com/MihailRis/voxelcore/commit/df67236adbb9c29eddb3ec5a455dd61fb03c0a16) +- [fix: temporary focus fix](https://github.com/MihailRis/voxelcore/commit/9fa6070cced55583ff6e0eaa654e4ca5b5495c32) +- [fix rivers in base:demo](https://github.com/MihailRis/voxelcore/commit/75cd9aeefb2cccb544e0169063908760977d6615) +- [fix gui.ask](https://github.com/MihailRis/voxelcore/commit/dd7e01488f3cbc4b2df58a945027ac3a9ea35eac) +- [fix 3d text render](https://github.com/MihailRis/voxelcore/commit/717d41e7a544d657ae8b27397b5c5dbd9fb50b80) +- [fix skeleton:get_model](https://github.com/MihailRis/voxelcore/commit/a73c181b0173b4d1c61159e03407cb5f3b3eb3bd) +- [fix iframe.src = ""](https://github.com/MihailRis/voxelcore/commit/e2a65412bc6d49b0b2d264b11cd8df2e2c4e1d8f) +- [fix blank texture overwritten by screen frame output](https://github.com/MihailRis/voxelcore/commit/fa0f87349b5c61ee0ca43d7d6b5b64237c39a6a4) +- [fix stairs model](https://github.com/MihailRis/voxelcore/commit/423685139fe83bb2e571fbdfa41327ce61a64dd0) +- [fix custom models solidity detection](https://github.com/MihailRis/voxelcore/commit/02dbd01e73f2c69168a1ba4c1929c9d5be263718) +- [fix default vcm aabb uv generation](https://github.com/MihailRis/voxelcore/commit/693befcde8d6a4dddfc9049d74d303b027953b25) +- [fix panel extra interval at end](https://github.com/MihailRis/voxelcore/commit/bd4d5f0e4bc8dd1d9652cde42b3c2b13a9924be4) +- [fix xml escapes in attribute values](https://github.com/MihailRis/voxelcore/commit/fc8065e5505654906e59d744ba636753d79e0210) +- [fix Texture::reload](https://github.com/MihailRis/voxelcore/commit/f2018334cb97c7b9a8187eb4e155dbda97b0b1cb) +- [fix side collision](https://github.com/MihailRis/voxelcore/commit/78e27c812a87c8ee2cec1d6605049b9f8535ef2d) +- [fix WorldConverter::createBlockFieldsConvertTasks](https://github.com/MihailRis/voxelcore/commit/fbe992755e70a3b4d321dc7d17981aec512bf0c1) +- [fix heightmap noise multiplier argument](https://github.com/MihailRis/voxelcore/commit/95b9b346ac16a50d3c72423503f579d3d712c392) +- [fix blocks render at the top of the world](https://github.com/MihailRis/voxelcore/commit/8214f1bd096ca3682212ac57648017ab8179948f) +- [fix containers scroll](https://github.com/MihailRis/voxelcore/commit/bf50c37b823cab0a5bc20d8877ae4b5c23eee697) +- [fix typos in comments and log messages](https://github.com/MihailRis/voxelcore/commit/515e27b402fd09a33d0e9800792e15f1f6caa7f8) +- [fix models load functions](https://github.com/MihailRis/voxelcore/commit/395dc15fb6460d5e50c3e613cb1ea46d3332580c) +- [fix rig:set_matrix for nil index](https://github.com/MihailRis/voxelcore/commit/4370eedc0a4324de15916f1a7890295133aa75c3) +- [fix maths_inline mat4.idt(dst)](https://github.com/MihailRis/voxelcore/commit/32876aa9e461afb687ddb1f94a8672bd81543018) +- [fixed packages for arch distro](https://github.com/MihailRis/voxelcore/commit/05cea922eb334607a2ffbb9229b9f22bf6b2dc74) +- [fix weather effects render](https://github.com/MihailRis/voxelcore/commit/9989f8119601b6f8d21eaccc7c554253a5cd5667) +- [fix missing textures load request for vcm](https://github.com/MihailRis/voxelcore/commit/41713e89a4f2a8d83d7dc62f8d25b7e23653c8ca) +- [fix: block fields not inherited](https://github.com/MihailRis/voxelcore/commit/7d0f714cf232809f609862c3a2b793ae84012e5e) +- [fix: validate content pack dependency versions](https://github.com/MihailRis/voxelcore/commit/28b849229c7bd7d52c25aa1f009ff1d342f3f423) +- [fix custom model blocks with disabled ambient-occlusion](https://github.com/MihailRis/voxelcore/commit/56d2ab9f1466b781a45e17298c3b4907c70a40bc) From 2f2da3b56ab5c64c94c47133d1fc32101c686b38 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 20 Sep 2026 17:45:41 +0300 Subject: [PATCH 03/91] =?UTF-8?q?update=20do=D1=81/*/scripting/builtins/li?= =?UTF-8?q?bfile.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/en/scripting/builtins/libfile.md | 6 ++++++ doc/ru/scripting/builtins/libfile.md | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/en/scripting/builtins/libfile.md b/doc/en/scripting/builtins/libfile.md index 0d4374cac..8f4378b44 100644 --- a/doc/en/scripting/builtins/libfile.md +++ b/doc/en/scripting/builtins/libfile.md @@ -163,6 +163,12 @@ file.ext(path: str) --> str Extracts the extension from the path. Example: `world:data/base/config.toml` -> `toml`. +```lua +file.remove_ext(path: string) -> string +``` + +Returns the path without the extension. Example: `world:data/base/config.toml` -> `world:data/base/config`. + ```lua file.prefix(path: str) --> str ``` diff --git a/doc/ru/scripting/builtins/libfile.md b/doc/ru/scripting/builtins/libfile.md index 0d1b9d58c..0c1e03ff6 100644 --- a/doc/ru/scripting/builtins/libfile.md +++ b/doc/ru/scripting/builtins/libfile.md @@ -78,6 +78,9 @@ file.stem(путь: string) -> string -- Извлекает расширение из пути. Пример: `world:data/base/config.toml` -> `toml`. file.ext(путь: string) -> string + +-- Возвращает путь без расширения. Пример: `world:data/base/config.toml` -> `world:data/base/config`. +file.remove_ext(путь: string) -> string ``` ## Директории @@ -145,4 +148,4 @@ file.open(путь: string, режим: string) -> io_stream -- * `/tmp/` или `\\\\.\\pipe\\` добавлять не нужно - движок делает это автоматически. -- * Недоступен режим с `+` file.open_named_pipe(имя: string, режим: string) -> io_stream -``` \ No newline at end of file +``` From f1d8d8cf2eafbfb7f2113957cbef5079ca3dc04c Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 20 Sep 2026 17:47:19 +0300 Subject: [PATCH 04/91] cleanup --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db7f72050..9a53867eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -146,8 +146,8 @@ Table of contents: - math.noise2d - math.sign - network.request -- PlayingTrack:pause -- PlayingTrack:stop +- PlayingTrack:pause +- PlayingTrack:stop - quat.mul - quat.mul_vec3 - rigidbody:set_selectable @@ -156,7 +156,7 @@ Table of contents: - socket:peek_async - string.url_decode - string.url_encode -- table.keys +- table.keys - test.click - test.fill - test.find_by_attr From f2168717bc87734be4aed0197fd1331a1c019814 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 20 Sep 2026 17:55:53 +0300 Subject: [PATCH 05/91] add doc/en/vca.md --- doc/en/vca.md | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 doc/en/vca.md diff --git a/doc/en/vca.md b/doc/en/vca.md new file mode 100644 index 000000000..adde137f6 --- /dev/null +++ b/doc/en/vca.md @@ -0,0 +1,118 @@ +# VCA + +A text-based animation format that uses [VCM](vcm.md) syntax. + +A VCA file consists of a set of directives. The order of the directives does not affect the order in which transformations are applied. + +Directives are applied to the given target, which can be an entity skeleton or a camera. +When targeting a skeleton, the directive specifies the bone name via the `bone` attribute: + +```vcd +@move bone bone_name ... +``` + +Each directive controls a single scalar value, such as x, y, z, etc., specified via the `by` attribute: + +```vcd +@move bone hand by y ... +``` + +Two kinds of curve definitions are currently available, each producing a value `f(t) = x`, where t is time: +- [keyframe curves (curve)](#keyframe-curves) +- [expression curves (func)](#expression-curves) + +## Animation directives + +- `@move` - translates an object/bone +- `@rotate` - rotates an object/bone +- `@scale` - scales an object/bone (multiplier) +- `@zoom` - camera zoom (multiplier) + +## Metadata + +Animation metadata is set in the file via the `configure` directive: +- `fps` - frame rate, used as the divisor when calculating duration +- `frames` - number of animation frames, used as the dividend when calculating duration +- `duration` - explicitly specified duration in seconds (requires `fps` to be specified when keyframes are present) +- `rotation-order` - specifies the order in which Euler angles are applied during rotation (since the format does not take directive order into account). Examples: XYZ, ZYX, YZX. + +Metadata applies globally. Its behavior does not depend on its position in the file, but placing it at the beginning is recommended. + +## Additional + +- `curve` - declares a custom curve type. Specify the curve name `name` and the value expression `func`. + +Two keys, `kl` and `kr`, and the value `t` in the range [0..1] are available in the expression. + +Example: + +`@curve test-linear func (kl.value + (kr.value - kl.value) * t)` + +Custom curves are referenced with a `.` prefix. Example: `@move by y curve .test-linear {...}`. + +## Keyframe curves + +The curve type must be specified via the `curve` attribute: +- `const` - values are not interpolated; they switch when a keyframe is reached +- `linear` - a polyline; linear interpolation is used +- `bezier` - Bézier curve keyframes with explicitly specified left and right tangents (lx, ly, rx, ry) + +Keyframes are described in the following `{...}` block as ordered `@key` directives: + +```vcd +@rotate by z curve linear { + @key ... + @key ... +} +``` + +A keyframe must contain a frame number `frame` and a value `value`. For `bezier` keyframes, the tangents are also specified. + +Example for `curve bezier`: +```vcd +@key frame 138 value 53.00411 lx 127.067 ly 53.00411 rx 138.001 ry 53.00411 +``` + +## Expression curves + +The attribute describes a function `f(t) = x`, where t is time in seconds. + +Example: `func (sin(t * 2.5) + pi)`. + +Operators available in expressions: + +- `a + b` - addition +- `a * b` - multiplication +- `a / b` - division +- `a % b` - modulo +- `a ^ b` - exponentiation + +Constants available in expressions: + +- `pi` - the number π +- `e` - Euler's number + +Functions available in expressions: + +- `sin(x)` - sine of x +- `cos(x)` - cosine of x +- `tan(x)` - tangent of x +- `noise(x, octaves)` - fast 1D noise of x with the given number of octaves +- `noise2d(x, y, octaves)` - 2D noise of x,y with the given number of octaves +- `sign(x)` - an integer indicating the sign of x (-1/0/1) +- `rand(low, high)` - a pseudo-random floating-point number in the range from low to high +- `round(x, places)` - rounds x to the given number of decimal places `places` (optional) +- `floor(x)` - rounds x down to the nearest integer +- `ceil(x)` - rounds x up to the nearest integer +- `exp(x)` - $e^{x}$ +- `min(x, ...)` - returns the smallest of the given arguments +- `max(x, ...)` - returns the largest of the given arguments +- `sqrt(x)` - square root of x +- `log(x)` - $ln({x})$ +- `log10(x)` - $log_{10}({x})$ +- `deg(x)` - converts radians to degrees +- `rad(x)` - converts degrees to radians + + +>[!WARNING] +> Using undocumented functions may have any undocumented consequences. From 68f1524eb90d1bbe76d4859341a340181df92e11 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 20 Sep 2026 17:57:29 +0300 Subject: [PATCH 06/91] update README.md, doc/*/main-page.md to 0.32 --- README.md | 2 +- doc/en/main-page.md | 4 +--- doc/ru/main-page.md | 3 --- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 362ef22a6..72fb19957 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Latest release - [Download](https://github.com/MihailRis/VoxelCore/releases/latest) | [Скачать](https://github.com/MihailRis/VoxelCore/releases/latest) -- [Documentation](https://github.com/MihailRis/VoxelCore/blob/release-0.31/doc/en/main-page.md) | [Документация](https://github.com/MihailRis/VoxelCore/blob/release-0.31/doc/ru/main-page.md) +- [Documentation](https://github.com/MihailRis/VoxelCore/blob/release-0.32/doc/en/main-page.md) | [Документация](https://github.com/MihailRis/VoxelCore/blob/release-0.32/doc/ru/main-page.md) --- diff --git a/doc/en/main-page.md b/doc/en/main-page.md index 65a22ee85..1f91efdc5 100644 --- a/doc/en/main-page.md +++ b/doc/en/main-page.md @@ -1,8 +1,5 @@ # Documentation -> [!WARNING] -> Version is in development. Proceed to [Documentation for 0.31.](https://github.com/MihailRis/voxelcore/blob/release-0.31/doc/en/main-page.md) - ## Sections - [Assets preloading](assets-preload.md) @@ -20,5 +17,6 @@ - [Scripting](scripting.md) - [Text styles](text-styles.md) - [VCM models format](vcm.md) +- [VCM animation format](vca.md) - [World generator engine](world-generator.md) - [XML UI building](xml-ui-layouts.md) diff --git a/doc/ru/main-page.md b/doc/ru/main-page.md index 916202151..b826d9dfd 100644 --- a/doc/ru/main-page.md +++ b/doc/ru/main-page.md @@ -1,8 +1,5 @@ # Документация -> [!WARNING] -> Версия находится в разработке. Перейдите к [документации для 0.31.](https://github.com/MihailRis/voxelcore/blob/release-0.31/doc/ru/main-page.md) - ## Разделы - [XML разметка интерфейса](xml-ui-layouts.md) From 60f184ae43be58c8844f60c22a17d8a101a4ab2e Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 20 Sep 2026 21:58:36 +0300 Subject: [PATCH 07/91] fix file.ext --- dev/tests/filesystem.lua | 5 +++++ res/modules/internal/extensions/file.lua | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dev/tests/filesystem.lua b/dev/tests/filesystem.lua index 38e7c4a04..80c080cdd 100644 --- a/dev/tests/filesystem.lua +++ b/dev/tests/filesystem.lua @@ -1,3 +1,8 @@ +debug.log("file extension") +asserts.equals(nil, file.ext("config:test")) +asserts.equals("cfg", file.ext("config:test.cfg")) +asserts.equals("gz", file.ext("config:test.cfg.gz")) + debug.log("check initial state") assert(file.exists("config:")) diff --git a/res/modules/internal/extensions/file.lua b/res/modules/internal/extensions/file.lua index d308eda9c..b19864cf6 100644 --- a/res/modules/internal/extensions/file.lua +++ b/res/modules/internal/extensions/file.lua @@ -8,7 +8,7 @@ function file.stem(path) end function file.ext(path) - return path:match("%.([^:/\\]+)$") + return path:match("[^:/\\.]%.([^.:/\\]+)$") end function file.prefix(path) From b9b17358a1576e740c4dcf7cf28e553b9d829db0 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 20 Sep 2026 22:01:18 +0300 Subject: [PATCH 08/91] fix file.remove_ext --- dev/tests/filesystem.lua | 1 + res/modules/internal/extensions/file.lua | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dev/tests/filesystem.lua b/dev/tests/filesystem.lua index 80c080cdd..cb5a052ac 100644 --- a/dev/tests/filesystem.lua +++ b/dev/tests/filesystem.lua @@ -2,6 +2,7 @@ debug.log("file extension") asserts.equals(nil, file.ext("config:test")) asserts.equals("cfg", file.ext("config:test.cfg")) asserts.equals("gz", file.ext("config:test.cfg.gz")) +asserts.equals("config:test.cfg", file.remove_ext("config:test.cfg.gz")) debug.log("check initial state") assert(file.exists("config:")) diff --git a/res/modules/internal/extensions/file.lua b/res/modules/internal/extensions/file.lua index b19864cf6..6d5dc30ba 100644 --- a/res/modules/internal/extensions/file.lua +++ b/res/modules/internal/extensions/file.lua @@ -24,7 +24,11 @@ function file.parent(path) end function file.remove_ext(path) - return string.format("%s/%s", file.parent(path), file.stem(path)) + local ext = file.ext(path) + if not ext then + return path + end + return path:sub(1, -#ext - 2) end function file.path(path) From 138e97e0c4371fbbca611c4c8f7d929f9bf03b6b Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 21 Sep 2026 01:09:55 +0300 Subject: [PATCH 09/91] update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a53867eb..2310c40f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -189,6 +189,8 @@ New overloads: ## Fixes +- [fix slow xml/vcm loading in Windows](https://github.com/MihailRis/voxelcore/pull/983) +- [fix file.ext](https://github.com/MihailRis/voxelcore/commit/b9b17358a1576e740c4dcf7cf28e553b9d829db0) - [fix stack_vector](https://github.com/MihailRis/voxelcore/commit/1fbf16e3dcf145f322849b182be20bac1272a82b) - [fix audio.input.request_open](https://github.com/MihailRis/voxelcore/commit/8a19c903e44b7569a38e470ec7b260a03cd4d673) - [fix: block/item.properties not inheriting parent content unit properties](https://github.com/MihailRis/voxelcore/commit/a9d185256ae14789c17b005b27f7be94895f7dca) From c573d01cb7dcb32a85bfda67d912498a45a8730d Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 23 Sep 2026 22:26:54 +0300 Subject: [PATCH 10/91] add 'texture' vca directive --- res/modules/animation.lua | 3 ++- res/modules/internal/animation_codegen.lua | 22 ++++++++++++++++---- res/modules/internal/formats/vca.lua | 24 +++++++++++++++++++--- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 3f6acf351..e6b00e7ca 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -42,13 +42,14 @@ local this = { CH_ROTATE = 2, CH_SCALE = 3, CH_ZOOM = 4, + CH_TEXTURE = 5, INT_CONST = 1, INT_LINEAR = 2, INT_BEZIER = 3, INT_CUSTOM = 4, - TRACE_CODEGEN = false, + TRACE_CODEGEN = true, maths = { bezier_interpolation = bezier_interpolation diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 0b2cd7ce3..7eadfb4e6 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -60,6 +60,11 @@ local env = { Y = {0, 1, 0}, Z = {0, 0, 1}, DST = mat4.idt(), + string_at = function(keys, frame) + local left, _ = key_neighbors(keys, frame) + left = keys[left] + return left.value + end, value_at = function(keys, frame, interp) local left, right = key_neighbors(keys, frame) if left == right then @@ -147,6 +152,10 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) code = code .. string.format( "\n local l%d = value_at_custom(keysets['%s'][%d], t * %s, %s)", i, lineset.target_name, i, raw_track.fps, valueat) + elseif line.channel == animation.CH_TEXTURE then + code = code .. string.format( + "\n local l%d = string_at(keysets['%s'][%d], t * %s)", + i, lineset.target_name, i, raw_track.fps) else code = code .. string.format( "\n local l%d = value_at(keysets['%s'][%d], t * %s, %s)", @@ -164,7 +173,9 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) scale[line.axis] = i has_tsf = true elseif line.channel == animation.CH_ZOOM then - code = code .. "\n zoom = l" .. i + code = code .. "\n zoom = l" .. i + elseif line.channel == animation.CH_TEXTURE then + code = code .. string.format("\n target:set_texture(%s, %s)", lineset.target_name:escape(), "l"..i) end end @@ -206,14 +217,17 @@ local function codegen_rig_target(raw_track, context) local code = "\n if target.set_matrix and target.index then\n" code = code .. " local dst = DST\n" for bone, lineset in pairs(raw_track.linesets) do - if lineset.target_type ~= "bone" then + if lineset.target_type ~= "bone" and lineset.target_type ~= "texture" then goto continue end local lineset_code = codegen_track( raw_track, lineset, context.memoised, context.keysets, true) - code = code .. "\n do" .. lineset_code .. "\n end\n" .. - " target:set_matrix(target:index(" .. string.escape(bone) .. "), dst)\n" + code = code .. "\n do" .. lineset_code .. "\n end\n" + if lineset.target_type == "bone" then + code = code .. + " target:set_matrix(target:index(" .. string.escape(bone) .. "), dst)\n" + end ::continue:: end return code .. " end" diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index f06c99a7b..e22e220eb 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -7,6 +7,7 @@ local action_to_channel = { rotate = animation.CH_ROTATE, scale = animation.CH_SCALE, zoom = animation.CH_ZOOM, + texture = animation.CH_TEXTURE, } local curve_to_interp = { @@ -50,6 +51,17 @@ local function parse_curve(line, node) end end +local function parse_simple_frames(line, node) + line.keys = {} + for j, key_node in ipairs(node) do + local keyframe = { + frame = tonumber(key_node.frame), + value = key_node.value, + } + table.insert(line.keys, keyframe) + end +end + local function parse_track(root) local raw_track = { duration = math.huge, @@ -74,8 +86,10 @@ local function parse_track(root) local target_type = nil if node.bone then target_type = "bone" + elseif tag == "texture" then + target_type = "texture" end - local target_name = node.bone or "" + local target_name = node.bone or node.name or "" local lineset = linesets[target_name] if not lineset then lineset = { @@ -86,16 +100,20 @@ local function parse_track(root) linesets[target_name] = lineset end + local channel = action_to_channel[tag] + if not channel then + error("unknown directive " .. tag:escape()) + end local line = { axis = node.by and ("xyz"):find(node.by) or "", - channel = action_to_channel[tag] + channel = channel } if node.func then line.expression = node.func elseif node.curve then parse_curve(line, node) else - error("not implemented") + parse_simple_frames(line, node) end table.insert(lineset.lines, line) From 8b4cfd1099810033ece6781a00f9f9b69ff8dcb3 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 23 Sep 2026 22:27:12 +0300 Subject: [PATCH 11/91] disable codegen trace --- res/modules/animation.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index e6b00e7ca..cbed8a941 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -49,7 +49,7 @@ local this = { INT_BEZIER = 3, INT_CUSTOM = 4, - TRACE_CODEGEN = true, + TRACE_CODEGEN = false, maths = { bezier_interpolation = bezier_interpolation From 325db431bdcf0ee563a7df0b1a5ecfd7fe71448a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 23 Sep 2026 22:36:09 +0300 Subject: [PATCH 12/91] update doc/*/vca.md --- doc/en/vca.md | 13 +++++++++++++ doc/ru/vca.md | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/doc/en/vca.md b/doc/en/vca.md index adde137f6..d8c0c238f 100644 --- a/doc/en/vca.md +++ b/doc/en/vca.md @@ -27,6 +27,7 @@ Two kinds of curve definitions are currently available, each producing a value ` - `@rotate` - rotates an object/bone - `@scale` - scales an object/bone (multiplier) - `@zoom` - camera zoom (multiplier) +- `@texture` - change of a dynamically assigned texture (see [skeleton:set_texture](scripting/ecs.md#skeleton)) ## Metadata @@ -73,6 +74,18 @@ Example for `curve bezier`: @key frame 138 value 53.00411 lx 127.067 ly 53.00411 rx 138.001 ry 53.00411 ``` +For the `texture` directive, it is simpler. Example: + +```vcd +@texture name $0 { + @key frame 0 value entities/tireman:face_0 + @key frame 24 value entities/tireman:face_1 +} +``` + +> Here, `entities/tireman` is the name of the texture atlas containing `face_*` textures. +> The texture does not necessarily have to be in an atlas. + ## Expression curves The attribute describes a function `f(t) = x`, where t is time in seconds. diff --git a/doc/ru/vca.md b/doc/ru/vca.md index 795541dc1..c4d97c2ec 100644 --- a/doc/ru/vca.md +++ b/doc/ru/vca.md @@ -27,6 +27,7 @@ VCA файл состоит из набора директив, порядок - `@rotate` - поворот объекта/кости - `@scale` - масштабирование объекта/кости (множитель) - `@zoom` - масштаб камеры (множитель) +- `@texture` - смена динамически-назначаемой текстуры (см. [skeleton:set_texture](scripting/ecs.md#skeleton)) ## Мета-информация @@ -73,6 +74,18 @@ VCA файл состоит из набора директив, порядок @key frame 138 value 53.00411 lx 127.067 ly 53.00411 rx 138.001 ry 53.00411 ``` +Для директивы texture всё проще. Пример: + +```vcd +@texture name $0 { + @key frame 0 value entities/tireman:face_0 + @key frame 24 value entities/tireman:face_1 +} +``` + +> entities/tireman здесь - имя текстурного атласа, в котором находятся face_\* текстуры. +> Текстура не обязательно должна находиться в атласе. + ## Кривые через выражения Через атрибут описывается функция `f(t) = x` где t - время в секундах. From 3de6d7f4025f310426a5111fa6ce047e190888f1 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 24 Sep 2026 12:35:53 +0300 Subject: [PATCH 13/91] fix camera exponentially shaking --- src/logic/PlayerController.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/logic/PlayerController.cpp b/src/logic/PlayerController.cpp index 2a63f131b..891c4c086 100644 --- a/src/logic/PlayerController.cpp +++ b/src/logic/PlayerController.cpp @@ -104,6 +104,8 @@ void CameraControl::updateMouse(PlayerInput& input, int windowHeight) { glm::vec3 CameraControl::updateCameraShaking( const Hitbox& hitbox, float delta ) { + delta = glm::min(delta, 0.1f); + glm::vec3 offset {}; const float k = CAM_SHAKE_DELTA_K; const float ov = CAM_SHAKE_OFFSET_Y; From 77b9de34640686198ebbc357444932dac77056b4 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 25 Sep 2026 17:14:23 +0300 Subject: [PATCH 14/91] add Mozilla Public License Version 2.0 --- LICENSE | 373 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 373 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..d0a1fa148 --- /dev/null +++ b/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at https://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. From d0cc59ad3ad2d7348ed82e4cd560fc9684150a1a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 25 Sep 2026 20:37:24 +0300 Subject: [PATCH 15/91] add 'cull-face' parameter to `tri` and `rect` primitives --- src/coders/vcm.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/coders/vcm.cpp b/src/coders/vcm.cpp index 42a503477..a1ca758de 100644 --- a/src/coders/vcm.cpp +++ b/src/coders/vcm.cpp @@ -198,6 +198,31 @@ static void perform_rect(const xmlelement& root, ModelBuilder& builder) { } else { normal = glm::cross(glm::normalize(right), glm::normalize(up)); } + + auto cullFace = root.attr("cull-face", "back").getText(); + if (cullFace == "front") { + normal *= -1.0f; + } else if (cullFace == "off") { + builder.addRect( + texture, + shading, + from + right * 0.5f + up * 0.5f, + right * 0.5f, + up * 0.5f, + normal, + region + ); + builder.addRect( + texture, + shading, + from + right * 0.5f + up * 0.5f, + right * -0.5f, + up * -0.5f, + -normal, + region + ); + return; + } builder.addRect( texture, shading, @@ -246,6 +271,17 @@ static void perform_triangle(const xmlelement& root, ModelBuilder& builder) { } std::string texture = root.attr("texture", "$0").getText(); + + auto cullFace = root.attr("cull-face", "back").getText(); + if (cullFace == "front") { + std::swap(pointB, pointC); + std::swap(uvs[1], uvs[2]); + normal *= -1.0f; + } else if (cullFace == "off") { + builder.addTriangle(texture, shading, pointA, pointB, pointC, normal, uvs[0], uvs[1], uvs[2]); + builder.addTriangle(texture, shading, pointA, pointC, pointB, -normal, uvs[0], uvs[2], uvs[1]); + return; + } builder.addTriangle(texture, shading, pointA, pointB, pointC, normal, uvs[0], uvs[1], uvs[2]); } From 60f74ae54ac13c8ee16e6ff41583e14f196e27ff Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 25 Sep 2026 20:39:22 +0300 Subject: [PATCH 16/91] update doc/*/vcm.md --- doc/en/vcm.md | 2 ++ doc/ru/vcm.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/doc/en/vcm.md b/doc/en/vcm.md index 116d9a1d6..b09c615a4 100644 --- a/doc/en/vcm.md +++ b/doc/en/vcm.md @@ -42,6 +42,7 @@ This primitive describes a triangle. - `region-scale` - multiplier vector for the UV region. Example: `region-scale (0.5,1)` - `shading` - determines whether shading is enabled on the primitive. Example: `shading off` - `normal` - overrides normal vector. Example: `normal (0,1,0)` +- `cull-face` - determines which side will be culled. Example: `cull-face front` or `cull-face off` (disables face culling) By default, texture coordinates are not affected by shape or size, unlike other primitives. @@ -58,6 +59,7 @@ This primitive describes a parallelogram using the right and up vectors. - `shading` - determines whether shading is enabled on the primitive. Example: `shading off` - `flip` - flips the UV region horizontally or vertically. Example: `flip v` - `normal` - overrides normal vector. Example: `normal (0,1,0)` +- `cull-face` - determines which side will be culled. Example: `cull-face front` or `cull-face off` (disables face culling) ### `box` Properties diff --git a/doc/ru/vcm.md b/doc/ru/vcm.md index 335f6a7a7..0a1dbc314 100644 --- a/doc/ru/vcm.md +++ b/doc/ru/vcm.md @@ -42,6 +42,7 @@ - `region-scale` вектор-множитель для UV региона. Пример: `region-scale (0.5,1)` - `shading` определяет возможность затенения на примитиве. Пример: `shading off` - `normal` переопределяет вектор нормали. Пример: `normal (0,1,0)` +- `cull-face` - определяет, какая сторона будет отсечена. Пример: `cull-face front` или `cull-face off` (отлючает отсечение сторон) Текстурные координаты по-умолчанию не зависят от формы из размера, в отличие от других примитивов. @@ -58,6 +59,7 @@ - `shading` - определяет возможность затенения на примитиве. Пример: `shading off` - `flip` - отражает UV регион по горизонтали или вертикали. Пример: `flip v` - `normal` - переопределяет вектор нормали. Пример: `normal (0,1,0)` +- `cull-face` - определяет, какая сторона будет отсечена. Пример: `cull-face front` или `cull-face off` (отлючает отсечение сторон) ### Свойства `box` From 5310de45f0261dfcf2d4ad4ff1fc7e7a84b4b659 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 25 Sep 2026 23:32:59 +0300 Subject: [PATCH 17/91] fix: cos function is not available in VCA expressions --- res/modules/internal/animation_codegen.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 7eadfb4e6..66db0bed4 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -121,7 +121,7 @@ local env = { local math_funcs = { "sqrt", "min", "max", "deg", "rad", "log", "log10", "floor", "ceil", "sin", - "tan", "noise", "noise2", "sign", "round", "exp", "pi", "e" + "cos", "tan", "noise", "noise2", "sign", "round", "exp", "pi", "e" } for _, name in ipairs(math_funcs) do env[name] = math[name] From e485aedc8ee41184bf6dd229945601ccae83f4f4 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 25 Sep 2026 23:56:32 +0300 Subject: [PATCH 18/91] add 'period' keyframes-based line parameter --- res/modules/animation.lua | 3 ++- res/modules/internal/animation_codegen.lua | 12 ++++++------ res/modules/internal/formats/vca.lua | 4 +++- res/scripts/components/animator.lua | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index cbed8a941..35a77b78e 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -48,8 +48,9 @@ local this = { INT_LINEAR = 2, INT_BEZIER = 3, INT_CUSTOM = 4, + ALMOST_HUGE = 1e9, - TRACE_CODEGEN = false, + TRACE_CODEGEN = true, maths = { bezier_interpolation = bezier_interpolation diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 66db0bed4..316dd22b3 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -150,16 +150,16 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) local valueat = string.format("curves[%s]", string.escape(line.curve_func)) code = code .. string.format( - "\n local l%d = value_at_custom(keysets['%s'][%d], t * %s, %s)", - i, lineset.target_name, i, raw_track.fps, valueat) + "\n local l%d = value_at_custom(keysets['%s'][%d], t * %s %% %s, %s)", + i, lineset.target_name, i, raw_track.fps, line.period, valueat) elseif line.channel == animation.CH_TEXTURE then code = code .. string.format( - "\n local l%d = string_at(keysets['%s'][%d], t * %s)", - i, lineset.target_name, i, raw_track.fps) + "\n local l%d = string_at(keysets['%s'][%d], t * %s %% %s)", + i, lineset.target_name, i, raw_track.fps, line.period) else code = code .. string.format( - "\n local l%d = value_at(keysets['%s'][%d], t * %s, %s)", - i, lineset.target_name, i, raw_track.fps, line.interp) + "\n local l%d = value_at(keysets['%s'][%d], t * %s %% %s, %s)", + i, lineset.target_name, i, raw_track.fps, line.period, line.interp) end end diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index e22e220eb..99f03f15b 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -106,8 +106,10 @@ local function parse_track(root) end local line = { axis = node.by and ("xyz"):find(node.by) or "", - channel = channel + channel = channel, + period = node.period or animation.ALMOST_HUGE } + debug.print(animation.ALMOST_HUGE) if node.func then line.expression = node.func elseif node.curve then diff --git a/res/scripts/components/animator.lua b/res/scripts/components/animator.lua index 5bd3ef4fa..9fc5735fe 100644 --- a/res/scripts/components/animator.lua +++ b/res/scripts/components/animator.lua @@ -1,4 +1,4 @@ -local ALMOST_HUGE = 1e9 +local ALMOST_HUGE = animation.ALMOST_HUGE local rig = entity.skeleton From 0dfc87700d5723e6958dd6021791d897996b2001 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 25 Sep 2026 23:58:42 +0300 Subject: [PATCH 19/91] cleanup --- res/modules/animation.lua | 5 +++-- res/modules/internal/formats/vca.lua | 3 +-- res/scripts/components/animator.lua | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 35a77b78e..411623364 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -48,9 +48,10 @@ local this = { INT_LINEAR = 2, INT_BEZIER = 3, INT_CUSTOM = 4, - ALMOST_HUGE = 1e9, + MAX_DURATION = 1e9, + MAX_FRAMES = 1e9, - TRACE_CODEGEN = true, + TRACE_CODEGEN = false, maths = { bezier_interpolation = bezier_interpolation diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index 99f03f15b..4ecf4c895 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -107,9 +107,8 @@ local function parse_track(root) local line = { axis = node.by and ("xyz"):find(node.by) or "", channel = channel, - period = node.period or animation.ALMOST_HUGE + period = node.period or animation.MAX_FRAMES } - debug.print(animation.ALMOST_HUGE) if node.func then line.expression = node.func elseif node.curve then diff --git a/res/scripts/components/animator.lua b/res/scripts/components/animator.lua index 9fc5735fe..611ffa6f8 100644 --- a/res/scripts/components/animator.lua +++ b/res/scripts/components/animator.lua @@ -1,4 +1,4 @@ -local ALMOST_HUGE = animation.ALMOST_HUGE +local MAX_DURATION = animation.MAX_DURATION local rig = entity.skeleton @@ -54,7 +54,7 @@ local function update(delta) if state.track and intensity > 0.0 then state.track.func( rig, - state.timer % math.min(ALMOST_HUGE, state.track.duration), + state.timer % math.min(MAX_DURATION, state.track.duration), intensity * state.max_intencity ) end From 926bfc545d479046949217f1e813e0ca7d223db4 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 00:03:03 +0300 Subject: [PATCH 20/91] update doc/*/vca.md --- doc/en/vca.md | 10 ++++++++++ doc/ru/vca.md | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/doc/en/vca.md b/doc/en/vca.md index d8c0c238f..7b2bda0b5 100644 --- a/doc/en/vca.md +++ b/doc/en/vca.md @@ -86,6 +86,16 @@ For the `texture` directive, it is simpler. Example: > Here, `entities/tireman` is the name of the texture atlas containing `face_*` textures. > The texture does not necessarily have to be in an atlas. +If you do not wish to limit the animation duration via `configure` but want to loop the keyframe animation for a specific line, you can use the `period` parameter to specify the animation's repetition period in frames. Example: + +```vcd +@move by y curve linear period 24 { + @key frame 0 value 0 + @key frame 12 value 1 + @key frame 24 value 0 +} +``` + ## Expression curves The attribute describes a function `f(t) = x`, where t is time in seconds. diff --git a/doc/ru/vca.md b/doc/ru/vca.md index c4d97c2ec..2cba3c3ab 100644 --- a/doc/ru/vca.md +++ b/doc/ru/vca.md @@ -86,6 +86,16 @@ VCA файл состоит из набора директив, порядок > entities/tireman здесь - имя текстурного атласа, в котором находятся face_\* текстуры. > Текстура не обязательно должна находиться в атласе. +Если вы не хотите ограничивать длительность анимации через `configure`, но хотите зациклить анимацию по ключевым кадрам для конкретной линии, то можно использовать параметр `period` для указания периода повторения анимации в кадрах. Пример: + +```vcd +@move by y curve linear period 24 { + @key frame 0 value 0 + @key frame 12 value 1 + @key frame 24 value 0 +} +``` + ## Кривые через выражения Через атрибут описывается функция `f(t) = x` где t - время в секундах. From f5de330f3f7f3a324886a867a11d8525d5402369 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 18:07:45 +0300 Subject: [PATCH 21/91] fix abs function is not available in VCA expressions --- res/modules/internal/animation_codegen.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 316dd22b3..dc6a29f0e 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -121,7 +121,7 @@ local env = { local math_funcs = { "sqrt", "min", "max", "deg", "rad", "log", "log10", "floor", "ceil", "sin", - "cos", "tan", "noise", "noise2", "sign", "round", "exp", "pi", "e" + "cos", "tan", "abs", "noise", "noise2", "sign", "round", "exp", "pi", "e" } for _, name in ipairs(math_funcs) do env[name] = math[name] From e467c85adc7748091790b66fe5e7dbaeca4416a1 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 19:13:08 +0300 Subject: [PATCH 22/91] add 'enable-fog' setting --- res/shaders/lib/fog.glsl | 4 ++++ src/graphics/render/WorldRenderer.cpp | 3 +++ src/io/settings_io.cpp | 1 + src/settings.hpp | 2 ++ 4 files changed, 10 insertions(+) diff --git a/res/shaders/lib/fog.glsl b/res/shaders/lib/fog.glsl index 597380bb6..9d20317f7 100644 --- a/res/shaders/lib/fog.glsl +++ b/res/shaders/lib/fog.glsl @@ -8,12 +8,16 @@ uniform float u_weatherFogDencity; uniform float u_weatherFogCurve; float calc_fog(float depth, float fogFactor, float fogCurve) { +#ifdef ENABLE_FOG return min( 1.0, max(pow(depth * u_fogFactor * fogFactor, u_fogCurve * fogCurve), min(pow(depth * u_weatherFogDencity, u_weatherFogCurve), u_weatherFogOpacity)) ); +#else + return 0.0; +#endif } float calc_fog(float depth) { diff --git a/src/graphics/render/WorldRenderer.cpp b/src/graphics/render/WorldRenderer.cpp index f3b793c0a..27dd4dcdd 100644 --- a/src/graphics/render/WorldRenderer.cpp +++ b/src/graphics/render/WorldRenderer.cpp @@ -135,6 +135,7 @@ WorldRenderer::WorldRenderer( debugLines = std::make_unique(level); cloudsRenderer = std::make_unique(); + keepAlive(observe_setting(settings.graphics.enableFog, dirtySettings)); keepAlive(observe_setting(settings.graphics.advancedRender, dirtySettings)); keepAlive(observe_setting(settings.graphics.shadowsQuality, dirtySettings)); keepAlive(observe_setting(settings.graphics.ssao, dirtySettings)); @@ -156,10 +157,12 @@ void WorldRenderer::refreshSettings() { gbufferPipeline = graphics.advancedRender.get(); int shadowsQuality = graphics.shadowsQuality.get() * gbufferPipeline; + bool enableFog = graphics.enableFog.get(); shadowMapping->setQuality(shadowsQuality); std::vector defines; if (shadowsQuality != 0) defines.emplace_back("ENABLE_SHADOWS"); + if (enableFog) defines.emplace_back("ENABLE_FOG"); if (graphics.ssao.get()) defines.emplace_back("ENABLE_SSAO"); if (gbufferPipeline) defines.emplace_back("ADVANCED_RENDER"); diff --git a/src/io/settings_io.cpp b/src/io/settings_io.cpp index 8e8b0a2dc..e72cb009d 100644 --- a/src/io/settings_io.cpp +++ b/src/io/settings_io.cpp @@ -69,6 +69,7 @@ SettingsHandler::SettingsHandler(EngineSettings& settings) { builder.add("padding", &settings.chunks.padding); builder.addSection("graphics"); + builder.add("enable-fog", &settings.graphics.enableFog); builder.add("fog-curve", &settings.graphics.fogCurve); builder.add("backlight", &settings.graphics.backlight); builder.add("dense-render", &settings.graphics.denseRender); diff --git a/src/settings.hpp b/src/settings.hpp index bc83ba345..320d0fc8d 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -63,6 +63,8 @@ struct CameraSettings { }; struct GraphicsSettings { + /// @brief Enable fog + FlagSetting enableFog {true}; /// @brief Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance. /// 1.0 is linear, 2.0 is quadratic NumberSetting fogCurve {1.0f, 1.0f, 6.0f}; From cdc5302dd1bff8fe8c9e6472e88eb9f8da168f2d Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 19:18:29 +0300 Subject: [PATCH 23/91] add 'Fog' settings to ui --- res/layouts/pages/settings_graphics.xml | 2 +- res/layouts/pages/settings_graphics.xml.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/res/layouts/pages/settings_graphics.xml b/res/layouts/pages/settings_graphics.xml index 2aa3aeca3..7567d5c8d 100644 --- a/res/layouts/pages/settings_graphics.xml +++ b/res/layouts/pages/settings_graphics.xml @@ -1,2 +1,2 @@ - + diff --git a/res/layouts/pages/settings_graphics.xml.lua b/res/layouts/pages/settings_graphics.xml.lua index 6a4596a04..ed249b0f3 100644 --- a/res/layouts/pages/settings_graphics.xml.lua +++ b/res/layouts/pages/settings_graphics.xml.lua @@ -40,6 +40,7 @@ function on_open() create_trackbar_setting("chunks.load-speed", "Load Speed", 1) create_trackbar_setting("graphics.fog-curve", "Fog Curve", 0.1) + create_checkbox("graphics.enable-fog", "Fog", "graphics.enable-fog.tooltip") create_checkbox("graphics.backlight", "Backlight", "graphics.backlight.tooltip") create_checkbox("graphics.soft-lighting", "Soft lighting", "graphics.soft-lighting.tooltip") create_checkbox("graphics.dense-render", "Dense blocks render", "graphics.dense-render.tooltip") From cbe2a27e346436648f0aef3ce8cdae33aa3ddcba Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 19:21:00 +0300 Subject: [PATCH 24/91] update en_US.txt, ru_RU.txt --- res/texts/en_US.txt | 1 + res/texts/ru_RU.txt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/res/texts/en_US.txt b/res/texts/en_US.txt index ff44ec754..294758a7e 100644 --- a/res/texts/en_US.txt +++ b/res/texts/en_US.txt @@ -19,6 +19,7 @@ devtools.output=Output # Tooltips audio.acoustic-effects.tooltip=Acoustic effects may not be supported by your system audio.recording-enabled.tooltip=Enables audio recording features +graphics.enable-fog.tooltip=Enables fog graphics.gamma.tooltip=Lighting brightness curve graphics.backlight.tooltip=Backlight to prevent total darkness graphics.dense-render.tooltip=Enables transparency in blocks like leaves diff --git a/res/texts/ru_RU.txt b/res/texts/ru_RU.txt index ed3bb9686..295d467af 100644 --- a/res/texts/ru_RU.txt +++ b/res/texts/ru_RU.txt @@ -40,6 +40,7 @@ pack.remove-confirm=Удалить весь поставляемый паком/ # Подсказки audio.acoustic-effects.tooltip=Акустические эффекты могут не поддерживаться системой audio.recording-enabled.tooltip=Включает функции записи звука +graphics.enable-fog.tooltip=Отображать туман / дымку graphics.gamma.tooltip=Кривая яркости освещения graphics.backlight.tooltip=Подсветка, предотвращающая полную темноту graphics.dense-render.tooltip=Включает прозрачность блоков, таких как листья @@ -89,6 +90,7 @@ settings.Soft lighting=Мягкое освещение settings.Camera Shaking=Тряска Камеры settings.Camera Inertia=Инерция Камеры settings.Camera FOV Effects=Эффекты поля зрения +settings.Fog=Туман settings.Fog Curve=Кривая Тумана settings.FOV=Поле Зрения settings.Fullscreen=Полный экран From 4f1411b005859a510fe8d8f1af8db9b848dd4454 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 19:51:08 +0300 Subject: [PATCH 25/91] fix infinite recursion on moveInto used to move to descendant node --- src/graphics/ui/elements/UINode.cpp | 4 ++-- src/graphics/ui/elements/UINode.hpp | 2 +- src/logic/scripting/lua/libs/libgui.cpp | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/graphics/ui/elements/UINode.cpp b/src/graphics/ui/elements/UINode.cpp index 85347b9a8..918d30b65 100644 --- a/src/graphics/ui/elements/UINode.cpp +++ b/src/graphics/ui/elements/UINode.cpp @@ -376,14 +376,14 @@ void UINode::setGravity(Gravity gravity) { } } -bool UINode::isSubnodeOf(const UINode* node) { +bool UINode::isDescendantOf(const UINode* node) { if (parent == nullptr) { return false; } if (parent == node) { return true; } - return parent->isSubnodeOf(node); + return parent->isDescendantOf(node); } void UINode::getIndices( diff --git a/src/graphics/ui/elements/UINode.hpp b/src/graphics/ui/elements/UINode.hpp index a7b18390c..4f6145f08 100644 --- a/src/graphics/ui/elements/UINode.hpp +++ b/src/graphics/ui/elements/UINode.hpp @@ -290,7 +290,7 @@ namespace gui { virtual void setGravity(Gravity gravity); - bool isSubnodeOf(const UINode* node); + bool isDescendantOf(const UINode* node); /// @brief collect all nodes having id static void getIndices( diff --git a/src/logic/scripting/lua/libs/libgui.cpp b/src/logic/scripting/lua/libs/libgui.cpp index 389bedc9a..dc4806d00 100644 --- a/src/logic/scripting/lua/libs/libgui.cpp +++ b/src/logic/scripting/lua/libs/libgui.cpp @@ -165,6 +165,13 @@ static int l_container_set_interval(lua::State* L) { static int l_move_into(lua::State* L) { auto node = get_document_node(L, 1); auto dest = get_document_node(L, 2); + if (dest.node == nullptr) { + return 0; + } + if (dest.node->isDescendantOf(node.node.get())) { + luaL_error(L, "unable to move element to its descendant"); + return 0; + } UINode::moveInto( node.node, std::dynamic_pointer_cast(dest.node) ); From c3b50b5ab2ebc88719e25f8964d70a4f389e389f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 20:28:20 +0300 Subject: [PATCH 26/91] fix recursive iframe --- src/graphics/ui/elements/InlineFrame.cpp | 6 +++++- src/graphics/ui/elements/UINode.cpp | 4 ++++ src/graphics/ui/elements/UINode.hpp | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/graphics/ui/elements/InlineFrame.cpp b/src/graphics/ui/elements/InlineFrame.cpp index eeef50e47..8699fd70b 100644 --- a/src/graphics/ui/elements/InlineFrame.cpp +++ b/src/graphics/ui/elements/InlineFrame.cpp @@ -25,8 +25,12 @@ void InlineFrame::setDocument(const std::shared_ptr& document) { if (document == nullptr) { return; } + auto newRoot = document->getRoot(); + if (newRoot->hasParent()) { + return; + } this->document = document; - this->root = document->getRoot(); + this->root = std::move(newRoot); add(root); root->setSize(size); diff --git a/src/graphics/ui/elements/UINode.cpp b/src/graphics/ui/elements/UINode.cpp index 918d30b65..3f099d2b8 100644 --- a/src/graphics/ui/elements/UINode.cpp +++ b/src/graphics/ui/elements/UINode.cpp @@ -60,6 +60,10 @@ bool UINode::isHover() const { return hover; } +bool UINode::hasParent() const { + return parent != nullptr; +} + void UINode::setParent(UINode* node) { parent = node; } diff --git a/src/graphics/ui/elements/UINode.hpp b/src/graphics/ui/elements/UINode.hpp index 4f6145f08..f22487323 100644 --- a/src/graphics/ui/elements/UINode.hpp +++ b/src/graphics/ui/elements/UINode.hpp @@ -176,6 +176,7 @@ namespace gui { void setMouseOver(bool flag); virtual void setParent(UINode* node); + bool hasParent() const; UINode* getParent() const; std::shared_ptr getParentShared() const; From 273682355a32827658568757a76830864249a12d Mon Sep 17 00:00:00 2001 From: nogitsune-youkai Date: Sat, 26 Sep 2026 19:30:06 +0300 Subject: [PATCH 27/91] Fix exception safety in util::stack_vector::push_back --- src/util/stack_vector.hpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/util/stack_vector.hpp b/src/util/stack_vector.hpp index 715ca3717..a58777845 100644 --- a/src/util/stack_vector.hpp +++ b/src/util/stack_vector.hpp @@ -48,21 +48,25 @@ namespace util { } void push_back(const T& value) { - if (size_ < capacity) { - auto data = reinterpret_cast(data_.ptr() + (size_++)); - new (data) T(value); - } else { + if (size_ >= capacity) { throw std::overflow_error("stack vector capacity exceeded"); } + + void* p = data_.data + size_ * sizeof(T); + ::new (p) T(value); + + ++size_; } void push_back(T&& value) { - if (size_ < capacity) { - auto data = reinterpret_cast(data_.ptr() + (size_++)); - new (data) T(std::move(value)); - } else { + if (size_ >= capacity) { throw std::overflow_error("stack vector capacity exceeded"); } + + void* p = data_.data + size_ * sizeof(T); + ::new (p) T(std::move(value)); + + ++size_; } void pop_back() { @@ -76,7 +80,7 @@ namespace util { void clear() { for (int i = 0; i < size_; ++i) { - data_.ptr()[i].~T(); + data_.ptr()[i].~T(); } size_ = 0; } From dc62ccfbc1f2538ed2f943112604e3eea4e0101b Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 22:40:17 +0300 Subject: [PATCH 28/91] update CHANGELOG.md --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2310c40f4..5fcf1f222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,8 @@ Table of contents: - `normal` attribute for `tri` and `rect` VCM primitives - `lighting-mode` entity property - vca syntax highlighting +- `cull-face` property for `tri` and `rect` VCM primitives +- `graphics.enable-fog` setting ## New Functions @@ -125,7 +127,7 @@ Table of contents: - ctypes.uint8 - entities.def_solid - events.remove -- file.remove_ext +- file.remove_ext - gfx.text3d.get_entity - gfx.text3d.set_entity - gui.screenshot @@ -189,6 +191,10 @@ New overloads: ## Fixes +- [fix exception safety in util::stack_vector::push_back](https://github.com/MihailRis/voxelcore/commit/273682355a32827658568757a76830864249a12d) +- [fix recursive iframe](https://github.com/MihailRis/voxelcore/commit/c3b50b5ab2ebc88719e25f8964d70a4f389e389f) +- [fix infinite recursion on moveInto used to move to descendant node](https://github.com/MihailRis/voxelcore/commit/4f1411b005859a510fe8d8f1af8db9b848dd4454) +- [fix camera exponentially shaking](https://github.com/MihailRis/voxelcore/commit/3de6d7f4025f310426a5111fa6ce047e190888f1) - [fix slow xml/vcm loading in Windows](https://github.com/MihailRis/voxelcore/pull/983) - [fix file.ext](https://github.com/MihailRis/voxelcore/commit/b9b17358a1576e740c4dcf7cf28e553b9d829db0) - [fix stack_vector](https://github.com/MihailRis/voxelcore/commit/1fbf16e3dcf145f322849b182be20bac1272a82b) From 6b36992119898d770c18b02dd431f074562d2525 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 23:09:40 +0300 Subject: [PATCH 29/91] make VCA animation line intensity multiplier implicit --- res/modules/internal/animation_codegen.lua | 17 ++++++++++++++--- src/engine/Time.hpp | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index dc6a29f0e..97deab9df 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -15,7 +15,13 @@ local exclude_patters = { } -- TODO: replace with actual expression -> lua translator -local function process_expression(src, memoised) +local function process_expression(src, memoised, ismul) + if ismul then + src = string.format("(%s) * intensity + (1.0 - intensity)", src) + else + src = string.format("(%s) * intensity", src) + end + for i, pattern in ipairs(exclude_patters) do if src:find(pattern) then debug.print(exclude_patters) @@ -127,6 +133,11 @@ for _, name in ipairs(math_funcs) do env[name] = math[name] end +is_multiplier = { + [animation.CH_SCALE] = true, + [animation.CH_ZOOM] = true, +} + local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) local lines = lineset.lines local code = "" @@ -137,7 +148,7 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) for i, line in ipairs(lines) do if line.expression then code = code .. "\n local l" .. i .. " = (" .. - process_expression(line.expression, memoised) .. ")" + process_expression(line.expression, memoised, is_multiplier[line.channel]) .. ")" elseif line.keys then local target_keysets = keysets[lineset.target_name] if not target_keysets then @@ -290,7 +301,7 @@ function internals.compile_animation_track(raw_track, track_name) code = memoised_code .. "\n" .. code end - local src = "return function(target, t, m)\n" + local src = "return function(target, t, intensity, m)\n m = m or 1\n" .. code .. "\nend" if animation.TRACE_CODEGEN then diff --git a/src/engine/Time.hpp b/src/engine/Time.hpp index 9f914b1fc..b335db313 100644 --- a/src/engine/Time.hpp +++ b/src/engine/Time.hpp @@ -6,12 +6,13 @@ class Time { uint64_t frame = 0; double lastTime = 0.0; double delta = 0.0; + double timeMultiplier = 1.0; public: Time() {} void update(double currentTime) { frame++; - delta = currentTime - lastTime; + delta = (currentTime - lastTime) * timeMultiplier; lastTime = currentTime; } From c3ca6be0565204a4b1d4d4b05d05adea2c2b97b3 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 23:13:54 +0300 Subject: [PATCH 30/91] add missing local --- res/modules/internal/animation_codegen.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 97deab9df..50ae8a5a0 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -133,7 +133,7 @@ for _, name in ipairs(math_funcs) do env[name] = math[name] end -is_multiplier = { +local is_multiplier = { [animation.CH_SCALE] = true, [animation.CH_ZOOM] = true, } From 0151fdfbf7922bf8040f5d42fef32d8dde6a35f5 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 27 Sep 2026 02:14:36 +0300 Subject: [PATCH 31/91] implement actual animation blending in core:animator --- res/modules/animation.lua | 3 +++ res/modules/internal/animation_codegen.lua | 9 +++++---- res/scripts/components/animator.lua | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 411623364..1e19822a4 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -97,6 +97,9 @@ local PlayingTrack = { } function this.play(name, target) + if target and target.reset_pose then + target:reset_pose() + end local track = setmetatable({ name = name, target = target, diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 50ae8a5a0..a8fabab8e 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -194,7 +194,6 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) return code end - code = code .. "\n mat4.idt(dst)" if translation[1] or translation[2] or translation[3] then code = code .. "\n mat4.translate(dst, {" .. (translation[1] and ("l" .. translation[1]) or '0').. ", " .. @@ -226,7 +225,6 @@ end local function codegen_rig_target(raw_track, context) local code = "\n if target.set_matrix and target.index then\n" - code = code .. " local dst = DST\n" for bone, lineset in pairs(raw_track.linesets) do if lineset.target_type ~= "bone" and lineset.target_type ~= "texture" then goto continue @@ -234,10 +232,13 @@ local function codegen_rig_target(raw_track, context) local lineset_code = codegen_track( raw_track, lineset, context.memoised, context.keysets, true) - code = code .. "\n do" .. lineset_code .. "\n end\n" + code = code + .. string.format("\n local bone_index = target:index(%s)" + .. "\n local dst = target:get_matrix(bone_index)", string.escape(bone)) + .. "\n do" .. lineset_code .. "\n end\n" if lineset.target_type == "bone" then code = code .. - " target:set_matrix(target:index(" .. string.escape(bone) .. "), dst)\n" + " target:set_matrix(bone_index, dst)\n" end ::continue:: end diff --git a/res/scripts/components/animator.lua b/res/scripts/components/animator.lua index 611ffa6f8..341f7cf11 100644 --- a/res/scripts/components/animator.lua +++ b/res/scripts/components/animator.lua @@ -38,6 +38,7 @@ function set_state(name, fade_time) end local function update(delta) + rig:reset_pose() for _, state in pairs(states) do state.timer = state.timer + delta @@ -51,7 +52,7 @@ local function update(delta) end state.track = state.track or animation.get_track(state.track_id) - if state.track and intensity > 0.0 then + if state.track then state.track.func( rig, state.timer % math.min(MAX_DURATION, state.track.duration), From 64ba1dad4e8e9b214fd11cfd7c4391ed4bffb677 Mon Sep 17 00:00:00 2001 From: boolean-false Date: Sun, 27 Sep 2026 17:33:55 +0700 Subject: [PATCH 32/91] fix glyph positions --- src/coders/vector_fonts.cpp | 17 ++++++++++------- src/graphics/core/Font.cpp | 27 +++++++++++++-------------- src/graphics/core/Font.hpp | 1 + 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/coders/vector_fonts.cpp b/src/coders/vector_fonts.cpp index a2b6b55d0..9ebb3c8d8 100644 --- a/src/coders/vector_fonts.cpp +++ b/src/coders/vector_fonts.cpp @@ -122,10 +122,16 @@ namespace { std::vector& glyphs ) { int size = canvas.getWidth() / 16; + + const size_t end = (pageid + 1) * 256; + if (glyphs.size() < end) { + glyphs.resize(end); + } + for (int c = 0; c < 256; c++) { int codepoint = pageid << 8 | c; if (!renderGlyph(codepoint, bitmapDst)) { - glyphs.push_back(Glyph {0, size / 2}); + glyphs[codepoint] = Glyph {0, size / 2}; continue; } @@ -133,13 +139,10 @@ namespace { Glyph glyph { face->glyph->bitmap_top - size, - static_cast(face->glyph->advance.x >> 6) + static_cast(face->glyph->advance.x >> 6), + face->glyph->bitmap_left }; - if (codepoint < glyphs.size()) { - glyphs[codepoint] = std::move(glyph); - } else { - glyphs.push_back(std::move(glyph)); - } + glyphs[codepoint] = glyph; } canvas.flipY(); } diff --git a/src/graphics/core/Font.cpp b/src/graphics/core/Font.cpp index 4843387e4..e94881adc 100644 --- a/src/graphics/core/Font.cpp +++ b/src/graphics/core/Font.cpp @@ -176,7 +176,7 @@ static inline void draw_text( int y = 0; bool hasLines = false; - float baseAdvance = glm::length(right); + const float cellAdvance = interval * font.getLineHeight(); do { for (size_t i = 0; i < text.length(); i++) { @@ -193,12 +193,12 @@ static inline void draw_text( continue; } int yOffset = 0; - float advance = baseAdvance; + int xOffset = 0; + float advance = 1.0f; if (auto glyph = font.getGlyph(c)) { yOffset = glyph->yOffset; - advance = glyph->xAdvance / - static_cast(font.getLineHeight()) * 2.0f * - baseAdvance; + xOffset = glyph->xOffset; + advance = glyph->xAdvance / cellAdvance; } uint charpage = c >> 8; if (charpage == page){ @@ -207,7 +207,7 @@ static inline void draw_text( batch, pos, glm::vec2( - x, + x + xOffset / cellAdvance, y - yOffset * (is3d ? -1 : 1) / static_cast(font.getLineHeight()) ), @@ -221,7 +221,7 @@ static inline void draw_text( else if (charpage > page && charpage < next){ next = charpage; } - x += advance / baseAdvance; + x += advance; } page = next; next = MAX_CODEPAGES; @@ -329,23 +329,22 @@ const Glyph* Font::getGlyph(int codepoint) { if (codepoint < 0) { return nullptr; } - if (codepoint < glyphs.size()) { + const int codepage = codepoint >> 8; + if (codepoint < glyphs.size() && + (!fontFile.has_value() || + (codepage < pages.size() && pages[codepage]))) { return &glyphs.at(codepoint); } if (!this->fontFile.has_value() || this->fontFile->expired()) { return nullptr; } - int codepage = codepoint >> 8; if (codepage >= 1024) { return nullptr; } - if (glyphs.size() < (codepage << 8)) { - glyphs.resize(codepage << 8); - } auto fontFile = this->fontFile->lock(); if (pages.size() <= codepage) { - pages.resize(codepage); + pages.resize(codepage + 1); } - pages.push_back(fontFile->renderPage(codepage, glyphs, lineHeight)); + pages[codepage] = fontFile->renderPage(codepage, glyphs, lineHeight); return &glyphs.at(codepoint); } diff --git a/src/graphics/core/Font.hpp b/src/graphics/core/Font.hpp index 1f0e3ce8c..19e77ef83 100644 --- a/src/graphics/core/Font.hpp +++ b/src/graphics/core/Font.hpp @@ -26,6 +26,7 @@ namespace vector_fonts { struct Glyph { int yOffset; int xAdvance; + int xOffset = 0; }; class Font { From 61af506f4c9990bf39ef8e8803df56daae25d451 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 27 Sep 2026 16:14:14 +0300 Subject: [PATCH 33/91] fix xml.tostring --- dev/tests/parsing.lua | 33 +++++++++++++++++++++++++ src/logic/scripting/lua/libs/libxml.cpp | 9 ++++++- test/coders/xml.cpp | 6 +++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 dev/tests/parsing.lua diff --git a/dev/tests/parsing.lua b/dev/tests/parsing.lua new file mode 100644 index 000000000..3b1a4840d --- /dev/null +++ b/dev/tests/parsing.lua @@ -0,0 +1,33 @@ +local src = "test" +local parsed = xml.parse(src) +asserts.equals(src, xml.tostring(parsed, false)) + +local src = "{\"test\": \"test\", \"sub\": {\"test\": \"test\"}}" +local parsed = json.parse(src) +asserts.equals("test", parsed.test) +asserts.equals("test", parsed.sub.test) + +-- toml +local src = [[ +[section] +key = "value" +# comment +key2 = "other value" +number = 42 +pi = 3.14159 +enabled = true +items = ["a", "b", "c"] +table = { x = 1, y = 2 } +]] +local parsed = toml.parse(src) + +asserts.equals("value", parsed.section.key) +asserts.equals("other value", parsed.section.key2) +asserts.equals(42, parsed.section.number) +asserts.equals(3.14159, parsed.section.pi) +asserts.equals(true, parsed.section.enabled) +asserts.equals("a", parsed.section.items[1]) +asserts.equals("b", parsed.section.items[2]) +asserts.equals("c", parsed.section.items[3]) +asserts.equals(1, parsed.section.table.x) +asserts.equals(2, parsed.section.table.y) diff --git a/src/logic/scripting/lua/libs/libxml.cpp b/src/logic/scripting/lua/libs/libxml.cpp index 4aa11f3dd..575a849cb 100644 --- a/src/logic/scripting/lua/libs/libxml.cpp +++ b/src/logic/scripting/lua/libs/libxml.cpp @@ -30,7 +30,7 @@ static int push_xml(lua::State* L, const xml::xmlelement& elem) { } static std::unique_ptr toxml(lua::State* L) { - lua::getfield(L, TAG_ATTR); + lua::requirefield(L, TAG_ATTR); auto tag = lua::require_lstring(L, -1); lua::pop(L); @@ -39,6 +39,13 @@ static std::unique_ptr toxml(lua::State* L) { for (int i = 0; i < length; i++) { lua::rawgeti(L, i + 1); + if (lua::isstring(L, -1)) { + auto textElement = std::make_unique("#"); + textElement->set("#", std::string(lua::require_lstring(L, -1))); + elem->add(std::move(textElement)); + lua::pop(L); + continue; + } elem->add(toxml(L)); lua::pop(L); } diff --git a/test/coders/xml.cpp b/test/coders/xml.cpp index 1357a4492..a394d40a6 100644 --- a/test/coders/xml.cpp +++ b/test/coders/xml.cpp @@ -22,3 +22,9 @@ TEST(XML, VCM) { throw err; } } + +TEST(XML, TWO_WAYS) { + auto src = "test"; + auto document = xml::parse("", src); + ASSERT_EQ(src, xml::stringify(*document->getRoot(), false)); +} From 4549d4892403b6ebf320bb526df3d3fc9a8bcc22 Mon Sep 17 00:00:00 2001 From: nogitsune-youkai Date: Sun, 27 Sep 2026 19:47:52 +0300 Subject: [PATCH 34/91] Fix: Make clear and pop_back noexcept compliant --- src/util/stack_vector.hpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/util/stack_vector.hpp b/src/util/stack_vector.hpp index a58777845..e6565a811 100644 --- a/src/util/stack_vector.hpp +++ b/src/util/stack_vector.hpp @@ -69,18 +69,16 @@ namespace util { ++size_; } - void pop_back() { + void pop_back() noexcept { if (size_ > 0) { data_.ptr()[size_ - 1].~T(); --size_; - } else { - throw std::underflow_error("stack vector is empty"); - } + } } - void clear() { + void clear() noexcept { for (int i = 0; i < size_; ++i) { - data_.ptr()[i].~T(); + data_.ptr()[i].~T(); } size_ = 0; } From 771c72324cfffcb29b8727348e8f0db62f09eaee Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 27 Sep 2026 23:13:45 +0300 Subject: [PATCH 35/91] update advanced shading --- res/shaders/effects/deferred_lighting.glsl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/res/shaders/effects/deferred_lighting.glsl b/res/shaders/effects/deferred_lighting.glsl index 55e267bf3..8df2dd0d7 100644 --- a/res/shaders/effects/deferred_lighting.glsl +++ b/res/shaders/effects/deferred_lighting.glsl @@ -26,8 +26,12 @@ vec4 effect() { float emission = texture(u_emission, v_uv).r; + float rg = 1.0; #ifdef ENABLE_SHADOWS - light *= calc_shadow(modelpos, normal, length(pos)); + float shadow_mul = calc_shadow(modelpos, normal, length(pos)); + light *= shadow_mul; + rg *= min(1.0, shadow_mul + emission); + light *= 2.0; #endif light = max(light, emission); @@ -40,5 +44,5 @@ vec4 effect() { mix(1.0, CLOUDS_FOG_FACTOR_MUL, emission), mix(1.0, CLOUDS_FOG_CURVE_MUL, emission) ); - return vec4(mix(texture(u_screen, v_uv).rgb * mix(1.0, light, 1.0), fogColor, fog), 1.0); + return vec4(mix(texture(u_screen, v_uv).rgb * mix(1.0, light, 1.0) * vec3(rg, 0.5 + rg * 0.5, 1.0), fogColor, fog), 1.0); } From 2b8d97a2cacd6e37999d5230f5cb5aed4b446f3c Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 27 Sep 2026 23:21:45 +0300 Subject: [PATCH 36/91] feat: color temperature compensation --- res/shaders/effects/deferred_lighting.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/res/shaders/effects/deferred_lighting.glsl b/res/shaders/effects/deferred_lighting.glsl index 8df2dd0d7..274ceae56 100644 --- a/res/shaders/effects/deferred_lighting.glsl +++ b/res/shaders/effects/deferred_lighting.glsl @@ -3,6 +3,7 @@ #define CLOUDS_FOG_FACTOR_MUL 0.3f #define CLOUDS_FOG_CURVE_MUL 0.4f +#define COLOR_TEMPERATURE_COMPENSATION 1.12f vec4 effect() { vec4 pos = texture(u_position, v_uv); @@ -30,7 +31,7 @@ vec4 effect() { #ifdef ENABLE_SHADOWS float shadow_mul = calc_shadow(modelpos, normal, length(pos)); light *= shadow_mul; - rg *= min(1.0, shadow_mul + emission); + rg *= min(1.0, shadow_mul + emission) + COLOR_TEMPERATURE_COMPENSATION; light *= 2.0; #endif From 8726a95a9bbf15ef211420b5b0934c2ca4ff867e Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 27 Sep 2026 23:23:21 +0300 Subject: [PATCH 37/91] fix --- res/shaders/effects/deferred_lighting.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/shaders/effects/deferred_lighting.glsl b/res/shaders/effects/deferred_lighting.glsl index 274ceae56..ebcf138aa 100644 --- a/res/shaders/effects/deferred_lighting.glsl +++ b/res/shaders/effects/deferred_lighting.glsl @@ -31,7 +31,7 @@ vec4 effect() { #ifdef ENABLE_SHADOWS float shadow_mul = calc_shadow(modelpos, normal, length(pos)); light *= shadow_mul; - rg *= min(1.0, shadow_mul + emission) + COLOR_TEMPERATURE_COMPENSATION; + rg *= min(1.0, shadow_mul + emission) * COLOR_TEMPERATURE_COMPENSATION; light *= 2.0; #endif From 611852c273b3cc20315b2e04a9b3d955693aa892 Mon Sep 17 00:00:00 2001 From: nogitsune-youkai Date: Mon, 28 Sep 2026 00:38:38 +0300 Subject: [PATCH 38/91] Refactor: Use size_type for sizes and indices --- src/util/stack_vector.hpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/util/stack_vector.hpp b/src/util/stack_vector.hpp index e6565a811..87749396b 100644 --- a/src/util/stack_vector.hpp +++ b/src/util/stack_vector.hpp @@ -1,9 +1,12 @@ #pragma once +#include +#include #include +#include namespace util { - template + template class stack_vector { struct buffer { alignas(alignof(T)) char data[sizeof(T) * capacity]; @@ -16,18 +19,19 @@ namespace util { } }; public: + using size_type = std::size_t; stack_vector() : size_(0) {} stack_vector(const stack_vector& other) : size_(other.size_) { - for (int i = 0; i < size_; ++i) { + for (size_type i = 0; i < size_; ++i) { new (&data_.ptr()[i]) T(other.data_.ptr()[i]); } } stack_vector(stack_vector&& other) noexcept : size_(other.size_) { - for (int i = 0; i < size_; ++i) { + for (size_type i = 0; i < size_; ++i) { new (&data_.ptr()[i]) T(std::move(other.data_.ptr()[i])); } other.size_ = 0; @@ -77,29 +81,29 @@ namespace util { } void clear() noexcept { - for (int i = 0; i < size_; ++i) { + for (size_type i = 0; i < size_; ++i) { data_.ptr()[i].~T(); } size_ = 0; } - T& operator[](int index) { + T& operator[](size_type index) { return data_.ptr()[index]; } - const T& operator[](int index) const { + const T& operator[](size_type index) const { return data_.ptr()[index]; } - T& at(int index) { - if (index < 0 || index >= size_) { + T& at(size_type index) { + if (index >= size_) { throw std::out_of_range("index out of range"); } return data_.ptr()[index]; } - const T& at(int index) const { - if (index < 0 || index >= size_) { + const T& at(size_type index) const { + if (index >= size_) { throw std::out_of_range("index out of range"); } return data_.ptr()[index]; @@ -121,7 +125,7 @@ namespace util { return data_.ptr()[size_ - 1]; } - int size() const { + size_type size() const { return size_; } @@ -150,6 +154,6 @@ namespace util { } private: buffer data_; - int size_; + size_type size_; }; } From ffba11e87fd1268208def134fa32412b075b8154 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 28 Sep 2026 01:40:48 +0300 Subject: [PATCH 39/91] update clouds shader --- res/shaders/clouds.glslv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/shaders/clouds.glslv b/res/shaders/clouds.glslv index 0b9c17774..e1576f633 100644 --- a/res/shaders/clouds.glslv +++ b/res/shaders/clouds.glslv @@ -22,7 +22,7 @@ void main() { vec3 pos3d = a_modelpos.xyz - u_cameraPos; - a_realnormal = v_normal.xyz * 2.0 - 1.0; + a_realnormal = vec3(0.0, 1.0, 0.0); a_normal = calc_screen_normal(a_realnormal); a_torchLight = vec4(calc_torch_light( From 19a952a3bec85a26365a544c031acac1e8b265bf Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 28 Sep 2026 01:47:23 +0300 Subject: [PATCH 40/91] update shadows.glsl --- res/shaders/lib/shadows.glsl | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/res/shaders/lib/shadows.glsl b/res/shaders/lib/shadows.glsl index 658e9a699..a686683f2 100644 --- a/res/shaders/lib/shadows.glsl +++ b/res/shaders/lib/shadows.glsl @@ -25,18 +25,14 @@ float calc_shadow( projCoords.z -= 0.00001 / u_shadowsRes + bias; float shadow = 0.0; - if (dot(realnormal, u_sunDir) < 0.0) { - // 3x3 kernel - for (int y = -1; y <= 1; y++) { - for (int x = -1; x <= 1; x++) { - vec3 offset = vec3(x, y, -(abs(x) + abs(y)) * 0.8) * step * 1.0 * u_shadowsSoftness; - shadow += texture(shadowsMap, projCoords + offset); - } + // 3x3 kernel + for (int y = -1; y <= 1; y++) { + for (int x = -1; x <= 1; x++) { + vec3 offset = vec3(x, y, -(abs(x) + abs(y)) * 0.8) * step * 1.0 * u_shadowsSoftness; + shadow += texture(shadowsMap, projCoords + offset); } - shadow /= 9.0; - } else { - shadow = 0.0; } + shadow /= 9.0; return shadow; } From 3378001b9bff52120725234afe2e625798871625 Mon Sep 17 00:00:00 2001 From: nogitsune-youkai Date: Mon, 28 Sep 2026 22:02:08 +0300 Subject: [PATCH 41/91] Fix: Add asserts to prevent undefined behavior on empty containers --- src/util/stack_vector.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/stack_vector.hpp b/src/util/stack_vector.hpp index 87749396b..3c506f160 100644 --- a/src/util/stack_vector.hpp +++ b/src/util/stack_vector.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -74,6 +75,7 @@ namespace util { } void pop_back() noexcept { + assert(!empty() && "pop_back() called on empty stack_vector"); if (size_ > 0) { data_.ptr()[size_ - 1].~T(); --size_; @@ -110,18 +112,22 @@ namespace util { } T& front() { + assert(!empty() && "front() called on empty stack_vector"); return data_.ptr()[0]; } T& back() { + assert(!empty() && "back() called on empty stack_vector"); return data_.ptr()[size_ - 1]; } const T& front() const { + assert(!empty() && "front() called on empty stack_vector"); return data_.ptr()[0]; } const T& back() const { + assert(!empty() && "back() called on empty stack_vector"); return data_.ptr()[size_ - 1]; } From ca68ddc03aad65bb365e6263bf68485b1d85e245 Mon Sep 17 00:00:00 2001 From: nogitsune-youkai Date: Tue, 29 Sep 2026 01:20:54 +0300 Subject: [PATCH 42/91] Improve Windows presets --- CMakePresets.json | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 508719628..86a6fd075 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -2,19 +2,36 @@ "version": 6, "configurePresets": [ { - "name": "default-vs-msvc-windows", + "name": "windows-msvc-base", + "hidden": true, "condition": { "type": "equals", "rhs": "${hostSystemName}", "lhs": "Windows" }, - "generator": "Visual Studio 17 2022", "binaryDir": "${sourceDir}/build", "cacheVariables": { "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", "VOXELENGINE_BUILD_TESTS": "ON" } }, + { + "name": "default-vs-msvc-windows", + "displayName": "Visual Studio (auto: latest installed)", + "inherits": "windows-msvc-base" + }, + { + "name": "vs2022", + "displayName": "Visual Studio 2022", + "inherits": "windows-msvc-base", + "generator": "Visual Studio 17 2022" + }, + { + "name": "vs2026", + "displayName": "Visual Studio 2026", + "inherits": "windows-msvc-base", + "generator": "Visual Studio 18 2026" + }, { "name": "default-ninja-mingw-windows", "condition": { From 7211e99bc87b3ed69c690fca0a3cd64fc49b8fd1 Mon Sep 17 00:00:00 2001 From: boolean-false Date: Tue, 29 Sep 2026 20:31:14 +0700 Subject: [PATCH 43/91] fix text width and caret positioning in text boxes --- src/graphics/core/Font.cpp | 46 ++++++++++++++++++---------- src/graphics/core/Font.hpp | 10 ++++-- src/graphics/ui/elements/TextBox.cpp | 38 ++++++++++++++++------- 3 files changed, 63 insertions(+), 31 deletions(-) diff --git a/src/graphics/core/Font.cpp b/src/graphics/core/Font.cpp index e94881adc..fde3e0c17 100644 --- a/src/graphics/core/Font.cpp +++ b/src/graphics/core/Font.cpp @@ -29,6 +29,10 @@ Font::Font( if (this->fontFile.has_value()) { if (auto fontPtr = this->fontFile->lock()) { monospace = fontPtr->isMonospace(); + if (monospace && this->glyphs.size() > '0' && + this->glyphs['0'].xAdvance > 0) { + glyphInterval = this->glyphs['0'].xAdvance; + } } } } @@ -62,21 +66,13 @@ bool Font::isPrintableChar(uint codepoint) const { int FontMetrics::calcWidth(std::wstring_view text, size_t offset, size_t length) const { auto font = this->font.has_value() ? this->font->lock() : nullptr; - if (font == nullptr || font->isMonospace()) { - return std::min(text.length() - offset, length) * _glyphInterval; + if (font != nullptr) { + return font->calcWidth(text, offset, length); } - int totalWidth = 0; - for (int i = offset; i < offset + length && i < text.length(); i++) { - auto codepoint = text[i]; - if (!font->isPrintableChar(codepoint)) { - totalWidth += _glyphInterval; - } else if (auto glyph = font->getGlyph(codepoint)) { - totalWidth += glyph->xAdvance; - } else { - totalWidth += _glyphInterval; - } + if (offset >= text.length()) { + return 0; } - return totalWidth; + return std::min(text.length() - offset, length) * _glyphInterval; } int Font::calcWidth(std::wstring_view text, size_t length) const { @@ -84,7 +80,24 @@ int Font::calcWidth(std::wstring_view text, size_t length) const { } int Font::calcWidth(std::wstring_view text, size_t offset, size_t length) const { - return std::min(text.length()-offset, length) * glyphInterval; + if (offset >= text.length()) { + return 0; + } + size_t end = offset + std::min(text.length() - offset, length); + int width = 0; + for (size_t i = offset; i < end; i++) { + width += getAdvance(text[i]); + } + return width; +} + +int Font::getAdvance(uint codepoint) const { + if (isPrintableChar(codepoint)) { + if (auto glyph = getGlyph(codepoint)) { + return glyph->xAdvance; + } + } + return glyphInterval; } static inline void draw_glyph( @@ -194,11 +207,10 @@ static inline void draw_text( } int yOffset = 0; int xOffset = 0; - float advance = 1.0f; + float advance = font.getAdvance(c) / cellAdvance; if (auto glyph = font.getGlyph(c)) { yOffset = glyph->yOffset; xOffset = glyph->xOffset; - advance = glyph->xAdvance / cellAdvance; } uint charpage = c >> 8; if (charpage == page){ @@ -325,7 +337,7 @@ std::unique_ptr Font::createBitmapFont( return std::make_unique(std::move(textures), std::move(glyphs), res, 4); } -const Glyph* Font::getGlyph(int codepoint) { +const Glyph* Font::getGlyph(int codepoint) const { if (codepoint < 0) { return nullptr; } diff --git a/src/graphics/core/Font.hpp b/src/graphics/core/Font.hpp index 19e77ef83..b20b5e530 100644 --- a/src/graphics/core/Font.hpp +++ b/src/graphics/core/Font.hpp @@ -57,6 +57,10 @@ public: /// @return pixel width of the substring int calcWidth(std::wstring_view text, size_t offset, size_t length) const; + /// @brief Get the horizontal advance of a character in pixels + /// @param codepoint character unicode codepoint + int getAdvance(uint codepoint) const; + /// @brief Check if character is visible (non-whitespace) /// @param codepoint character unicode codepoint bool isPrintableChar(uint codepoint) const; @@ -87,7 +91,7 @@ public: return {std::nullopt, lineHeight, yoffset, glyphInterval}; } - const Glyph* getGlyph(int codepoint); + const Glyph* getGlyph(int codepoint) const; static std::unique_ptr createBitmapFont( std::vector> pages @@ -97,7 +101,7 @@ private: int yoffset; int glyphInterval; bool monospace = true; - std::vector> pages; - std::vector glyphs; + mutable std::vector> pages; + mutable std::vector glyphs; std::optional> fontFile; }; diff --git a/src/graphics/ui/elements/TextBox.cpp b/src/graphics/ui/elements/TextBox.cpp index d60b09142..2f6a20301 100644 --- a/src/graphics/ui/elements/TextBox.cpp +++ b/src/graphics/ui/elements/TextBox.cpp @@ -255,9 +255,9 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) { // drawing caret here if (isFocused() && editable && static_cast((time - caretLastMove) * 2) % 2 == 0) { uint line = label->getLineByTextIndex(caret); - auto linestart = label->getTextLineOffset(line); - uint lcaret = caret - label->getTextLineOffset(line); - int width = rawTextCache.metrics.calcWidth(input.substr(linestart), 0, lcaret); + size_t lineStart = label->getTextLineOffset(line); + size_t lineCaret = caret - lineStart; + int width = rawTextCache.metrics.calcWidth(input, lineStart, lineCaret); batch->rect( lcoord.x + width, @@ -275,11 +275,13 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) { uint endLine = label->getLineByTextIndex(selectionEnd); batch->setColor(glm::vec4(0.8f, 0.9f, 1.0f, 0.25f)); + size_t startLineOffset = label->getTextLineOffset(startLine); + size_t endLineOffset = label->getTextLineOffset(endLine); int start = rawTextCache.metrics.calcWidth( - labelText, 0, selectionStart - label->getTextLineOffset(startLine) + labelText, startLineOffset, selectionStart - startLineOffset ); int end = rawTextCache.metrics.calcWidth( - labelText, 0, selectionEnd - label->getTextLineOffset(endLine) + labelText, endLineOffset, selectionEnd - endLineOffset ); int lineY = label->getLineYOffset(startLine); @@ -352,6 +354,11 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) { } void TextBox::drawBackground(const DrawContext& pctx, const Assets& assets) { + if (lineNumbersLabel->getFontName() != label->getFontName()) { + lineNumbersLabel->setFontName(label->getFontName()); + } + lineNumbersLabel->setLineInterval(label->getLineInterval()); + auto font = assets.getShared(label->getFontName()); if (font != nullptr) { rawTextCache.prepare(font, font->getMetrics(), label->getSize().x); @@ -681,13 +688,19 @@ int TextBox::calcIndexAt(int x, int y) const { uint line = label->getLineByYOffset(y - lcoord.y); line = std::min(line, label->getLinesNumber() - 1); size_t lineLength = getLineLength(line); + size_t lineStart = label->getTextLineOffset(line); uint offset = 0; - while (lcoord.x + rawTextCache.metrics.calcWidth(labelText, 0, offset) < x && - offset < lineLength - 1) { + while (offset < lineLength - 1) { + int width = rawTextCache.metrics.calcWidth( + labelText, lineStart, offset + ); + if (lcoord.x + width >= x) { + break; + } offset++; } return std::min( - offset + label->getTextLineOffset(line), labelText.length() + offset + lineStart, labelText.length() ); } @@ -1224,9 +1237,12 @@ void TextBox::setCaret(size_t position) { offset -= getSize().y; scrolled(-glm::ceil(offset / static_cast(scrollStep) + 0.5f)); } - int lcaret = caret - rawTextCache.getTextLineOffset(line); - int realoffset = rawTextCache.metrics.calcWidth(labelText, 0, lcaret) - - static_cast(textOffset); + size_t lineStart = rawTextCache.getTextLineOffset(line); + size_t lineCaret = caret - lineStart; + int caretWidth = rawTextCache.metrics.calcWidth( + labelText, lineStart, lineCaret + ); + int realoffset = caretWidth - static_cast(textOffset); if (realoffset - width > 0) { setTextOffset(textOffset + realoffset - width); From ea63d29221903a948ed84b2c982e5a99e296037e Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 29 Sep 2026 18:39:46 +0300 Subject: [PATCH 44/91] fix custom curves --- res/modules/internal/animation_codegen.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index a8fabab8e..004cdc4a3 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -15,11 +15,13 @@ local exclude_patters = { } -- TODO: replace with actual expression -> lua translator -local function process_expression(src, memoised, ismul) - if ismul then - src = string.format("(%s) * intensity + (1.0 - intensity)", src) - else - src = string.format("(%s) * intensity", src) +local function process_expression(src, memoised, ismul, iscurve) + if not iscurve then + if ismul then + src = string.format("(%s) * intensity + (1.0 - intensity)", src) + else + src = string.format("(%s) * intensity", src) + end end for i, pattern in ipairs(exclude_patters) do @@ -284,7 +286,7 @@ function internals.compile_animation_track(raw_track, track_name) for name, curve in pairs(raw_track.curves) do context.curves[name] = load(string.format( "return function(kl, kr, t) return %s end", - process_expression(curve.func, context.memoised) + process_expression(curve.func, context.memoised, false, true) ), "", "t", env)() end From d3de449b7b0f1c777dd5cf714967d9d976461a70 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 29 Sep 2026 18:41:02 +0300 Subject: [PATCH 45/91] fix absolute bezier keyframes --- res/modules/animation.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 1e19822a4..d08b1bc18 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -21,8 +21,10 @@ local function bezier_interpolation(k0, k1, t) local u = t for i=1,8 do - local x = bezier(k0.frame, k0.rx, k1.lx, k1.frame, u) - local dx = bezier_derivative(k0.frame, k0.rx, k1.lx, k1.frame, u) + local x = bezier( + k0.frame, k0.rx + k0.frame, k1.lx + k1.frame, k1.frame, u) + local dx = bezier_derivative( + k0.frame, k0.rx + k0.frame, k1.lx + k1.frame, k1.frame, u) if math.abs(dx) < 1e-8 then break From dd577dd08059b2a4fa32bf1d1505916fa47d3ada Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 29 Sep 2026 18:44:19 +0300 Subject: [PATCH 46/91] cleanup --- res/modules/internal/animation_codegen.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 004cdc4a3..0b96dc15b 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -15,18 +15,15 @@ local exclude_patters = { } -- TODO: replace with actual expression -> lua translator -local function process_expression(src, memoised, ismul, iscurve) - if not iscurve then - if ismul then - src = string.format("(%s) * intensity + (1.0 - intensity)", src) - else - src = string.format("(%s) * intensity", src) - end +local function process_expression(src, memoised, mode) + if mode == 'mul' then + src = string.format("(%s) * intensity + (1.0 - intensity)", src) + elseif mode == "add" then + src = string.format("(%s) * intensity", src) end for i, pattern in ipairs(exclude_patters) do if src:find(pattern) then - debug.print(exclude_patters) error("invalid syntax "..string.escape(src)) end end @@ -150,7 +147,8 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) for i, line in ipairs(lines) do if line.expression then code = code .. "\n local l" .. i .. " = (" .. - process_expression(line.expression, memoised, is_multiplier[line.channel]) .. ")" + process_expression(line.expression, memoised, + is_multiplier[line.channel] and "mul" or "add") .. ")" elseif line.keys then local target_keysets = keysets[lineset.target_name] if not target_keysets then @@ -286,7 +284,7 @@ function internals.compile_animation_track(raw_track, track_name) for name, curve in pairs(raw_track.curves) do context.curves[name] = load(string.format( "return function(kl, kr, t) return %s end", - process_expression(curve.func, context.memoised, false, true) + process_expression(curve.func, context.memoised, "curve") ), "", "t", env)() end From e4eae0416e2971be99fb4af2379e070bf50eace0 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 29 Sep 2026 18:59:28 +0300 Subject: [PATCH 47/91] fix the --- res/modules/animation.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index d08b1bc18..817b1611f 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -36,7 +36,7 @@ local function bezier_interpolation(k0, k1, t) if u > 1 then u = 1 end end - return bezier(k0.value, k0.ry, k1.ly, k1.value, u) + return bezier(k0.value, k0.ry + k0.value, k1.ly + k1.value, k1.value, u) end local this = { From 5a0a1cf326e6f3f594ef637c6eaae1a604ac9094 Mon Sep 17 00:00:00 2001 From: Astazium <113135541+Astazium@users.noreply.github.com> Date: Wed, 30 Sep 2026 20:43:43 +0300 Subject: [PATCH 48/91] ui fixes --- src/graphics/ui/elements/InlineFrame.cpp | 11 +++- src/graphics/ui/elements/SplitBox.cpp | 13 +++++ src/graphics/ui/elements/SplitBox.hpp | 1 + src/logic/scripting/scripting_functional.cpp | 54 ++++++++++++++------ 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/src/graphics/ui/elements/InlineFrame.cpp b/src/graphics/ui/elements/InlineFrame.cpp index 8699fd70b..acf00916e 100644 --- a/src/graphics/ui/elements/InlineFrame.cpp +++ b/src/graphics/ui/elements/InlineFrame.cpp @@ -35,8 +35,15 @@ void InlineFrame::setDocument(const std::shared_ptr& document) { root->setSize(size); - gui.postRunnable([this]() { - scripting::on_ui_open(*this->document, {}); + gui.postRunnable([weak = weak_from_this(), document]() { + auto node = weak.lock(); + if (node == nullptr) { + return; + } + if (static_cast(*node).document != document) { + return; + } + scripting::on_ui_open(*document, {}); }); } diff --git a/src/graphics/ui/elements/SplitBox.cpp b/src/graphics/ui/elements/SplitBox.cpp index 247ef7410..c35374529 100644 --- a/src/graphics/ui/elements/SplitBox.cpp +++ b/src/graphics/ui/elements/SplitBox.cpp @@ -82,6 +82,19 @@ void SplitBox::doubleClick(int x, int y) { refresh(); } +std::shared_ptr SplitBox::getAt(const glm::vec2& pos) { + auto hover = Container::getAt(pos); + if (hover.get() != this) { + return hover; + } + for (const auto& node : nodes) { + if (node->isVisible() && node->isInside(pos)) { + return nullptr; + } + } + return hover; +} + void SplitBox::fullRefresh() { refresh(); reposition(); diff --git a/src/graphics/ui/elements/SplitBox.hpp b/src/graphics/ui/elements/SplitBox.hpp index 8482e73ec..1a452c2ff 100644 --- a/src/graphics/ui/elements/SplitBox.hpp +++ b/src/graphics/ui/elements/SplitBox.hpp @@ -11,6 +11,7 @@ namespace gui { virtual void refresh() override; virtual void fullRefresh() override; virtual void doubleClick(int x, int y) override; + virtual std::shared_ptr getAt(const glm::vec2& pos) override; private: float splitPos; }; diff --git a/src/logic/scripting/scripting_functional.cpp b/src/logic/scripting/scripting_functional.cpp index a6ef42a48..c71133ca8 100644 --- a/src/logic/scripting/scripting_functional.cpp +++ b/src/logic/scripting/scripting_functional.cpp @@ -99,14 +99,21 @@ template std::function create_supplier( const scriptenv& env, const std::string& src, const std::string& file ) { - return [=]() { + return [=, errorLogged = false]() mutable { + lua::stackguard guard(lua::get_main_state()); if (auto L = process_callback(env, src, file)) { - if (lua::isfunction(L, -1)) { - lua::call_nothrow(L, 0); + if (lua::isfunction(L, -1) && !lua::call_nothrow(L, 0)) { + return T {}; + } + try { + return tovalueFunc(L, -1); + } catch (const std::exception& err) { + if (!errorLogged) { + logger.error() << "supplier " << util::quote(src) << ": " + << err.what(); + errorLogged = true; + } } - auto str = tovalueFunc(L, -1); - lua::pop(L); - return str; } return T {}; }; @@ -158,16 +165,33 @@ int_array_consumer scripting::create_int_array_consumer( vec2supplier scripting::create_vec2_supplier( const scriptenv& env, const std::string& src, const std::string& file ) { - return [=]() { - if (auto L = process_callback(env, src, file)) { - if (lua::isfunction(L, -1)) { - lua::call_nothrow(L, 0); + return [=, errorLogged = false]() mutable { + auto L = lua::get_main_state(); + lua::stackguard guard(L); + int top = lua::gettop(L); + if (process_callback(env, src, file)) { + if (lua::isfunction(L, -1) && !lua::call_nothrow(L, 0)) { + return glm::vec2(0, 0); + } + if (lua::gettop(L) - top < 2) { + if (!errorLogged) { + logger.error() << "supplier " << util::quote(src) + << ": two numbers expected"; + errorLogged = true; + } + return glm::vec2(0, 0); + } + try { + auto y = lua::tonumber(L, -1); + auto x = lua::tonumber(L, -2); + return glm::vec2(x, y); + } catch (const std::exception& err) { + if (!errorLogged) { + logger.error() << "supplier " << util::quote(src) << ": " + << err.what(); + errorLogged = true; + } } - auto y = lua::tonumber(L, -1); - lua::pop(L); - auto x = lua::tonumber(L, -1); - lua::pop(L); - return glm::vec2(x, y); } return glm::vec2(0, 0); }; From d062c28376d3d00eb7ea52472d95f7d89666a479 Mon Sep 17 00:00:00 2001 From: nogitsune-youkai Date: Fri, 2 Oct 2026 17:23:49 +0300 Subject: [PATCH 49/91] Fix: correct luajit lookup on Windows (#1006) * Fix: correct luajit paths * fixed comment * removed unnecessary comments --- src/CMakeLists.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bbe8a9763..802c06e1a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,23 +27,23 @@ endif() if(CMAKE_SYSTEM_NAME STREQUAL "Windows") find_package(vorbis REQUIRED) + + set(LUAJIT_PACKAGE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}") if(VCPKG_TARGET_TRIPLET MATCHES "static") add_library(luajit STATIC IMPORTED) set_target_properties( luajit PROPERTIES IMPORTED_LOCATION - "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/lib/libluajit-5.1.a" + "${LUAJIT_PACKAGE_DIR}/lib/libluajit-5.1.a" INTERFACE_INCLUDE_DIRECTORIES - "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/" + "${LUAJIT_PACKAGE_DIR}/include/" ) else() - set(LUAJIT_PACKAGE_DIR "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}") - - if(EXISTS "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/luajit-2.1") - set(LUAJIT_INCLUDE_DIR "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/luajit-2.1") + if(EXISTS "${LUAJIT_PACKAGE_DIR}/include/luajit-2.1") + set(LUAJIT_INCLUDE_DIR "${LUAJIT_PACKAGE_DIR}/include/luajit-2.1") else() - set(LUAJIT_INCLUDE_DIR "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/luajit") + set(LUAJIT_INCLUDE_DIR "${LUAJIT_PACKAGE_DIR}/include/luajit") endif() add_library(luajit SHARED IMPORTED) @@ -51,9 +51,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") luajit PROPERTIES IMPORTED_LOCATION - "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/bin/lua51.dll" + "${LUAJIT_PACKAGE_DIR}/bin/lua51.dll" IMPORTED_IMPLIB - "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/lib/lua51.lib" + "${LUAJIT_PACKAGE_DIR}/lib/lua51.lib" INTERFACE_INCLUDE_DIRECTORIES "${LUAJIT_INCLUDE_DIR}" ) endif() From ef4207aed092bee8a0f1a658fadcae84d1324d51 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 2 Oct 2026 17:44:48 +0300 Subject: [PATCH 50/91] fixes --- res/modules/animation.lua | 3 +++ res/modules/internal/animation_codegen.lua | 4 ++-- res/scripts/components/animator.lua | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 817b1611f..0c7bb7741 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -135,6 +135,9 @@ function internals.on_animation_frame() if track_info.__timer > track.duration then table.remove(playing_tracks, i) else + if track_info.target.reset_pose then + track_info.target:reset_pose() + end track.func(track_info.target, track_info.__timer) end end diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 0b96dc15b..525240f66 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -247,7 +247,7 @@ end local function codegen_object_target(raw_track, context) local code = "\n if target.set_pos then\n" - code = code .. " local dst = DST\n" + code = code .. " local dst = mat4.idt()\n" local lineset = raw_track.linesets[""] if not lineset then return "" @@ -302,7 +302,7 @@ function internals.compile_animation_track(raw_track, track_name) code = memoised_code .. "\n" .. code end - local src = "return function(target, t, intensity, m)\n m = m or 1\n" + local src = "return function(target, t, intensity, m)\n m = m or 1\n intensity = intensity or 1.0\n" .. code .. "\nend" if animation.TRACE_CODEGEN then diff --git a/res/scripts/components/animator.lua b/res/scripts/components/animator.lua index 341f7cf11..e5f959df7 100644 --- a/res/scripts/components/animator.lua +++ b/res/scripts/components/animator.lua @@ -12,7 +12,7 @@ function create_state(name, track_id, max_intencity) fade_time = 0.0, fade_timer = 0.0, fade_in = false, - max_intencity = max_intencity, + max_intencity = max_intencity or 1.0, } end @@ -25,14 +25,14 @@ function set_state(name, fade_time) end if current_state then current_state.fade_in = false - current_state.fade_time = fade_time + current_state.fade_time = fade_time or 0.0 current_state.fade_timer = 0.0 end current_state = state if state then state.timer = 0.0 state.fade_in = true - state.fade_time = fade_time + state.fade_time = fade_time or 0.0 state.fade_timer = 0.0 end end From 2f4fff264f98455d7b3edbb0e036bbb845998d4a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 3 Oct 2026 02:29:40 +0300 Subject: [PATCH 51/91] update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fcf1f222..74efa6b3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 0.32 - 20xx.xx.xx +# 0.32 - 2026.10.03 [Documentation](https://github.com/MihailRis/VoxelEngine-Cpp/tree/release-0.32/doc/en/main-page.md) for 0.32 @@ -16,7 +16,7 @@ Table of contents: - animation - semi-transparent entities - client-side --script, --test support -- environments +- environments (in-development) - translators - VCA format From f6a7a99a7498d35f73426ac449c58646b7e070d8 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 3 Oct 2026 11:10:56 +0300 Subject: [PATCH 52/91] revert "update shadows.glsl" This reverts commit 19a952a3bec85a26365a544c031acac1e8b265bf. --- res/shaders/lib/shadows.glsl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/res/shaders/lib/shadows.glsl b/res/shaders/lib/shadows.glsl index a686683f2..658e9a699 100644 --- a/res/shaders/lib/shadows.glsl +++ b/res/shaders/lib/shadows.glsl @@ -25,14 +25,18 @@ float calc_shadow( projCoords.z -= 0.00001 / u_shadowsRes + bias; float shadow = 0.0; - // 3x3 kernel - for (int y = -1; y <= 1; y++) { - for (int x = -1; x <= 1; x++) { - vec3 offset = vec3(x, y, -(abs(x) + abs(y)) * 0.8) * step * 1.0 * u_shadowsSoftness; - shadow += texture(shadowsMap, projCoords + offset); + if (dot(realnormal, u_sunDir) < 0.0) { + // 3x3 kernel + for (int y = -1; y <= 1; y++) { + for (int x = -1; x <= 1; x++) { + vec3 offset = vec3(x, y, -(abs(x) + abs(y)) * 0.8) * step * 1.0 * u_shadowsSoftness; + shadow += texture(shadowsMap, projCoords + offset); + } } + shadow /= 9.0; + } else { + shadow = 0.0; } - shadow /= 9.0; return shadow; } From dacebf94bc4e6fdb2224be22caae0821b2bc5e78 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 3 Oct 2026 11:13:27 +0300 Subject: [PATCH 53/91] 0.32 release From a9069dd22e4cecc925e94ae6b1c51f928242c3ae Mon Sep 17 00:00:00 2001 From: ostermine Date: Mon, 5 Oct 2026 02:36:18 +0300 Subject: [PATCH 54/91] docs: add OpenSSL to Linux build dependencies in README src/CMakeLists.txt requires OpenSSL 3.0 (Crypto) since the crypto library was added, but the README install commands did not list it, so configuring on a clean system fails with "Could NOT find OpenSSL". CI workflows and the Dockerfile already install libssl-dev. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 72fb19957..67788d9fd 100644 --- a/README.md +++ b/README.md @@ -30,13 +30,13 @@ sudo make install ```sh su - -apt-get install entt-devel libglfw3-devel libGLEW-devel libglm-devel libpng-devel libvorbis-devel libopenal-devel libluajit-devel libstdc++13-devel-static libcurl-devel libfreetype-devel +apt-get install entt-devel libglfw3-devel libGLEW-devel libglm-devel libpng-devel libvorbis-devel libopenal-devel libluajit-devel libstdc++13-devel-static libcurl-devel libfreetype-devel libssl-devel ``` #### Debian based distros ```sh -sudo apt install libglfw3 libglfw3-dev libglew-dev libglm-dev libpng-dev libopenal-dev libluajit-5.1-dev libvorbis-dev libcurl4-openssl-dev libfreetype6-dev +sudo apt install libglfw3 libglfw3-dev libglew-dev libglm-dev libpng-dev libopenal-dev libluajit-5.1-dev libvorbis-dev libcurl4-openssl-dev libssl-dev libfreetype6-dev ``` > [!TIP] @@ -50,13 +50,13 @@ sudo apt install libglfw3 libglfw3-dev libglew-dev libglm-dev libpng-dev libopen #### RHEL based distros ```sh -sudo dnf install glfw-devel glew-devel glm-devel libpng-devel libvorbis-devel openal-soft-devel luajit-devel libcurl-devel libfreetype-devel +sudo dnf install glfw-devel glew-devel glm-devel libpng-devel libvorbis-devel openal-soft-devel luajit-devel libcurl-devel libfreetype-devel openssl-devel ``` #### Arch based distros ```sh -sudo pacman -S glfw glew glm libpng libvorbis openal luajit curl freetype2 +sudo pacman -S glfw glew glm libpng libvorbis openal luajit curl freetype2 openssl ``` ### Building engine with CMake From ef85592e21320bbc121d439c919379ba92e97f5e Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 5 Oct 2026 21:21:33 +0300 Subject: [PATCH 55/91] fix chunks render limits --- src/graphics/render/ChunksRenderer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/graphics/render/ChunksRenderer.cpp b/src/graphics/render/ChunksRenderer.cpp index 82a7fa6d6..6cccbe3fa 100644 --- a/src/graphics/render/ChunksRenderer.cpp +++ b/src/graphics/render/ChunksRenderer.cpp @@ -22,7 +22,7 @@ static debug::Logger logger("chunks-render"); size_t ChunksRenderer::visibleChunks = 0; -static constexpr inline size_t MAX_CHUNKS_ENQUEUED_IN_FRAME = 4; +static constexpr inline size_t MAX_CHUNKS_ENQUEUED_IN_FRAME = 64; class RendererWorker : public util::Worker { BlocksRenderer renderer; @@ -197,8 +197,7 @@ void ChunksRenderer::update() { int loadDistance = settings.chunks.loadDistance.get(); - const int topN = 10; - int top = std::min(meshBuildQueue.size(), topN); + int top = std::min(meshBuildQueue.size(), MAX_CHUNKS_ENQUEUED_IN_FRAME); for (int i = 0; i < top; i++) { glm::ivec2 offset = meshBuildQueue[i]; size_t index = From 3c7755f61bab3e3311a089d8b99024ad081d1c10 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 5 Oct 2026 21:39:18 +0300 Subject: [PATCH 56/91] fix 'selectable' with static entities --- src/objects/Entities.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/objects/Entities.cpp b/src/objects/Entities.cpp index c2ce479c6..46746684e 100644 --- a/src/objects/Entities.cpp +++ b/src/objects/Entities.cpp @@ -328,14 +328,17 @@ void Entities::preparePhysics(float delta) { auto view = registry->view(); for (auto [entity, eid, rigidbody] : view.each()) { auto bodyType = rigidbody.hitbox.type; - if (eid.destroyFlag || !rigidbody.enabled || bodyType == BodyType::STATIC) { + if (eid.destroyFlag || !rigidbody.enabled) { continue; } + rigidbody.hitbox.selectable = rigidbody.selectable; rigidbody.hitbox.mass = bodyType == BodyType::DYNAMIC ? rigidbody.mass : std::numeric_limits::infinity(); rigidbody.hitbox.elasticity = rigidbody.elasticity; - rigidbody.hitbox.selectable = rigidbody.selectable; + if (bodyType == BodyType::STATIC) { + continue; + } hitboxes.emplace_back(&rigidbody.hitbox); if (!eid.def.solid) { continue; From 446b6edd03d0b25e3531160025851fc45248448c Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 5 Oct 2026 21:57:16 +0300 Subject: [PATCH 57/91] update doc/*/scripting/ecs.md --- doc/en/scripting/ecs.md | 6 ++++-- doc/ru/scripting/ecs.md | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/en/scripting/ecs.md b/doc/en/scripting/ecs.md index 0473fc852..0968e2d8d 100644 --- a/doc/en/scripting/ecs.md +++ b/doc/en/scripting/ecs.md @@ -185,9 +185,11 @@ rig:index(name: str) -> int -- or the skeleton if no index is specified rig:is_visible([optional] index: int) -> bool +-- Sets the visibility status of the skeleton +rig:set_visible(status: bool) + -- Sets the visibility status of a bone by index --- or the skeleton if no index is specified -rig:set_visible([optional] index: int, status: bool) +rig:set_visible(index: int, status: bool) -- Returns the color of the entity rig:get_color() -> vec4 diff --git a/doc/ru/scripting/ecs.md b/doc/ru/scripting/ecs.md index d6a823cf0..fb03721c6 100644 --- a/doc/ru/scripting/ecs.md +++ b/doc/ru/scripting/ecs.md @@ -174,9 +174,11 @@ rig:index(name: str) -> int -- или всего скелета, если индекс не указан rig:is_visible([optional] index: int) -> bool +-- Устанавливает статус видимости всего скелета +rig:set_visible(status: bool) + -- Устанавливает статус видимости кости по индексу --- или всего скелета, если индекс не указан -rig:set_visible([optional] index: int, status: bool) +rig:set_visible(index: int, status: bool) -- Возвращает цвет сущности rig:get_color() -> vec4 From 76e5e5b6f847e597d53180802957517701de7b8a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 5 Oct 2026 22:11:21 +0300 Subject: [PATCH 58/91] fix vca 'configure' directive parsing --- res/modules/internal/formats/vca.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index 4ecf4c895..c44d28904 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -18,12 +18,12 @@ local curve_to_interp = { local function parse_configure(raw_track, node) if node.fps then - raw_track.fps = node.fps + raw_track.fps = tonumber(node.fps) end if node.frames then - raw_track.duration = node.frames / (node.fps or DEFAULT_FPS) + raw_track.duration = tonumber(node.frames) / (tonumber(raw_track.fps) or DEFAULT_FPS) elseif node.duration then - raw_track.duration = node.duration + raw_track.duration = tonumber(node.duration) end raw_track.rotation_order = string.upper(node["rotation-order"] or "XYZ") end From cdc32173c385ea80419762e69cada1501a7107d2 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 5 Oct 2026 22:26:04 +0300 Subject: [PATCH 59/91] update doc/*/xml-ui-layouts.md --- doc/en/xml-ui-layouts.md | 3 +++ doc/ru/xml-ui-layouts.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/doc/en/xml-ui-layouts.md b/doc/en/xml-ui-layouts.md index 704a0b786..8d04ff4ec 100644 --- a/doc/en/xml-ui-layouts.md +++ b/doc/en/xml-ui-layouts.md @@ -215,6 +215,9 @@ Element is a container. Does not have specific attributes. > [!WARNING] > Inventories position is controlled by the engine and can not be changed by attributes *pos* and *margin* +> [!WARNING] +> Slots not linked to an inventory will not be displayed. "Linked to an inventory" refers to the association between an inventory UI element and an inventory via an ID. This link can be explicitly established using `inventory_ui.inventory = inventory_id`. [(see ui.md)](scripting/ui.md#inventory) + ## *slot* Element must be in direct sub-element of *inventory*. diff --git a/doc/ru/xml-ui-layouts.md b/doc/ru/xml-ui-layouts.md index 9be788e7f..94f396495 100644 --- a/doc/ru/xml-ui-layouts.md +++ b/doc/ru/xml-ui-layouts.md @@ -216,6 +216,9 @@ > [!WARNING] > Расположение инвентарей управляется движком и не может быть изменено свойствами pos, margin и т.д. +> [!WARNING] +> Слоты без привязки к инвентарю не будут отображаться. Под приязкой к инвентарю понимается связь UI элемента inventory с инвентарём по id. Которая может быть явно создана через `inventory_ui.inventory = inventory_id`. [(см ui.md)](scripting/ui.md#инвентарь-inventory) + ## Одиночный слот - *slot* Элемент должен находиться внутри `inventory` элемента, без посредников. From cf35023adfb504cabf3bd825dd2079743f24f46f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 6 Oct 2026 12:53:50 +0300 Subject: [PATCH 60/91] fix 'mouse:' input prefix is not available --- src/delegates.hpp | 2 +- src/logic/scripting/lua/libs/libinput.cpp | 5 ++++- src/logic/scripting/lua/lua_util.cpp | 2 +- src/logic/scripting/lua/lua_util.hpp | 2 +- src/window/detail/GLFWWindow.cpp | 9 ++++++++- src/window/input.hpp | 5 +++-- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/delegates.hpp b/src/delegates.hpp index f583f951d..abd489ca2 100644 --- a/src/delegates.hpp +++ b/src/delegates.hpp @@ -8,7 +8,7 @@ using runnable = std::function; template using supplier = std::function; template using consumer = std::function; -using KeyCallback = std::function; +using InputCallback = std::function; // data sources using wstringsupplier = std::function; diff --git a/src/logic/scripting/lua/libs/libinput.cpp b/src/logic/scripting/lua/libs/libinput.cpp index 68469bb23..352da415a 100644 --- a/src/logic/scripting/lua/libs/libinput.cpp +++ b/src/logic/scripting/lua/libs/libinput.cpp @@ -44,10 +44,13 @@ static int l_add_callback(lua::State* L) { auto& input = engine->getInput(); if (pos != std::string::npos) { - std::string prefix = bindname.substr(0, pos); + auto prefix = std::string_view(bindname).substr(0, pos); if (prefix == "key") { auto key = input_util::keycode_from(bindname.substr(pos + 1)); handler = input.addKeyCallback(key, actual_callback); + } else if (prefix == "mouse") { + auto mouse = input_util::mousecode_from(bindname.substr(pos + 1)); + handler = input.addMouseCallback(mouse, actual_callback); } } diff --git a/src/logic/scripting/lua/lua_util.cpp b/src/logic/scripting/lua/lua_util.cpp index 6457911b0..d1ca02473 100644 --- a/src/logic/scripting/lua/lua_util.cpp +++ b/src/logic/scripting/lua/lua_util.cpp @@ -263,7 +263,7 @@ runnable lua::create_runnable(State* L) { }; } -KeyCallback lua::create_simple_handler(State* L) { +InputCallback lua::create_simple_handler(State* L) { auto funcptr = create_lambda_handler(L); return [=]() -> bool { if (!get_from_registry(L, LAMBDAS_TABLE, *funcptr, false)) { diff --git a/src/logic/scripting/lua/lua_util.hpp b/src/logic/scripting/lua/lua_util.hpp index 61b56cef3..690fcb32d 100644 --- a/src/logic/scripting/lua/lua_util.hpp +++ b/src/logic/scripting/lua/lua_util.hpp @@ -665,7 +665,7 @@ namespace lua { } runnable create_runnable(lua::State*); - KeyCallback create_simple_handler(lua::State*); + InputCallback create_simple_handler(lua::State*); scripting::common_func create_lambda(lua::State*); scripting::common_func create_lambda_nothrow(lua::State*); diff --git a/src/window/detail/GLFWWindow.cpp b/src/window/detail/GLFWWindow.cpp index ca168a064..08b39bd07 100644 --- a/src/window/detail/GLFWWindow.cpp +++ b/src/window/detail/GLFWWindow.cpp @@ -216,10 +216,17 @@ public: return bindings; } - ObserverHandler addKeyCallback(Keycode key, KeyCallback callback) override { + ObserverHandler addKeyCallback(Keycode key, InputCallback callback) override { return keyCallbacks[key].add(std::move(callback)); } + ObserverHandler addMouseCallback(Mousecode button, InputCallback callback) override { + return addKeyCallback( + static_cast(MOUSE_KEYS_OFFSET + static_cast(button)), + std::move(callback) + ); + } + const std::vector& getPressedKeys() const override { return pressedKeys; } diff --git a/src/window/input.hpp b/src/window/input.hpp index 59d663672..839eeca96 100644 --- a/src/window/input.hpp +++ b/src/window/input.hpp @@ -288,12 +288,13 @@ public: virtual const Bindings& getBindings() const = 0; - virtual ObserverHandler addKeyCallback(Keycode key, KeyCallback callback) = 0; + virtual ObserverHandler addKeyCallback(Keycode key, InputCallback callback) = 0; + virtual ObserverHandler addMouseCallback(Mousecode button, InputCallback callback) = 0; virtual const std::vector& getPressedKeys() const = 0; virtual const std::vector& getCodepoints() const = 0; - ObserverHandler addCallback(const std::string& name, KeyCallback callback) { + ObserverHandler addCallback(const std::string& name, InputCallback callback) { return getBindings().require(name).onactived.add(callback); } }; From 5060a8635deca8f8a9867fcd4006988f48a5b432 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 7 Oct 2026 23:09:40 +0300 Subject: [PATCH 61/91] fix locked cursor if world was closed with menu hidden --- src/frontend/screens/MenuScreen.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/frontend/screens/MenuScreen.cpp b/src/frontend/screens/MenuScreen.cpp index 6472578d9..d9628ceb3 100644 --- a/src/frontend/screens/MenuScreen.cpp +++ b/src/frontend/screens/MenuScreen.cpp @@ -28,7 +28,10 @@ MenuScreen::~MenuScreen() = default; void MenuScreen::onOpen() { engine.getContentControl().resetContent({}); - auto menu = engine.getGUI().getMenu(); + auto& gui = engine.getGUI(); + gui.setActiveFrame(gui::GUI::CORE_MAIN); + + auto menu = gui.getMenu(); menu->reset(); } From e8a83423d8d0c6bbc14f6974b7c05c106801ddbf Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 9 Oct 2026 00:09:48 +0300 Subject: [PATCH 62/91] fix outdated doc/*/scripting/builtins/libgfx-skeletons.md --- doc/en/scripting/builtins/libgfx-skeletons.md | 10 ++++++++-- doc/ru/scripting/builtins/libgfx-skeletons.md | 12 +++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/en/scripting/builtins/libgfx-skeletons.md b/doc/en/scripting/builtins/libgfx-skeletons.md index 4146b4be6..5518cb349 100644 --- a/doc/en/scripting/builtins/libgfx-skeletons.md +++ b/doc/en/scripting/builtins/libgfx-skeletons.md @@ -41,8 +41,14 @@ skeleton:is_visible([optional] index: int) -> bool skeleton:set_visible([optional] index: int, status: bool) -- Returns the color of the entity -skeleton:get_color() -> vec3 +skeleton:get_color() -> vec4 + +-- Returns the color of the bone +skeleton:get_color(index: int) -> vec4 -- Sets the color of the entity -skeleton:set_color(color: vec3) +skeleton:set_color(color: vec4) + +-- Sets the color of the bone +skeleton:set_color(color: vec4, bone: int) ``` diff --git a/doc/ru/scripting/builtins/libgfx-skeletons.md b/doc/ru/scripting/builtins/libgfx-skeletons.md index 2a04d598c..95fa4fe48 100644 --- a/doc/ru/scripting/builtins/libgfx-skeletons.md +++ b/doc/ru/scripting/builtins/libgfx-skeletons.md @@ -42,8 +42,14 @@ skeleton:is_visible([опционально] index: int) -> boolean skeleton:set_visible([опционально] index: int, status: boolean) -- Возвращает цвет сущности -skeleton:get_color() -> vec3 +skeleton:get_color() -> vec4 + +-- Возвращает цвет кости +skeleton:get_color(index: int) -> vec4 -- Устанавливает цвет сущности -skeleton:set_color(color: vec3) -``` \ No newline at end of file +skeleton:set_color(color: vec4) + +-- Устанавливает цвет кости +skeleton:set_color(color: vec4, index: int) +``` From d8017ff99553039e6d0114a033eb9c352076eaee Mon Sep 17 00:00:00 2001 From: ostermine Date: Sat, 10 Oct 2026 00:52:23 +0300 Subject: [PATCH 63/91] fix reload_module ignoring pack environment reload_module loaded the new module code with the global environment, while require runs modules in their pack environment. After reload, PACK_ID and other pack globals were nil in the module. --- dev/tests/reload_module.lua | 33 +++++++++++++++++++++++++++++++++ res/scripts/stdmin.lua | 16 ++++++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 dev/tests/reload_module.lua diff --git a/dev/tests/reload_module.lua b/dev/tests/reload_module.lua new file mode 100644 index 000000000..8ee5ab232 --- /dev/null +++ b/dev/tests/reload_module.lua @@ -0,0 +1,33 @@ +-- reload_module must run the module in its pack environment, as require does +local util = require "core:tests_util" +util.create_demo_world() + +-- a pack with a module that uses pack environment (PACK_ID) +local PACK = "world:content/reload_test" +file.mkdirs(PACK .. "/modules") +file.write(PACK .. "/package.json", json.tostring({id="reload_test", title="reload_test"})) + +local function write_module(version) + file.write(PACK .. "/modules/mod.lua", string.format([[ +local this = {} +function this.info() return PACK_ID, %d end +return this +]], version)) +end + +write_module(1) +app.reconfig_packs({"reload_test"}, {}) +app.tick() + +local mod = require "reload_test:mod" +local packid, version = mod.info() +assert(packid == "reload_test" and version == 1) + +write_module(2) +reload_module("reload_test:mod") +packid, version = mod.info() +assert(version == 2, "module is not reloaded") +assert(packid == "reload_test", "reloaded module has no pack environment") + +app.close_world(true) +app.delete_world("demo") diff --git a/res/scripts/stdmin.lua b/res/scripts/stdmin.lua index e1b735478..9fe297aab 100644 --- a/res/scripts/stdmin.lua +++ b/res/scripts/stdmin.lua @@ -183,6 +183,12 @@ function on_deprecated_call(name, alternatives) end end +local __pack_envs = __vc__pack_envs +function __vc_internals.get_pack_env(packid) + return __pack_envs[packid] +end +__vc__pack_envs = nil + function reload_module(name) local prefix, name = parse_path(name) local path = prefix..":modules/"..name..".lua" @@ -196,6 +202,10 @@ function reload_module(name) if script == nil then error(err) end + local env = __pack_envs[prefix] + if env then + script = setfenv(script, env) + end local result = script() if not result then return @@ -270,12 +280,6 @@ function __vc_lock_internal_modules() __internal_locked = true end -local __pack_envs = __vc__pack_envs -function __vc_internals.get_pack_env(packid) - return __pack_envs[packid] -end -__vc__pack_envs = nil - function require(path) if not string.find(path, ':') then local prefix, _ = parse_path(_debug_getinfo(2).source) From a22ceaf165a808317d19fc48e1acc21534975f25 Mon Sep 17 00:00:00 2001 From: ostermine Date: Sat, 10 Oct 2026 01:26:09 +0300 Subject: [PATCH 64/91] add key names for punctuation keys Bindings can now use minus, equal, left-bracket, right-bracket, backslash, semicolon, apostrophe, comma, period and slash (GLFW key codes). --- src/window/input.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/window/input.cpp b/src/window/input.cpp index cbb05a888..57454020d 100644 --- a/src/window/input.cpp +++ b/src/window/input.cpp @@ -36,6 +36,16 @@ static std::unordered_map keycodes { {"left-super", GLFW_KEY_LEFT_SUPER}, {"right-super", GLFW_KEY_RIGHT_SUPER}, {"grave-accent", GLFW_KEY_GRAVE_ACCENT}, + {"minus", GLFW_KEY_MINUS}, + {"equal", GLFW_KEY_EQUAL}, + {"left-bracket", GLFW_KEY_LEFT_BRACKET}, + {"right-bracket", GLFW_KEY_RIGHT_BRACKET}, + {"backslash", GLFW_KEY_BACKSLASH}, + {"semicolon", GLFW_KEY_SEMICOLON}, + {"apostrophe", GLFW_KEY_APOSTROPHE}, + {"comma", GLFW_KEY_COMMA}, + {"period", GLFW_KEY_PERIOD}, + {"slash", GLFW_KEY_SLASH}, {"left", GLFW_KEY_LEFT}, {"right", GLFW_KEY_RIGHT}, {"down", GLFW_KEY_DOWN}, From a2321e0e28a21dd1abc39db67f727ca7ed728dcc Mon Sep 17 00:00:00 2001 From: DIvan2000 Date: Sat, 10 Oct 2026 05:04:14 +0400 Subject: [PATCH 65/91] fix program filename --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ead09d092..83b5cc955 100644 --- a/flake.nix +++ b/flake.nix @@ -64,7 +64,7 @@ packages.default = voxel-core; apps.default = { type = "app"; - program = "${voxel-core}/bin/VoxelCore"; + program = "${voxel-core}/bin/VoxelEngine"; }; } ); From 8962042627ded0641db85f4a8b6d896d7d7dbbf4 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 10:54:36 +0300 Subject: [PATCH 66/91] complete the rename of voxelengine to voxelcore --- .github/workflows/appimage.yml | 6 +++--- .github/workflows/cmake.yml | 6 +++--- .github/workflows/macos.yml | 20 ++++++++++---------- .github/workflows/release.yml | 2 +- .github/workflows/windows-clang.yml | 3 +-- .github/workflows/windows.yml | 3 +-- CMakeLists.txt | 12 ++++++------ Dockerfile | 2 +- README.md | 4 ++-- dev/AppImageBuilder.yml | 2 +- dev/VoxelCore.desktop | 4 ++-- dev/cmake/BuildAppdir.cmake | 2 +- dev/tests/network_http.lua | 2 +- doc/en/scripting/builtins/libnetwork.md | 2 +- doc/ru/scripting/builtins/libnetwork.md | 2 +- doc/specs/binary_json_spec.md | 2 +- flake.nix | 4 ++-- run.sh | 4 ++-- src/CMakeLists.txt | 12 ++++++------ test/CMakeLists.txt | 10 +++++----- test/network/curltest.cpp | 2 +- 21 files changed, 52 insertions(+), 54 deletions(-) diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index 5bfebeb4d..7b53b3fbf 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -50,13 +50,13 @@ jobs: - name: Run engine tests timeout-minutes: 5 run: | - chmod +x build/VoxelEngine + chmod +x build/VoxelCore chmod +x AppDir/usr/bin/vctest - AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build --memchecker valgrind + AppDir/usr/bin/vctest -e build/VoxelCore -d dev/tests -u build --memchecker valgrind - name: Build AppImage uses: AppImageCrafters/build-appimage-action@fe2205a4d6056be47051f7b1b3811106e9814910 env: - UPDATE_INFO: gh-releases-zsync|MihailRis|VoxelEngine-Cpp|latest|*x86_64.AppImage.zsync + UPDATE_INFO: gh-releases-zsync|MihailRis|voxelcore|latest|*x86_64.AppImage.zsync with: recipe: dev/AppImageBuilder.yml - uses: actions/upload-artifact@v4 diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 52f7b7183..6956a1f3d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -62,7 +62,7 @@ jobs: # Build your program with the given configuration run: | cmake --build ${{github.workspace}}/build --config ${{inputs.build_type}} - mv ${{github.workspace}}/build/VoxelEngine VoxelEngine + mv ${{github.workspace}}/build/VoxelCore VoxelCore - name: Run tests if: ${{ inputs.run_tests }} run: ctest --test-dir ${{github.workspace}}/build @@ -70,7 +70,7 @@ jobs: if: ${{ inputs.upload_artifacts }} uses: actions/upload-artifact@v4 with: - name: VoxelEngine + name: VoxelCore path: | - VoxelEngine + VoxelCore res/* diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index b4d9f6328..a446821d8 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -39,7 +39,7 @@ jobs: run: chmod +x dev/fix_dylibs.sh - name: Fix dylibs - run: ./dev/fix_dylibs.sh VoxelEngine Release build + run: ./dev/fix_dylibs.sh VoxelCore Release build - name: Run tests run: ctest --output-on-failure --test-dir build @@ -47,19 +47,19 @@ jobs: - name: Run engine tests timeout-minutes: 5 run: | - chmod +x build/VoxelEngine + chmod +x build/VoxelCore chmod +x AppDir/usr/bin/vctest - AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build --output-always --debugger "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- " + AppDir/usr/bin/vctest -e build/VoxelCore -d dev/tests -u build --output-always --debugger "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- " - name: Create DMG run: | - mkdir VoxelEngineDmgContent - cp -r build/res VoxelEngineDmgContent/ - cp -r build/VoxelEngine VoxelEngineDmgContent/ - cp -r build/libs VoxelEngineDmgContent/libs - hdiutil create VoxelEngineMacApp.dmg -volname "VoxelEngine" -srcfolder VoxelEngineDmgContent -ov -format UDZO + mkdir VoxelCoreDmgContent + cp -r build/res VoxelCoreDmgContent/ + cp -r build/VoxelCore VoxelCoreDmgContent/ + cp -r build/libs VoxelCoreDmgContent/libs + hdiutil create VoxelCoreMacApp.dmg -volname "VoxelCore" -srcfolder VoxelCoreDmgContent -ov -format UDZO - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: VoxelEngineMacOs - path: VoxelEngineMacApp.dmg + name: VoxelCoreMacOs + path: VoxelCoreMacApp.dmg diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a1d17c64..f6b539ba1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,7 +48,7 @@ jobs: mkdir release mv ./artifacts/AppImage/VoxelCore-latest-x86_64.AppImage \ ./release/voxelcore-${RELEASE_VERSION}_x86-64.AppImage - mv ./artifacts/VoxelEngineMacOs/VoxelEngineMacApp.dmg \ + mv ./artifacts/VoxelCoreMacOs/VoxelCoreMacApp.dmg \ ./release/voxelcore-${RELEASE_VERSION}_macos.dmg (cd ./artifacts/Windows-Build && zip -r ../../release/voxelcore-${RELEASE_VERSION}_win64.zip .) ls -la ./release diff --git a/.github/workflows/windows-clang.yml b/.github/workflows/windows-clang.yml index 5dd91a576..1fe591ac8 100644 --- a/.github/workflows/windows-clang.yml +++ b/.github/workflows/windows-clang.yml @@ -59,11 +59,10 @@ jobs: run: | mkdir packaged mkdir packaged/res - cp build/VoxelEngine.exe packaged/ + cp build/VoxelCore.exe packaged/ cp build/vctest/vctest.exe packaged/ cp build/*.dll packaged/ cp -r build/res/* packaged/res/ - mv packaged/VoxelEngine.exe packaged/VoxelCore.exe - uses: actions/upload-artifact@v4 with: name: Windows-Build diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ffcb0c318..ec5322bc0 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -37,7 +37,7 @@ jobs: run: ctest --preset default-vs-msvc-windows - name: Run engine tests run: | - build/vctest/RelWithDebInfo/vctest.exe -e build/RelWithDebInfo/VoxelEngine.exe -d dev/tests -u build + build/vctest/RelWithDebInfo/vctest.exe -e build/RelWithDebInfo/VoxelCore.exe -d dev/tests -u build timeout-minutes: 5 - name: Package for Windows run: | @@ -45,7 +45,6 @@ jobs: cp -r build/RelWithDebInfo/* packaged/ cp build/vctest/RelWithDebInfo/vctest.exe packaged/ cp C:/Windows/System32/msvcp140.dll packaged/msvcp140.dll - mv packaged/VoxelEngine.exe packaged/VoxelCore.exe working-directory: ${{ github.workspace }} - uses: actions/upload-artifact@v4 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 27a9d507b..a9ac24a1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -project(VoxelEngine) +project(VoxelCore) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -27,23 +27,23 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") endif() add_subdirectory(src) -add_executable(VoxelEngine src/main.cpp) +add_executable(VoxelCore src/main.cpp) if(VOXELENGINE_BUILD_APPDIR) include(${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/BuildAppdir.cmake) endif() -target_link_libraries(VoxelEngine PRIVATE VoxelEngineSrc +target_link_libraries(VoxelCore PRIVATE VoxelCoreSrc $<$:winmm>) -target_link_options(VoxelEngine PRIVATE $<$:-no-pie>) +target_link_options(VoxelCore PRIVATE $<$:-no-pie>) # Deploy res to build dir add_custom_command( - TARGET VoxelEngine + TARGET VoxelCore POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different - ${CMAKE_CURRENT_SOURCE_DIR}/res $/res) + ${CMAKE_CURRENT_SOURCE_DIR}/res $/res) if(VOXELENGINE_BUILD_TESTS) enable_testing() diff --git a/Dockerfile b/Dockerfile index 3a06d1afc..fb1a628c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Build docker container: docker build -t voxelcore . # Build project: docker run --rm -it -v$(pwd):/project voxelcore bash -c "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE -Bbuild && cmake --build build" -# Run project in docker: docker run --rm -it -v$(pwd):/project -v/tmp/.X11-unix:/tmp/.X11-unix -v${XAUTHORITY}:/home/user/.Xauthority:ro -eDISPLAY --network=host voxelcore ./build/VoxelEngine +# Run project in docker: docker run --rm -it -v$(pwd):/project -v/tmp/.X11-unix:/tmp/.X11-unix -v${XAUTHORITY}:/home/user/.Xauthority:ro -eDISPLAY --network=host voxelcore ./build/VoxelCore FROM debian:bookworm-slim LABEL Description="Docker container for building VoxelCore for Linux" diff --git a/README.md b/README.md index 67788d9fd..d040e7707 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ docker run --rm -it \ -v "$XAUTHORITY:/home/user/.Xauthority:ro" \ -e DISPLAY="$DISPLAY" \ --network=host \ - voxel-engine ./build/VoxelEngine + voxel-engine ./build/VoxelCore ``` ### On Windows @@ -218,5 +218,5 @@ docker run --rm -it -v "${PWD}:/project" voxel-engine bash -c "cmake -DCMAKE_BUI #### Step 4. Run the application ```powershell -docker run --rm -it -v "${PWD}:/project" -e DISPLAY=host.docker.internal:0.0 --network=host voxel-engine ./build/VoxelEngine +docker run --rm -it -v "${PWD}:/project" -e DISPLAY=host.docker.internal:0.0 --network=host voxel-engine ./build/VoxelCore ``` diff --git a/dev/AppImageBuilder.yml b/dev/AppImageBuilder.yml index b2c7f09ec..bed1dde47 100644 --- a/dev/AppImageBuilder.yml +++ b/dev/AppImageBuilder.yml @@ -6,7 +6,7 @@ AppDir: name: VoxelCore icon: VoxelCore version: latest - exec: usr/bin/VoxelEngine + exec: usr/bin/VoxelCore exec_args: --dir $HOME/.config/voxelcore --res $APPDIR/usr/share/VoxelCore/res $@ apt: arch: amd64 diff --git a/dev/VoxelCore.desktop b/dev/VoxelCore.desktop index 48809b392..eeaf4be30 100644 --- a/dev/VoxelCore.desktop +++ b/dev/VoxelCore.desktop @@ -3,8 +3,8 @@ Version=1.0 Type=Application Name=VoxelCore Comment=Minecraft-like game engine in C++ with OpenGL -TryExec=VoxelEngine -Exec=VoxelEngine +TryExec=VoxelCore +Exec=VoxelCore Icon=VoxelCore MimeType=image/x-foo; Categories=Game; diff --git a/dev/cmake/BuildAppdir.cmake b/dev/cmake/BuildAppdir.cmake index e3a017e94..7445d1016 100644 --- a/dev/cmake/BuildAppdir.cmake +++ b/dev/cmake/BuildAppdir.cmake @@ -12,4 +12,4 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.desktop DESTINATION ${CMAKE_ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin) -install(TARGETS VoxelEngine DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin) +install(TARGETS VoxelCore DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin) diff --git a/dev/tests/network_http.lua b/dev/tests/network_http.lua index 12149de09..76fd7f54e 100644 --- a/dev/tests/network_http.lua +++ b/dev/tests/network_http.lua @@ -1,6 +1,6 @@ local response_received = false -network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s) +network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s) print(json.parse(s).name) response_received = true end, function (code) diff --git a/doc/en/scripting/builtins/libnetwork.md b/doc/en/scripting/builtins/libnetwork.md index 8893407d4..ecd76bbf3 100644 --- a/doc/en/scripting/builtins/libnetwork.md +++ b/doc/en/scripting/builtins/libnetwork.md @@ -50,7 +50,7 @@ network.get( ) -- Example: -network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s) +network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s) print(json.parse(s).name) -- will output the name of the latest engine release end) diff --git a/doc/ru/scripting/builtins/libnetwork.md b/doc/ru/scripting/builtins/libnetwork.md index c60f0f178..2c322405e 100644 --- a/doc/ru/scripting/builtins/libnetwork.md +++ b/doc/ru/scripting/builtins/libnetwork.md @@ -50,7 +50,7 @@ network.get( ) -- Пример: -network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s) +network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s) print(json.parse(s).name) -- выведет имя последнего релиза движка end) diff --git a/doc/specs/binary_json_spec.md b/doc/specs/binary_json_spec.md index 46ed868d6..4bed562e4 100644 --- a/doc/specs/binary_json_spec.md +++ b/doc/specs/binary_json_spec.md @@ -2,7 +2,7 @@ Format version: 1.1 -This binary data format is developed for use as binary version of JSON in [VoxelEngine-Cpp](https://github.com/MihailRis/VoxelEngine-Cpp) and not compatible with [BSON](https://bsonspec.org/spec.html) due to elements/entries syntax and type codes differences +This binary data format is developed for use as binary version of JSON in [voxelcore](https://github.com/MihailRis/voxelcore) and not compatible with [BSON](https://bsonspec.org/spec.html) due to elements/entries syntax and type codes differences ## Basic types diff --git a/flake.nix b/flake.nix index 83b5cc955..cb6bfe6ca 100644 --- a/flake.nix +++ b/flake.nix @@ -56,7 +56,7 @@ installPhase = '' mkdir -p $out/bin - cp VoxelEngine $out/bin/ + cp VoxelCore $out/bin/ ''; }; in @@ -64,7 +64,7 @@ packages.default = voxel-core; apps.default = { type = "app"; - program = "${voxel-core}/bin/VoxelEngine"; + program = "${voxel-core}/bin/VoxelCore"; }; } ); diff --git a/run.sh b/run.sh index 612f06935..40532ad5c 100755 --- a/run.sh +++ b/run.sh @@ -62,5 +62,5 @@ done if [[ $run ]]; then echo "[RUN SCRIPT] Run project" - ./build/VoxelEngine -fi \ No newline at end of file + ./build/VoxelCore +fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 802c06e1a..8eae55c33 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,10 @@ -project(VoxelEngineSrc) +project(VoxelCoreSrc) file(GLOB_RECURSE headers ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp) -add_library(VoxelEngineSrc STATIC ${sources} ${headers}) +add_library(VoxelCoreSrc STATIC ${sources} ${headers}) find_package(OpenGL REQUIRED) find_package(GLEW REQUIRED) @@ -70,10 +70,10 @@ else() add_library(luajit::luajit ALIAS PkgConfig::luajit) endif() -target_include_directories(VoxelEngineSrc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(VoxelCoreSrc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries( - VoxelEngineSrc + VoxelCoreSrc PRIVATE glfw OpenGL::GL GLEW::GLEW @@ -91,7 +91,7 @@ target_link_libraries( ) target_compile_options( - VoxelEngineSrc + VoxelCoreSrc PUBLIC $<$: /utf-8 /MP @@ -129,7 +129,7 @@ target_compile_options( >) target_link_options( - VoxelEngineSrc + VoxelCoreSrc PUBLIC $<$: -no-pie diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e2aae2a74..708fb8da1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,22 +1,22 @@ -project(VoxelEngineTest) +project(VoxelCoreTest) file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) find_package(GTest) -add_executable(VoxelEngineTest ${sources}) +add_executable(VoxelCoreTest ${sources}) -target_link_libraries(VoxelEngineTest PRIVATE VoxelEngineSrc GTest::gtest_main) +target_link_libraries(VoxelCoreTest PRIVATE VoxelCoreSrc GTest::gtest_main) # HACK: copy res to test/ folder for fixing problem compatibility MultiConfig # and non MultiConfig builds. Delete in future and use only root res folder Also # this resolve problem with ctests, because it set cwd to # ${CMAKE_CURRENT_BINARY_DIR} add_custom_command( - TARGET VoxelEngineTest + TARGET VoxelCoreTest POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_SOURCE_DIR}/res ${CMAKE_CURRENT_BINARY_DIR}/res) include(GoogleTest) -gtest_discover_tests(VoxelEngineTest) +gtest_discover_tests(VoxelCoreTest) diff --git a/test/network/curltest.cpp b/test/network/curltest.cpp index e7fc4840d..44a5bb38e 100644 --- a/test/network/curltest.cpp +++ b/test/network/curltest.cpp @@ -8,7 +8,7 @@ TEST(curltest, curltest) { auto network = network::Network::create(settings); network::HttpRequest request {}; - request.url = "https://raw.githubusercontent.com/MihailRis/VoxelEngine-Cpp/refs/" + request.url = "https://raw.githubusercontent.com/MihailRis/voxelcore/refs/" "heads/curl/res/content/base/blocks/lamp.json"; request.onResponse = [](network::HttpResponse response) { if (response.body.empty()) { From 521ebf43abf971f737bb473f3a3deb4a61772a11 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 11:36:31 +0300 Subject: [PATCH 67/91] remove incorrect fix --- src/graphics/ui/elements/SplitBox.cpp | 13 ------------- src/graphics/ui/elements/SplitBox.hpp | 1 - 2 files changed, 14 deletions(-) diff --git a/src/graphics/ui/elements/SplitBox.cpp b/src/graphics/ui/elements/SplitBox.cpp index c35374529..247ef7410 100644 --- a/src/graphics/ui/elements/SplitBox.cpp +++ b/src/graphics/ui/elements/SplitBox.cpp @@ -82,19 +82,6 @@ void SplitBox::doubleClick(int x, int y) { refresh(); } -std::shared_ptr SplitBox::getAt(const glm::vec2& pos) { - auto hover = Container::getAt(pos); - if (hover.get() != this) { - return hover; - } - for (const auto& node : nodes) { - if (node->isVisible() && node->isInside(pos)) { - return nullptr; - } - } - return hover; -} - void SplitBox::fullRefresh() { refresh(); reposition(); diff --git a/src/graphics/ui/elements/SplitBox.hpp b/src/graphics/ui/elements/SplitBox.hpp index 1a452c2ff..8482e73ec 100644 --- a/src/graphics/ui/elements/SplitBox.hpp +++ b/src/graphics/ui/elements/SplitBox.hpp @@ -11,7 +11,6 @@ namespace gui { virtual void refresh() override; virtual void fullRefresh() override; virtual void doubleClick(int x, int y) override; - virtual std::shared_ptr getAt(const glm::vec2& pos) override; private: float splitPos; }; From 8ce3b6dc23010ccdd6009a52060fb960251d08e1 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 15:45:56 +0300 Subject: [PATCH 68/91] add '--test' to run.sh --- run.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/run.sh b/run.sh index 40532ad5c..13b824d3c 100755 --- a/run.sh +++ b/run.sh @@ -31,6 +31,17 @@ function norun { } +function test { + echo "[RUN SCRIPT] Run tests" + cd build + rm -rf ./vctest-run + mkdir ./vctest-run + ./vctest/vctest --exe ./VoxelEngine --res res --user ./vctest-run --tests ../dev/tests --memchecker valgrind + cd .. + run= +} + + function help { echo "[RUN SCRIPT] Usage: ./run [ARGUMENT]..." echo "[RUN SCRIPT] Arguments:" @@ -38,6 +49,7 @@ function help { echo "[RUN SCRIPT] -b, --build Build project" echo "[RUN SCRIPT] -r, --rebuild Rebuild project" echo "[RUN SCRIPT] -R, --norun Build without run" + echo "[RUN SCRIPT] -t, --test Run tests (without run)" echo "[RUN SCRIPT] -h, --help Print this page" } @@ -48,6 +60,7 @@ while [ -n "$1" ]; do -b | --build) build ;; -r | --rebuild) rebuild ;; -R | --norun) norun ;; + -t | --test) test ;; -h | --help) help norun break ;; From fa5466f675a381861e20dcbb8c2e7ba33288f557 Mon Sep 17 00:00:00 2001 From: ostermine Date: Sat, 10 Oct 2026 15:54:28 +0300 Subject: [PATCH 69/91] fix zip archives paths and add zip files test - create_zip from a subdirectory wrote entry names with a leading '/', so the mounted archive looked empty - memory_ostream did not support tellp(), so create_zip into a memory device wrote invalid offsets (-1) to the archive - ZipFileDevice added missing parent directories for the first entry only - ZipFileDevice::exists returned false for the archive root - MemoryDevice::mkdirs recreated existing directories, dropping their content (mkdir("a/b") cleared "a"); overwriting a file duplicated its name in the directory listing Added dev/tests/zip_files.lua: builds archives with file.create_zip from memory device root, subdirectories and the real filesystem, mounts them and checks reading, listing and read-only access. memory_filesystem.lua got checks for the MemoryDevice issues. Closes #544 --- dev/tests/memory_filesystem.lua | 11 +++ dev/tests/zip_files.lua | 118 +++++++++++++++++++++++++++++++ src/io/devices/MemoryDevice.cpp | 13 ++++ src/io/devices/ZipFileDevice.cpp | 18 ++++- src/io/memory_ostream.hpp | 13 ++++ 5 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 dev/tests/zip_files.lua diff --git a/dev/tests/memory_filesystem.lua b/dev/tests/memory_filesystem.lua index e246279a7..20d8e9700 100644 --- a/dev/tests/memory_filesystem.lua +++ b/dev/tests/memory_filesystem.lua @@ -41,6 +41,17 @@ assert(entries[1] == "memtest:dir/subdir/a.txt") assert(entries[2] == "memtest:dir/subdir/b.txt") assert(entries[3] == "memtest:dir/subdir/other") +debug.log("create sibling directory") +file.mkdir("memtest:dir/subdir/sibling") +assert(file.isfile("memtest:dir/subdir/a.txt")) +assert(file.isdir("memtest:dir/subdir/other")) +asserts.equals(4, #file.list("memtest:dir/subdir")) + +debug.log("overwrite file") +file.write("memtest:dir/subdir/a.txt", "overwritten") +asserts.equals("overwritten", file.read("memtest:dir/subdir/a.txt")) +asserts.equals(4, #file.list("memtest:dir/subdir")) + debug.log("remove tree") file.remove_tree("memtest:dir") assert(not file.isdir("memtest:dir")) diff --git a/dev/tests/zip_files.lua b/dev/tests/zip_files.lua new file mode 100644 index 000000000..ad5f4e7e0 --- /dev/null +++ b/dev/tests/zip_files.lua @@ -0,0 +1,118 @@ +local function sorted_list(path) + local entries = file.list(path) + table.sort(entries) + return entries +end + +local function check_list(expected, path) + local entries = sorted_list(path) + asserts.equals(#expected, #entries) + for i, name in ipairs(expected) do + asserts.equals(name, entries[i]) + end +end + +local function join(root, name) + if root:sub(-1) == ":" then + return root..name + end + return root.."/"..name +end + +local bytes = {0xDE, 0xAD, 0x00, 0xC0, 0xDE} + +local function create_tree(root) + file.mkdirs(join(root, "sub/deep")) + file.mkdir(join(root, "empty")) + file.write(join(root, "root.txt"), "root file") + file.write(join(root, "sub/a.txt"), "example, пример") + file.write_bytes(join(root, "sub/deep/binary"), bytes) +end + +local function check_tree(m) + debug.log("check directories") + assert(file.exists(m..":")) + assert(file.isdir(m..":")) + assert(file.isdir(m..":sub")) + assert(file.isdir(m..":sub/deep")) + assert(file.isdir(m..":empty")) + assert(not file.isfile(m..":sub")) + + debug.log("check files") + assert(file.isfile(m..":root.txt")) + assert(file.isfile(m..":sub/a.txt")) + assert(not file.isdir(m..":sub/a.txt")) + assert(not file.exists(m..":missing.txt")) + assert(not file.exists(m..":sub/missing.txt")) + + debug.log("read files") + asserts.equals("root file", file.read(m..":root.txt")) + asserts.equals("example, пример", file.read(m..":sub/a.txt")) + asserts.equals(#"root file", file.length(m..":root.txt")) + + local rbytes = file.read_bytes(m..":sub/deep/binary") + asserts.equals(#bytes, #rbytes) + for i, b in ipairs(bytes) do + asserts.equals(b, rbytes[i]) + end + + debug.log("read file with io_stream") + local stream = file.open(m..":root.txt", "r") + asserts.equals("root file", stream:read_line()) + stream:close() + + debug.log("list directories") + check_list({m..":empty", m..":root.txt", m..":sub"}, m..":") + check_list({m..":sub/a.txt", m..":sub/deep"}, m..":sub") + check_list({m..":sub/deep/binary"}, m..":sub/deep") + check_list({}, m..":empty") + + debug.log("check read-only") + assert(not file.is_writeable(m..":")) + assert(not pcall(file.write, m..":new.txt", "text")) + local ok, created = pcall(file.mkdir, m..":newdir") + assert(not (ok and created)) + assert(not file.exists(m..":newdir")) +end + +local function check_zip(src, zipfile) + debug.log("create zip "..zipfile.." from "..src) + file.create_zip(src, zipfile) + assert(file.isfile(zipfile)) + + debug.log("mount "..zipfile) + local m = file.mount(zipfile) + check_tree(m) + + debug.log("unmount "..m) + file.unmount(m) + assert(not pcall(file.read, m..":root.txt")) + assert(not pcall(file.unmount, m)) +end + +local mem = file.create_memory_device() +local out = file.create_memory_device() + +debug.log("zip memory device root") +create_tree(mem..":") +check_zip(mem..":", out..":root.zip") + +debug.log("zip memory device subdirectory") +create_tree(mem..":pack") +check_zip(mem..":pack", out..":pack.zip") + +debug.log("zip nested subdirectory") +create_tree(mem..":a/b/pack") +check_zip(mem..":a/b/pack", out..":nested.zip") + +debug.log("zip real filesystem directory") +if file.exists("config:ziptest") then + file.remove_tree("config:ziptest") +end +create_tree("config:ziptest/pack") +check_zip("config:ziptest/pack", "config:ziptest/pack.zip") +file.remove_tree("config:ziptest") + +debug.log("mount non-zip file") +file.write(out..":text.txt", "not an archive") +assert(not pcall(file.mount, out..":text.txt")) diff --git a/src/io/devices/MemoryDevice.cpp b/src/io/devices/MemoryDevice.cpp index f9f4760ee..8cf440c4e 100644 --- a/src/io/devices/MemoryDevice.cpp +++ b/src/io/devices/MemoryDevice.cpp @@ -180,6 +180,10 @@ std::unique_ptr io::MemoryDevice::list(std::string_view path } io::MemoryDevice::Dir* io::MemoryDevice::createDir(std::string path) { + const auto& found = nodes.find(path); + if (found != nodes.end()) { + return found->second.get_if(); + } io::path filePath = path; io::path parent = filePath.parent(); auto parentDir = getDir(parent.string()); @@ -195,6 +199,15 @@ io::MemoryDevice::Dir* io::MemoryDevice::createDir(std::string path) { io::MemoryDevice::Node* io::MemoryDevice::createFile( std::string path, util::Buffer&& content ) { + const auto& found = nodes.find(path); + if (found != nodes.end()) { + auto& node = found->second; + if (!node.holds_alternative()) { + return nullptr; + } + node.data = File {std::move(content)}; + return &node; + } io::path filePath = path; io::path parent = filePath.parent(); auto dir = getDir(parent.string()); diff --git a/src/io/devices/ZipFileDevice.cpp b/src/io/devices/ZipFileDevice.cpp index dce053887..2c52439ae 100644 --- a/src/io/devices/ZipFileDevice.cpp +++ b/src/io/devices/ZipFileDevice.cpp @@ -173,7 +173,13 @@ ZipFileDevice::ZipFileDevice( entries[entry.fileName] = std::move(entry); } - for (auto& [name, _] : entries) { + // Add missing parent directories entries + std::vector names; + names.reserve(entries.size()); + for (const auto& [name, _] : entries) { + names.push_back(name); + } + for (const auto& name : names) { io::path path = name; while (!(path = path.parent()).pathPart().empty()) { @@ -184,7 +190,6 @@ ZipFileDevice::ZipFileDevice( entry.isDirectory = true; entries[path.pathPart()] = entry; } - break; } for (auto& [_, entry] : entries) { @@ -253,6 +258,9 @@ file_time_type ZipFileDevice::lastWriteTime(std::string_view path) { } bool ZipFileDevice::exists(std::string_view path) { + if (path.empty()) { + return true; + } return entries.find(std::string(path)) != entries.end(); } @@ -441,7 +449,11 @@ static size_t write_zip( void io::write_zip(const path& folder, const path& file) { ByteBuilder central_dir; auto out = io::write(file); - size_t entries = write_zip(folder.pathPart(), folder, *out, central_dir); + auto root = folder.pathPart(); + if (!root.empty() && root.back() != '/') { + root += '/'; + } + size_t entries = write_zip(root, folder, *out, central_dir); size_t central_dir_offset = out->tellp(); out->write(reinterpret_cast(central_dir.data()), central_dir.size()); diff --git a/src/io/memory_ostream.hpp b/src/io/memory_ostream.hpp index 3ff14a994..329277aff 100644 --- a/src/io/memory_ostream.hpp +++ b/src/io/memory_ostream.hpp @@ -50,6 +50,19 @@ protected: return c; } + pos_type seekoff( + off_type off, + std::ios_base::seekdir way, + std::ios_base::openmode mode = std::ios_base::out + ) override { + // only position query (tellp) is supported + if (off == 0 && way == std::ios_base::cur && + (mode & std::ios_base::out)) { + return pos_type(off_type(size())); + } + return pos_type(off_type(-1)); + } + std::streamsize xsputn(const char* s, std::streamsize count) override { const std::streamsize avail = epptr() - pptr(); From a56158b78e3ffcb7be7af2951375adb5dc4ac2e0 Mon Sep 17 00:00:00 2001 From: ostermine Date: Sat, 10 Oct 2026 16:39:20 +0300 Subject: [PATCH 70/91] fix crash in create_zip for files without modification time MemoryDevice::lastWriteTime returns file_time_type::min(). Converting it to the system clock overflows, and on Windows std::localtime returns nullptr for the resulting time, which was dereferenced (access violation in zip_files test on MSVC). Unknown or out of range time is now written as 1980-01-01 00:00, the earliest MS-DOS date. --- src/io/devices/ZipFileDevice.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/io/devices/ZipFileDevice.cpp b/src/io/devices/ZipFileDevice.cpp index 2c52439ae..025c1c335 100644 --- a/src/io/devices/ZipFileDevice.cpp +++ b/src/io/devices/ZipFileDevice.cpp @@ -58,11 +58,22 @@ namespace { } uint32_t to_ms_dos_timestamp(const file_time_type& fileTime) { + // 1980-01-01 00:00, the earliest MS-DOS date; used for unknown time + // (devices without timestamps return file_time_type::min()) + constexpr uint32_t DOS_EPOCH = (0 << 9 | 1 << 5 | 1) << 16; + if (fileTime == file_time_type::min()) { + return DOS_EPOCH; + } auto timePoint = time_point_cast( fileTime - file_time_type::clock::now() + system_clock::now() ); std::time_t timeT = system_clock::to_time_t(timePoint); - std::tm tm = *std::localtime(&timeT); + // localtime returns nullptr for out of range time on Windows + const std::tm* tmPtr = std::localtime(&timeT); + if (tmPtr == nullptr || tmPtr->tm_year < 80) { + return DOS_EPOCH; + } + const std::tm& tm = *tmPtr; uint16_t date = (tm.tm_year - 80) << 9 | (tm.tm_mon + 1) << 5 | tm.tm_mday; uint16_t time = (tm.tm_hour << 11) | (tm.tm_min << 5) | (tm.tm_sec / 2); return (date << 16) | time; From bf98174e1531b70ff0d4be523e6f71195d1c595e Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 16:48:04 +0300 Subject: [PATCH 71/91] fix shader info log is truncated --- src/graphics/core/Shader.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/graphics/core/Shader.cpp b/src/graphics/core/Shader.cpp index 1c752ef5a..463151f3a 100644 --- a/src/graphics/core/Shader.cpp +++ b/src/graphics/core/Shader.cpp @@ -125,12 +125,14 @@ glshader compile_shader(GLenum type, const GLchar* source, const std::string& fi glCompileShader(shader); glGetShaderiv(shader, GL_COMPILE_STATUS, &success); if (!success) { - GLchar infoLog[GL_LOG_LEN]; - glGetShaderInfoLog(shader, GL_LOG_LEN, nullptr, infoLog); + GLint infoLogLength; + glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength); + auto infoLog = std::make_unique(infoLogLength); + glGetShaderInfoLog(shader, infoLogLength, nullptr, infoLog.get()); glDeleteShader(shader); throw std::runtime_error( "vertex shader compilation failed (" + file + "):\n" + - std::string(infoLog) + std::string(infoLog.get(), infoLogLength) ); } return glshader(new GLuint(shader), shader_deleter); //-V508 @@ -172,10 +174,14 @@ static GLuint compile_program( glGetProgramiv(program, GL_LINK_STATUS, &success); if (!success) { - GLchar infoLog[GL_LOG_LEN]; - glGetProgramInfoLog(program, GL_LOG_LEN, nullptr, infoLog); + GLint infoLogLength; + glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength); + auto infoLog = std::make_unique(infoLogLength); + glGetProgramInfoLog(program, infoLogLength, nullptr, infoLog.get()); + glDeleteProgram(program); throw std::runtime_error( - "shader program linking failed:\n" + std::string(infoLog) + "shader program linking failed:\n" + + std::string(infoLog.get(), infoLogLength) ); } return program; From 28e85a336f3ceed5dd130e976e2e172891c42d0d Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 16:50:44 +0300 Subject: [PATCH 72/91] oh --- src/graphics/core/Shader.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/graphics/core/Shader.cpp b/src/graphics/core/Shader.cpp index 463151f3a..9dc574fa0 100644 --- a/src/graphics/core/Shader.cpp +++ b/src/graphics/core/Shader.cpp @@ -113,8 +113,6 @@ static inline auto shader_deleter = [](GLuint* shader) { delete shader; }; -inline const uint GL_LOG_LEN = 512; - // shader should be deleted after shader program linking using glshader = std::unique_ptr; From bd3ad9f9644ceeb40c09c330cdf590ed5fff4978 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 17:42:21 +0300 Subject: [PATCH 73/91] fix '--test' run.sh --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 13b824d3c..4cc16d57d 100755 --- a/run.sh +++ b/run.sh @@ -36,7 +36,7 @@ function test { cd build rm -rf ./vctest-run mkdir ./vctest-run - ./vctest/vctest --exe ./VoxelEngine --res res --user ./vctest-run --tests ../dev/tests --memchecker valgrind + ./vctest/vctest --exe ./VoxelCore --res res --user ./vctest-run --tests ../dev/tests --memchecker valgrind cd .. run= } From 0efabc1883b70deb12cd2de3815e2391e950fceb Mon Sep 17 00:00:00 2001 From: ostermine Date: Sat, 10 Oct 2026 18:41:37 +0300 Subject: [PATCH 74/91] remove comments only relevant to the PR --- src/io/devices/ZipFileDevice.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/io/devices/ZipFileDevice.cpp b/src/io/devices/ZipFileDevice.cpp index 025c1c335..8420e1e1d 100644 --- a/src/io/devices/ZipFileDevice.cpp +++ b/src/io/devices/ZipFileDevice.cpp @@ -58,8 +58,7 @@ namespace { } uint32_t to_ms_dos_timestamp(const file_time_type& fileTime) { - // 1980-01-01 00:00, the earliest MS-DOS date; used for unknown time - // (devices without timestamps return file_time_type::min()) + // 1980-01-01 00:00, the earliest MS-DOS date constexpr uint32_t DOS_EPOCH = (0 << 9 | 1 << 5 | 1) << 16; if (fileTime == file_time_type::min()) { return DOS_EPOCH; @@ -68,7 +67,6 @@ namespace { fileTime - file_time_type::clock::now() + system_clock::now() ); std::time_t timeT = system_clock::to_time_t(timePoint); - // localtime returns nullptr for out of range time on Windows const std::tm* tmPtr = std::localtime(&timeT); if (tmPtr == nullptr || tmPtr->tm_year < 80) { return DOS_EPOCH; From 40db547817c94b1476551053002e2e3455fda57a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 10 Oct 2026 20:42:07 +0300 Subject: [PATCH 75/91] fix: entities frustum-culling not uses hitbox size (it uses entity scale only) --- src/objects/Entities.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/objects/Entities.cpp b/src/objects/Entities.cpp index 46746684e..c231a91cd 100644 --- a/src/objects/Entities.cpp +++ b/src/objects/Entities.cpp @@ -480,15 +480,17 @@ void Entities::render( const Frustum* frustum, entityid_t fpsEntity ) { - auto view = registry->view(); - for (auto [entity, eid, transform, skeleton] : view.each()) { + auto view = registry->view(); + for (auto [entity, eid, transform, skeleton, rigidbody] : view.each()) { if (eid.uid == fpsEntity) { continue; } const auto& def = eid.def; const auto& pos = transform.pos; const auto& size = transform.size; - if (frustum && !frustum->isBoxVisible(pos - size, pos + size)) { + const auto& halfSize = rigidbody.hitbox.getHalfSize(); + // todo: more correct frustum culling + if (frustum && !frustum->isBoxVisible(pos - halfSize, pos + halfSize)) { continue; } From eb2afe822d71d6eeeb13585d85d1dfaf1182fdd1 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 11 Oct 2026 13:05:30 +0300 Subject: [PATCH 76/91] cleanup --- dev/tests/zip_files.lua | 1 + src/io/devices/ZipFileDevice.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/zip_files.lua b/dev/tests/zip_files.lua index ad5f4e7e0..e7ed664cb 100644 --- a/dev/tests/zip_files.lua +++ b/dev/tests/zip_files.lua @@ -86,6 +86,7 @@ local function check_zip(src, zipfile) debug.log("unmount "..m) file.unmount(m) + assert(not file.exists(m..":")) assert(not pcall(file.read, m..":root.txt")) assert(not pcall(file.unmount, m)) end diff --git a/src/io/devices/ZipFileDevice.cpp b/src/io/devices/ZipFileDevice.cpp index 8420e1e1d..f097f77f6 100644 --- a/src/io/devices/ZipFileDevice.cpp +++ b/src/io/devices/ZipFileDevice.cpp @@ -182,7 +182,6 @@ ZipFileDevice::ZipFileDevice( entries[entry.fileName] = std::move(entry); } - // Add missing parent directories entries std::vector names; names.reserve(entries.size()); for (const auto& [name, _] : entries) { From e57e6a5cbee1543e43917ff5debde8d7732ce03d Mon Sep 17 00:00:00 2001 From: ostermine Date: Sun, 11 Oct 2026 21:36:34 +0300 Subject: [PATCH 77/91] fix modelviewer background is not transparent --- src/graphics/ui/elements/ModelViewer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/graphics/ui/elements/ModelViewer.cpp b/src/graphics/ui/elements/ModelViewer.cpp index 435f3340d..043475d13 100644 --- a/src/graphics/ui/elements/ModelViewer.cpp +++ b/src/graphics/ui/elements/ModelViewer.cpp @@ -120,7 +120,7 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) { if (size.x <= 0 || size.y <= 0) { return; } - fbo = std::make_unique(size.x, size.y); + fbo = std::make_unique(size.x, size.y, true); } fbo->resize(size.x, size.y); { @@ -130,7 +130,14 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) { ctx.setViewport({size.x, size.y}); ctx.setDepthTest(true); ctx.setCullFace(true); + // transparent background, the screen clear color is restored below + GLfloat clearColor[4]; + glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); display::clear(); + glClearColor( + clearColor[0], clearColor[1], clearColor[2], clearColor[3] + ); auto& ui3dShader = assets.require("ui3d"); ui3dShader.use(); From 50a02d251bf931019b86795c153b2d34b4ee242e Mon Sep 17 00:00:00 2001 From: ostermine Date: Sun, 11 Oct 2026 22:15:10 +0300 Subject: [PATCH 78/91] remove obvious comment --- src/graphics/ui/elements/ModelViewer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/graphics/ui/elements/ModelViewer.cpp b/src/graphics/ui/elements/ModelViewer.cpp index 043475d13..d3ea155b3 100644 --- a/src/graphics/ui/elements/ModelViewer.cpp +++ b/src/graphics/ui/elements/ModelViewer.cpp @@ -130,7 +130,6 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) { ctx.setViewport({size.x, size.y}); ctx.setDepthTest(true); ctx.setCullFace(true); - // transparent background, the screen clear color is restored below GLfloat clearColor[4]; glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); From d753c7485897ac077e6a2fb17305be63241afa74 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 11 Oct 2026 22:17:47 +0300 Subject: [PATCH 79/91] update StdfsDevice::resolve, remove, removeAll --- src/io/devices/StdfsDevice.cpp | 46 +++++++++++++++++++++++++++++----- src/io/devices/StdfsDevice.hpp | 1 + 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/io/devices/StdfsDevice.cpp b/src/io/devices/StdfsDevice.cpp index fc0602b52..6f0e37e0e 100644 --- a/src/io/devices/StdfsDevice.cpp +++ b/src/io/devices/StdfsDevice.cpp @@ -20,10 +20,29 @@ StdfsDevice::StdfsDevice(fs::path root, bool createDirectory) << ": " << ec.message(); } } + absoluteRoot = fs::absolute(this->root).lexically_normal(); + if (!absoluteRoot.has_filename() && absoluteRoot.has_relative_path()) { + absoluteRoot = absoluteRoot.parent_path(); + } } fs::path StdfsDevice::resolve(std::string_view path) { - return root / fs::u8path(io::path(std::string(path)).normalized().string()); + if (path.find_first_of(std::string_view("\0\\:", 3)) != std::string_view::npos) { + throw std::runtime_error("invalid path"); + } + fs::path rel = fs::u8path(io::path(std::string(path)).normalized().string()); + if (rel.has_root_name() || rel.has_root_directory()) { + throw std::runtime_error("absolute paths are not allowed"); + } + fs::path full = (absoluteRoot / rel).lexically_normal(); + fs::path inside = full.lexically_relative(absoluteRoot); + if (inside.empty() || *inside.begin() == "..") { + throw std::runtime_error("path escapes device root"); + } + if (inside == ".") { + return absoluteRoot; + } + return full; } std::unique_ptr StdfsDevice::write(std::string_view path) { @@ -90,17 +109,32 @@ bool StdfsDevice::mkdirs(std::string_view path) { bool StdfsDevice::remove(std::string_view path) { auto resolved = resolve(path); - return fs::remove(resolved); + if (resolved == absoluteRoot) { + throw std::runtime_error("unable to remove device root"); + } + std::error_code ec; + bool removed = fs::remove(resolved, ec); + if (ec) { + logger.error() << "error removing " << resolved << ": " << ec.message(); + } + return removed; } uint64_t StdfsDevice::removeAll(std::string_view path) { auto resolved = resolve(path); - if (fs::exists(resolved)) { - logger.info() << "removeAll " << resolved; - return fs::remove_all(resolved); - } else { + if (resolved == absoluteRoot) { + throw std::runtime_error("unable to remove device root"); + } + std::error_code ec; + auto removed = fs::remove_all(resolved, ec); + if (ec) { + logger.error() << "error removing " << resolved << ": " << ec.message(); return 0; } + if (removed > 0) { + logger.info() << "removeAll " << resolved << ": " << removed; + } + return removed; } class StdfsPathsGenerator : public PathsGenerator { diff --git a/src/io/devices/StdfsDevice.hpp b/src/io/devices/StdfsDevice.hpp index 677cad25b..9259a9256 100644 --- a/src/io/devices/StdfsDevice.hpp +++ b/src/io/devices/StdfsDevice.hpp @@ -23,5 +23,6 @@ namespace io { std::unique_ptr list(std::string_view path) override; private: std::filesystem::path root; + std::filesystem::path absoluteRoot; }; } From 1a3f3e77e66b9f8289831dc96384076dd258c105 Mon Sep 17 00:00:00 2001 From: ostermine Date: Sun, 11 Oct 2026 22:46:32 +0300 Subject: [PATCH 80/91] docs: list punctuation key names --- doc/en/scripting/user-input.md | 2 ++ doc/ru/scripting/user-input.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/doc/en/scripting/user-input.md b/doc/en/scripting/user-input.md index d8a6e4e8e..654de1871 100644 --- a/doc/en/scripting/user-input.md +++ b/doc/en/scripting/user-input.md @@ -22,6 +22,8 @@ packid.binding.name="inputtype:codename" - a..z - 0..9 - f1..f25 +- grave-accent, minus, equal, left-bracket, right-bracket, backslash +- semicolon, apostrophe, comma, period, slash ## *input* library diff --git a/doc/ru/scripting/user-input.md b/doc/ru/scripting/user-input.md index ffcadd27c..413f74864 100644 --- a/doc/ru/scripting/user-input.md +++ b/doc/ru/scripting/user-input.md @@ -20,6 +20,8 @@ packid.binding.name="inputtype:codename" - a..z - 0..9 - f1..f25 +- grave-accent, minus, equal, left-bracket, right-bracket, backslash +- semicolon, apostrophe, comma, period, slash ## Библиотека input From ab129367adc2f515e9452d4928163df2715e0a04 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 12 Oct 2026 00:15:28 +0300 Subject: [PATCH 81/91] fix registry access in generator scripts --- src/logic/scripting/lua/lua_engine.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/logic/scripting/lua/lua_engine.cpp b/src/logic/scripting/lua/lua_engine.cpp index 812f67665..1e73ea903 100644 --- a/src/logic/scripting/lua/lua_engine.cpp +++ b/src/logic/scripting/lua/lua_engine.cpp @@ -196,6 +196,10 @@ void lua::init_state(State* L, StateType stateType) { if (stateType == StateType::GENERATOR) { pushnil(L); setglobal(L, "ffi"); + + static const char* removed_debug[] { + "getregistry", "getupvalue", "setupvalue", "getinfo", nullptr}; + remove_lib_funcs(L, "debug", removed_debug); } } From 6f466d52f263081c72595a61bc2efdf958e4acb9 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 12 Oct 2026 00:21:24 +0300 Subject: [PATCH 82/91] fix: missing network.request protocol filter --- src/network/Curl.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/network/Curl.cpp b/src/network/Curl.cpp index 0e08162fb..11afa5ae5 100644 --- a/src/network/Curl.cpp +++ b/src/network/Curl.cpp @@ -113,6 +113,14 @@ public: curl_easy_setopt(curl, CURLOPT_URL, request.url.c_str()); curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, request.method.c_str()); + +#if LIBCURL_VERSION_NUM >= 0x075500 + curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "http,https"); + curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, "http,https"); +#else + curl_easy_setopt(curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); +#endif curl_slist* hs = nullptr; From f246619c6bbc2c144e36475cf7fcc16c3df21b73 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 12 Oct 2026 00:30:49 +0300 Subject: [PATCH 83/91] fix potential fatal errors --- src/coders/vec3.cpp | 3 +++ src/io/io.cpp | 3 +++ src/logic/scripting/lua/libs/libnetwork.cpp | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/coders/vec3.cpp b/src/coders/vec3.cpp index e00bdd662..119cbed92 100644 --- a/src/coders/vec3.cpp +++ b/src/coders/vec3.cpp @@ -133,6 +133,9 @@ static model::Mesh load_mesh( if (flags == FLAG_ZLIB) { throw std::runtime_error("compression is not supported yet"); } + if (attributeCount <= 0) { + throw std::runtime_error("mesh must have at least one attribute"); + } std::vector attributes; for (int i = 0; i < attributeCount; i++) { attributes.push_back(load_attribute(reader)); diff --git a/src/io/io.cpp b/src/io/io.cpp index 638108587..d550654e4 100644 --- a/src/io/io.cpp +++ b/src/io/io.cpp @@ -152,6 +152,9 @@ std::vector io::read_bytes(const path& filename) { std::string io::read_string(const path& filename) { size_t size; auto bytes = read_bytes(filename, size); + if (bytes == nullptr) { + throw std::runtime_error("could not read file " + filename.string()); + } return std::string((const char*)bytes.get(), size); } diff --git a/src/logic/scripting/lua/libs/libnetwork.cpp b/src/logic/scripting/lua/libs/libnetwork.cpp index 59d50f075..0d48e4a29 100644 --- a/src/logic/scripting/lua/libs/libnetwork.cpp +++ b/src/logic/scripting/lua/libs/libnetwork.cpp @@ -266,8 +266,10 @@ static int l_peek(lua::State* L, network::Network& network) { static int l_available(lua::State* L, network::Network& network) { u64id_t id = lua::tointeger(L, 1); - if (auto connection = network.getConnection(id, false)) { - return lua::pushinteger(L, dynamic_cast(connection)->available()); + if (auto connection = dynamic_cast( + network.getConnection(id, false) + )) { + return lua::pushinteger(L, connection->available()); } return 0; From 293d68a0fbaf6c721aaed269ceff06bac5522e77 Mon Sep 17 00:00:00 2001 From: ostermine Date: Sat, 10 Oct 2026 03:49:12 +0300 Subject: [PATCH 84/91] call on_hud_render before rendering the frame Hud scripts update the first-person hand skeleton, blockwraps and animations in on_hud_render, which ran after renderFrame, so these changes were drawn one frame late. With fast camera rotation the hand visibly lagged and jittered behind the view. --- src/frontend/screens/LevelScreen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontend/screens/LevelScreen.cpp b/src/frontend/screens/LevelScreen.cpp index 24ee44378..36448f47f 100644 --- a/src/frontend/screens/LevelScreen.cpp +++ b/src/frontend/screens/LevelScreen.cpp @@ -271,11 +271,11 @@ void LevelScreen::draw(float delta) { if (!hud->isPause()) { scripting::on_entities_render(engine.getTime().getDelta()); - } - renderer->renderFrame(ctx, camera, hudVisible, *postProcessing); - if (!hud->isPause()) { + // before the frame: changes made by hud scripts (hand skeleton, + // blockwraps, animations) must be rendered with the current camera scripting::on_frontend_render(); } + renderer->renderFrame(ctx, camera, hudVisible, *postProcessing); if (hudVisible) { hud->draw(ctx); From 57fa6393c2b5af46f8fe8e6b5a3aab5ba4e92e11 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 12 Oct 2026 20:06:30 +0300 Subject: [PATCH 85/91] feat: 'res:project' as default project --- res/{ => project}/project.toml | 0 res/{ => project}/project_client.lua | 0 src/constants.hpp | 1 + src/engine/Engine.cpp | 8 +++++++- 4 files changed, 8 insertions(+), 1 deletion(-) rename res/{ => project}/project.toml (100%) rename res/{ => project}/project_client.lua (100%) diff --git a/res/project.toml b/res/project/project.toml similarity index 100% rename from res/project.toml rename to res/project/project.toml diff --git a/res/project_client.lua b/res/project/project_client.lua similarity index 100% rename from res/project_client.lua rename to res/project/project_client.lua diff --git a/src/constants.hpp b/src/constants.hpp index 03900b9e3..a64a05e38 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -86,3 +86,4 @@ inline const std::string SOUNDS_FOLDER = "sounds"; inline const std::string TEXTURES_FOLDER = "textures"; inline const std::string FONT_DEFAULT = "normal"; +inline const std::string DEFAULT_PROJECT_PATH = "project"; diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index b3185f371..6cf1f15cd 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -132,7 +132,13 @@ void Engine::initialize(CoreParameters coreParameters) { logger.info() << "engine runs in headless mode"; } if (params.projectFolder.empty()) { - params.projectFolder = params.resFolder; + auto mainProjectPath = + params.resFolder / std::filesystem::u8path(DEFAULT_PROJECT_PATH); + if (std::filesystem::is_directory(mainProjectPath)) { + params.projectFolder = mainProjectPath; + } else { + params.projectFolder = params.resFolder; + } } paths = std::make_unique(params); loadProject(); From 03e0fd9259fc021fe50d255901d7c5fd443916ee Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 12 Oct 2026 22:08:32 +0300 Subject: [PATCH 86/91] feat: 'user:project' as default project option --- src/engine/Engine.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 6cf1f15cd..1a4361f9e 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -132,10 +132,14 @@ void Engine::initialize(CoreParameters coreParameters) { logger.info() << "engine runs in headless mode"; } if (params.projectFolder.empty()) { - auto mainProjectPath = + auto userDefProjectPath = + params.userFolder / std::filesystem::u8path(DEFAULT_PROJECT_PATH); + auto resDefProjectPath = params.resFolder / std::filesystem::u8path(DEFAULT_PROJECT_PATH); - if (std::filesystem::is_directory(mainProjectPath)) { - params.projectFolder = mainProjectPath; + if (std::filesystem::is_directory(userDefProjectPath)) { + params.projectFolder = userDefProjectPath; + } else if (std::filesystem::is_directory(resDefProjectPath)) { + params.projectFolder = resDefProjectPath; } else { params.projectFolder = params.resFolder; } From c7a43593b1e89e2b9eb36b73d167c9b206830dad Mon Sep 17 00:00:00 2001 From: Andrey Tazetdinov Date: Tue, 13 Oct 2026 18:09:35 +0200 Subject: [PATCH 87/91] optimize PhysicsSolver --- src/physics/PhysicsSolver.cpp | 113 +++++++++++++++++++++++++++++----- src/physics/PhysicsSolver.hpp | 24 +++++++- 2 files changed, 119 insertions(+), 18 deletions(-) diff --git a/src/physics/PhysicsSolver.cpp b/src/physics/PhysicsSolver.cpp index a3a190f82..1b32a6ae5 100644 --- a/src/physics/PhysicsSolver.cpp +++ b/src/physics/PhysicsSolver.cpp @@ -14,6 +14,7 @@ inline constexpr float E = 0.03f; inline constexpr float MAX_FIX = 0.1f; +inline constexpr int MAX_NEARBY_REBUILDS = 4; static debug::Logger logger("physics-solver"); @@ -141,12 +142,15 @@ static void calc_collision( } bool PhysicsSolver::calcCollisionNegY( - Hitbox& hitbox, const glm::vec3& half, float dt + Hitbox& hitbox, + const glm::vec3& half, + float dt, + const std::vector& solids ) { auto& pos = hitbox.position; auto& vel = hitbox.velocity; - for (auto box : solidHitboxes) { + for (auto box : solids) { if (glm::distance2(box->position, pos) < E) { continue; } @@ -215,23 +219,24 @@ void PhysicsSolver::calcCollisions( glm::vec3& pos, const glm::vec3& half, float stepHeight, - float dt + float dt, + const std::vector& solids ) { stepHeight = calc_step_height(chunks, pos, half, stepHeight); auto prevPos = pos; - calc_collision<0, 1, 2, -1>(hitbox, chunks, solidHitboxes, half, stepHeight); - calc_collision<0, 1, 2, 1>(hitbox, chunks, solidHitboxes, half, stepHeight); + calc_collision<0, 1, 2, -1>(hitbox, chunks, solids, half, stepHeight); + calc_collision<0, 1, 2, 1>(hitbox, chunks, solids, half, stepHeight); float xpos = pos.x; pos.x = prevPos.x; - calc_collision<2, 1, 0, -1>(hitbox, chunks, solidHitboxes, half, stepHeight); - calc_collision<2, 1, 0, 1>(hitbox, chunks, solidHitboxes, half, stepHeight); + calc_collision<2, 1, 0, -1>(hitbox, chunks, solids, half, stepHeight); + calc_collision<2, 1, 0, 1>(hitbox, chunks, solids, half, stepHeight); pos.x = xpos; - if (calcCollisionNegY(hitbox, half, dt)) { + if (calcCollisionNegY(hitbox, half, dt, solids)) { hitbox.grounded = true; } @@ -255,7 +260,7 @@ void PhysicsSolver::calcCollisions( } } } - for (auto box : solidHitboxes) { + for (auto box : solids) { if (glm::distance2(box->position, pos) < E) { continue; } @@ -297,7 +302,7 @@ void PhysicsSolver::calcCollisions( } } } - for (auto box : solidHitboxes) { + for (auto box : solids) { if (glm::distance2(box->position, pos) < E) { continue; } @@ -314,7 +319,11 @@ void PhysicsSolver::calcCollisions( } void PhysicsSolver::calcSubstep( - Hitbox& hitbox, glm::vec3& vel, glm::vec3& pos, float dt + Hitbox& hitbox, + glm::vec3& vel, + glm::vec3& pos, + float dt, + const std::vector& solids ) { auto initpos = pos; auto half = hitbox.getHalfSize(); @@ -328,7 +337,8 @@ void PhysicsSolver::calcSubstep( half, (hitbox.prevGrounded && gravityScale > 0.0f) ? hitbox.stepHeight : 0.0f, - dt + dt, + solids ); } @@ -359,7 +369,7 @@ void PhysicsSolver::calcSubstep( } } } - for (auto box : solidHitboxes) { + for (auto box : solids) { if (glm::distance2(box->position, pos) < E) { continue; } @@ -376,6 +386,58 @@ void PhysicsSolver::calcSubstep( hitbox.grounded = true; } +static float calc_move_budget( + const Hitbox& hitbox, const glm::vec3& gravity, float time +) { + float speed = glm::length(hitbox.velocity) * 1.25f + + glm::length(gravity) * glm::abs(hitbox.gravityScale) * time; + return speed * time + 0.05f; +} + +static glm::vec3 calc_extents(const Hitbox& hitbox) { + return glm::max(hitbox.halfsize, hitbox.getHalfSize()); +} + +void PhysicsSolver::findNearbySolids(float time) { + size_t count = hitboxes.size(); + nearbySolids.resize(count); + nearbyOrigins.resize(count); + nearbyBudgets.resize(count); + solidBudgets.resize(solidHitboxes.size()); + + float maxSolidHalfY = 0.0f; + for (size_t j = 0; j < solidHitboxes.size(); j++) { + const auto& box = *solidHitboxes[j]; + solidBudgets[j] = calc_move_budget(box, gravity, time); + maxSolidHalfY = glm::max(maxSolidHalfY, calc_extents(box).y); + } + for (size_t i = 0; i < count; i++) { + const auto& hitbox = *hitboxes[i]; + auto& solids = nearbySolids[i]; + solids.clear(); + nearbyOrigins[i] = hitbox.position; + nearbyBudgets[i] = calc_move_budget(hitbox, gravity, time); + + auto ext = calc_extents(hitbox); + + glm::vec3 reach( + 0.5f, + hitbox.stepHeight * 2.0f + E * 8.0f + ext.y * 0.5f + + maxSolidHalfY + 0.5f + MAX_FIX * 2.0f, + 0.5f + ); + reach += ext + nearbyBudgets[i]; + for (size_t j = 0; j < solidHitboxes.size(); j++) { + const auto& box = *solidHitboxes[j]; + auto limit = reach + calc_extents(box) + solidBudgets[j]; + auto diff = glm::abs(box.position - hitbox.position); + if (diff.x <= limit.x && diff.y <= limit.y && diff.z <= limit.z) { + solids.push_back(solidHitboxes[j]); + } + } + } +} + void PhysicsSolver::step( const GlobalChunks& chunks, float delta, uint substeps ) { @@ -387,11 +449,32 @@ void PhysicsSolver::step( } float dt = delta / static_cast(substeps); + findNearbySolids(delta); + + int rebuildsLeft = MAX_NEARBY_REBUILDS; for (uint i = 0; i < substeps; i++) { - for (auto hitbox : hitboxes) { + for (size_t j = 0; j < hitboxes.size(); j++) { + auto hitbox = hitboxes[j]; glm::vec3& pos = hitbox->position; hitbox->prevPosition = hitbox->position; - calcSubstep(*hitbox, hitbox->velocity, pos, dt); + calcSubstep( + *hitbox, + hitbox->velocity, + pos, + dt, + rebuildsLeft >= 0 ? nearbySolids[j] : solidHitboxes + ); + if (rebuildsLeft < 0) { + continue; + } + + auto moved = glm::abs(pos - nearbyOrigins[j]); + if (glm::max(moved.x, glm::max(moved.y, moved.z)) > + nearbyBudgets[j]) { + if (--rebuildsLeft >= 0) { + findNearbySolids(dt * static_cast(substeps - i)); + } + } } } diff --git a/src/physics/PhysicsSolver.hpp b/src/physics/PhysicsSolver.hpp index e616696ca..32edfcaf1 100644 --- a/src/physics/PhysicsSolver.hpp +++ b/src/physics/PhysicsSolver.hpp @@ -38,6 +38,12 @@ private: std::vector sensors; std::vector solidHitboxes; std::vector hitboxes; + std::vector> nearbySolids; + std::vector nearbyOrigins; + std::vector nearbyBudgets; + std::vector solidBudgets; + + void findNearbySolids(float time); void calcCollisions( Hitbox& hitbox, @@ -45,12 +51,24 @@ private: glm::vec3& pos, const glm::vec3& half, float stepHeight, - float dt + float dt, + const std::vector& solids ); - void calcSubstep(Hitbox& hitbox, glm::vec3& vel, glm::vec3& pos, float dt); + void calcSubstep( + Hitbox& hitbox, + glm::vec3& vel, + glm::vec3& pos, + float dt, + const std::vector& solids + ); - bool calcCollisionNegY(Hitbox& hitbox, const glm::vec3& half, float dt); + bool calcCollisionNegY( + Hitbox& hitbox, + const glm::vec3& half, + float dt, + const std::vector& solids + ); void updateSensors(Hitbox& hitbox); }; From 40ff68aa8683bf6bd924301884051e3d5aa08df9 Mon Sep 17 00:00:00 2001 From: ostermine Date: Wed, 14 Oct 2026 00:30:08 +0300 Subject: [PATCH 88/91] remove comment --- src/frontend/screens/LevelScreen.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/frontend/screens/LevelScreen.cpp b/src/frontend/screens/LevelScreen.cpp index 36448f47f..e6f1a0d7e 100644 --- a/src/frontend/screens/LevelScreen.cpp +++ b/src/frontend/screens/LevelScreen.cpp @@ -271,8 +271,6 @@ void LevelScreen::draw(float delta) { if (!hud->isPause()) { scripting::on_entities_render(engine.getTime().getDelta()); - // before the frame: changes made by hud scripts (hand skeleton, - // blockwraps, animations) must be rendered with the current camera scripting::on_frontend_render(); } renderer->renderFrame(ctx, camera, hudVisible, *postProcessing); From 7e41439e1ac4116e6d32b046923ab13e3cd20706 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 14 Oct 2026 00:38:38 +0300 Subject: [PATCH 89/91] fix: model-primitives texture regions are broken --- src/graphics/render/ModelsGenerator.cpp | 43 +++++++++++++++++++------ 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/graphics/render/ModelsGenerator.cpp b/src/graphics/render/ModelsGenerator.cpp index da82680bb..531cc1c84 100644 --- a/src/graphics/render/ModelsGenerator.cpp +++ b/src/graphics/render/ModelsGenerator.cpp @@ -8,6 +8,22 @@ #include "debug/Logger.hpp" #include "core_defs.hpp" +inline constexpr uint FACE_WEST = FACE_MX; +inline constexpr uint FACE_EAST = FACE_PX; +inline constexpr uint FACE_BOTTOM = FACE_MY; +inline constexpr uint FACE_TOP = FACE_PY; +inline constexpr uint FACE_SOUTH = FACE_MZ; +inline constexpr uint FACE_NORTH = FACE_PZ; + +inline constexpr std::array LEGACY_CUSTOM_MODEL_TEXTURE_ORDER = { + FACE_WEST, + FACE_EAST, + FACE_BOTTOM, + FACE_TOP, + FACE_SOUTH, + FACE_NORTH, +}; + static debug::Logger logger("models-generator"); static void configure_textures( @@ -49,6 +65,21 @@ static inline UVRegion get_region_for( return texreg.region; } +static inline void map_legacy_box_textures( + const std::vector& modelTextures, + size_t offset, + UVRegion (&boxtexfaces)[6], + const Assets& assets +) { + for (size_t i = 0; i < 6; ++i) { + const auto legacyFace = LEGACY_CUSTOM_MODEL_TEXTURE_ORDER[i]; + boxtexfaces[legacyFace] = get_region_for(modelTextures[offset + i], assets); + } + boxtexfaces[FACE_TOP].scale(glm::vec2(-1, 1)); + boxtexfaces[FACE_EAST].scale(glm::vec2(-1, 1)); + boxtexfaces[FACE_NORTH].scale(glm::vec2(-1, 1)); +} + void ModelsGenerator::prepareModel( Assets& assets, const Block& def, Variant& variant, uint8_t variantId ) { @@ -120,16 +151,8 @@ model::Model ModelsGenerator::fromCustom( for (size_t i = 0; i < modelBoxes.size(); i++) { auto& mesh = model.addMesh("blocks:"); mesh.shading = lighting; - UVRegion boxtexfaces[6] = { - get_region_for(modelTextures[i * 6 + 5], assets), - get_region_for(modelTextures[i * 6 + 4], assets), - get_region_for(modelTextures[i * 6 + 3], assets), - get_region_for(modelTextures[i * 6 + 2], assets), - get_region_for(modelTextures[i * 6 + 1], assets), - get_region_for(modelTextures[i * 6 + 0], assets) - }; - boxtexfaces[2].scale(glm::vec2(-1)); - boxtexfaces[5].scale(glm::vec2(-1, 1)); + UVRegion boxtexfaces[6] = {}; + map_legacy_box_textures(modelTextures, i * 6, boxtexfaces, assets); bool enabled[6] {1,1,1,1,1,1}; mesh.addBox( From 674ae220c6cac2453f4b292161aab5f7620754e6 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 14 Oct 2026 00:39:30 +0300 Subject: [PATCH 90/91] cleanup --- src/graphics/render/ModelsGenerator.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/graphics/render/ModelsGenerator.cpp b/src/graphics/render/ModelsGenerator.cpp index 531cc1c84..d69987d28 100644 --- a/src/graphics/render/ModelsGenerator.cpp +++ b/src/graphics/render/ModelsGenerator.cpp @@ -255,17 +255,14 @@ model::Model ModelsGenerator::loadCustomBlockModel( modelBoxes.push_back(modelbox); if (boxarr.size() == 7) { - for (uint j = 6; j < 12; j++) { - modelTextures.emplace_back(boxarr[6].asString()); - } + const auto texture = boxarr[6].asString(); + modelTextures.insert(modelTextures.end(), 6, texture); } else if (boxarr.size() == 12) { for (uint j = 6; j < 12; j++) { modelTextures.emplace_back(boxarr[j].asString()); } } else { - for (uint j = 6; j < 12; j++) { - modelTextures.emplace_back("notfound"); - } + modelTextures.insert(modelTextures.end(), 6, "notfound"); } } } From 73c16a2f586a94eaea13334b9149c6013d9b69ac Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 15 Oct 2026 12:10:17 +0300 Subject: [PATCH 91/91] fix player serialization --- src/objects/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objects/Player.cpp b/src/objects/Player.cpp index 1defcedc9..28153d635 100644 --- a/src/objects/Player.cpp +++ b/src/objects/Player.cpp @@ -322,7 +322,7 @@ void Player::deserialize(const dv::value& src) { src.at("loading-chunks").get(loadingChunks); setChosenSlot(src["chosen-slot"].asInteger()); - eid = src["entity"].asNumber(); + eid = src["entity"].asInteger(); if (src.has("inventory")) { getInventory()->deserialize(src["inventory"]);