diff --git a/test_out.txt b/test_out.txt new file mode 100644 index 0000000..7440c45 --- /dev/null +++ b/test_out.txt @@ -0,0 +1,15 @@ +Godot Engine v4.6.2.stable.official.71f334935 - https://godotengine.org + +roundtrip bounds.position = (0.0, 0.0, 0.0) (expected (0.5, 1.5, 2.5)) +roundtrip coord = (0, 0, 0) (expected (1, 2, 3)) +format_version present? -> +version field -> 1 +SCRIPT ERROR: Invalid assignment of property or key 'properties' with value of type 'bool' on a base object of type 'RefCounted (WorldObjectData)'. + at: _parse_object_section (res://scripts/chunk_data_decoder.gd:407) + GDScript backtrace (most recent call first): + [0] _parse_object_section (res://scripts/chunk_data_decoder.gd:407) + [1] _init (res://test_review.gd:25) +SCRIPT ERROR: Out of bounds get index '0' (on base: 'Array[WorldObjectData]') + at: _init (res://test_review.gd:26) + GDScript backtrace (most recent call first): + [0] _init (res://test_review.gd:26) diff --git a/test_review.gd b/test_review.gd new file mode 100644 index 0000000..b17114b --- /dev/null +++ b/test_review.gd @@ -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()