Commit graph

4573 commits

Author SHA1 Message Date
ostermine
ebd506de09 fix block positions rounded to float in ray casts and routes
iendpoint of block.raycast, entities.raycast and world.raycast and
nodes of a pathfinding route are integer block positions, but they were
pushed to Lua through glm::vec3. An odd coordinate above 16.7M came
back as a neighbour block.
2026-11-12 10:05:09 +03:00
ostermine
56ab3de514 make audio positions relative to the listener
OpenAL takes positions as floats. Positions of the listener and of the
speakers were passed in the world space, so far from the world origin
both were rounded to the float step (2 m at 30M blocks): a sound next
to the player came from a wrong side and with a wrong volume.

A speaker keeps its position as worldvec3, the listener stays in the
OpenAL origin, and a source is placed at "speaker - listener". Sources
are refreshed in the speaker update, once per frame.
2026-11-12 10:05:08 +03:00
ostermine
d012f0530b use double precision for particles, emitters and 3D texts
Positions of particles, of static emitters and of text notes are
worldvec3. gfx.particles, gfx.text3d, gfx.blockwraps, pathfinding and
generation.create_fragment read positions from Lua as doubles: a float
can not hold an odd block coordinate above 16.7M, the object went to a
neighbour block.
2026-11-12 10:05:07 +03:00
ostermine
cb39ed464a use double precision for positions of entities and players
Transform::pos, Hitbox::position and Player::position were floats. At
65k blocks the float step is 8 mm, at 1M it is 6-12 cm, at 30M it is
2 m. The physics moves a body by 3 cm or less per substep and pushes it
out of a wall by 10 cm or less: steps got rounded to the grid (the body
changed its speed, then stopped), the AABB of a body was off by a float
step and gave false collisions with the blocks around.

Positions of bodies, entity transforms, players, spawn points and the
skeleton position interpolation are worldvec3 now. Collisions are still
calculated in floats, but in the coordinates relative to the block the
body is in: the solver takes the origin, block lookups and hitboxes of
other bodies are shifted by it, the result is added back in doubles.
So the precision of the physics is the same anywhere in the world.

A calculated sensor is stored relative to the position of its entity.
Entities::getAllInside takes the corners in doubles,
Entities::hasBlockingInside takes the origin of the AABB.

The save format does not change: positions are written as numbers
(float64) as before, saves are compatible in both directions. Lua
functions keep their signatures, they only stop rounding to float.
2026-11-12 10:05:07 +03:00
ostermine
ad69663b2e use double precision for camera position and ray casts
A float position has a step of 6 cm at 1M blocks and of 2 m at 30M:
the camera moved by jumps and rays started not where the camera is.

worldvec3 (glm::dvec3) is the type of a position in the world.
Camera::position, the start and the end of block and entity ray casts
and the hit position of the player selection use it. Lua numbers are
doubles already, so cameras.set_pos/get_pos, block.raycast,
entities.raycast and world.raycast only stop rounding to float.
Entities::rayCast intersects a hitbox in the coordinates relative to
its position instead of a float AABB in the world space.
2026-11-12 10:05:06 +03:00
ostermine
89bdadd6aa render the world relative to an origin near the camera
World coordinates were passed to GPU as floats: u_model of a chunk and
of a model had the world translation, vertices of translucent blocks,
particles, precipitation, block wrappers, lines and 3D texts were built
in the world space, and the camera position was subtracted in shaders.
The float step grows with the distance from the world origin (6 cm at
1M blocks, 2 m at 30M): blocks got skewed, then stuck together.

Camera::getOrigin() is an integer point near the camera (X and Z are
rounded to 1024 blocks, Y is 0). Camera::getView() is relative to it,
and every position passed to GPU is "world - origin" calculated on CPU,
so the shaders keep working with small numbers and do not change:
u_cameraPos, a_modelpos, u_inverseView and the shadows matrices are in
the same space as before, shifted by the origin. Matrices of a shadow
map are converted from the origin of its camera to the origin of the
player camera. The clouds shader gets the origin wrapped by the period
of its waves, the waves stay bound to the world.

Vertices of translucent blocks are local to the chunk now, as vertices
of opaque ones, and drawn with u_model of the chunk.
2026-11-12 10:05:06 +03:00
ostermine
e1f6daabb7 fix camera view rotation far from the world origin
Camera::getView built the view with lookAt(position, position + front):
the direction came back as a difference of large floats. Far from the
origin the view turned away from where the camera looks - at 16M blocks
by up to 24 degrees, at 30M the camera looked straight up or down
whatever its yaw (at pitch 0 the direction is a zero vector, the matrix
is NaN). The rotation is built from front itself now, then translated
by -position: the same matrix, without the subtraction.
2026-11-12 10:05:05 +03:00
ostermine
67c913041e fix headless tick rate: schedule ticks by deadlines
ServerMainloop slept the rest of the tick and then restarted counting from
the moment it woke up, so every sleep overshoot made the tick longer. With a
coarse timer (a VirtualBox guest of a Windows host) --tps 20 gave 12-17 ticks
per second. Ticks now follow absolute deadlines on steady_clock; after falling
more than 5 ticks behind the schedule is reset instead of running a burst of
ticks.

