/**************************************************************************/ /* variant_converters.h */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #ifndef VARIANT_CONVERTERS_H #define VARIANT_CONVERTERS_H #include "core/error/error_macros.h" #include "core/variant/array.h" #include "core/variant/variant.h" #include <initializer_list> #include <type_traits> template <typename T> struct VariantConverterStd140 { … }; template <> struct VariantConverterStd140<float> { … }; template <> struct VariantConverterStd140<int32_t> { … }; template <> struct VariantConverterStd140<uint32_t> { … }; template <> struct VariantConverterStd140<Basis> { … }; template <> struct VariantConverterStd140<Transform2D> { … }; template <> struct VariantConverterStd140<Transform3D> { … }; template <> struct VariantConverterStd140<Projection> { … }; template <typename T, typename P> T construct_vector(const std::initializer_list<P> &values) { … } // Compatibility converter, tries to convert certain Variant types into a Vector2/3/4(i). template <typename T> T convert_to_vector(const Variant &p_variant, bool p_linear_color = false) { … } inline bool is_number_array(const Array &p_array) { … } inline bool is_convertible_array(Variant::Type type) { … } is_vector_type_v; is_vector_type_v; template <typename T, typename P> void convert_item_std140(const T &p_item, P *p_write, bool p_compact = false) { … } template <typename T, typename P> Vector<P> convert_array_std140(const Variant &p_variant, [[maybe_unused]] bool p_linear_color = false) { … } template <typename T, typename From, typename To> void write_array_std140(const Vector<From> &p_values, To *p_write, int p_array_size, int p_stride) { … } #endif // VARIANT_CONVERTERS_H