Merge branch 'dev' into pathfinding-update

This commit is contained in:
MihailRis 2026-11-01 18:37:28 +03:00
commit 98cd85f4f6
16 changed files with 124 additions and 17 deletions

View file

@ -11,6 +11,11 @@ on:
required: true
type: string
description: 'Build name passed as VC_BUILD_NAME define'
version_patch:
required: false
type: string
default: ''
description: 'Engine version patch number passed as VC_VERSION_PATCH define'
jobs:
build-appimage:
@ -36,7 +41,7 @@ jobs:
sudo ln -s /usr/lib/x86_64-linux-gnu/libluajit-5.1.a /usr/lib/x86_64-linux-gnu/liblua5.1.a
sudo ln -s /usr/include/luajit-2.1 /usr/include/lua
- name: Configure
run: cmake -S . -B build -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_APPDIR=1 -DVOXELENGINE_BUILD_TESTS=ON -DVC_BUILD_NAME="${{ inputs.build_name }}"
run: cmake -S . -B build -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_APPDIR=1 -DVOXELENGINE_BUILD_TESTS=ON -DVC_BUILD_NAME="${{ inputs.build_name }}" -DVC_VERSION_PATCH="${{ inputs.version_patch }}"
- name: Build
run: cmake --build build -t install
- name: Run tests

View file

@ -11,6 +11,11 @@ on:
required: true
type: string
description: 'Build name passed as VC_BUILD_NAME define'
version_patch:
required: false
type: string
default: ''
description: 'Engine version patch number passed as VC_VERSION_PATCH define'
jobs:
build-dmg:
@ -29,7 +34,7 @@ jobs:
run: |
cmake -DOPENAL_INCLUDE_DIR=$(brew --prefix openal-soft)/include \
-DOPENAL_LIBRARY=$(brew --prefix openal-soft)/lib/libopenal.dylib \
-S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVOXELENGINE_BUILD_TESTS=ON -DVOXELENGINE_BUILD_APPDIR=1 -DVC_BUILD_NAME="${{ inputs.build_name }}"
-S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVOXELENGINE_BUILD_TESTS=ON -DVOXELENGINE_BUILD_APPDIR=1 -DVC_BUILD_NAME="${{ inputs.build_name }}" -DVC_VERSION_PATCH="${{ inputs.version_patch }}"
- name: Build
run: |

View file

