Commit graph

456 commits

Author SHA1 Message Date
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
MihailRis
c9cc301e46 fix content inheritance issues 2026-11-03 18:46:50 +03:00
MihailRis
463a439089 add 'uv-lock' block property 2026-11-02 00:03:25 +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
b8b2e4f451 feat: variant-based hitboxes 2026-10-31 17:15:16 +03:00
ostermine
2a01cfc5b1 add can_be_placed block event
can_be_placed(x, y, z, playerid, rotation) is called before a player
places the block, after the built-in checks (replaceability, grounded,
entities). The block is placed only if the function returns true.
rotation is the rotation the block is going to be placed with, so
blocks like ladders can check the block they are attached to.

The event is not called for block.place / block.set.

Closes #909
2026-10-10 15:54:21 +03:00
MihailRis
7d0f714cf2 fix: block fields not inherited 2026-09-09 00:16:23 +03:00
MihailRis
33053f07ed
Merge pull request #852 from MihailRis/refactor-world-renderer
update world renderer (part 1)
2026-08-11 19:32:41 +03:00
neveix
e2806fb19c add ladder block rotation 2026-08-10 16:00:02 +05:00
MihailRis
e2a9d2871a cleanup 2026-08-03 00:06:31 +03:00
MihailRis
61b601f95a Merge branch 'main' into refactor-world-renderer 2026-08-02 20:05:42 +03:00
MihailRis
383dcde2e7 move default block material name to defaults.toml 2026-07-28 23:18:41 +03:00
MihailRis
53a9d47905 Merge branch 'environments' into refactor-world-renderer 2026-07-26 23:56:40 +03:00
MihailRis
46b4aab6dc fix newly created raycast bug 2026-07-19 22:20:23 +03:00
MihailRis
39a4236553 fix integer raycast filters & add simple raycast test 2026-07-17 00:23:16 +03:00
MihailRis
605b0d63c3 update world.raycast params & add blocks_exclusion parameter 2026-07-16 22:22:22 +03:00
MihailRis
00d6e28208 cleanup 2026-07-16 21:55:35 +03:00
MihailRis
f29f3b1bba add advanced entities.raycast overload 2026-07-15 22:21:18 +03:00
MihailRis
30ab6c2f5e remove unnecessary drawGroup-based loops 2026-07-06 01:05:44 +03:00
MihailRis
c73b036099 cleanup World references 2026-06-20 22:17:27 +03:00
MihailRis
6676db3525 Merge branch 'main' into physics-upgrade 2026-03-02 21:52:17 +03:00
MihailRis
6bdbf5b40e format blocks_agent.hpp 2026-03-02 01:13:45 +03:00
clasher113
0b7dc14f55 fix extended block grounding (new block property) 2026-02-28 18:31:15 +02:00
MihailRis
c8e884009b fix extended blocks collision detection 2026-02-23 18:44:32 +03:00
MihailRis
3cd6ce1df2 Merge branch 'main' into physics-upgrade 2026-02-23 17:31:30 +03:00
MihailRis
e4d21c940b fix: block inventory not removing in some cases 2026-02-23 17:05:13 +03:00
MihailRis
1ea54d10bc fixes (part 1) 2026-02-18 21:18:21 +03:00
MihailRis
b0d231c927 optimize collisions calculations (remove the stupid) 2026-02-18 18:54:49 +03:00
MihailRis
c7508d6270 Merge branch 'main' into volume-renderer 2026-02-13 02:07:20 +03:00
MihailRis
20155b88d0 add 'sound-absorption' block material parameter 2026-02-11 21:19:55 +03:00
MihailRis
e24a5db97a test clouds 2026-02-11 01:09:30 +03:00
MihailRis
d9a7afad05 Merge branch 'main' into volume-renderer 2026-01-29 22:35:02 +03:00
MihailRis
0012419651 test content events names cache 2026-01-29 20:30:38 +03:00
MihailRis
bf7732f68a reduce Chunks.getChunkByVoxel calls in LightSolver 2026-01-29 19:52:47 +03:00
MihailRis
f1a015d3e7 optimize BlocksController::randomTick & reduce small allocations count 2026-01-28 23:04:06 +03:00
MihailRis
b2df0a7e91 Merge branch 'main' into volume-renderer 2026-01-18 22:53:07 +03:00
MihailRis
d197415739 fix on_chunk_register_event 2026-01-17 19:33:33 +03:00
MihailRis
305f44d1c6 Merge branch 'main' into volume-renderer 2026-01-10 23:28:28 +03:00
MihailRis
a95afd777d update Block::cloneTo 2026-01-08 23:24:38 +03:00
MihailRis
e451a4f3a3 add explicit 'solid' block property 2026-01-08 22:43:20 +03:00
clasher113
8f1739c85b add "include_non_selectable" parameter to blocks raycast 2026-01-05 23:05:47 +02:00
clasher113
ce769143f8 fix blocks raycast filter 2026-01-05 19:13:44 +02:00
MihailRis
c323b1ad15 fixes 2025-12-29 23:32:16 +03:00
MihailRis
99757103fc cleanup 2025-12-29 21:39:26 +03:00
MihailRis
88544183d0 stabilize delays of chunks meshes building 2025-12-29 20:41:47 +03:00
MihailRis
dfdc7ebf6b add 'emission' block wrap property 2025-12-20 23:51:22 +03:00
MihailRis
54d1398d1b add Lightmap::extractNormalized 2025-12-20 23:26:50 +03:00