diff --git a/_extensions/gdscript.py b/_extensions/gdscript.py index f00728e32..77aefc17c 100644 --- a/_extensions/gdscript.py +++ b/_extensions/gdscript.py @@ -282,13 +282,15 @@ class GDScriptLexer(RegexLexer): "NodePath", "Dictionary", "Array", - "PoolByteArray", - "PoolIntArray", - "PoolRealArray", - "PoolStringArray", - "PoolVector2Array", - "PoolVector3Array", - "PoolColorArray", + "PackedByteArray", + "PackedInt32Array", + "PackedInt64Array", + "PackedFloat32Array", + "PackedFloat64Array", + "PackedStringArray", + "PackedVector2Array", + "PackedVector3Array", + "PackedColorArray", "null", ), prefix=r"(?`` is a type-safe wrapper around ``Godot.Collections.Array``. Use the ``Godot.Collections.Array(Godot.Collections.Array)`` constructor to create one. diff --git a/getting_started/scripting/gdscript/gdscript_basics.rst b/getting_started/scripting/gdscript/gdscript_basics.rst index 58507c3cb..cf95215a2 100644 --- a/getting_started/scripting/gdscript/gdscript_basics.rst +++ b/getting_started/scripting/gdscript/gdscript_basics.rst @@ -339,7 +339,7 @@ Built-in types Built-in types are stack-allocated. They are passed as values. This means a copy is created on each assignment or when passing them as arguments to functions. The only exceptions are ``Array``\ s and ``Dictionaries``, which are passed by -reference so they are shared. (Pooled arrays such as ``PoolByteArray`` are still +reference so they are shared. (Pooled arrays such as ``PackedByteArray`` are still passed as values.) Basic built-in types @@ -370,7 +370,7 @@ It is stored as a 64-bit value, equivalent to "int64_t" in C++. Stores real numbers, including decimals, using floating-point values. It is stored as a 64-bit value, equivalent to "double" in C++. Note: Currently, data structures such as Vector2, Vector3, and -PoolRealArray store 32-bit single-precision "float" values. +PackedFloat32Array store 32-bit single-precision "float" values. :ref:`String ` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -490,13 +490,15 @@ arrays are available. These only accept a single data type. They avoid memory fragmentation and use less memory, but are atomic and tend to run slower than generic arrays. They are therefore only recommended to use for large data sets: -- :ref:`PoolByteArray `: An array of bytes (integers from 0 to 255). -- :ref:`PoolIntArray `: An array of integers. -- :ref:`PoolRealArray `: An array of floats. -- :ref:`PoolStringArray `: An array of strings. -- :ref:`PoolVector2Array `: An array of :ref:`Vector2 ` objects. -- :ref:`PoolVector3Array `: An array of :ref:`Vector3 ` objects. -- :ref:`PoolColorArray `: An array of :ref:`Color ` objects. +- :ref:`PackedByteArray `: An array of bytes (integers from 0 to 255). +- :ref:`PackedInt32Array `: An array of 32-bit integers. +- :ref:`PackedInt64Array `: An array of 64-bit integers. +- :ref:`PackedFloat32Array `: An array of 32-bit floats. +- :ref:`PackedFloat64Array `: An array of 64-bit floats. +- :ref:`PackedStringArray `: An array of strings. +- :ref:`PackedVector2Array `: An array of :ref:`Vector2 ` objects. +- :ref:`PackedVector3Array `: An array of :ref:`Vector3 ` objects. +- :ref:`PackedColorArray `: An array of :ref:`Color ` objects. :ref:`Dictionary ` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/getting_started/scripting/gdscript/gdscript_exports.rst b/getting_started/scripting/gdscript/gdscript_exports.rst index e3c597243..97bb51def 100644 --- a/getting_started/scripting/gdscript/gdscript_exports.rst +++ b/getting_started/scripting/gdscript/gdscript_exports.rst @@ -173,8 +173,8 @@ initializers, but they must be constant expressions. # Typed arrays also work, only initialized empty: - export var vector3s = PoolVector3Array() - export var strings = PoolStringArray() + export var vector3s = PackedVector3Array() + export var strings = PackedStringArray() # Regular array, created local for every instance. # Default value can include run-time values, but can't diff --git a/getting_started/workflow/best_practices/data_preferences.rst b/getting_started/workflow/best_practices/data_preferences.rst index 6675db813..fc956c3a5 100644 --- a/getting_started/workflow/best_practices/data_preferences.rst +++ b/getting_started/workflow/best_practices/data_preferences.rst @@ -54,7 +54,7 @@ to each other. array object in traditional C++ libraries. It is a "templated" type, meaning that its records can only contain a particular type (denoted by angled brackets). So, for example, a - :ref:`PoolStringArray ` would be something like + :ref:`PackedStringArray ` would be something like a ``Vector``. Contiguous memory stores imply the following operation performance: diff --git a/getting_started/workflow/export/exporting_for_web.rst b/getting_started/workflow/export/exporting_for_web.rst index 117cfa72d..64cd17dbe 100644 --- a/getting_started/workflow/export/exporting_for_web.rst +++ b/getting_started/workflow/export/exporting_for_web.rst @@ -193,7 +193,7 @@ returned by ``eval()`` under certain circumstances: * JavaScript ``boolean`` is returned as GDScript :ref:`class_bool` * JavaScript ``string`` is returned as GDScript :ref:`class_String` * JavaScript ``ArrayBuffer``, ``TypedArray`` and ``DataView`` are returned as - GDScript :ref:`class_PoolByteArray` + GDScript :ref:`PackedByteArray` :: diff --git a/tutorials/2d/custom_drawing_in_2d.rst b/tutorials/2d/custom_drawing_in_2d.rst index e934e3911..eadbd4dbf 100644 --- a/tutorials/2d/custom_drawing_in_2d.rst +++ b/tutorials/2d/custom_drawing_in_2d.rst @@ -171,7 +171,7 @@ In our example, we will simply use a fixed number of points, no matter the radiu func draw_circle_arc(center, radius, angle_from, angle_to, color): var nb_points = 32 - var points_arc = PoolVector2Array() + var points_arc = PackedVector2Array() for i in range(nb_points + 1): var angle_point = deg2rad(angle_from + i * (angle_to-angle_from) / nb_points - 90) @@ -200,7 +200,7 @@ In our example, we will simply use a fixed number of points, no matter the radiu Remember the number of points our shape has to be decomposed into? We fixed this number in the ``nb_points`` variable to a value of ``32``. Then, we initialize an empty -``PoolVector2Array``, which is simply an array of ``Vector2``\ s. +``PackedVector2Array``, which is simply an array of ``Vector2``\ s. The next step consists of computing the actual positions of these 32 points that compose an arc. This is done in the first for-loop: we iterate over the number of @@ -219,7 +219,7 @@ between -1 and 1, the position is located on a circle of radius 1. To have this position on our support circle, which has a radius of ``radius``, we simply need to multiply the position by ``radius``. Finally, we need to position our support circle at the ``center`` position, which is performed by adding it to our ``Vector2`` value. -Finally, we insert the point in the ``PoolVector2Array`` which was previously defined. +Finally, we insert the point in the ``PackedVector2Array`` which was previously defined. Now, we need to actually draw our points. As you can imagine, we will not simply draw our 32 points: we need to draw everything that is between each of them. @@ -276,9 +276,9 @@ the same as before, except that we draw a polygon instead of lines: func draw_circle_arc_poly(center, radius, angle_from, angle_to, color): var nb_points = 32 - var points_arc = PoolVector2Array() + var points_arc = PackedVector2Array() points_arc.push_back(center) - var colors = PoolColorArray([color]) + var colors = PackedColorArray([color]) for i in range(nb_points + 1): var angle_point = deg2rad(angle_from + i * (angle_to - angle_from) / nb_points - 90) diff --git a/tutorials/content/procedural_geometry/arraymesh.rst b/tutorials/content/procedural_geometry/arraymesh.rst index 818e1c419..62f619397 100644 --- a/tutorials/content/procedural_geometry/arraymesh.rst +++ b/tutorials/content/procedural_geometry/arraymesh.rst @@ -14,19 +14,19 @@ lines, points, etc. A complete list can be found under the :ref:`Mesh ` of vertex normals. +``ArrayMesh.ARRAY_NORMAL`` is a :ref:`PackedVector3Array ` of vertex normals. The surface array can be indexed or non-indexed. Creating a non-indexed array is as easy as not assigning an array at the index ``ArrayMesh.ARRAY_INDEX``. A non-indexed array stores unique vertex information for diff --git a/tutorials/misc/binary_serialization_api.rst b/tutorials/misc/binary_serialization_api.rst index ae0eb8f85..2463428a7 100644 --- a/tutorials/misc/binary_serialization_api.rst +++ b/tutorials/misc/binary_serialization_api.rst @@ -64,19 +64,23 @@ integer, specifying the type of data: +--------+--------------------------+ | 20 | raw array | +--------+--------------------------+ -| 21 | int array | +| 21 | int32 array | +--------+--------------------------+ -| 22 | real array | +| 22 | int64 array | +--------+--------------------------+ -| 23 | string array | +| 23 | float32 array | +--------+--------------------------+ -| 24 | vector2 array | +| 24 | float64 array | +--------+--------------------------+ -| 25 | vector3 array | +| 25 | string array | +--------+--------------------------+ -| 26 | color array | +| 26 | vector2 array | +--------+--------------------------+ -| 27 | max | +| 27 | vector3 array | ++--------+--------------------------+ +| 28 | color array | ++--------+--------------------------+ +| 29 | max | +--------+--------------------------+ Following this is the actual packet contents, which varies for each type @@ -109,7 +113,7 @@ of packet: +----------+-------+---------+-------------------------+ | Offset | Len | Type | Description | +==========+=======+=========+=========================+ -| 4 | 4 | Float | IEE 754 32-Bits Float | +| 4 | 4 | Float | IEEE 754 32-Bits Float | +----------+-------+---------+-------------------------+ 4: :ref:`String` @@ -376,8 +380,8 @@ one after the other, using this same format. Then what follows is, for amount of "elements", values one after the other, using this same format. -20: :ref:`PoolByteArray` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +20: :ref:`PackedByteArray` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +---------------+-------+-----------+------------------------+ | Offset | Len | Type | Description | @@ -389,8 +393,8 @@ other, using this same format. The array data is padded to 4 bytes. -21: :ref:`PoolIntArray` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +21: :ref:`PackedInt32Array` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------+-------+-----------+---------------------------+ | Offset | Len | Type | Description | @@ -400,19 +404,41 @@ The array data is padded to 4 bytes. | 8..8+length\*4 | 4 | Integer | 32 Bits Signed Integer | +------------------+-------+-----------+---------------------------+ -22: :ref:`PoolRealArray` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +22: :ref:`PackedInt64Array` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------+-------+-----------+---------------------------+ | Offset | Len | Type | Description | +==================+=======+===========+===========================+ -| 4 | 4 |Integer | Array Length (Floats) | +| 4 | 8 | Integer | Array Length (Integers) | +------------------+-------+-----------+---------------------------+ -| 8..8+length\*4 | 4 |Integer | 32 Bits IEE 754 Float | +| 8..8+length\*8 | 8 | Integer | 64 Bits Signed Integer | +------------------+-------+-----------+---------------------------+ -23: :ref:`PoolStringArray` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +23: :ref:`PackedFloat32Array` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ++------------------+-------+-----------+---------------------------+ +| Offset | Len | Type | Description | ++==================+=======+===========+===========================+ +| 4 | 4 | Integer | Array Length (Floats) | ++------------------+-------+-----------+---------------------------+ +| 8..8+length\*4 | 4 | Integer | 32 Bits IEEE 754 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 | ++------------------+-------+-----------+---------------------------+ + +25: :ref:`PackedStringArray` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +----------+-------+-----------+--------------------------+ | Offset | Len | Type | Description | @@ -432,8 +458,8 @@ For each String: Every string is padded to 4 bytes. -24: :ref:`PoolVector2Array` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +26: :ref:`PackedVector2Array` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-------------------+-------+-----------+----------------+ | Offset | Len | Type | Description | @@ -445,8 +471,8 @@ Every string is padded to 4 bytes. | 8..12+length\*8 | 4 | Float | Y Coordinate | +-------------------+-------+-----------+----------------+ -25: :ref:`PoolVector3Array` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +27: :ref:`PackedVector3Array` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +--------------------+-------+-----------+----------------+ | Offset | Len | Type | Description | @@ -460,8 +486,8 @@ Every string is padded to 4 bytes. | 8..16+length\*12 | 4 | Float | Z Coordinate | +--------------------+-------+-----------+----------------+ -26: :ref:`PoolColorArray` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +28: :ref:`PackedColorArray` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +--------------------+-------+-----------+----------------+ | Offset | Len | Type | Description | diff --git a/tutorials/networking/http_client_class.rst b/tutorials/networking/http_client_class.rst index acc709a90..119c390e4 100644 --- a/tutorials/networking/http_client_class.rst +++ b/tutorials/networking/http_client_class.rst @@ -81,7 +81,7 @@ It will connect and fetch a website. # This method works for both anyway - var rb = PoolByteArray() # Array that will hold the data. + var rb = PackedByteArray() # Array that will hold the data. while http.get_status() == HTTPClient.STATUS_BODY: # While there is body left to be read diff --git a/tutorials/plugins/editor/spatial_gizmos.rst b/tutorials/plugins/editor/spatial_gizmos.rst index 4fa8e0270..18c6ef075 100644 --- a/tutorials/plugins/editor/spatial_gizmos.rst +++ b/tutorials/plugins/editor/spatial_gizmos.rst @@ -89,12 +89,12 @@ or all the handle related ones. var spatial = gizmo.get_spatial_node() - var lines = PoolVector3Array() + var lines = PackedVector3Array() lines.push_back(Vector3(0, 1, 0)) lines.push_back(Vector3(0, spatial.my_custom_value, 0)) - var handles = PoolVector3Array() + var handles = PackedVector3Array() handles.push_back(Vector3(0, 1, 0)) handles.push_back(Vector3(0, spatial.my_custom_value, 0)) @@ -129,12 +129,12 @@ So the final plugin would look somewhat like this: var spatial = gizmo.get_spatial_node() - var lines = PoolVector3Array() + var lines = PackedVector3Array() lines.push_back(Vector3(0, 1, 0)) lines.push_back(Vector3(0, spatial.my_custom_value, 0)) - var handles = PoolVector3Array() + var handles = PackedVector3Array() handles.push_back(Vector3(0, 1, 0)) handles.push_back(Vector3(0, spatial.my_custom_value, 0)) @@ -195,12 +195,12 @@ This way all the gizmo logic and drawing methods can be implemented in a new cla var spatial = get_spatial_node() - var lines = PoolVector3Array() + var lines = PackedVector3Array() lines.push_back(Vector3(0, 1, 0)) lines.push_back(Vector3(gizmo_size, spatial.my_custom_value, 0)) - var handles = PoolVector3Array() + var handles = PackedVector3Array() handles.push_back(Vector3(0, 1, 0)) handles.push_back(Vector3(gizmo_size, spatial.my_custom_value, 0)) diff --git a/tutorials/shading/advanced_postprocessing.rst b/tutorials/shading/advanced_postprocessing.rst index 9fee1436d..e6b080251 100644 --- a/tutorials/shading/advanced_postprocessing.rst +++ b/tutorials/shading/advanced_postprocessing.rst @@ -162,7 +162,7 @@ Now, attach a script to the MeshInstance and use the following code: func _ready(): # Create a single triangle out of vertices: - var verts = PoolVector3Array() + var verts = PackedVector3Array() verts.append(Vector3(-1.0, -1.0, 0.0)) verts.append(Vector3(-1.0, 3.0, 0.0)) verts.append(Vector3(3.0, -1.0, 0.0))