This commit is contained in:
clasher113 2025-08-15 12:28:40 +03:00
commit 89eb354e5d
7 changed files with 102 additions and 13 deletions

View File

@ -143,6 +143,8 @@ Block is not a physical obstacle if **false**
An array of 6 numbers describing an offset an size of a block hitbox.
The numbers are specified in the range [0.0, 1.0] - i.e. within the block (in the case of an extended block, the hitbox can be larger than one, but must not go beyond the "size" property).
Array *\[0.25, 0.0, 0.5, 0.75, 0.4, 0.3\]* describes hitbox width:
- offset 0.25m east
- offset 0.0m up
@ -151,6 +153,15 @@ Array *\[0.25, 0.0, 0.5, 0.75, 0.4, 0.3\]* describes hitbox width:
- 0.4m height
- 0.3m length (from south to north)
For composite hitboxes, the *hitboxes* property is used - an array of hitboxes, for example:
```json
"hitboxes": [
[0, 0, 0, 1, 0.625, 1],
[0, 0.6875, 0, 1, 0.3125, 1]
]
```
### *grounded*
Is block may only be set on a solid block and destructs on below block destruction.

View File

@ -152,7 +152,7 @@
Массив из 6 чисел описывающих смещение и размер хитбокса блока.
Числа указываются в диапазоне [0.0, 1.0] - т.е в пределах блока.
Числа указываются в диапазоне [0.0, 1.0] - т.е в пределах блока (в случае расширенного блока хитбокс может быть больше единицы, но не должен выходить за пределы size).
Массив `[0.25, 0.0, 0.5, 0.75, 0.4, 0.3]` описывает хитбокс:
- смещен на 0.25 м на запад
@ -162,6 +162,15 @@
- высотой 0.4 м
- длиной (с юга на север) 0.3 м
Для составных хитбоксов используется свойство *hitboxes* - массив хитбоксов, например:
```json
"hitboxes": [
[0, 0, 0, 1, 0.625, 1],
[0, 0.6875, 0, 1, 0.3125, 1]
]
```
### Приземленность - *grounded*
Блок может быть установлен только на полный блок.

View File

@ -1,16 +1,69 @@
{
description = "VoxelCore voxel game engine in C++";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: {
devShells.default = with nixpkgs.legacyPackages.${system}; mkShell {
nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [ glm glfw glew zlib libpng libvorbis openal luajit curl ]; # libglvnd
packages = [ glfw mesa freeglut entt ];
LD_LIBRARY_PATH = "${wayland}/lib:$LD_LIBRARY_PATH";
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
voxel-core = pkgs.stdenv.mkDerivation {
name = "voxel-core";
src = ./.;
nativeBuildInputs = with pkgs; [
cmake
pkg-config
];
buildInputs = with pkgs; [
glm
glfw
glew
zlib
libpng
libvorbis
openal
luajit
curl
entt
mesa
freeglut
]; # libglvnd
packages = with pkgs; [
glfw
mesa
freeglut
entt
];
cmakeFlags = [
"-DCMAKE_PREFIX_PATH=${pkgs.entt}"
"-DCMAKE_INCLUDE_PATH=${pkgs.entt}/include"
];
installPhase = ''
mkdir -p $out/bin
cp VoxelEngine $out/bin/
'';
};
});
in
{
packages.default = voxel-core;
apps.default = {
type = "app";
program = "${voxel-core}/bin/VoxelCore";
};
}
);
}

View File

@ -538,6 +538,7 @@ void Hud::closeInventory() {
exchangeSlotInv = nullptr;
inventoryOpen = false;
inventoryView = nullptr;
secondInvView = nullptr;
secondUI = nullptr;
for (auto& element : elements) {
@ -597,6 +598,9 @@ void Hud::remove(const std::shared_ptr<UINode>& node) {
}
}
cleanup();
if (node == secondUI) {
closeInventory();
}
}
void Hud::setDebug(bool flag) {

View File

@ -126,7 +126,15 @@ void Batch3D::sprite(
float scale = 1.0f / static_cast<float>(atlasRes);
float u = (index % atlasRes) * scale;
float v = 1.0f - ((index / atlasRes) * scale) - scale;
sprite(pos, up, right, w, h, UVRegion(u, v, u+scale, v+scale), tint);
sprite(
pos + right * w + up * h, // revert centering
up,
right,
w,
h,
UVRegion(u, v, u + scale, v + scale),
tint
);
}
void Batch3D::sprite(

View File

@ -51,6 +51,7 @@ void TextsRenderer::renderNote(
glm::vec3 yvec = note.getAxisY();
int width = font.calcWidth(text, text.length());
int height = font.getLineHeight();
if (preset.displayMode == NoteDisplayMode::Y_FREE_BILLBOARD ||
preset.displayMode == NoteDisplayMode::XY_FREE_BILLBOARD) {
xvec = camera.position - pos;
@ -96,8 +97,11 @@ void TextsRenderer::renderNote(
pos = screenPos / screenPos.w;
}
} else if (!frustum.isBoxVisible(pos - xvec * (width * 0.5f * preset.scale),
pos + xvec * (width * 0.5f * preset.scale))) {
} else if (!frustum.isBoxVisible(
pos - xvec * (width * 0.5f) * preset.scale,
pos + xvec * (width * 0.5f) * preset.scale +
yvec * static_cast<float>(height) * preset.scale
)) {
return;
}
auto color = preset.color;

View File

@ -46,7 +46,7 @@ static int l_open(lua::State* L) {
}
return lua::pushinteger(L, hud->openInventory(
layout,
level->inventories->get(invid),
lua::isnoneornil(L, 3) ? nullptr : level->inventories->get(invid),
playerInventory
)->getId());
}