The time of a tick is its scheduled time, so delta is exactly 1 / tps while
the loop keeps up, as in test mode. With the wake-up time deltas jitter
around 1 / tps, and the world tick clock, which calls on_world_tick at most
once per update, skipped every few ticks.
2026-11-05 13:46:49 +03:00
MihailRis
9be7cfa724 fix fatal errors caused by incorrect interval event callbacks timing
Some checks failed
x86-64 AppImage / build-appimage (ubuntu-22.04) (push) Has been cancelled
Build / Build (push) Has been cancelled
Macos Build / build-dmg (push) Has been cancelled
Windows Build (CLang) / build-windows (clang, windows-latest) (push) Has been cancelled
MSVC Build / build-windows (windows-2022) (push) Has been cancelled
2026-11-05 03:35:32 +03:00
MihailRis
97c790350d
Merge pull request #1072 from MihailRis/dev
Some checks are pending
x86-64 AppImage / build-appimage (ubuntu-22.04) (push) Waiting to run
Build / Build (push) Waiting to run
Macos Build / build-dmg (push) Waiting to run
Windows Build (CLang) / build-windows (clang, windows-latest) (push) Waiting to run
MSVC Build / build-windows (windows-2022) (push) Waiting to run
0.33 development
2026-11-04 16:23:46 +03:00
MihailRis
f4d4209e48 fix reverb room rolloff factor minimum value 2026-11-04 15:58:55 +03:00
MihailRis
c641a18d32 fix lighting settings based chunk meshes rebuilding 2026-11-04 12:43:42 +03:00
MihailRis
498868a8d5 cleanup 2026-11-03 22:45:30 +03:00
MihailRis
1bb66ebf1f fix audio streams cleanup 2026-11-03 22:26:03 +03:00
MihailRis
24718a2993 reverting it because voices are not reasom
This reverts commit ecc4c1794e.
2026-11-03 22:08:44 +03:00
MihailRis
ecc4c1794e replace 'units' with 'blocks', 'items' for some reason 2026-11-03 22:01:43 +03:00
MihailRis
3de0187a87 feat: removing world missing content from UI 2026-11-03 21:29:42 +03:00
MihailRis
c9cc301e46 fix content inheritance issues 2026-11-03 18:46:50 +03:00
MihailRis
7d3584629f cleanup 2026-11-02 00:07:47 +03:00
MihailRis
463a439089 add 'uv-lock' block property 2026-11-02 00:03:25 +03:00
MihailRis
3ec03738b4 add pathfinding.set_height 2026-11-01 18:41:40 +03:00
MihailRis
98cd85f4f6 Merge branch 'dev' into pathfinding-update 2026-11-01 18:37:28 +03:00
MihailRis
b37da1a728 add pathfinding.set_width 2026-11-01 18:07:21 +03:00
MihailRis
1fe64a8b51 remove extra pathfinding route steps & add pathfinding agent width 2026-11-01 18:05:31 +03:00
MihailRis
5390541334 update app.get_version 2026-11-01 17:31:53 +03:00
MihailRis
3e22dd6329 pass patch number to the engine 2026-11-01 17:30:34 +03:00
MihailRis
1da6ef9747 extract render-related code from Entities to EntitiesRenderer 2026-11-01 03:34:16 +03:00
MihailRis
dbc6a52132 update CMakeLists.txt 2026-11-01 02:29:17 +03:00
MihailRis
7ef07a75cd remove EnTT from Entities.cpp 2026-11-01 02:24:15 +03:00
MihailRis
0ae335599a add MeshStats vertices count to Mesh::drawInstanced 2026-11-01 02:05:27 +03:00
MihailRis
5011a654be Merge branch 'main' into dev 2026-11-01 02:03:50 +03:00
MihailRis
c4a0b7a992 update debug panel 2026-11-01 01:38:44 +03:00
MihailRis
d4deb34722 add util::format_count 2026-11-01 01:38:24 +03:00
MihailRis
d857e7326d add vertices count to debug panel 2026-11-01 01:30:39 +03:00
MihailRis
c21871c3c9 upgrade entities frustum culling 2026-10-31 23:41:40 +03:00
MihailRis
c444e266ba add container:clearInterval 2026-10-31 17:57:17 +03:00
MihailRis
b8b2e4f451 feat: variant-based hitboxes 2026-10-31 17:15:16 +03:00
MihailRis
f19cb75534 improve audio::ope_PCM_stream error messages & feat: specifying stream path without extension 2026-10-27 14:20:01 +03:00
MihailRis
575bfb28e0 Merge branch 'main' into dev 2026-10-27 13:03:13 +03:00
MihailRis
5eae83be33
Merge pull request #1062 from MihailRis/entity-rotation-interpolation
entity rotation interpolation
2026-10-27 13:02:35 +03:00
MihailRis
9846ad289a feat: entity rotation interpolation 2026-10-26 19:30:53 +03:00
MihailRis
8cc25938ef feat: preload.json patterns support 2026-10-26 12:27:03 +03:00
MihailRis
581702a836 fix project start script not actually started before first tick 2026-10-25 21:33:54 +03:00
MihailRis
bf55ffa183 fix block.set behaviour if world is not open
Some checks failed
x86-64 AppImage / build-appimage (ubuntu-22.04) (push) Has been cancelled
Build / Build (push) Has been cancelled
Macos Build / build-dmg (push) Has been cancelled
Windows Build (CLang) / build-windows (clang, windows-latest) (push) Has been cancelled
MSVC Build / build-windows (windows-2022) (push) Has been cancelled
2026-10-21 23:11:57 +03:00
MihailRis
b49075347a fix block library typos 2026-10-21 12:42:35 +03:00
MihailRis
28648381f1 fix world.raycast 2026-10-21 12:37:30 +03:00
Andrey Tazetdinov
8798b34423 move to namespace 2026-10-21 11:28:33 +02:00
Andrey Tazetdinov
67ed7ac582 refactor physics solver 2026-10-21 11:25:06 +02:00
Andrey Tazetdinov
103f3b2b05 fixes 2026-10-21 11:25:06 +02:00
Andrey Tazetdinov
bf8d9e827a physics solver spatial grid 2026-10-21 11:25:06 +02:00