Merge branch 'main' into dev

This commit is contained in:
MihailRis 2026-04-11 23:40:37 +03:00
commit 767fa7c7a9
10 changed files with 51 additions and 31 deletions

View file

@ -416,7 +416,7 @@ Structure:
Where: Where:
- structure_name - a string containing the name of the structure, registered in structures.toml. - structure_name - a string containing the name of the structure, registered in structures.toml.
- structure_position - a vec3 (an array of three numbers) relative to the position of the chunk. - structure_position - a vec3 (an array of three numbers).
- rotation - a number from 0 to 3 indicating the rotation of the structure along the Y axis. - rotation - a number from 0 to 3 indicating the rotation of the structure along the Y axis.
- priority - a number determining the order in which structures are placed. Structures with lower priority are overlapped by structures with higher priority. - priority - a number determining the order in which structures are placed. Structures with lower priority are overlapped by structures with higher priority.

View file

@ -419,7 +419,7 @@ end
Где: Где:
- имя_структуры - строка содержащая имя структуры, зарегистрированная в structures.toml. - имя_структуры - строка содержащая имя структуры, зарегистрированная в structures.toml.
- позиция_структуры - vec3 (массив из трех чисел) относительно позиции чанка. - позиция_структуры - vec3 (массив из трех чисел).
- поворот - число от 0 до 3 обозначающая поворот структуры по оси Y. - поворот - число от 0 до 3 обозначающая поворот структуры по оси Y.
- приоритет - число определяющее порядок установки структур. Структуры с меньшем приоритетом перекрываются структурами с большим. - приоритет - число определяющее порядок установки структур. Структуры с меньшем приоритетом перекрываются структурами с большим.

View file

