From 71f66e062246db5eac846510405387ecba03b13a Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 21 Mar 2022 18:20:41 +0100 Subject: [PATCH] Added the new variabt types to ResourceFormatBinary. --- core/io/resource_format_binary.cpp | 77 ++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index afb5eea35..ae881d83f 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -73,6 +73,11 @@ enum { VARIANT_VECTOR2_ARRAY = 37, VARIANT_INT64 = 40, VARIANT_DOUBLE = 41, + VARIANT_VECTOR2I = 42, + VARIANT_RECT2I = 43, + VARIANT_VECTOR3I = 44, + VARIANT_VECTOR3I_ARRAY = 45, + VARIANT_VECTOR2I_ARRAY = 46, #ifndef DISABLE_DEPRECATED VARIANT_IMAGE = 21, // - no longer variant type IMAGE_ENCODING_EMPTY = 0, @@ -152,6 +157,13 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { v.y = f->get_real(); r_v = v; + } break; + case VARIANT_VECTOR2I: { + Vector2i v; + v.x = f->get_32(); + v.y = f->get_32(); + r_v = v; + } break; case VARIANT_RECT2: { Rect2 v; @@ -161,6 +173,15 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { v.size.y = f->get_real(); r_v = v; + } break; + case VARIANT_RECT2I: { + Rect2i v; + v.position.x = f->get_32(); + v.position.y = f->get_32(); + v.size.x = f->get_32(); + v.size.y = f->get_32(); + r_v = v; + } break; case VARIANT_VECTOR3: { Vector3 v; @@ -169,6 +190,13 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { v.z = f->get_real(); r_v = v; } break; + case VARIANT_VECTOR3I: { + Vector3i v; + v.x = f->get_32(); + v.y = f->get_32(); + v.z = f->get_32(); + r_v = v; + } break; case VARIANT_PLANE: { Plane v; v.normal.x = f->get_real(); @@ -464,6 +492,30 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { w.release(); r_v = array; + } break; + case VARIANT_VECTOR2I_ARRAY: { + uint32_t len = f->get_32(); + + PoolVector array; + array.resize(len); + PoolVector::Write w = array.write(); + if (sizeof(Vector2i) == 8) { + f->get_buffer((uint8_t *)w.ptr(), len * sizeof(uint32_t) * 2); +#ifdef BIG_ENDIAN_ENABLED + { + uint32_t *ptr = (uint32_t *)w.ptr(); + for (int i = 0; i < len * 2; i++) { + ptr[i] = BSWAP32(ptr[i]); + } + } + +#endif + } else { + ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Vector2i size is NOT 8!"); + } + w.release(); + r_v = array; + } break; case VARIANT_VECTOR3_ARRAY: { uint32_t len = f->get_32(); @@ -489,6 +541,31 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { w.release(); r_v = array; + } break; + case VARIANT_VECTOR3I_ARRAY: { + uint32_t len = f->get_32(); + + PoolVector array; + array.resize(len); + PoolVector::Write w = array.write(); + if (sizeof(Vector3i) == 12) { + f->get_buffer((uint8_t *)w.ptr(), len * sizeof(uint32_t) * 3); +#ifdef BIG_ENDIAN_ENABLED + { + uint32_t *ptr = (uint32_t *)w.ptr(); + for (int i = 0; i < len * 3; i++) { + ptr[i] = BSWAP32(ptr[i]); + } + } + +#endif + + } else { + ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Vector3i size is NOT 12!"); + } + w.release(); + r_v = array; + } break; case VARIANT_COLOR_ARRAY: { uint32_t len = f->get_32();