diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/global_constants.cpp | 12 | ||||
| -rw-r--r-- | core/image.cpp | 2 | ||||
| -rw-r--r-- | core/io/resource_format_binary.cpp | 6 | ||||
| -rw-r--r-- | core/message_queue.cpp | 15 | ||||
| -rw-r--r-- | core/ring_buffer.h | 26 | ||||
| -rw-r--r-- | core/variant.h | 4 | ||||
| -rw-r--r-- | core/variant_op.cpp | 31 | ||||
| -rw-r--r-- | core/variant_parser.cpp | 66 |
8 files changed, 63 insertions, 99 deletions
diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 3098df421a..18f34b5d37 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -506,21 +506,21 @@ static _GlobalConstant _global_constants[] = { { "TYPE_TRANSFORM2D", Variant::TRANSFORM2D }, { "TYPE_PLANE", Variant::PLANE }, { "TYPE_QUAT", Variant::QUAT }, // 10 - { "TYPE_RECT3", Variant::RECT3 }, //sorry naming convention fail :( not like it's used often + { "TYPE_RECT3", Variant::RECT3 }, { "TYPE_BASIS", Variant::BASIS }, { "TYPE_TRANSFORM", Variant::TRANSFORM }, { "TYPE_COLOR", Variant::COLOR }, - { "TYPE_NODE_PATH", Variant::NODE_PATH }, + { "TYPE_NODE_PATH", Variant::NODE_PATH }, // 15 { "TYPE_RID", Variant::_RID }, { "TYPE_OBJECT", Variant::OBJECT }, { "TYPE_INPUT_EVENT", Variant::INPUT_EVENT }, - { "TYPE_DICTIONARY", Variant::DICTIONARY }, // 20 - { "TYPE_ARRAY", Variant::ARRAY }, + { "TYPE_DICTIONARY", Variant::DICTIONARY }, + { "TYPE_ARRAY", Variant::ARRAY }, // 20 { "TYPE_RAW_ARRAY", Variant::POOL_BYTE_ARRAY }, { "TYPE_INT_ARRAY", Variant::POOL_INT_ARRAY }, { "TYPE_REAL_ARRAY", Variant::POOL_REAL_ARRAY }, - { "TYPE_STRING_ARRAY", Variant::POOL_STRING_ARRAY }, // 25 - { "TYPE_VECTOR2_ARRAY", Variant::POOL_VECTOR2_ARRAY }, + { "TYPE_STRING_ARRAY", Variant::POOL_STRING_ARRAY }, + { "TYPE_VECTOR2_ARRAY", Variant::POOL_VECTOR2_ARRAY }, // 25 { "TYPE_VECTOR3_ARRAY", Variant::POOL_VECTOR3_ARRAY }, { "TYPE_COLOR_ARRAY", Variant::POOL_COLOR_ARRAY }, { "TYPE_MAX", Variant::VARIANT_MAX }, diff --git a/core/image.cpp b/core/image.cpp index a490c06275..85ca63be5e 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1960,7 +1960,7 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("get_mipmap_offset", "mipmap"), &Image::get_mipmap_offset); ClassDB::bind_method(D_METHOD("resize_to_po2", "square"), &Image::resize_to_po2, DEFVAL("false")); - ClassDB::bind_method(D_METHOD("resize", "width", "height", "interpolation"), &Image::resize_to_po2, DEFVAL(INTERPOLATE_BILINEAR)); + ClassDB::bind_method(D_METHOD("resize", "width", "height", "interpolation"), &Image::resize, DEFVAL(INTERPOLATE_BILINEAR)); ClassDB::bind_method(D_METHOD("shrink_x2"), &Image::shrink_x2); ClassDB::bind_method(D_METHOD("expand_x2_hq2x"), &Image::expand_x2_hq2x); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index d6e2925d57..4ad3d261b2 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -49,7 +49,7 @@ enum { VARIANT_VECTOR3 = 12, VARIANT_PLANE = 13, VARIANT_QUAT = 14, - VARIANT_AABB = 15, + VARIANT_RECT3 = 15, VARIANT_MATRIX3 = 16, VARIANT_TRANSFORM = 17, VARIANT_MATRIX32 = 18, @@ -188,7 +188,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { r_v = v; } break; - case VARIANT_AABB: { + case VARIANT_RECT3: { Rect3 v; v.pos.x = f->get_real(); @@ -1332,7 +1332,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant &p_property, } break; case Variant::RECT3: { - f->store_32(VARIANT_AABB); + f->store_32(VARIANT_RECT3); Rect3 val = p_property; f->store_real(val.pos.x); f->store_real(val.pos.y); diff --git a/core/message_queue.cpp b/core/message_queue.cpp index fa1c8112cc..d7d31b6c1e 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -318,12 +318,19 @@ void MessageQueue::flush() { while (read_pos < buffer_end) { - _THREAD_SAFE_UNLOCK_ - //lock on each interation, so a call can re-add itself to the message queue Message *message = (Message *)&buffer[read_pos]; + uint32_t advance = sizeof(Message); + if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) + advance += sizeof(Variant) * message->args; + + //pre-advance so this function is reentrant + read_pos += advance; + + _THREAD_SAFE_UNLOCK_ + Object *target = ObjectDB::get_instance(message->instance_ID); if (target != NULL) { @@ -359,13 +366,9 @@ void MessageQueue::flush() { } } - uint32_t advance = sizeof(Message); - if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) - advance += sizeof(Variant) * message->args; message->~Message(); _THREAD_SAFE_LOCK_ - read_pos += advance; } buffer_end = 0; // reset buffer diff --git a/core/ring_buffer.h b/core/ring_buffer.h index d5085e9560..8b32bb5e10 100644 --- a/core/ring_buffer.h +++ b/core/ring_buffer.h @@ -101,6 +101,32 @@ public: return p_size; }; + int find(const T &t, int p_offset, int p_max_size) { + + int left = data_left(); + if ((p_offset + p_max_size) > left) { + p_max_size -= left - p_offset; + if (p_max_size <= 0) + return 0; + } + p_max_size = MIN(left, p_max_size); + int pos = read_pos; + inc(pos, p_offset); + int to_read = p_max_size; + while (to_read) { + int end = pos + to_read; + end = MIN(end, size()); + int total = end - pos; + for (int i = 0; i < total; i++) { + if (data[pos + i] == t) + return i + (p_max_size - to_read); + }; + to_read -= total; + pos = 0; + } + return -1; + } + inline int advance_read(int p_n) { p_n = MIN(p_n, data_left()); inc(read_pos, p_n); diff --git a/core/variant.h b/core/variant.h index 021f1d0144..76097dfbdd 100644 --- a/core/variant.h +++ b/core/variant.h @@ -91,13 +91,13 @@ public: TRANSFORM2D, PLANE, QUAT, // 10 - RECT3, //sorry naming convention fail :( not like it's used often + RECT3, BASIS, TRANSFORM, // misc types COLOR, - NODE_PATH, + NODE_PATH, // 15 _RID, OBJECT, INPUT_EVENT, diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 1de46a07eb..8bae6a168b 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -1303,7 +1303,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } } - } break; + } break; // 10 case RECT3: { if (p_value.type != Variant::VECTOR3) @@ -1328,7 +1328,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) return; } } - } break; //sorry naming convention fail :( not like it's used often // 10 + } break; case BASIS: { if (p_value.type != Variant::VECTOR3) @@ -1896,13 +1896,13 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) dic->operator[](p_index) = p_value; valid = true; //always valid, i guess? should this really be ok? return; - } break; // 20 - DEFAULT_OP_ARRAY_CMD(ARRAY, Array, ;, (*arr)[index] = p_value; return ) + } break; + DEFAULT_OP_ARRAY_CMD(ARRAY, Array, ;, (*arr)[index] = p_value; return ) // 20 DEFAULT_OP_DVECTOR_SET(POOL_BYTE_ARRAY, uint8_t, p_value.type != Variant::REAL && p_value.type != Variant::INT) DEFAULT_OP_DVECTOR_SET(POOL_INT_ARRAY, int, p_value.type != Variant::REAL && p_value.type != Variant::INT) DEFAULT_OP_DVECTOR_SET(POOL_REAL_ARRAY, real_t, p_value.type != Variant::REAL && p_value.type != Variant::INT) - DEFAULT_OP_DVECTOR_SET(POOL_STRING_ARRAY, String, p_value.type != Variant::STRING) // 25 - DEFAULT_OP_DVECTOR_SET(POOL_VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2) + DEFAULT_OP_DVECTOR_SET(POOL_STRING_ARRAY, String, p_value.type != Variant::STRING) + DEFAULT_OP_DVECTOR_SET(POOL_VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2) // 25 DEFAULT_OP_DVECTOR_SET(POOL_VECTOR3_ARRAY, Vector3, p_value.type != Variant::VECTOR3) DEFAULT_OP_DVECTOR_SET(POOL_COLOR_ARRAY, Color, p_value.type != Variant::COLOR) default: return; @@ -2103,7 +2103,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } } - } break; + } break; // 10 case RECT3: { if (p_index.get_type() == Variant::STRING) { @@ -2122,7 +2122,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { return v->size + v->pos; } } - } break; //sorry naming convention fail :( not like it's used often // 10 + } break; case BASIS: { if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { @@ -2498,13 +2498,13 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { valid = true; return *res; } - } break; // 20 - DEFAULT_OP_ARRAY_CMD(ARRAY, const Array, ;, return (*arr)[index]) + } break; + DEFAULT_OP_ARRAY_CMD(ARRAY, const Array, ;, return (*arr)[index]) // 20 DEFAULT_OP_DVECTOR_GET(POOL_BYTE_ARRAY, uint8_t) DEFAULT_OP_DVECTOR_GET(POOL_INT_ARRAY, int) DEFAULT_OP_DVECTOR_GET(POOL_REAL_ARRAY, real_t) DEFAULT_OP_DVECTOR_GET(POOL_STRING_ARRAY, String) - DEFAULT_OP_DVECTOR_GET(POOL_VECTOR2_ARRAY, Vector2) + DEFAULT_OP_DVECTOR_GET(POOL_VECTOR2_ARRAY, Vector2) // 25 DEFAULT_OP_DVECTOR_GET(POOL_VECTOR3_ARRAY, Vector3) DEFAULT_OP_DVECTOR_GET(POOL_COLOR_ARRAY, Color) default: return Variant(); @@ -2768,12 +2768,12 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::REAL, "z")); p_list->push_back(PropertyInfo(Variant::REAL, "w")); - } break; + } break; // 10 case RECT3: { p_list->push_back(PropertyInfo(Variant::VECTOR3, "pos")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "size")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "end")); - } break; //sorry naming convention fail :( not like it's used often // 10 + } break; case BASIS: { p_list->push_back(PropertyInfo(Variant::VECTOR3, "x")); @@ -2921,12 +2921,13 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::STRING, E->get())); } } - } break; // 20 - case ARRAY: + } break; + case ARRAY: // 20 case POOL_BYTE_ARRAY: case POOL_INT_ARRAY: case POOL_REAL_ARRAY: case POOL_STRING_ARRAY: + case POOL_VECTOR2_ARRAY: // 25 case POOL_VECTOR3_ARRAY: case POOL_COLOR_ARRAY: { diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index f650e5f833..798a830dd0 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -504,39 +504,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, return OK; } else if (token.type == TK_IDENTIFIER) { - /* - VECTOR2, // 5 - RECT2, - VECTOR3, - MATRIX32, - PLANE, - QUAT, // 10 - _AABB, //sorry naming convention fail :( not like it's used often - MATRIX3, - TRANSFORM, - // misc types - COLOR, - IMAGE, // 15 - NODE_PATH, - _RID, - OBJECT, - INPUT_EVENT, - DICTIONARY, // 20 - ARRAY, - - // arrays - RAW_ARRAY, - INT_ARRAY, - REAL_ARRAY, - STRING_ARRAY, // 25 - VECTOR2_ARRAY, - VECTOR3_ARRAY, - COLOR_ARRAY, - - VARIANT_MAX - -*/ String id = token.value; if (id == "true") value = true; @@ -1243,40 +1211,6 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, return ERR_PARSE_ERROR; } - /* - VECTOR2, // 5 - RECT2, - VECTOR3, - MATRIX32, - PLANE, - QUAT, // 10 - _AABB, //sorry naming convention fail :( not like it's used often - MATRIX3, - TRANSFORM, - - // misc types - COLOR, - IMAGE, // 15 - NODE_PATH, - _RID, - OBJECT, - INPUT_EVENT, - DICTIONARY, // 20 - ARRAY, - - // arrays - RAW_ARRAY, - INT_ARRAY, - REAL_ARRAY, - STRING_ARRAY, // 25 - VECTOR2_ARRAY, - VECTOR3_ARRAY, - COLOR_ARRAY, - - VARIANT_MAX - - */ - return OK; } else if (token.type == TK_NUMBER) { |