summaryrefslogtreecommitdiffstats
path: root/core/variant/variant_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/variant/variant_parser.cpp')
-rw-r--r--core/variant/variant_parser.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp
index 50f8007efa..9a0dd712ed 100644
--- a/core/variant/variant_parser.cpp
+++ b/core/variant/variant_parser.cpp
@@ -1395,6 +1395,24 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
value = arr;
+ } else if (id == "PackedVector4Array" || id == "PoolVector4Array" || id == "Vector4Array") {
+ Vector<real_t> args;
+ Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
+ if (err) {
+ return err;
+ }
+
+ Vector<Vector4> arr;
+ {
+ int len = args.size() / 4;
+ arr.resize(len);
+ Vector4 *w = arr.ptrw();
+ for (int i = 0; i < len; i++) {
+ w[i] = Vector4(args[i * 4 + 0], args[i * 4 + 1], args[i * 4 + 2], args[i * 4 + 3]);
+ }
+ }
+
+ value = arr;
} else if (id == "PackedColorArray" || id == "PoolColorArray" || id == "ColorArray") {
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
@@ -2248,6 +2266,21 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, ")");
} break;
+ case Variant::PACKED_VECTOR4_ARRAY: {
+ p_store_string_func(p_store_string_ud, "PackedVector4Array(");
+ Vector<Vector4> data = p_variant;
+ int len = data.size();
+ const Vector4 *ptr = data.ptr();
+
+ for (int i = 0; i < len; i++) {
+ if (i > 0) {
+ p_store_string_func(p_store_string_ud, ", ");
+ }
+ p_store_string_func(p_store_string_ud, rtos_fix(ptr[i].x) + ", " + rtos_fix(ptr[i].y) + ", " + rtos_fix(ptr[i].z) + ", " + rtos_fix(ptr[i].w));
+ }
+
+ p_store_string_func(p_store_string_ud, ")");
+ } break;
default: {
ERR_PRINT("Unknown variant type");