Add support for `PackedVector4Array`

pull/1456/head
David Snopek 2024-05-06 14:09:35 -05:00
parent 54fe2f9891
commit 23178e81ff
6 changed files with 481 additions and 27 deletions

View File

@ -545,6 +545,8 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
result.append("#include <godot_cpp/variant/vector2.hpp>") result.append("#include <godot_cpp/variant/vector2.hpp>")
if class_name == "PackedVector3Array": if class_name == "PackedVector3Array":
result.append("#include <godot_cpp/variant/vector3.hpp>") result.append("#include <godot_cpp/variant/vector3.hpp>")
if class_name == "PackedVector4Array":
result.append("#include <godot_cpp/variant/vector4.hpp>")
if is_packed_array(class_name): if is_packed_array(class_name):
result.append("#include <godot_cpp/core/error_macros.hpp>") result.append("#include <godot_cpp/core/error_macros.hpp>")
@ -2445,6 +2447,7 @@ def is_packed_array(type_name):
"PackedStringArray", "PackedStringArray",
"PackedVector2Array", "PackedVector2Array",
"PackedVector3Array", "PackedVector3Array",
"PackedVector4Array",
] ]

View File

@ -163,6 +163,10 @@
"name": "PackedColorArray", "name": "PackedColorArray",
"size": 8 "size": 8
}, },
{
"name": "PackedVector4Array",
"size": 8
},
{ {
"name": "Variant", "name": "Variant",
"size": 24 "size": 24
@ -324,6 +328,10 @@
"name": "PackedColorArray", "name": "PackedColorArray",
"size": 16 "size": 16
}, },
{
"name": "PackedVector4Array",
"size": 16
},
{ {
"name": "Variant", "name": "Variant",
"size": 24 "size": 24
@ -485,6 +493,10 @@
"name": "PackedColorArray", "name": "PackedColorArray",
"size": 8 "size": 8
}, },
{
"name": "PackedVector4Array",
"size": 8
},
{ {
"name": "Variant", "name": "Variant",
"size": 40 "size": 40
@ -646,6 +658,10 @@
"name": "PackedColorArray", "name": "PackedColorArray",
"size": 16 "size": 16
}, },
{
"name": "PackedVector4Array",
"size": 16
},
{ {
"name": "Variant", "name": "Variant",
"size": 40 "size": 40
@ -3932,8 +3948,12 @@
"value": 37 "value": 37
}, },
{ {
"name": "TYPE_MAX", "name": "TYPE_PACKED_VECTOR4_ARRAY",
"value": 38 "value": 38
},
{
"name": "TYPE_MAX",
"value": 39
} }
] ]
}, },
@ -6292,6 +6312,16 @@
"name": "!=", "name": "!=",
"right_type": "PackedColorArray", "right_type": "PackedColorArray",
"return_type": "bool" "return_type": "bool"
},
{
"name": "==",
"right_type": "PackedVector4Array",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "PackedVector4Array",
"return_type": "bool"
} }
], ],
"constructors": [ "constructors": [
@ -7445,6 +7475,11 @@
"name": "%", "name": "%",
"right_type": "PackedColorArray", "right_type": "PackedColorArray",
"return_type": "String" "return_type": "String"
},
{
"name": "%",
"right_type": "PackedVector4Array",
"return_type": "String"
} }
], ],
"methods": [ "methods": [
@ -12334,6 +12369,11 @@
"name": "in", "name": "in",
"right_type": "Array", "right_type": "Array",
"return_type": "bool" "return_type": "bool"
},
{
"name": "in",
"right_type": "PackedVector4Array",
"return_type": "bool"
} }
], ],
"methods": [ "methods": [
@ -17144,6 +17184,11 @@
"name": "%", "name": "%",
"right_type": "PackedColorArray", "right_type": "PackedColorArray",
"return_type": "String" "return_type": "String"
},
{
"name": "%",
"right_type": "PackedVector4Array",
"return_type": "String"
} }
], ],
"methods": [ "methods": [
@ -19972,6 +20017,15 @@
"type": "PackedColorArray" "type": "PackedColorArray"
} }
] ]
},
{
"index": 12,
"arguments": [
{
"name": "from",
"type": "PackedVector4Array"
}
]
} }
], ],
"has_destructor": true "has_destructor": true
@ -23636,6 +23690,351 @@
} }
], ],
"has_destructor": true "has_destructor": true
},
{
"name": "PackedVector4Array",
"indexing_return_type": "Vector4",
"is_keyed": false,
"operators": [
{
"name": "==",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "not",
"return_type": "bool"
},
{
"name": "in",
"right_type": "Dictionary",
"return_type": "bool"
},
{
"name": "in",
"right_type": "Array",
"return_type": "bool"
},
{
"name": "==",
"right_type": "PackedVector4Array",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "PackedVector4Array",
"return_type": "bool"
},
{
"name": "+",
"right_type": "PackedVector4Array",
"return_type": "PackedVector4Array"
}
],
"methods": [
{
"name": "size",
"return_type": "int",
"is_vararg": false,
"is_const": true,
"is_static": false,
"hash": 3173160232
},
{
"name": "is_empty",
"return_type": "bool",
"is_vararg": false,
"is_const": true,
"is_static": false,
"hash": 3918633141
},
{
"name": "set",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 1350366223,
"arguments": [
{
"name": "index",
"type": "int"
},
{
"name": "value",
"type": "Vector4"
}
]
},
{
"name": "push_back",
"return_type": "bool",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 3289167688,
"arguments": [
{
"name": "value",
"type": "Vector4"
}
]
},
{
"name": "append",
"return_type": "bool",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 3289167688,
"arguments": [
{
"name": "value",
"type": "Vector4"
}
]
},
{
"name": "append_array",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 537428395,
"arguments": [
{
"name": "array",
"type": "PackedVector4Array"
}
]
},
{
"name": "remove_at",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 2823966027,
"arguments": [
{
"name": "index",
"type": "int"
}
]
},
{
"name": "insert",
"return_type": "int",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 11085009,
"arguments": [
{
"name": "at_index",
"type": "int"
},
{
"name": "value",
"type": "Vector4"
}
]
},
{
"name": "fill",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 3761353134,
"arguments": [
{
"name": "value",
"type": "Vector4"
}
]
},
{
"name": "resize",
"return_type": "int",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 848867239,
"arguments": [
{
"name": "new_size",
"type": "int"
}
]
},
{
"name": "clear",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 3218959716
},
{
"name": "has",
"return_type": "bool",
"is_vararg": false,
"is_const": true,
"is_static": false,
"hash": 88913544,
"arguments": [
{
"name": "value",
"type": "Vector4"
}
]
},
{
"name": "reverse",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 3218959716
},
{
"name": "slice",
"return_type": "PackedVector4Array",
"is_vararg": false,
"is_const": true,
"is_static": false,
"hash": 2942803855,
"arguments": [
{
"name": "begin",
"type": "int"
},
{
"name": "end",
"type": "int",
"default_value": "2147483647"
}
]
},
{
"name": "to_byte_array",
"return_type": "PackedByteArray",
"is_vararg": false,
"is_const": true,
"is_static": false,
"hash": 247621236
},
{
"name": "sort",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 3218959716
},
{
"name": "bsearch",
"return_type": "int",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 735671678,
"arguments": [
{
"name": "value",
"type": "Vector4"
},
{
"name": "before",
"type": "bool",
"default_value": "true"
}
]
},
{
"name": "duplicate",
"return_type": "PackedVector4Array",
"is_vararg": false,
"is_const": false,
"is_static": false,
"hash": 3186305013
},
{
"name": "find",
"return_type": "int",
"is_vararg": false,
"is_const": true,
"is_static": false,
"hash": 3091171314,
"arguments": [
{
"name": "value",
"type": "Vector4"
},
{
"name": "from",
"type": "int",
"default_value": "0"
}
]
},
{
"name": "rfind",
"return_type": "int",
"is_vararg": false,
"is_const": true,
"is_static": false,
"hash": 3091171314,
"arguments": [
{
"name": "value",
"type": "Vector4"
},
{
"name": "from",
"type": "int",
"default_value": "-1"
}
]
},
{
"name": "count",
"return_type": "int",
"is_vararg": false,
"is_const": true,
"is_static": false,
"hash": 3956594488,
"arguments": [
{
"name": "value",
"type": "Vector4"
}
]
}
],
"constructors": [
{
"index": 0
},
{
"index": 1,
"arguments": [
{
"name": "from",
"type": "PackedVector4Array"
}
]
},
{
"index": 2,
"arguments": [
{
"name": "from",
"type": "Array"
}
]
}
],
"has_destructor": true
} }
], ],
"classes": [ "classes": [

View File

@ -96,6 +96,7 @@ typedef enum {
GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY, GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY,
GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY, GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY,
GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY, GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY,
GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR4_ARRAY,
GDEXTENSION_VARIANT_TYPE_VARIANT_MAX GDEXTENSION_VARIANT_TYPE_VARIANT_MAX
} GDExtensionVariantType; } GDExtensionVariantType;
@ -1962,32 +1963,6 @@ typedef uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndex)(GDExtension
*/ */
typedef const uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); typedef const uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
/**
* @name packed_color_array_operator_index
* @since 4.1
*
* Gets a pointer to a color in a PackedColorArray.
*
* @param p_self A pointer to a PackedColorArray object.
* @param p_index The index of the Color to get.
*
* @return A pointer to the requested Color.
*/
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
/**
* @name packed_color_array_operator_index_const
* @since 4.1
*
* Gets a const pointer to a color in a PackedColorArray.
*
* @param p_self A const pointer to a const PackedColorArray object.
* @param p_index The index of the Color to get.
*
* @return A const pointer to the requested Color.
*/
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
/** /**
* @name packed_float32_array_operator_index * @name packed_float32_array_operator_index
* @since 4.1 * @since 4.1
@ -2170,6 +2145,58 @@ typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndex
*/ */
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
/**
* @name packed_vector4_array_operator_index
* @since 4.3
*
* Gets a pointer to a Vector4 in a PackedVector4Array.
*
* @param p_self A pointer to a PackedVector4Array object.
* @param p_index The index of the Vector4 to get.
*
* @return A pointer to the requested Vector4.
*/
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector4ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
/**
* @name packed_vector4_array_operator_index_const
* @since 4.3
*
* Gets a const pointer to a Vector4 in a PackedVector4Array.
*
* @param p_self A const pointer to a PackedVector4Array object.
* @param p_index The index of the Vector4 to get.
*
* @return A const pointer to the requested Vector4.
*/
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector4ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
/**
* @name packed_color_array_operator_index
* @since 4.1
*
* Gets a pointer to a color in a PackedColorArray.
*
* @param p_self A pointer to a PackedColorArray object.
* @param p_index The index of the Color to get.
*
* @return A pointer to the requested Color.
*/
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
/**
* @name packed_color_array_operator_index_const
* @since 4.1
*
* Gets a const pointer to a color in a PackedColorArray.
*
* @param p_self A const pointer to a PackedColorArray object.
* @param p_index The index of the Color to get.
*
* @return A const pointer to the requested Color.
*/
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
/** /**
* @name array_operator_index * @name array_operator_index
* @since 4.1 * @since 4.1

View File

@ -148,6 +148,8 @@ extern "C" GDExtensionInterfacePackedVector2ArrayOperatorIndex gdextension_inter
extern "C" GDExtensionInterfacePackedVector2ArrayOperatorIndexConst gdextension_interface_packed_vector2_array_operator_index_const; extern "C" GDExtensionInterfacePackedVector2ArrayOperatorIndexConst gdextension_interface_packed_vector2_array_operator_index_const;
extern "C" GDExtensionInterfacePackedVector3ArrayOperatorIndex gdextension_interface_packed_vector3_array_operator_index; extern "C" GDExtensionInterfacePackedVector3ArrayOperatorIndex gdextension_interface_packed_vector3_array_operator_index;
extern "C" GDExtensionInterfacePackedVector3ArrayOperatorIndexConst gdextension_interface_packed_vector3_array_operator_index_const; extern "C" GDExtensionInterfacePackedVector3ArrayOperatorIndexConst gdextension_interface_packed_vector3_array_operator_index_const;
extern "C" GDExtensionInterfacePackedVector4ArrayOperatorIndex gdextension_interface_packed_vector4_array_operator_index;
extern "C" GDExtensionInterfacePackedVector4ArrayOperatorIndexConst gdextension_interface_packed_vector4_array_operator_index_const;
extern "C" GDExtensionInterfaceArrayOperatorIndex gdextension_interface_array_operator_index; extern "C" GDExtensionInterfaceArrayOperatorIndex gdextension_interface_array_operator_index;
extern "C" GDExtensionInterfaceArrayOperatorIndexConst gdextension_interface_array_operator_index_const; extern "C" GDExtensionInterfaceArrayOperatorIndexConst gdextension_interface_array_operator_index_const;
extern "C" GDExtensionInterfaceArrayRef gdextension_interface_array_ref; extern "C" GDExtensionInterfaceArrayRef gdextension_interface_array_ref;

View File

@ -154,6 +154,8 @@ GDExtensionInterfacePackedVector2ArrayOperatorIndex gdextension_interface_packed
GDExtensionInterfacePackedVector2ArrayOperatorIndexConst gdextension_interface_packed_vector2_array_operator_index_const = nullptr; GDExtensionInterfacePackedVector2ArrayOperatorIndexConst gdextension_interface_packed_vector2_array_operator_index_const = nullptr;
GDExtensionInterfacePackedVector3ArrayOperatorIndex gdextension_interface_packed_vector3_array_operator_index = nullptr; GDExtensionInterfacePackedVector3ArrayOperatorIndex gdextension_interface_packed_vector3_array_operator_index = nullptr;
GDExtensionInterfacePackedVector3ArrayOperatorIndexConst gdextension_interface_packed_vector3_array_operator_index_const = nullptr; GDExtensionInterfacePackedVector3ArrayOperatorIndexConst gdextension_interface_packed_vector3_array_operator_index_const = nullptr;
GDExtensionInterfacePackedVector4ArrayOperatorIndex gdextension_interface_packed_vector4_array_operator_index = nullptr;
GDExtensionInterfacePackedVector4ArrayOperatorIndexConst gdextension_interface_packed_vector4_array_operator_index_const = nullptr;
GDExtensionInterfaceArrayOperatorIndex gdextension_interface_array_operator_index = nullptr; GDExtensionInterfaceArrayOperatorIndex gdextension_interface_array_operator_index = nullptr;
GDExtensionInterfaceArrayOperatorIndexConst gdextension_interface_array_operator_index_const = nullptr; GDExtensionInterfaceArrayOperatorIndexConst gdextension_interface_array_operator_index_const = nullptr;
GDExtensionInterfaceArrayRef gdextension_interface_array_ref = nullptr; GDExtensionInterfaceArrayRef gdextension_interface_array_ref = nullptr;
@ -394,6 +396,8 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
LOAD_PROC_ADDRESS(packed_vector2_array_operator_index_const, GDExtensionInterfacePackedVector2ArrayOperatorIndexConst); LOAD_PROC_ADDRESS(packed_vector2_array_operator_index_const, GDExtensionInterfacePackedVector2ArrayOperatorIndexConst);
LOAD_PROC_ADDRESS(packed_vector3_array_operator_index, GDExtensionInterfacePackedVector3ArrayOperatorIndex); LOAD_PROC_ADDRESS(packed_vector3_array_operator_index, GDExtensionInterfacePackedVector3ArrayOperatorIndex);
LOAD_PROC_ADDRESS(packed_vector3_array_operator_index_const, GDExtensionInterfacePackedVector3ArrayOperatorIndexConst); LOAD_PROC_ADDRESS(packed_vector3_array_operator_index_const, GDExtensionInterfacePackedVector3ArrayOperatorIndexConst);
LOAD_PROC_ADDRESS(packed_vector4_array_operator_index, GDExtensionInterfacePackedVector4ArrayOperatorIndex);
LOAD_PROC_ADDRESS(packed_vector4_array_operator_index_const, GDExtensionInterfacePackedVector4ArrayOperatorIndexConst);
LOAD_PROC_ADDRESS(array_operator_index, GDExtensionInterfaceArrayOperatorIndex); LOAD_PROC_ADDRESS(array_operator_index, GDExtensionInterfaceArrayOperatorIndex);
LOAD_PROC_ADDRESS(array_operator_index_const, GDExtensionInterfaceArrayOperatorIndexConst); LOAD_PROC_ADDRESS(array_operator_index_const, GDExtensionInterfaceArrayOperatorIndexConst);
LOAD_PROC_ADDRESS(array_ref, GDExtensionInterfaceArrayRef); LOAD_PROC_ADDRESS(array_ref, GDExtensionInterfaceArrayRef);

View File

@ -43,6 +43,7 @@
#include <godot_cpp/variant/packed_string_array.hpp> #include <godot_cpp/variant/packed_string_array.hpp>
#include <godot_cpp/variant/packed_vector2_array.hpp> #include <godot_cpp/variant/packed_vector2_array.hpp>
#include <godot_cpp/variant/packed_vector3_array.hpp> #include <godot_cpp/variant/packed_vector3_array.hpp>
#include <godot_cpp/variant/packed_vector4_array.hpp>
namespace godot { namespace godot {
@ -198,6 +199,24 @@ Vector3 *PackedVector3Array::ptrw() {
return (Vector3 *)internal::gdextension_interface_packed_vector3_array_operator_index((GDExtensionTypePtr *)this, 0); return (Vector3 *)internal::gdextension_interface_packed_vector3_array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const Vector4 &PackedVector4Array::operator[](int64_t p_index) const {
const Vector4 *vec = (const Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
return *vec;
}
Vector4 &PackedVector4Array::operator[](int64_t p_index) {
Vector4 *vec = (Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index((GDExtensionTypePtr *)this, p_index);
return *vec;
}
const Vector4 *PackedVector4Array::ptr() const {
return (const Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index_const((GDExtensionTypePtr *)this, 0);
}
Vector4 *PackedVector4Array::ptrw() {
return (Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index((GDExtensionTypePtr *)this, 0);
}
const Variant &Array::operator[](int64_t p_index) const { const Variant &Array::operator[](int64_t p_index) const {
const Variant *var = (const Variant *)internal::gdextension_interface_array_operator_index_const((GDExtensionTypePtr *)this, p_index); const Variant *var = (const Variant *)internal::gdextension_interface_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
return *var; return *var;