diff options
author | K. S. Ernest (iFire) Lee <fire@users.noreply.github.com> | 2024-04-08 07:51:34 -0700 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-05-03 00:58:27 +0200 |
commit | f9b488508ccc294db03d427c15c182864fae74de (patch) | |
tree | 4d48dd7b8b85c219faf6ecb8a43a9c3d57f71b38 /core/extension | |
parent | b9e022302aa4a5d97f8b25a1db809e64b46b6f96 (diff) | |
download | redot-engine-f9b488508ccc294db03d427c15c182864fae74de.tar.gz |
Add PackedVector4Array Variant type
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Diffstat (limited to 'core/extension')
-rw-r--r-- | core/extension/extension_api_dump.cpp | 2 | ||||
-rw-r--r-- | core/extension/gdextension_interface.cpp | 22 | ||||
-rw-r--r-- | core/extension/gdextension_interface.h | 79 |
3 files changed, 77 insertions, 26 deletions
diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index 69be2d2a8f..d7fba74365 100644 --- a/core/extension/extension_api_dump.cpp +++ b/core/extension/extension_api_dump.cpp @@ -189,6 +189,7 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) { { Variant::PACKED_VECTOR2_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 }, { Variant::PACKED_VECTOR3_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 }, { Variant::PACKED_COLOR_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 }, + { Variant::PACKED_VECTOR4_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 }, { Variant::VARIANT_MAX, sizeof(uint64_t) + sizeof(float) * 4, sizeof(uint64_t) + sizeof(float) * 4, sizeof(uint64_t) + sizeof(double) * 4, sizeof(uint64_t) + sizeof(double) * 4 }, }; @@ -230,6 +231,7 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) { static_assert(type_size_array[Variant::PACKED_VECTOR2_ARRAY][sizeof(void *)] == sizeof(PackedVector2Array), "Size of PackedVector2Array mismatch"); static_assert(type_size_array[Variant::PACKED_VECTOR3_ARRAY][sizeof(void *)] == sizeof(PackedVector3Array), "Size of PackedVector3Array mismatch"); static_assert(type_size_array[Variant::PACKED_COLOR_ARRAY][sizeof(void *)] == sizeof(PackedColorArray), "Size of PackedColorArray mismatch"); + static_assert(type_size_array[Variant::PACKED_VECTOR4_ARRAY][sizeof(void *)] == sizeof(PackedVector4Array), "Size of PackedVector4Array mismatch"); static_assert(type_size_array[Variant::VARIANT_MAX][sizeof(void *)] == sizeof(Variant), "Size of Variant mismatch"); Array core_type_sizes; diff --git a/core/extension/gdextension_interface.cpp b/core/extension/gdextension_interface.cpp index 9b4aa98357..98f5cb4d02 100644 --- a/core/extension/gdextension_interface.cpp +++ b/core/extension/gdextension_interface.cpp @@ -595,6 +595,8 @@ static GDExtensionVariantFromTypeConstructorFunc gdextension_get_variant_from_ty return VariantTypeConstructor<PackedVector2Array>::variant_from_type; case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY: return VariantTypeConstructor<PackedVector3Array>::variant_from_type; + case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR4_ARRAY: + return VariantTypeConstructor<PackedVector4Array>::variant_from_type; case GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY: return VariantTypeConstructor<PackedColorArray>::variant_from_type; case GDEXTENSION_VARIANT_TYPE_NIL: @@ -678,6 +680,8 @@ static GDExtensionTypeFromVariantConstructorFunc gdextension_get_variant_to_type return VariantTypeConstructor<PackedVector2Array>::type_from_variant; case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY: return VariantTypeConstructor<PackedVector3Array>::type_from_variant; + case GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR4_ARRAY: + return VariantTypeConstructor<PackedVector4Array>::type_from_variant; case GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY: return VariantTypeConstructor<PackedColorArray>::type_from_variant; case GDEXTENSION_VARIANT_TYPE_NIL: @@ -1116,6 +1120,22 @@ static GDExtensionTypePtr gdextension_packed_vector3_array_operator_index_const( return (GDExtensionTypePtr)&self->ptr()[p_index]; } +static GDExtensionTypePtr gdextension_packed_vector4_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { + PackedVector4Array *self = (PackedVector4Array *)p_self; + if (unlikely(p_index < 0 || p_index >= self->size())) { + return nullptr; + } + return (GDExtensionTypePtr)&self->ptrw()[p_index]; +} + +static GDExtensionTypePtr gdextension_packed_vector4_array_operator_index_const(GDExtensionConstTypePtr p_self, GDExtensionInt p_index) { + const PackedVector4Array *self = (const PackedVector4Array *)p_self; + if (unlikely(p_index < 0 || p_index >= self->size())) { + return nullptr; + } + return (GDExtensionTypePtr)&self->ptr()[p_index]; +} + static GDExtensionVariantPtr gdextension_array_operator_index(GDExtensionTypePtr p_self, GDExtensionInt p_index) { Array *self = (Array *)p_self; if (unlikely(p_index < 0 || p_index >= self->size())) { @@ -1620,6 +1640,8 @@ void gdextension_setup_interface() { REGISTER_INTERFACE_FUNC(packed_vector2_array_operator_index_const); REGISTER_INTERFACE_FUNC(packed_vector3_array_operator_index); REGISTER_INTERFACE_FUNC(packed_vector3_array_operator_index_const); + REGISTER_INTERFACE_FUNC(packed_vector4_array_operator_index); + REGISTER_INTERFACE_FUNC(packed_vector4_array_operator_index_const); REGISTER_INTERFACE_FUNC(array_operator_index); REGISTER_INTERFACE_FUNC(array_operator_index_const); REGISTER_INTERFACE_FUNC(array_ref); diff --git a/core/extension/gdextension_interface.h b/core/extension/gdextension_interface.h index 00a98af4e2..bfe592cb4e 100644 --- a/core/extension/gdextension_interface.h +++ b/core/extension/gdextension_interface.h @@ -96,6 +96,7 @@ typedef enum { GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY, GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY, GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY, + GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR4_ARRAY, GDEXTENSION_VARIANT_TYPE_VARIANT_MAX } GDExtensionVariantType; @@ -1964,32 +1965,6 @@ typedef uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndex)(GDExtension 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 * @since 4.1 * @@ -2172,6 +2147,58 @@ typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndex 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 * @since 4.1 * |