@ -13,24 +13,32 @@ jobs:
prepare:
runs-on: ubuntu-latest
steps:
- run: echo "exists just for outputs"
- id: version
run: |
if [[ "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.([0-9]+) ]]; then
echo "patch=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
fi
outputs:
build_name: '${{ env.RELEASE_VERSION }}'
version_patch: '${{ steps.version.outputs.patch }}'
build_linux:
needs: [prepare]
uses: ./.github/workflows/appimage.yml
with:
build_name: '${{ needs.prepare.outputs.build_name }}'
version_patch: '${{ needs.prepare.outputs.version_patch }}'
build_macos:
needs: [prepare]
uses: ./.github/workflows/macos.yml
with:
build_name: '${{ needs.prepare.outputs.build_name }}'
version_patch: '${{ needs.prepare.outputs.version_patch }}'
build_windows:
needs: [prepare]
uses: ./.github/workflows/windows-clang.yml
with:
build_name: '${{ needs.prepare.outputs.build_name }}'
version_patch: '${{ needs.prepare.outputs.version_patch }}'
publish_release:
runs-on: ubuntu-latest
needs: [build_linux, build_macos, build_windows]

View file

@ -11,6 +11,11 @@ on:
required: true
type: string
description: 'Build name passed as VC_BUILD_NAME define'
version_patch:
required: false
type: string
default: ''
description: 'Engine version patch number passed as VC_VERSION_PATCH define'
jobs:
build-windows:
@ -53,7 +58,7 @@ jobs:
export VCPKG_ROOT=$(pwd)/vcpkg
mkdir build
cd build
cmake -G "MinGW Makefiles" -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DVC_BUILD_NAME="${{ inputs.build_name }}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake -G "MinGW Makefiles" -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DVC_BUILD_NAME="${{ inputs.build_name }}" -DVC_VERSION_PATCH="${{ inputs.version_patch }}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake --build . --config Release
- name: Package for Windows
run: |

View file

@ -12,6 +12,14 @@ option(VOXELENGINE_BUILD_TESTS "Build tests" OFF)
add_compile_definitions(VC_BUILD_NAME="${VC_BUILD_NAME}")
set(VC_VERSION_PATCH "" CACHE STRING "Engine version patch number")
if(NOT VC_VERSION_PATCH STREQUAL "")
if(NOT VC_VERSION_PATCH MATCHES "^[0-9]+$")
message(FATAL_ERROR "invalid VC_VERSION_PATCH: '${VC_VERSION_PATCH}'")
endif()
add_compile_definitions(VC_VERSION_PATCH=${VC_VERSION_PATCH})
endif()
# Need for static compilation on Windows with MSVC clang TODO: Make single build
# on Windows to avoid dependence on combinations of platforms and compilers and
# make it independent

View file

@ -0,0 +1,40 @@
app.tick()
app.set_setting("ui.language", "en_US")
local main_page = Document.new("core:pages/main")
test.click(main_page.worlds_btn)
local worlds_page = Document.new("core:pages/worlds")
test.click(worlds_page.new_world_btn)
local page = Document.new("core:pages/new_world")
local world_name = "test-"..random.uuid()
test.fill(page.name_box, world_name)
test.fill(page.seed_box, "randomseed")
test.click(page.generator_btn)
local generators_page = Document.new("core:pages/generators")
test.click(test.find_by_text(generators_page.root, "Flat_grass"))
local new_world_page = Document.new("core:pages/new_world")
test.click(new_world_page.create_world_btn)
app.sleep_until(function() return gui.root["hud.hotbar"].exists end)
test.press("escape")
local pause_page = Document.new("core:pages/pause")
test.click(pause_page.quit_btn)
test.click(main_page.worlds_btn)
local world_button = test.find_by_text(worlds_page.root, world_name).parent
local delete_button = test.find_by_attr(world_button, "src", "gui/delete_icon")
test.click(delete_button)
assert(test.find_by_text(
gui.root.root, string.format("Do you want to delete world forever? (user:worlds/%s)", world_name)
), "World deletion confirm dialog not shown")
test.press("enter")
assert(not world_button.exists, "World still shown in worlds list after deletion")

View file

@ -119,7 +119,8 @@ app.close_world(
```lua
-- Returns the major and minor versions of the engine.
app.get_version() -> int, int
-- If a patch number is available, it also returns it.
app.get_version() -> int, int, int | nil
-- Returns the value of a setting.
-- Throws an exception if the setting does not exist.

View file

@ -116,7 +116,8 @@ app.close_world(
```lua
-- Возвращает мажорную и минорную версии движка.
app.get_version() -> int, int
-- При наличии номера патча возвращает и его.
app.get_version() -> int, int, int | nil
-- Возвращает значение настройки.
-- Бросает исключение, если настройки не существует.

View file

@ -1,5 +1,5 @@
<panel size='400' color='0' interval='1' context='menu'>
<button onclick='menu.page="worlds"'>@Worlds</button>
<button id='worlds_btn' onclick='menu.page="worlds"'>@Worlds</button>
<button onclick='menu.page="scripts"'>@Scripts</button>
<button onclick='menu.page="settings"'>@Settings</button>
<button onclick='menu.page="content_menu"'>@Content</button>

View file

@ -7,11 +7,11 @@
</textbox>
<label>@Seed</label>
<textbox id='seed_box' placeholder='-' padding='4'></textbox>
<button onclick='save_state() menu.page="generators"' id='generator_btn'>
<button id='generator_btn' onclick='save_state() menu.page="generators"'>
@World generator
</button>
<button id='content_btn' onclick='save_state() menu.page="content"'/>
<button onclick='create_world()' margin='0,20,0,1'>
<button id='create_world_btn' onclick='create_world()' margin='0,20,0,1'>
@Create World
</button>
<button onclick='menu:back()'>@Back</button>

View file

@ -2,7 +2,7 @@
<button onclick='gui.close_menu()'>@Continue</button>
<button onclick='menu.page="content?mode=world"'>@Content</button>
<button onclick='menu.page="settings"'>@Settings</button>
<button onclick='app.close_world(true)'>
<button id='quit_btn' onclick='app.close_world(true)'>
@Save and Quit to Menu
</button>
</panel>

View file

@ -1,5 +1,5 @@
<panel size='400' color='0' interval='1' context='menu'>
<button onclick='menu.page="new_world"'>@New World</button>
<button id="new_world_btn" onclick='menu.page="new_world"'>@New World</button>
<panel id='worlds' size='390,1' padding='5' color='#FFFFFF11' max-length='400'>
</panel>

View file

@ -47,6 +47,25 @@ function next_waypoint()
return route[#route]
end
local function is_passed(waypoint, next_point, pos)
local wx, wz = waypoint[1] + 0.5, waypoint[3] + 0.5
local dx, dz = pos[1] - wx, pos[3] - wz
if dx * dx + dz * dz > 2.25 then
return false
end
return dx * (next_point[1] + 0.5 - wx) + dz * (next_point[3] + 0.5 - wz) > 0
end
local function drop_passed_waypoints(new_route)
table.remove(new_route, #new_route)
local pos = tsf:get_pos()
while #new_route >= 2 and
is_passed(new_route[#new_route], new_route[#new_route - 1], pos) do
table.remove(new_route, #new_route)
end
return new_route
end
local refresh_internal = 100
local frameid = math.random(0, refresh_internal)
@ -66,7 +85,7 @@ function on_update()
else
local new_route = pathfinding.pull_route(agent)
if new_route then
route = new_route
route = drop_passed_waypoints(new_route)
started = false
end
end

View file

@ -7,6 +7,11 @@
inline constexpr int ENGINE_VERSION_MAJOR = 0;
inline constexpr int ENGINE_VERSION_MINOR = 33;
#ifdef VC_VERSION_PATCH
inline constexpr int ENGINE_VERSION_PATCH = VC_VERSION_PATCH;
#else
inline constexpr int ENGINE_VERSION_PATCH = 0;
#endif
#ifdef NDEBUG
inline constexpr bool ENGINE_DEBUG_BUILD = false;
@ -14,7 +19,13 @@ inline constexpr bool ENGINE_DEBUG_BUILD = false;
inline constexpr bool ENGINE_DEBUG_BUILD = true;
#endif // NDEBUG
inline const std::string ENGINE_VERSION_STRING = "0.33";
inline const std::string ENGINE_VERSION_STRING =
std::to_string(ENGINE_VERSION_MAJOR) + "." +
std::to_string(ENGINE_VERSION_MINOR)
#ifdef VC_VERSION_PATCH
+ "." + std::to_string(ENGINE_VERSION_PATCH)
#endif
;
inline constexpr uint MAX_SUBPROCESSES = 1;
inline constexpr uint MAX_SUBPROCESS_DEPTH = 2;

View file

@ -42,8 +42,7 @@ WindowControl::Result WindowControl::initialize() {
#endif
title += "VoxelCore v";
if (buildName.empty()) {
title += std::to_string(ENGINE_VERSION_MAJOR) + "." +
std::to_string(ENGINE_VERSION_MINOR);
title += ENGINE_VERSION_STRING;
} else {
title += buildName;
}

View file

@ -328,10 +328,15 @@ static int l_delete_world(lua::State* L) {
}
/// @brief Get engine version
/// @return major, minor
/// @return major, minor, [patch]
static int l_get_version(lua::State* L) {
return lua::pushvec_stack(
L, glm::vec2(ENGINE_VERSION_MAJOR, ENGINE_VERSION_MINOR)
L,
#ifdef VC_VERSION_PATCH
glm::vec3(ENGINE_VERSION_MAJOR, ENGINE_VERSION_MINOR, ENGINE_VERSION_PATCH)
#else
glm::vec2(ENGINE_VERSION_MAJOR, ENGINE_VERSION_MINOR)
#endif
);
}