@ -287,7 +287,7 @@ void AssetsLoader::addDefaults(AssetsLoader& loader, const Content* content) {
for (const auto& file : io::directory_iterator(skeletonsDir)) { for (const auto& file : io::directory_iterator(skeletonsDir)) {
loader.add( loader.add(
AssetType::SKELETON, AssetType::SKELETON,
file.string(), (file.parent() / file.stem()).string(),
entry.first + ":" + file.stem() entry.first + ":" + file.stem()
); );
} }

View file

@ -455,7 +455,8 @@ assetload::postfunc assetload::skeleton(
const std::shared_ptr<AssetCfg>& settings const std::shared_ptr<AssetCfg>& settings
) { ) {
return [=](auto assets) { return [=](auto assets) {
std::string text = io::read_string(file); auto path = paths.find(file + ".json");
std::string text = io::read_string(path);
auto skeleton = rigging::SkeletonConfig::parse(text, file, name); auto skeleton = rigging::SkeletonConfig::parse(text, file, name);
for (auto& bone : skeleton->getBones()) { for (auto& bone : skeleton->getBones()) {
std::string model = bone->model.name; std::string model = bone->model.name;

View file

@ -173,7 +173,7 @@ void LevelScreen::saveWorldPreview() {
int previewSize = settings.ui.worldPreviewSize.get(); int previewSize = settings.ui.worldPreviewSize.get();
// camera special copy for world preview // camera special copy for world preview
Camera& camera = *player.fpCamera; Camera camera = *player.fpCamera;
camera.setFov(glm::radians(70.0f)); camera.setFov(glm::radians(70.0f));
DrawContext pctx(nullptr, engine.getWindow(), batch.get()); DrawContext pctx(nullptr, engine.getWindow(), batch.get());

View file

@ -71,10 +71,9 @@ void TextsRenderer::renderNote(
if (preset.displayMode == NoteDisplayMode::PROJECTED) { if (preset.displayMode == NoteDisplayMode::PROJECTED) {
float scale = 1.0f; float scale = 1.0f;
if (glm::abs(preset.perspective) > 0.0001f) { if (glm::abs(preset.perspective) > 0.0001f) {
float scale2 = scale / float scale2 =
(glm::distance(camera.position, pos) * scale / (glm::distance(camera.position, pos) * camera.zoom *
util::sqr(camera.zoom) * glm::sqrt(glm::tan(camera.getFov() * 0.5f)));
glm::sqrt(glm::tan(camera.getFov() * 0.5f)));
scale = scale2 * preset.perspective + scale = scale2 * preset.perspective +
scale * (1.0f - preset.perspective); scale * (1.0f - preset.perspective);
} }

View file

@ -12,6 +12,9 @@
#include "gui_xml.hpp" #include "gui_xml.hpp"
#include "logic/scripting/scripting.hpp" #include "logic/scripting/scripting.hpp"
#include "util/stringutil.hpp" #include "util/stringutil.hpp"
#include "debug/Logger.hpp"
debug::Logger logger("gui-util");
using namespace gui; using namespace gui;
@ -25,6 +28,20 @@ std::shared_ptr<gui::UINode> guiutil::create(
return reader.readXML("[string]", source); return reader.readXML("[string]", source);
} }
static bool notify_callback(const runnable& callback, std::string_view name) {
if (callback == nullptr) {
return false;
}
try {
callback();
return true;
} catch (std::exception& err) {
logger.error()
<< "exception thrown in " << name << ": " << err.what();
}
return false;
}
void guiutil::alert( void guiutil::alert(
Engine& engine, const std::wstring& text, const runnable& on_hidden Engine& engine, const std::wstring& text, const runnable& on_hidden
) { ) {
@ -47,9 +64,7 @@ void guiutil::alert(
auto& menu = *menuPtr; auto& menu = *menuPtr;
runnable on_hidden_final = [on_hidden, &menu]() { runnable on_hidden_final = [on_hidden, &menu]() {
menu.removePage("<alert>"); menu.removePage("<alert>");
if (on_hidden) { if (!notify_callback(on_hidden, "on_hidden") && !menu.back()) {
on_hidden();
} else if (!menu.back()) {
menu.reset(); menu.reset();
} }
}; };
@ -119,18 +134,16 @@ void guiutil::confirm(
runnable on_confirm_final = [on_confirm, menu]() { runnable on_confirm_final = [on_confirm, menu]() {
menu->removePage("<confirm>"); menu->removePage("<confirm>");
if (on_confirm) {
on_confirm(); if (!notify_callback(on_confirm, "on_confirm") && !menu->back()) {
} else if (!menu->back()) {
menu->reset(); menu->reset();
} }
}; };
runnable on_deny_final = [on_deny, menu]() { runnable on_deny_final = [on_deny, menu]() {
menu->removePage("<confirm>"); menu->removePage("<confirm>");
if (on_deny) {
on_deny(); if (!notify_callback(on_deny, "on_deny") && !menu->back()) {
} else if (!menu->back()) {
menu->reset(); menu->reset();
} }
}; };
@ -189,9 +202,16 @@ void guiutil::confirm_with_memo(
auto subpanel = std::make_shared<Panel>(gui, glm::vec2(600, 53)); auto subpanel = std::make_shared<Panel>(gui, glm::vec2(600, 53));
subpanel->setColor(glm::vec4(0)); subpanel->setColor(glm::vec4(0));
runnable on_confirm_final = [on_confirm, menu]() {
menu->removePage("<confirm>");
if (!notify_callback(on_confirm, "on_confirm") && !menu->back()) {
menu->reset();
}
};
subpanel->add(std::make_shared<Button>(gui, yestext, glm::vec4(8.f), [=](GUI&) { subpanel->add(std::make_shared<Button>(gui, yestext, glm::vec4(8.f), [=](GUI&) {
if (on_confirm) on_confirm(); on_confirm_final();
menu->back();
})); }));
subpanel->add(std::make_shared<Button>(gui, notext, glm::vec4(8.f), [=](GUI&) { subpanel->add(std::make_shared<Button>(gui, notext, glm::vec4(8.f), [=](GUI&) {

View file

@ -321,7 +321,10 @@ static void reconfig_packs_outside(
} }
for (const auto& id : packsToRemove) { for (const auto& id : packsToRemove) {
manager.exclude(id); manager.exclude(id);
names.erase(std::find(names.begin(), names.end(), id)); auto it = std::find(names.begin(), names.end(), id);
if (it != names.end()) {
names.erase(it);
}
} }
names = manager.assemble(names); names = manager.assemble(names);
contentControl.setContentPacksRaw(manager.getAll(names)); contentControl.setContentPacksRaw(manager.getAll(names));

View file

@ -8,7 +8,7 @@ inline const char* DEFAULT_CHANNEL = "regular";
inline int extract_channel_index(lua::State* L, int idx) { inline int extract_channel_index(lua::State* L, int idx) {
const char* channel = DEFAULT_CHANNEL; const char* channel = DEFAULT_CHANNEL;
if (!lua::isnoneornil(L, idx)) { if (lua::isstring(L, idx)) {
channel = lua::tostring(L, idx); channel = lua::tostring(L, idx);
} }
int index = audio::get_channel_index(channel); int index = audio::get_channel_index(channel);
@ -121,7 +121,7 @@ static int l_audio_play_stream(lua::State* L) {
return lua::pushinteger( return lua::pushinteger(
L, L,
static_cast<lua::Integer>(play_stream( static_cast<lua::Integer>(play_stream(
lua::tostring(L, 1), lua::require_string(L, 1),
false, false,
lua::tonumber(L, 2), lua::tonumber(L, 2),
lua::tonumber(L, 3), lua::tonumber(L, 3),
@ -144,7 +144,7 @@ static int l_audio_play_stream_2d(lua::State* L) {
return lua::pushinteger( return lua::pushinteger(
L, L,
static_cast<lua::Integer>(play_stream( static_cast<lua::Integer>(play_stream(
lua::tostring(L, 1), lua::require_string(L, 1),
true, true,
0.0, 0.0,
0.0, 0.0,
@ -170,7 +170,7 @@ static int l_audio_play_sound(lua::State* L) {
return lua::pushinteger( return lua::pushinteger(
L, L,
static_cast<lua::Integer>(play_sound( static_cast<lua::Integer>(play_sound(
lua::tostring(L, 1), lua::require_string(L, 1),
false, false,
lua::tonumber(L, 2), lua::tonumber(L, 2),
lua::tonumber(L, 3), lua::tonumber(L, 3),
@ -193,7 +193,7 @@ static int l_audio_play_sound_2d(lua::State* L) {
return lua::pushinteger( return lua::pushinteger(
L, L,
static_cast<lua::Integer>(play_sound( static_cast<lua::Integer>(play_sound(
lua::tostring(L, 1), lua::require_string(L, 1),
true, true,
0.0, 0.0,
0.0, 0.0,

View file

@ -151,10 +151,7 @@ bool PhysicsSolver::calcCollisionNegY(
continue; continue;
} }
auto aabb = AABB(pos - half, pos + half); auto aabb = AABB(pos - half, pos + half);
glm::vec3 scale(1.0f); aabb.scale(glm::vec3(1.0f - E * 4.0f, 1.0f - E * 2, 1.0f - E * 4.0f));
scale.x = 1.0f - E * 4.0f;
scale.z = 1.0f - E * 4.0f;
aabb.scale(scale);
auto boxhalf = box->getHalfSize(); auto boxhalf = box->getHalfSize();
if (box->position.y < pos.y && box->getAABB().intersects(aabb)) { if (box->position.y < pos.y && box->getAABB().intersects(aabb)) {
@ -279,7 +276,7 @@ void PhysicsSolver::calcCollisions(
// step on // step on
if (stepHeight > 0.0 && vel.y <= 0.0f) { if (stepHeight > 0.0 && vel.y <= 0.0f) {
AABB boxAABB = AABB(pos - half, pos + half); AABB boxAABB = AABB(pos - half, pos + half);
boxAABB.scale(glm::vec3(1.0f - E * 2, 1.0f - E * 2, 1.0f - E * 2)); boxAABB.scale(glm::vec3(1.0f - E * 4.0f, 1.0f - E * 2, 1.0f - E * 4.0f));
for (int ix = 0; ix <= glm::ceil((half.x - E) * 2); ix++) { for (int ix = 0; ix <= glm::ceil((half.x - E) * 2); ix++) {
float x = (pos.x - half.x) + ix; float x = (pos.x - half.x) + ix;
for (int iz = 0; iz <= glm::ceil((half.z - E) * 2); iz++) { for (int iz = 0; iz <= glm::ceil((half.z - E) * 2); iz++) {