fix(world): correct 3D chunk coordinate mapping and streaming proximity
checkpoint / checkpoint (push) Successful in 5m55s
checkpoint / checkpoint (push) Successful in 5m55s
This commit is contained in:
+5
-2
@@ -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
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user