Added the new variabt types to ResourceFormatBinary.

This commit is contained in:
Relintai 2022-03-21 18:20:41 +01:00
parent 23a106b50c
commit 71f66e0622

View File

@ -73,6 +73,11 @@ enum {
VARIANT_VECTOR2_ARRAY = 37, VARIANT_VECTOR2_ARRAY = 37,
VARIANT_INT64 = 40, VARIANT_INT64 = 40,
VARIANT_DOUBLE = 41, VARIANT_DOUBLE = 41,
VARIANT_VECTOR2I = 42,
VARIANT_RECT2I = 43,
VARIANT_VECTOR3I = 44,
VARIANT_VECTOR3I_ARRAY = 45,
VARIANT_VECTOR2I_ARRAY = 46,
#ifndef DISABLE_DEPRECATED #ifndef DISABLE_DEPRECATED
VARIANT_IMAGE = 21, // - no longer variant type VARIANT_IMAGE = 21, // - no longer variant type
IMAGE_ENCODING_EMPTY = 0, IMAGE_ENCODING_EMPTY = 0,
@ -152,6 +157,13 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
v.y = f->get_real(); v.y = f->get_real();
r_v = v; r_v = v;
} break;
case VARIANT_VECTOR2I: {
Vector2i v;
v.x = f->get_32();
v.y = f->get_32();
r_v = v;
} break; } break;
case VARIANT_RECT2: { case VARIANT_RECT2: {
Rect2 v; Rect2 v;
@ -161,6 +173,15 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
v.size.y = f->get_real(); v.size.y = f->get_real();
r_v = v; 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; } break;
case VARIANT_VECTOR3: { case VARIANT_VECTOR3: {
Vector3 v; Vector3 v;
@ -169,6 +190,13 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
v.z = f->get_real(); v.z = f->get_real();
r_v = v; r_v = v;
} break; } 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: { case VARIANT_PLANE: {
Plane v; Plane v;
v.normal.x = f->get_real(); v.normal.x = f->get_real();
@ -464,6 +492,30 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
w.release(); w.release();
r_v = array; r_v = array;
} break;
case VARIANT_VECTOR2I_ARRAY: {
uint32_t len = f->get_32();
PoolVector<Vector2i> array;
array.resize(len);
PoolVector<Vector2i>::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; } break;
case VARIANT_VECTOR3_ARRAY: { case VARIANT_VECTOR3_ARRAY: {
uint32_t len = f->get_32(); uint32_t len = f->get_32();
@ -489,6 +541,31 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
w.release(); w.release();
r_v = array; r_v = array;
} break;
case VARIANT_VECTOR3I_ARRAY: {
uint32_t len = f->get_32();
PoolVector<Vector3i> array;
array.resize(len);
PoolVector<Vector3i>::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; } break;
case VARIANT_COLOR_ARRAY: { case VARIANT_COLOR_ARRAY: {
uint32_t len = f->get_32(); uint32_t len = f->get_32();