diff --git a/tutorials/io/binary_serialization_api.rst b/tutorials/io/binary_serialization_api.rst index 09bd39bdb4d..4f19edd2113 100644 --- a/tutorials/io/binary_serialization_api.rst +++ b/tutorials/io/binary_serialization_api.rst @@ -1,5 +1,3 @@ -:article_outdated: True - .. _doc_binary_serialization_api: Binary serialization API @@ -33,77 +31,138 @@ The packet is designed to be always padded to 4 bytes. All values are little-endian-encoded. All packets have a 4-byte header representing an integer, specifying the type of data. -The lowest value two bytes are used to determine the type, while the highest value -two bytes contain flags: +The header is structured as follows: + +- Byte 0 (bits 0-7): ``Variant::Type`` +- Byte 1 (bits 8-15): Unused +- Bytes 2-3 (bits 16-31): Additional data (type-specific flags) :: - base_type = val & 0xFFFF; - flags = val >> 16; - -+--------+--------------------------+ -| Type | Value | -+========+==========================+ -| 0 | null | -+--------+--------------------------+ -| 1 | bool | -+--------+--------------------------+ -| 2 | integer | -+--------+--------------------------+ -| 3 | float | -+--------+--------------------------+ -| 4 | string | -+--------+--------------------------+ -| 5 | vector2 | -+--------+--------------------------+ -| 6 | rect2 | -+--------+--------------------------+ -| 7 | vector3 | -+--------+--------------------------+ -| 8 | transform2d | -+--------+--------------------------+ -| 9 | plane | -+--------+--------------------------+ -| 10 | quaternion | -+--------+--------------------------+ -| 11 | aabb | -+--------+--------------------------+ -| 12 | basis | -+--------+--------------------------+ -| 13 | transform3d | -+--------+--------------------------+ -| 14 | color | -+--------+--------------------------+ -| 15 | node path | -+--------+--------------------------+ -| 16 | rid | -+--------+--------------------------+ -| 17 | object | -+--------+--------------------------+ -| 18 | dictionary | -+--------+--------------------------+ -| 19 | array | -+--------+--------------------------+ -| 20 | raw array | -+--------+--------------------------+ -| 21 | int32 array | -+--------+--------------------------+ -| 22 | int64 array | -+--------+--------------------------+ -| 23 | float32 array | -+--------+--------------------------+ -| 24 | float64 array | -+--------+--------------------------+ -| 25 | string array | -+--------+--------------------------+ -| 26 | vector2 array | -+--------+--------------------------+ -| 27 | vector3 array | -+--------+--------------------------+ -| 28 | color array | -+--------+--------------------------+ -| 29 | max | -+--------+--------------------------+ + type = header & 0xFF; + flags = header >> 16; + ++-------------+----------------------+ +| Value | Type Description | ++=============+======================+ +| 0 (0x00) | null | ++-------------+----------------------+ +| 1 (0x01) | bool | ++-------------+----------------------+ +| 2 (0x02) | int | ++-------------+----------------------+ +| 3 (0x03) | float | ++-------------+----------------------+ +| 4 (0x04) | String | ++-------------+----------------------+ +| 5 (0x05) | Vector2 | ++-------------+----------------------+ +| 6 (0x06) | Vector2i | ++-------------+----------------------+ +| 7 (0x07) | Rect2 | ++-------------+----------------------+ +| 8 (0x08) | Rect2i | ++-------------+----------------------+ +| 9 (0x09) | Vector3 | ++-------------+----------------------+ +| 10 (0x0A) | Vector3i | ++-------------+----------------------+ +| 11 (0x0B) | Vector4 | ++-------------+----------------------+ +| 12 (0x0C) | Vector4i | ++-------------+----------------------+ +| 13 (0x0D) | Transform2D | ++-------------+----------------------+ +| 14 (0x0E) | Plane | ++-------------+----------------------+ +| 15 (0x0F) | Quaternion | ++-------------+----------------------+ +| 16 (0x10) | AABB | ++-------------+----------------------+ +| 17 (0x11) | Basis | ++-------------+----------------------+ +| 18 (0x12) | Transform3D | ++-------------+----------------------+ +| 19 (0x13) | Projection | ++-------------+----------------------+ +| 20 (0x14) | Color | ++-------------+----------------------+ +| 21 (0x15) | StringName | ++-------------+----------------------+ +| 22 (0x16) | NodePath | ++-------------+----------------------+ +| 23 (0x17) | RID | ++-------------+----------------------+ +| 24 (0x18) | Object | ++-------------+----------------------+ +| 25 (0x19) | Callable | ++-------------+----------------------+ +| 26 (0x1A) | Signal | ++-------------+----------------------+ +| 27 (0x1B) | Dictionary | ++-------------+----------------------+ +| 28 (0x1C) | Array | ++-------------+----------------------+ +| 29 (0x1D) | PackedByteArray | ++-------------+----------------------+ +| 30 (0x1E) | PackedInt32Array | ++-------------+----------------------+ +| 31 (0x1F) | PackedInt64Array | ++-------------+----------------------+ +| 32 (0x20) | PackedFloat32Array | ++-------------+----------------------+ +| 33 (0x21) | PackedFloat64Array | ++-------------+----------------------+ +| 34 (0x22) | PackedStringArray | ++-------------+----------------------+ +| 35 (0x23) | PackedVector2Array | ++-------------+----------------------+ +| 36 (0x24) | PackedVector3Array | ++-------------+----------------------+ +| 37 (0x25) | PackedColorArray | ++-------------+----------------------+ +| 38 (0x26) | PackedVector4Array | ++-------------+----------------------+ + +Header Flags +~~~~~~~~~~~~ + +The header's upper 16 bits contain type-specific flags: + ++--------------------------------------------+---------------------------------------------+ +| Flag | Description | ++============================================+=============================================+ +| ``ENCODE_FLAG_64 = (1 << 16)`` | Used for int, float, and math types to | +| | indicate 64-bit (long/double) precision | ++--------------------------------------------+---------------------------------------------+ +| ``ENCODE_FLAG_OBJECT_AS_ID = (1 << 16)`` | Used for Object to indicate serialization | +| | as an instance ID only | ++--------------------------------------------+---------------------------------------------+ + +.. note:: + + For integers and floats used in any of these data types, if the ENCODE_FLAG_64 flag is set + then the value is serialized as a 64-bit integer or double-precision float respectively. + +For typed containers (Array and Dictionary), additional flags indicate the container's type information: + +**Array (bits 16-17):** + ++--------+----------------------------+ +| Value | Meaning | ++========+============================+ +| 0b00 | Untyped | ++--------+----------------------------+ +| 0b01 | Typed with built-in type | ++--------+----------------------------+ +| 0b10 | Typed with class name | ++--------+----------------------------+ +| 0b11 | Typed with script path | ++--------+----------------------------+ + +**Dictionary key type (bits 16-17) and value type (bits 18-19):** + +Same values as Array. Following this is the actual packet contents, which varies for each type of packet. Note that this assumes Godot is compiled with single-precision floats, @@ -112,498 +171,722 @@ length of "Float" fields within data structures should be 8, and the offset should be ``(offset - 4) * 2 + 4``. The "float" type itself always uses double precision. -0: null +.. _nil-section: + +0: NIL ~~~~~~~ +null + 1: :ref:`bool` ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+-----------+---------------------------+ -| Offset | Len | Type | Description | -+==========+=======+===========+===========================+ -| 4 | 4 | Integer | 0 for False, 1 for True | -+----------+-------+-----------+---------------------------+ ++----------+----------+-----------+---------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+===========================+ +| 4 | 4 | Integer | 0 for False, 1 for True | ++----------+----------+-----------+---------------------------+ 2: :ref:`int` ~~~~~~~~~~~~~~~~~~~~~~~~ -If no flags are set (flags == 0), the integer is sent as a 32 bit integer: - -+----------+-------+-----------+--------------------------+ -| Offset | Len | Type | Description | -+==========+=======+===========+==========================+ -| 4 | 4 | Integer | 32-bit signed integer | -+----------+-------+-----------+--------------------------+ ++----------+----------+-----------+-------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+=========================+ +| 4 | 4 | Integer | 32-bit signed integer | ++----------+----------+-----------+-------------------------+ -If flag ``ENCODE_FLAG_64`` is set (``flags & 1 == 1``), the integer is sent as -a 64-bit integer: - -+----------+-------+-----------+--------------------------+ -| Offset | Len | Type | Description | -+==========+=======+===========+==========================+ -| 4 | 8 | Integer | 64-bit signed integer | -+----------+-------+-----------+--------------------------+ 3: :ref:`float` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If no flags are set (flags == 0), the float is sent as a 32 bit single precision: - -+----------+-------+---------+-----------------------------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+===================================+ -| 4 | 4 | Float | IEEE 754 single-precision float | -+----------+-------+---------+-----------------------------------+ - -If flag ``ENCODE_FLAG_64`` is set (``flags & 1 == 1``), the float is sent as -a 64-bit double precision number: ++----------+----------+---------+-----------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+===================================+ +| 4 | 4 | Float | IEEE 754 single-precision float | ++----------+----------+---------+-----------------------------------+ -+----------+-------+---------+-----------------------------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+===================================+ -| 4 | 8 | Float | IEEE 754 double-precision float | -+----------+-------+---------+-----------------------------------+ +.. _string-section: 4: :ref:`String` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+-----------+----------------------------+ -| Offset | Len | Type | Description | -+==========+=======+===========+============================+ -| 4 | 4 | Integer | String length (in bytes) | -+----------+-------+-----------+----------------------------+ -| 8 | X | Bytes | UTF-8 encoded string | -+----------+-------+-----------+----------------------------+ - -This field is padded to 4 bytes. ++----------+----------+-----------+--------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+============================================+ +| 4 | 4 | Integer | String length (in bytes, N) | ++----------+----------+-----------+--------------------------------------------+ +| 8 | N | Bytes | UTF-8 encoded string (padded to 4 bytes) | ++----------+----------+-----------+--------------------------------------------+ 5: :ref:`Vector2` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+----------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+================+ -| 4 | 4 | Float | X coordinate | -+----------+-------+---------+----------------+ -| 8 | 4 | Float | Y coordinate | -+----------+-------+---------+----------------+ - -6: :ref:`Rect2` ++----------+----------+---------+----------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+================+ +| 4 | 4 | Float | X coordinate | ++----------+----------+---------+----------------+ +| 8 | 4 | Float | Y coordinate | ++----------+----------+---------+----------------+ + +6: :ref:`Vector2i` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ++----------+----------+-----------+----------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+================+ +| 4 | 4 | Integer | X coordinate | ++----------+----------+-----------+----------------+ +| 8 | 4 | Integer | Y coordinate | ++----------+----------+-----------+----------------+ + +7: :ref:`Rect2` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+----------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+================+ -| 4 | 4 | Float | X coordinate | -+----------+-------+---------+----------------+ -| 8 | 4 | Float | Y coordinate | -+----------+-------+---------+----------------+ -| 12 | 4 | Float | X size | -+----------+-------+---------+----------------+ -| 16 | 4 | Float | Y size | -+----------+-------+---------+----------------+ - -7: :ref:`Vector3` ++----------+----------+---------+---------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+===============+ +| 4 | 4 | Float | X position | ++----------+----------+---------+---------------+ +| 8 | 4 | Float | Y position | ++----------+----------+---------+---------------+ +| 12 | 4 | Float | X size | ++----------+----------+---------+---------------+ +| 16 | 4 | Float | Y size | ++----------+----------+---------+---------------+ + +8: :ref:`Rect2i` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ++----------+----------+-----------+---------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+===============+ +| 4 | 4 | Integer | X position | ++----------+----------+-----------+---------------+ +| 8 | 4 | Integer | Y position | ++----------+----------+-----------+---------------+ +| 12 | 4 | Integer | X size | ++----------+----------+-----------+---------------+ +| 16 | 4 | Integer | Y size | ++----------+----------+-----------+---------------+ + +9: :ref:`Vector3` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+----------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+================+ -| 4 | 4 | Float | X coordinate | -+----------+-------+---------+----------------+ -| 8 | 4 | Float | Y coordinate | -+----------+-------+---------+----------------+ -| 12 | 4 | Float | Z coordinate | -+----------+-------+---------+----------------+ - -8: :ref:`Transform2D` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -+----------+-------+---------+---------------------------------------------------------------+ -| 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` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++----------+----------+---------+----------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+================+ +| 4 | 4 | Float | X coordinate | ++----------+----------+---------+----------------+ +| 8 | 4 | Float | Y coordinate | ++----------+----------+---------+----------------+ +| 12 | 4 | Float | Z coordinate | ++----------+----------+---------+----------------+ + +10: :ref:`Vector3i` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ++----------+----------+-----------+----------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+================+ +| 4 | 4 | Integer | X coordinate | ++----------+----------+-----------+----------------+ +| 8 | 4 | Integer | Y coordinate | ++----------+----------+-----------+----------------+ +| 12 | 4 | Integer | Z coordinate | ++----------+----------+-----------+----------------+ + +11: :ref:`Vector4` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ++----------+----------+---------+----------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+================+ +| 4 | 4 | Float | X coordinate | ++----------+----------+---------+----------------+ +| 8 | 4 | Float | Y coordinate | ++----------+----------+---------+----------------+ +| 12 | 4 | Float | Z coordinate | ++----------+----------+---------+----------------+ +| 16 | 4 | Float | W coordinate | ++----------+----------+---------+----------------+ + +12: :ref:`Vector4i` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ++----------+----------+-----------+----------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+================+ +| 4 | 4 | Integer | X coordinate | ++----------+----------+-----------+----------------+ +| 8 | 4 | Integer | Y coordinate | ++----------+----------+-----------+----------------+ +| 12 | 4 | Integer | Z coordinate | ++----------+----------+-----------+----------------+ +| 16 | 4 | Integer | W coordinate | ++----------+----------+-----------+----------------+ + +13: :ref:`Transform2D` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ++----------+----------+---------+-----------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+=========================================+ +| 4 | 4 | Float | The X component of the X Vector2 | ++----------+----------+---------+-----------------------------------------+ +| 8 | 4 | Float | The Y component of the X Vector2 | ++----------+----------+---------+-----------------------------------------+ +| 12 | 4 | Float | The X component of the Y Vector2 | ++----------+----------+---------+-----------------------------------------+ +| 16 | 4 | Float | The Y component of the Y Vector2 | ++----------+----------+---------+-----------------------------------------+ +| 20 | 4 | Float | The X component of the Origin Vector2 | ++----------+----------+---------+-----------------------------------------+ +| 24 | 4 | Float | The Y component of the Origin Vector2 | ++----------+----------+---------+-----------------------------------------+ + +14: :ref:`Plane` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+---------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+===============+ -| 4 | 4 | Float | Normal X | -+----------+-------+---------+---------------+ -| 8 | 4 | Float | Normal Y | -+----------+-------+---------+---------------+ -| 12 | 4 | Float | Normal Z | -+----------+-------+---------+---------------+ -| 16 | 4 | Float | Distance | -+----------+-------+---------+---------------+ - -10: :ref:`Quaternion` ++----------+----------+---------+---------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+===============+ +| 4 | 4 | Float | Normal X | ++----------+----------+---------+---------------+ +| 8 | 4 | Float | Normal Y | ++----------+----------+---------+---------------+ +| 12 | 4 | Float | Normal Z | ++----------+----------+---------+---------------+ +| 16 | 4 | Float | Distance D | ++----------+----------+---------+---------------+ + +15: :ref:`Quaternion` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+---------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+===============+ -| 4 | 4 | Float | Imaginary X | -+----------+-------+---------+---------------+ -| 8 | 4 | Float | Imaginary Y | -+----------+-------+---------+---------------+ -| 12 | 4 | Float | Imaginary Z | -+----------+-------+---------+---------------+ -| 16 | 4 | Float | Real W | -+----------+-------+---------+---------------+ - -11: :ref:`AABB` ++----------+----------+---------+---------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+===============+ +| 4 | 4 | Float | Imaginary X | ++----------+----------+---------+---------------+ +| 8 | 4 | Float | Imaginary Y | ++----------+----------+---------+---------------+ +| 12 | 4 | Float | Imaginary Z | ++----------+----------+---------+---------------+ +| 16 | 4 | Float | Real W | ++----------+----------+---------+---------------+ + +16: :ref:`AABB` ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+----------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+================+ -| 4 | 4 | Float | X coordinate | -+----------+-------+---------+----------------+ -| 8 | 4 | Float | Y coordinate | -+----------+-------+---------+----------------+ -| 12 | 4 | Float | Z coordinate | -+----------+-------+---------+----------------+ -| 16 | 4 | Float | X size | -+----------+-------+---------+----------------+ -| 20 | 4 | Float | Y size | -+----------+-------+---------+----------------+ -| 24 | 4 | Float | Z size | -+----------+-------+---------+----------------+ - -12: :ref:`Basis` ++----------+----------+---------+---------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+===============+ +| 4 | 4 | Float | X position | ++----------+----------+---------+---------------+ +| 8 | 4 | Float | Y position | ++----------+----------+---------+---------------+ +| 12 | 4 | Float | Z position | ++----------+----------+---------+---------------+ +| 16 | 4 | Float | X size | ++----------+----------+---------+---------------+ +| 20 | 4 | Float | Y size | ++----------+----------+---------+---------------+ +| 24 | 4 | Float | Z size | ++----------+----------+---------+---------------+ + +17: :ref:`Basis` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+---------------------------------------------------------------+ -| 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:`Transform3D` ++----------+----------+---------+---------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+===============+ +| 4 | 4 | Float | x.x | ++----------+----------+---------+---------------+ +| 8 | 4 | Float | x.y | ++----------+----------+---------+---------------+ +| 12 | 4 | Float | x.z | ++----------+----------+---------+---------------+ +| 16 | 4 | Float | y.x | ++----------+----------+---------+---------------+ +| 20 | 4 | Float | y.y | ++----------+----------+---------+---------------+ +| 24 | 4 | Float | y.z | ++----------+----------+---------+---------------+ +| 28 | 4 | Float | z.x | ++----------+----------+---------+---------------+ +| 32 | 4 | Float | z.y | ++----------+----------+---------+---------------+ +| 36 | 4 | Float | z.z | ++----------+----------+---------+---------------+ + +18: :ref:`Transform3D` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+---------------------------------------------------------------+ -| 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` ++----------+----------+---------+---------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+===============+ +| 4 | 4 | Float | basis.x.x | ++----------+----------+---------+---------------+ +| 8 | 4 | Float | basis.x.y | ++----------+----------+---------+---------------+ +| 12 | 4 | Float | basis.x.z | ++----------+----------+---------+---------------+ +| 16 | 4 | Float | basis.y.x | ++----------+----------+---------+---------------+ +| 20 | 4 | Float | basis.y.y | ++----------+----------+---------+---------------+ +| 24 | 4 | Float | basis.y.z | ++----------+----------+---------+---------------+ +| 28 | 4 | Float | basis.z.x | ++----------+----------+---------+---------------+ +| 32 | 4 | Float | basis.z.y | ++----------+----------+---------+---------------+ +| 36 | 4 | Float | basis.z.z | ++----------+----------+---------+---------------+ +| 40 | 4 | Float | origin.x | ++----------+----------+---------+---------------+ +| 44 | 4 | Float | origin.y | ++----------+----------+---------+---------------+ +| 48 | 4 | Float | origin.z | ++----------+----------+---------+---------------+ + +19: :ref:`Projection` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ++----------+----------+---------+-------------------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+=========================+ +| 4 | 4 | Float | x.x (Column 0, Row 0) | ++----------+----------+---------+-------------------------+ +| 8 | 4 | Float | x.y (Column 0, Row 1) | ++----------+----------+---------+-------------------------+ +| 12 | 4 | Float | x.z (Column 0, Row 2) | ++----------+----------+---------+-------------------------+ +| 16 | 4 | Float | x.w (Column 0, Row 3) | ++----------+----------+---------+-------------------------+ +| 20 | 4 | Float | y.x (Column 1, Row 0) | ++----------+----------+---------+-------------------------+ +| 24 | 4 | Float | y.y (Column 1, Row 1) | ++----------+----------+---------+-------------------------+ +| 28 | 4 | Float | y.z (Column 1, Row 2) | ++----------+----------+---------+-------------------------+ +| 32 | 4 | Float | y.w (Column 1, Row 3) | ++----------+----------+---------+-------------------------+ +| 36 | 4 | Float | z.x (Column 2, Row 0) | ++----------+----------+---------+-------------------------+ +| 40 | 4 | Float | z.y (Column 2, Row 1) | ++----------+----------+---------+-------------------------+ +| 44 | 4 | Float | z.z (Column 2, Row 2) | ++----------+----------+---------+-------------------------+ +| 48 | 4 | Float | z.w (Column 2, Row 3) | ++----------+----------+---------+-------------------------+ +| 52 | 4 | Float | w.x (Column 3, Row 0) | ++----------+----------+---------+-------------------------+ +| 56 | 4 | Float | w.y (Column 3, Row 1) | ++----------+----------+---------+-------------------------+ +| 60 | 4 | Float | w.z (Column 3, Row 2) | ++----------+----------+---------+-------------------------+ +| 64 | 4 | Float | w.w (Column 3, Row 3) | ++----------+----------+---------+-------------------------+ + +20: :ref:`Color` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+--------------------------------------------------------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+==============================================================+ -| 4 | 4 | Float | Red (typically 0..1, can be above 1 for overbright colors) | -+----------+-------+---------+--------------------------------------------------------------+ -| 8 | 4 | Float | Green (typically 0..1, can be above 1 for overbright colors) | -+----------+-------+---------+--------------------------------------------------------------+ -| 12 | 4 | Float | Blue (typically 0..1, can be above 1 for overbright colors) | -+----------+-------+---------+--------------------------------------------------------------+ -| 16 | 4 | Float | Alpha (0..1) | -+----------+-------+---------+--------------------------------------------------------------+ - -15: :ref:`NodePath` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++----------+----------+---------+----------------------------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+=========+================================================================+ +| 4 | 4 | Float | Red (typically 0..1, can be above 1 for overbright colors) | ++----------+----------+---------+----------------------------------------------------------------+ +| 8 | 4 | Float | Green (typically 0..1, can be above 1 for overbright colors) | ++----------+----------+---------+----------------------------------------------------------------+ +| 12 | 4 | Float | Blue (typically 0..1, can be above 1 for overbright colors) | ++----------+----------+---------+----------------------------------------------------------------+ +| 16 | 4 | Float | Alpha (0..1) | ++----------+----------+---------+----------------------------------------------------------------+ + +21: :ref:`StringName` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+-----------+-----------------------------------------------------------------------------------------+ -| Offset | Len | Type | Description | -+==========+=======+===========+=========================================================================================+ -| 4 | 4 | Integer | String length, or new format (val&0x80000000!=0 and NameCount=val&0x7FFFFFFF) | -+----------+-------+-----------+-----------------------------------------------------------------------------------------+ +Serialized identically to :ref:`String `. -For old format: -~~~~~~~~~~~~~~~ +22: :ref:`NodePath` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+---------+------------------------+ -| Offset | Len | Type | Description | -+==========+=======+=========+========================+ -| 8 | X | Bytes | UTF-8 encoded string | -+----------+-------+---------+------------------------+ ++----------+----------+-----------+-----------------------------------------------------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+=========================================================================================+ +| 4 | 4 | Integer | Name count with new format flag (val & 0x80000000 != 0, NameCount = val & 0x7FFFFFFF) | ++----------+----------+-----------+-----------------------------------------------------------------------------------------+ -Padded to 4 bytes. +The old format is no longer supported and will return an error. For new format: ~~~~~~~~~~~~~~~ -+----------+-------+-----------+-------------------------------------+ -| Offset | Len | Type | Description | -+==========+=======+===========+=====================================+ -| 4 | 4 | Integer | Sub-name count | -+----------+-------+-----------+-------------------------------------+ -| 8 | 4 | Integer | Flags (absolute: val&1 != 0 ) | -+----------+-------+-----------+-------------------------------------+ ++----------+----------+-----------+--------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+============================================+ +| 8 | 4 | Integer | Sub-name count | ++----------+----------+-----------+--------------------------------------------+ +| 12 | 4 | Integer | Flags (bit 0: absolute, bit 1: property) | ++----------+----------+-----------+--------------------------------------------+ -For each Name and Sub-Name +.. note:: -+----------+-------+-----------+------------------------+ -| Offset | Len | Type | Description | -+==========+=======+===========+========================+ -| X+0 | 4 | Integer | String length | -+----------+-------+-----------+------------------------+ -| X+4 | X | Bytes | UTF-8 encoded string | -+----------+-------+-----------+------------------------+ + If bit 1 (property flag) is set, the sub-name count is incremented by 1 + internally. This is an obsolete format for backwards compatibility. -Every name string is padded to 4 bytes. +For each Name and Sub-Name (offsets are relative to the start of each string entry): -16: :ref:`RID` (unsupported) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++----------+----------+-----------+-----------------------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+===========================================================+ +| 0 | 4 | Integer | Name/Sub-Name (String length, in bytes, N) | ++----------+----------+-----------+-----------------------------------------------------------+ +| 4 | N | Bytes | Name/Sub-Name (UTF-8 encoded string, padded to 4 bytes) | ++----------+----------+-----------+-----------------------------------------------------------+ + +23: :ref:`RID` +~~~~~~~~~~~~~~~~~~~~~~~~~ -17: :ref:`Object` ++----------+----------+-----------+-----------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+=================+ +| 4 | 8 | Integer | 64-bit RID ID | ++----------+----------+-----------+-----------------+ + +24: :ref:`Object` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -An Object could be serialized in three different ways: as a null value, with -``full_objects = false``, or with ``full_objects = true``. - -A null value -^^^^^^^^^^^^ - -+----------+-------+------------+-------------------------------------------------+ -| Offset | Len | Type | Description | -+==========+=======+============+=================================================+ -| 4 | 4 | Integer | Zero (32-bit signed integer) | -+----------+-------+------------+-------------------------------------------------+ - -``full_objects`` disabled -^^^^^^^^^^^^^^^^^^^^^^^^^ - -+----------+-------+------------+-------------------------------------------------+ -| Offset | Len | Type | Description | -+==========+=======+============+=================================================+ -| 4 | 8 | Integer | The Object instance ID (64-bit signed integer) | -+----------+-------+------------+-------------------------------------------------+ - -``full_objects`` enabled -^^^^^^^^^^^^^^^^^^^^^^^^ - -+----------+-------+----------------+----------------------------------------------------------+ -| Offset | Len | Type | Description | -+==========+=======+================+==========================================================+ -| 4 | 4 | Integer | Class name (String length) | -+----------+-------+----------------+----------------------------------------------------------+ -| 8 | X | Bytes | Class name (UTF-8 encoded string) | -+----------+-------+----------------+----------------------------------------------------------+ -| X+8 | 4 | Integer | The number of properties that are serialized | -+----------+-------+----------------+----------------------------------------------------------+ - -For each property: - -+----------+-------+----------------+----------------------------------------------------------+ -| Offset | Len | Type | Description | -+==========+=======+================+==========================================================+ -| Y | 4 | Integer | Property name (String length) | -+----------+-------+----------------+----------------------------------------------------------+ -| Y+4 | Z | Bytes | Property name (UTF-8 encoded string) | -+----------+-------+----------------+----------------------------------------------------------+ -| Y+4+Z | W | | Property value, using this same format | -+----------+-------+----------------+----------------------------------------------------------+ - -.. Note:: +An Object can be serialized in two ways, determined by the ``ENCODE_FLAG_OBJECT_AS_ID`` header flag (``flags & 1 == 1``). + +With ``ENCODE_FLAG_OBJECT_AS_ID`` set (Instance ID only) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ++----------+----------+-----------+-----------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+===================================+ +| 4 | 8 | Integer | The Object instance ID (64-bit) | ++----------+----------+-----------+-----------------------------------+ + +If the instance ID is 0, it represents a null object. + +Without ``ENCODE_FLAG_OBJECT_AS_ID`` (full object) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This mode requires ``full_objects = true`` when decoding, otherwise an error +is returned. + +**Null object:** + ++----------+----------+-----------+------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+==============================+ +| 4 | 4 | Integer | 0 (Representing a nullptr) | ++----------+----------+-----------+------------------------------+ + +**Non-null object:** + +Header: ++----------+----------+-----------+--------------------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+========================================================+ +| 4 | 4 | Integer | Class name (String length, in bytes, N) | ++----------+----------+-----------+--------------------------------------------------------+ +| 8 | N | Bytes | Class name (UTF-8 encoded string, padded to 4 bytes) | ++----------+----------+-----------+--------------------------------------------------------+ +| 8+N | 4 | Integer | The number of properties that are serialized (P) | ++----------+----------+-----------+--------------------------------------------------------+ + +Following this header is a contiguous block of key-value property entries, defined below, +where the offset is relative to the start of each property entry: + ++----------+--------------+--------------+-----------------------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==============+==============+===========================================================+ +| 0 | 4 | Integer | Property name (String length, in bytes, N) | ++----------+--------------+--------------+-----------------------------------------------------------+ +| 4 | N | Bytes | Property name (UTF-8 encoded string, padded to 4 bytes) | ++----------+--------------+--------------+-----------------------------------------------------------+ +| 4+N | | | Property value, using this same format | ++----------+--------------+--------------+-----------------------------------------------------------+ + +.. note:: Not all properties are included. Only properties that are configured with the :ref:`PROPERTY_USAGE_STORAGE` flag set will be serialized. You can add a new usage flag to a property by overriding the :ref:`_get_property_list` method in your class. You can also check how property usage is configured by - calling ``Object._get_property_list`` See + calling ``Object._get_property_list``. See :ref:`PropertyUsageFlags` for the possible usage flags. -18: :ref:`Dictionary` +.. note:: + + If a property named ``script`` is present and its value is a String, it is + treated specially: the string is interpreted as a resource path to a Script, + which is loaded and assigned to the object. + +25: :ref:`Callable` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Callables cannot be meaningfully serialized. No additional data is written, +and decoding produces an empty Callable. + +26: :ref:`Signal` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ++----------+----------+-----------+---------------------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+=========================================================+ +| 4 | 4 | Integer | Signal name (String length, in bytes, N) | ++----------+----------+-----------+---------------------------------------------------------+ +| 8 | N | Bytes | Signal name (UTF-8 encoded string, padded to 4 bytes) | ++----------+----------+-----------+---------------------------------------------------------+ +| 8+N | 8 | Integer | Object instance ID (64-bit) | ++----------+----------+-----------+---------------------------------------------------------+ + +27: :ref:`Dictionary` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+-----------+---------------------------------------------------------------------+ -| Offset | Len | Type | Description | -+==========+=======+===========+=====================================================================+ -| 4 | 4 | Integer | val&0x7FFFFFFF = elements, val&0x80000000 = shared (bool) | -+----------+-------+-----------+---------------------------------------------------------------------+ +For typed dictionaries, the header flags indicate the variant type for both keys +and values (see Header Flags section). Depending on these flags, type +information is encoded before the element count. + +**Container Type Encoding (for each of key type and value type, if not NONE):** -Then what follows is, for amount of "elements", pairs of key and value, -one after the other, using this same format. +If type kind is ``BUILTIN`` (0b01): -19: :ref:`Array` ++----------+----------+-----------+-------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+===================+ +| 4 | 4 | Integer | Variant type ID | ++----------+----------+-----------+-------------------+ + +If type kind is ``CLASS_NAME`` (0b10) or ``SCRIPT`` (0b11): + ++----------+----------+-----------+--------------------------------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+====================================================================+ +| 4 | 4 | Integer | Class name/Script path (String length, in bytes, N) | ++----------+----------+-----------+--------------------------------------------------------------------+ +| 8 | N | Bytes | Class name/Script path (UTF-8 encoded string, padded to 4 bytes) | ++----------+----------+-----------+--------------------------------------------------------------------+ + +Value type encoding, if applicable, immediately follows key type encoding. + +**Element count (immediately following all type information):** + ++----------+----------+-----------+----------------------------------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+======================================================================+ +| 0 | 4 | Integer | val & 0x7FFFFFFF = element count, val & 0x80000000 = shared (bool) | ++----------+----------+-----------+----------------------------------------------------------------------+ + +Following this header is a contiguous block of key-value pairs, +encoded using the same serialization format defined in this document. + +28: :ref:`Array` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+-----------+---------------------------------------------------------------------+ -| Offset | Len | Type | Description | -+==========+=======+===========+=====================================================================+ -| 4 | 4 | Integer | val&0x7FFFFFFF = elements, val&0x80000000 = shared (bool) | -+----------+-------+-----------+---------------------------------------------------------------------+ +For typed arrays, the header flags indicate the element type kind (see Header +Flags section). The container type is encoded the same way as Dictionary. + +**Element count (immediately following type information, if any):** -Then what follows is, for amount of "elements", values one after the -other, using this same format. ++----------+----------+-----------+----------------------------------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+======================================================================+ +| 0 | 4 | Integer | val & 0x7FFFFFFF = element count, val & 0x80000000 = shared (bool) | ++----------+----------+-----------+----------------------------------------------------------------------+ -20: :ref:`PackedByteArray` +Following the element count is a contiguous block of values, +encoded using the same serialization format defined in this document. + +29: :ref:`PackedByteArray` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+---------------+-------+-----------+------------------------+ -| Offset | Len | Type | Description | -+===============+=======+===========+========================+ -| 4 | 4 | Integer | Array length (Bytes) | -+---------------+-------+-----------+------------------------+ -| 8..8+length | 1 | Byte | Byte (0..255) | -+---------------+-------+-----------+------------------------+ ++----------+----------+-----------+---------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+=================================+ +| 4 | 4 | Integer | Array length (L) | ++----------+----------+-----------+---------------------------------+ +| 8 + i | 1 | Byte | Array element #i (0 <= i < L) | ++----------+----------+-----------+---------------------------------+ The array data is padded to 4 bytes. -21: :ref:`PackedInt32Array` +30: :ref:`PackedInt32Array` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+------------------+-------+-----------+---------------------------+ -| Offset | Len | Type | Description | -+==================+=======+===========+===========================+ -| 4 | 4 | Integer | Array length (Integers) | -+------------------+-------+-----------+---------------------------+ -| 8..8+length\*4 | 4 | Integer | 32-bit signed integer | -+------------------+-------+-----------+---------------------------+ ++--------------+----------+-----------+---------------------------------+ +| Offset | Length | Type | Description | ++==============+==========+===========+=================================+ +| 4 | 4 | Integer | Array length (L) | ++--------------+----------+-----------+---------------------------------+ +| 8 + i \* 4 | 4 | Integer | Array element #i (0 <= i < L) | ++--------------+----------+-----------+---------------------------------+ -22: :ref:`PackedInt64Array` +31: :ref:`PackedInt64Array` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+------------------+-------+-----------+---------------------------+ -| Offset | Len | Type | Description | -+==================+=======+===========+===========================+ -| 4 | 8 | Integer | Array length (Integers) | -+------------------+-------+-----------+---------------------------+ -| 8..8+length\*8 | 8 | Integer | 64-bit signed integer | -+------------------+-------+-----------+---------------------------+ ++--------------+----------+-----------+---------------------------------+ +| Offset | Length | Type | Description | ++==============+==========+===========+=================================+ +| 4 | 4 | Integer | Array length (L) | ++--------------+----------+-----------+---------------------------------+ +| 8 + i \* 8 | 8 | Integer | Array element #i (0 <= i < L) | ++--------------+----------+-----------+---------------------------------+ -23: :ref:`PackedFloat32Array` +32: :ref:`PackedFloat32Array` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+------------------+-------+-----------+-------------------------------------------+ -| Offset | Len | Type | Description | -+==================+=======+===========+===========================================+ -| 4 | 4 | Integer | Array length (Floats) | -+------------------+-------+-----------+-------------------------------------------+ -| 8..8+length\*4 | 4 | Integer | 32-bit IEEE 754 single-precision float | -+------------------+-------+-----------+-------------------------------------------+ ++--------------+----------+-----------+---------------------------------+ +| Offset | Length | Type | Description | ++==============+==========+===========+=================================+ +| 4 | 4 | Integer | Array length (L) | ++--------------+----------+-----------+---------------------------------+ +| 8 + i \* 4 | 4 | Float | Array element #i (0 <= i < L) | ++--------------+----------+-----------+---------------------------------+ -24: :ref:`PackedFloat64Array` +33: :ref:`PackedFloat64Array` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+------------------+-------+-----------+-------------------------------------------+ -| Offset | Len | Type | Description | -+==================+=======+===========+===========================================+ -| 4 | 4 | Integer | Array length (Floats) | -+------------------+-------+-----------+-------------------------------------------+ -| 8..8+length\*8 | 8 | Integer | 64-bit IEEE 754 double-precision float | -+------------------+-------+-----------+-------------------------------------------+ ++--------------+----------+-----------+---------------------------------+ +| Offset | Length | Type | Description | ++==============+==========+===========+=================================+ +| 4 | 4 | Integer | Array length (L) | ++--------------+----------+-----------+---------------------------------+ +| 8 + i \* 8 | 8 | Float | Array element #i (0 <= i < L) | ++--------------+----------+-----------+---------------------------------+ -25: :ref:`PackedStringArray` +34: :ref:`PackedStringArray` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+----------+-------+-----------+--------------------------+ -| Offset | Len | Type | Description | -+==========+=======+===========+==========================+ -| 4 | 4 | Integer | Array length (Strings) | -+----------+-------+-----------+--------------------------+ ++----------+----------+-----------+--------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+==========================+ +| 4 | 4 | Integer | Array length (Strings) | ++----------+----------+-----------+--------------------------+ + +Following the array length is a contiguous block of strings. -For each String: +For each string entry (0 <= i < length): -+----------+-------+-----------+------------------------+ -| Offset | Len | Type | Description | -+==========+=======+===========+========================+ -| X+0 | 4 | Integer | String length | -+----------+-------+-----------+------------------------+ -| X+4 | X | Bytes | UTF-8 encoded string | -+----------+-------+-----------+------------------------+ +.. note:: + Offsets below are relative to the start of each string entry. + ++----------+----------+-----------+----------------------------------------------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+====================================================+ +| 0 | 4 | Integer | String length (N, including the null terminator) | ++----------+----------+-----------+----------------------------------------------------+ +| 4 | N | Bytes | UTF-8 encoded string with a null terminator | ++----------+----------+-----------+----------------------------------------------------+ Every string is padded to 4 bytes. -26: :ref:`PackedVector2Array` +.. note:: + + Unlike regular String encoding, PackedStringArray encodes strings with a + null terminator included in the length. + +35: :ref:`PackedVector2Array` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+-------------------+-------+-----------+----------------+ -| Offset | Len | Type | Description | -+===================+=======+===========+================+ -| 4 | 4 | Integer | Array length | -+-------------------+-------+-----------+----------------+ -| 8..8+length\*8 | 4 | Float | X coordinate | -+-------------------+-------+-----------+----------------+ -| 8..12+length\*8 | 4 | Float | Y coordinate | -+-------------------+-------+-----------+----------------+ - -27: :ref:`PackedVector3Array` ++----------+----------+-----------+----------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+================+ +| 4 | 4 | Integer | Array length | ++----------+----------+-----------+----------------+ + +Following the array length is a contiguous block of Vector2's. + +For each Vector2 entry (0 <= i < length): + ++---------------+----------+---------+----------------+ +| Offset | Length | Type | Description | ++===============+==========+=========+================+ +| 8 + i \* 8 | 4 | Float | X coordinate | ++---------------+----------+---------+----------------+ +| 12 + i \* 8 | 4 | Float | Y coordinate | ++---------------+----------+---------+----------------+ + +36: :ref:`PackedVector3Array` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+--------------------+-------+-----------+----------------+ -| Offset | Len | Type | Description | -+====================+=======+===========+================+ -| 4 | 4 | Integer | Array length | -+--------------------+-------+-----------+----------------+ -| 8..8+length\*12 | 4 | Float | X coordinate | -+--------------------+-------+-----------+----------------+ -| 8..12+length\*12 | 4 | Float | Y coordinate | -+--------------------+-------+-----------+----------------+ -| 8..16+length\*12 | 4 | Float | Z coordinate | -+--------------------+-------+-----------+----------------+ - -28: :ref:`PackedColorArray` ++----------+----------+-----------+----------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+================+ +| 4 | 4 | Integer | Array length | ++----------+----------+-----------+----------------+ + +Following the array length is a contiguous block of Vector3's. + +For each Vector3 entry (0 <= i < length): + ++----------------+----------+---------+----------------+ +| Offset | Length | Type | Description | ++================+==========+=========+================+ +| 8 + i \* 12 | 4 | Float | X coordinate | ++----------------+----------+---------+----------------+ +| 12 + i \* 12 | 4 | Float | Y coordinate | ++----------------+----------+---------+----------------+ +| 16 + i \* 12 | 4 | Float | Z coordinate | ++----------------+----------+---------+----------------+ + +37: :ref:`PackedColorArray` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+--------------------+-------+-----------+--------------------------------------------------------------+ -| Offset | Len | Type | Description | -+====================+=======+===========+==============================================================+ -| 4 | 4 | Integer | Array length | -+--------------------+-------+-----------+--------------------------------------------------------------+ -| 8..8+length\*16 | 4 | Float | Red (typically 0..1, can be above 1 for overbright colors) | -+--------------------+-------+-----------+--------------------------------------------------------------+ -| 8..12+length\*16 | 4 | Float | Green (typically 0..1, can be above 1 for overbright colors) | -+--------------------+-------+-----------+--------------------------------------------------------------+ -| 8..16+length\*16 | 4 | Float | Blue (typically 0..1, can be above 1 for overbright colors) | -+--------------------+-------+-----------+--------------------------------------------------------------+ -| 8..20+length\*16 | 4 | Float | Alpha (0..1) | -+--------------------+-------+-----------+--------------------------------------------------------------+ ++----------+----------+-----------+----------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+================+ +| 4 | 4 | Integer | Array length | ++----------+----------+-----------+----------------+ + +Following the array length is a contiguous block of Colors. + +For each Color entry (0 <= i < length): + ++----------------+----------+---------+----------------------------------------------------------------+ +| Offset | Length | Type | Description | ++================+==========+=========+================================================================+ +| 8 + i \* 16 | 4 | Float | Red (typically 0..1, can be above 1 for overbright colors) | ++----------------+----------+---------+----------------------------------------------------------------+ +| 12 + i \* 16 | 4 | Float | Green (typically 0..1, can be above 1 for overbright colors) | ++----------------+----------+---------+----------------------------------------------------------------+ +| 16 + i \* 16 | 4 | Float | Blue (typically 0..1, can be above 1 for overbright colors) | ++----------------+----------+---------+----------------------------------------------------------------+ +| 20 + i \* 16 | 4 | Float | Alpha (0..1) | ++----------------+----------+---------+----------------------------------------------------------------+ + +.. note:: + + Colors are always encoded in single precision. + +38: :ref:`PackedVector4Array` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ++----------+----------+-----------+----------------+ +| Offset | Length | Type | Description | ++==========+==========+===========+================+ +| 4 | 4 | Integer | Array length | ++----------+----------+-----------+----------------+ + +Following the array length is a contiguous block of Vector4's. + +For each Vector4 entry (0 <= i < length): + ++----------------+----------+---------+----------------+ +| Offset | Length | Type | Description | ++================+==========+=========+================+ +| 8 + i \* 16 | 4 | Float | X coordinate | ++----------------+----------+---------+----------------+ +| 12 + i \* 16 | 4 | Float | Y coordinate | ++----------------+----------+---------+----------------+ +| 16 + i \* 16 | 4 | Float | Z coordinate | ++----------------+----------+---------+----------------+ +| 20 + i \* 16 | 4 | Float | W coordinate | ++----------------+----------+---------+----------------+