fix(world): correct 3D chunk coordinate mapping and streaming proximity
checkpoint / checkpoint (push) Successful in 5m55s

This commit is contained in:
2026-09-17 12:06:06 +00:00
parent d2b62c5d25
commit bbd9ffc46f
3 changed files with 121 additions and 5 deletions
+5 -2
View File
@@ -70,11 +70,14 @@ static func compute_bounds(p_coord: Vector3i) -> AABB:
## Compute the chunk coordinate that contains a world-space position.
## Maps Godot 3D world space (X = East/West, Y = Height/Up, Z = North/South)
## to chunk coordinates (cx = X, cy = Z, cz = Y).
static func coord_for_position(p_pos: Vector3) -> Vector3i:
var cz: int = int(floor((p_pos.y - CHUNK_ORIGIN.y) / CHUNK_SIZE_Z)) if CHUNK_SIZE_Z > 1 else 0
return Vector3i(
int(floor((p_pos.x - CHUNK_ORIGIN.x) / CHUNK_SIZE_X)),
int(floor((p_pos.y - CHUNK_ORIGIN.y) / CHUNK_SIZE_Y)),
int(floor((p_pos.z - CHUNK_ORIGIN.z) / CHUNK_SIZE_Z))
int(floor((p_pos.z - CHUNK_ORIGIN.z) / CHUNK_SIZE_Y)),
cz
)