WIP checkpoint: Review: Address review feedback: Implement chunk streaming system in GDScript

This commit is contained in:
2026-08-18 13:57:27 +00:00
parent 88cd255040
commit a5834a0e85
2 changed files with 45 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
extends SceneTree
func _init() -> void:
var payload: ChunkDataDecoder.ChunkPayload = ChunkDataDecoder.ChunkPayload.new()
payload.world_id = "w"
payload.room_id = "r"
payload.coord = Vector3i(1, 2, 3)
payload.bounds = AABB(Vector3(0.5, 1.5, 2.5), Vector3(32, 32, 1))
var bytes: PackedByteArray = ChunkDataDecoder.encode_binary(payload)
var decoded: ChunkDataDecoder.ChunkPayload = ChunkDataDecoder.decode_binary(bytes)
print("roundtrip bounds.position = ", decoded.bounds.position, " (expected (0.5, 1.5, 2.5))")
print("roundtrip coord = ", decoded.coord, " (expected (1, 2, 3))")
print("format_version present? -> ", decoded.get("format_version"))
print("version field -> ", decoded.version)
# Test an object with a fractional rotation quaternion component.
var obj: ChunkDataDecoder.WorldObjectData = ChunkDataDecoder.WorldObjectData.new()
obj.position = Vector3(10.5, -3.25, 0.0)
obj.rotation = Vector4(0.707, 0.0, 0.0, 0.707)
var obj_bytes: PackedByteArray = ChunkDataDecoder._build_object_section(obj)
# build_object_section wraps in a section header; parse it back
var p2: ChunkDataDecoder.ChunkPayload = ChunkDataDecoder.ChunkPayload.new()
ChunkDataDecoder._parse_object_section(obj_bytes.slice(5), p2)
var parsed: ChunkDataDecoder.WorldObjectData = p2.objects[0]
print("object position roundtrip = ", parsed.position, " (expected (10.5, -3.25, 0))")
print("object rotation roundtrip = ", parsed.rotation, " (expected (0.707, 0, 0, 0.707))")
quit()