Prechádzať zdrojové kódy

Merge pull request #3281 from aaronfranke/binary-serialization

Update Transform and Basis value descriptions for binary serialization
Aaron Franke 5 rokov pred
rodič
commit
48615ece9e
1 zmenil súbory, kde vykonal 88 pridanie a 85 odobranie
  1. 88 85
      tutorials/misc/binary_serialization_api.rst

+ 88 - 85
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<class_float>`/real
+3: :ref:`float<class_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<class_string>`
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -171,21 +174,21 @@ This field is padded to 4 bytes.
 8: :ref:`Transform2D<class_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<class_plane>`
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -239,58 +242,58 @@ This field is padded to 4 bytes.
 12: :ref:`Basis<class_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<class_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<class_color>`
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -418,24 +421,24 @@ The array data is padded to 4 bytes.
 23: :ref:`PackedFloat32Array<class_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<class_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<class_PackedStringArray>`
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~