diff --git a/tutorials/misc/binary_serialization_api.rst b/tutorials/misc/binary_serialization_api.rst index 2463428a7..c9f2a51e3 100644 --- a/tutorials/misc/binary_serialization_api.rst +++ b/tutorials/misc/binary_serialization_api.rst @@ -84,7 +84,10 @@ integer, specifying the type of data: +--------+--------------------------+ Following this is the actual packet contents, which varies for each type -of packet: +of packet. Note that this assumes Godot is compiled with single precision +floats. If instead doubles are used, the length of "Float" fields within +data structures should be 8, and the offset should be (offset - 4) * 2 + 4. +The "float" type itself is always double precision. 0: null ~~~~~~~ @@ -104,17 +107,17 @@ of packet: +----------+-------+-----------+--------------------------+ | Offset | Len | Type | Description | +==========+=======+===========+==========================+ -| 4 | 4 | Integer | Signed, 32-Bit Integer | +| 4 | 8 | Integer | Signed, 64-bit Integer | +----------+-------+-----------+--------------------------+ -3: :ref:`float`/real +3: :ref:`float` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+-------------------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+=========================+ -| 4 | 4 | Float | IEEE 754 32-Bits Float | -+----------+-------+---------+-------------------------+ ++----------+-------+---------+-----------------------------------+ +| Offset | Len | Type | Description | ++==========+=======+=========+===================================+ +| 4 | 8 | Float | IEEE 754 Double-precision Float | ++----------+-------+---------+-----------------------------------+ 4: :ref:`String` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -171,21 +174,21 @@ This field is padded to 4 bytes. 8: :ref:`Transform2D` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+---------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+===============+ -| 4 | 4 | Float | [0][0] | -+----------+-------+---------+---------------+ -| 8 | 4 | Float | [0][1] | -+----------+-------+---------+---------------+ -| 12 | 4 | Float | [1][0] | -+----------+-------+---------+---------------+ -| 16 | 4 | Float | [1][1] | -+----------+-------+---------+---------------+ -| 20 | 4 | Float | [2][0] | -+----------+-------+---------+---------------+ -| 24 | 4 | Float | [2][1] | -+----------+-------+---------+---------------+ ++----------+-------+---------+---------------------------------------------------------------+ +| Offset | Len | Type | Description | ++==========+=======+=========+===============================================================+ +| 4 | 4 | Float | The X component of the X column vector, accessed via [0][0] | ++----------+-------+---------+---------------------------------------------------------------+ +| 8 | 4 | Float | The Y component of the X column vector, accessed via [0][1] | ++----------+-------+---------+---------------------------------------------------------------+ +| 12 | 4 | Float | The X component of the Y column vector, accessed via [1][0] | ++----------+-------+---------+---------------------------------------------------------------+ +| 16 | 4 | Float | The Y component of the Y column vector, accessed via [1][1] | ++----------+-------+---------+---------------------------------------------------------------+ +| 20 | 4 | Float | The X component of the origin vector, accessed via [2][0] | ++----------+-------+---------+---------------------------------------------------------------+ +| 24 | 4 | Float | The Y component of the origin vector, accessed via [2][1] | ++----------+-------+---------+---------------------------------------------------------------+ 9: :ref:`Plane` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -239,58 +242,58 @@ This field is padded to 4 bytes. 12: :ref:`Basis` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+---------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+===============+ -| 4 | 4 | Float | [0][0] | -+----------+-------+---------+---------------+ -| 8 | 4 | Float | [0][1] | -+----------+-------+---------+---------------+ -| 12 | 4 | Float | [0][2] | -+----------+-------+---------+---------------+ -| 16 | 4 | Float | [1][0] | -+----------+-------+---------+---------------+ -| 20 | 4 | Float | [1][1] | -+----------+-------+---------+---------------+ -| 24 | 4 | Float | [1][2] | -+----------+-------+---------+---------------+ -| 28 | 4 | Float | [2][0] | -+----------+-------+---------+---------------+ -| 32 | 4 | Float | [2][1] | -+----------+-------+---------+---------------+ -| 36 | 4 | Float | [2][2] | -+----------+-------+---------+---------------+ ++----------+-------+---------+---------------------------------------------------------------+ +| Offset | Len | Type | Description | ++==========+=======+=========+===============================================================+ +| 4 | 4 | Float | The X component of the X column vector, accessed via [0][0] | ++----------+-------+---------+---------------------------------------------------------------+ +| 8 | 4 | Float | The Y component of the X column vector, accessed via [0][1] | ++----------+-------+---------+---------------------------------------------------------------+ +| 12 | 4 | Float | The Z component of the X column vector, accessed via [0][2] | ++----------+-------+---------+---------------------------------------------------------------+ +| 16 | 4 | Float | The X component of the Y column vector, accessed via [1][0] | ++----------+-------+---------+---------------------------------------------------------------+ +| 20 | 4 | Float | The Y component of the Y column vector, accessed via [1][1] | ++----------+-------+---------+---------------------------------------------------------------+ +| 24 | 4 | Float | The Z component of the Y column vector, accessed via [1][2] | ++----------+-------+---------+---------------------------------------------------------------+ +| 28 | 4 | Float | The X component of the Z column vector, accessed via [2][0] | ++----------+-------+---------+---------------------------------------------------------------+ +| 32 | 4 | Float | The Y component of the Z column vector, accessed via [2][1] | ++----------+-------+---------+---------------------------------------------------------------+ +| 36 | 4 | Float | The Z component of the Z column vector, accessed via [2][2] | ++----------+-------+---------+---------------------------------------------------------------+ 13: :ref:`Transform` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+---------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+===============+ -| 4 | 4 | Float | [0][0] | -+----------+-------+---------+---------------+ -| 8 | 4 | Float | [0][1] | -+----------+-------+---------+---------------+ -| 12 | 4 | Float | [0][2] | -+----------+-------+---------+---------------+ -| 16 | 4 | Float | [1][0] | -+----------+-------+---------+---------------+ -| 20 | 4 | Float | [1][1] | -+----------+-------+---------+---------------+ -| 24 | 4 | Float | [1][2] | -+----------+-------+---------+---------------+ -| 28 | 4 | Float | [2][0] | -+----------+-------+---------+---------------+ -| 32 | 4 | Float | [2][1] | -+----------+-------+---------+---------------+ -| 36 | 4 | Float | [2][2] | -+----------+-------+---------+---------------+ -| 40 | 4 | Float | [3][0] | -+----------+-------+---------+---------------+ -| 44 | 4 | Float | [3][1] | -+----------+-------+---------+---------------+ -| 48 | 4 | Float | [3][2] | -+----------+-------+---------+---------------+ ++----------+-------+---------+---------------------------------------------------------------+ +| Offset | Len | Type | Description | ++==========+=======+=========+===============================================================+ +| 4 | 4 | Float | The X component of the X column vector, accessed via [0][0] | ++----------+-------+---------+---------------------------------------------------------------+ +| 8 | 4 | Float | The Y component of the X column vector, accessed via [0][1] | ++----------+-------+---------+---------------------------------------------------------------+ +| 12 | 4 | Float | The Z component of the X column vector, accessed via [0][2] | ++----------+-------+---------+---------------------------------------------------------------+ +| 16 | 4 | Float | The X component of the Y column vector, accessed via [1][0] | ++----------+-------+---------+---------------------------------------------------------------+ +| 20 | 4 | Float | The Y component of the Y column vector, accessed via [1][1] | ++----------+-------+---------+---------------------------------------------------------------+ +| 24 | 4 | Float | The Z component of the Y column vector, accessed via [1][2] | ++----------+-------+---------+---------------------------------------------------------------+ +| 28 | 4 | Float | The X component of the Z column vector, accessed via [2][0] | ++----------+-------+---------+---------------------------------------------------------------+ +| 32 | 4 | Float | The Y component of the Z column vector, accessed via [2][1] | ++----------+-------+---------+---------------------------------------------------------------+ +| 36 | 4 | Float | The Z component of the Z column vector, accessed via [2][2] | ++----------+-------+---------+---------------------------------------------------------------+ +| 40 | 4 | Float | The X component of the origin vector, accessed via [3][0] | ++----------+-------+---------+---------------------------------------------------------------+ +| 44 | 4 | Float | The Y component of the origin vector, accessed via [3][1] | ++----------+-------+---------+---------------------------------------------------------------+ +| 48 | 4 | Float | The Z component of the origin vector, accessed via [3][2] | ++----------+-------+---------+---------------------------------------------------------------+ 14: :ref:`Color` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -418,24 +421,24 @@ The array data is padded to 4 bytes. 23: :ref:`PackedFloat32Array` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+------------------+-------+-----------+---------------------------+ -| Offset | Len | Type | Description | -+==================+=======+===========+===========================+ -| 4 | 4 | Integer | Array Length (Floats) | -+------------------+-------+-----------+---------------------------+ -| 8..8+length\*4 | 4 | Integer | 32 Bits IEEE 754 Float | -+------------------+-------+-----------+---------------------------+ ++------------------+-------+-----------+-------------------------------------------+ +| Offset | Len | Type | Description | ++==================+=======+===========+===========================================+ +| 4 | 4 | Integer | Array Length (Floats) | ++------------------+-------+-----------+-------------------------------------------+ +| 8..8+length\*4 | 4 | Integer | 32 Bits IEEE 754 Single-precision float | ++------------------+-------+-----------+-------------------------------------------+ 24: :ref:`PackedFloat64Array` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+------------------+-------+-----------+---------------------------+ -| Offset | Len | Type | Description | -+==================+=======+===========+===========================+ -| 4 | 4 | Integer | Array Length (Floats) | -+------------------+-------+-----------+---------------------------+ -| 8..8+length\*8 | 8 | Integer | 64 Bits IEEE 754 Float | -+------------------+-------+-----------+---------------------------+ ++------------------+-------+-----------+-------------------------------------------+ +| Offset | Len | Type | Description | ++==================+=======+===========+===========================================+ +| 4 | 4 | Integer | Array Length (Floats) | ++------------------+-------+-----------+-------------------------------------------+ +| 8..8+length\*8 | 8 | Integer | 64 Bits IEEE 754 Double-precision float | ++------------------+-------+-----------+-------------------------------------------+ 25: :ref:`PackedStringArray` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~