diff options
Diffstat (limited to 'core/variant.cpp')
-rw-r--r-- | core/variant.cpp | 94 |
1 files changed, 8 insertions, 86 deletions
diff --git a/core/variant.cpp b/core/variant.cpp index 771d97a4eb..0807a33788 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -6,6 +6,7 @@ /* http://www.godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -119,11 +120,6 @@ String Variant::get_type_name(Variant::Type p_type) { return "Color"; } break; - case IMAGE: { - - return "Image"; - - } break; case _RID: { return "RID"; @@ -137,11 +133,6 @@ String Variant::get_type_name(Variant::Type p_type) { return "NodePath"; } break; - case INPUT_EVENT: { - - return "InputEvent"; - - } break; case DICTIONARY: { return "Dictionary"; @@ -166,7 +157,7 @@ String Variant::get_type_name(Variant::Type p_type) { } break; case POOL_REAL_ARRAY: { - return "PoolFloatArray"; + return "PoolRealArray"; } break; case POOL_STRING_ARRAY: { @@ -248,7 +239,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { static const Type invalid[] = { OBJECT, - IMAGE, NIL }; @@ -790,11 +780,6 @@ bool Variant::is_zero() const { return *reinterpret_cast<const Color *>(_data._mem) == Color(); } break; - case IMAGE: { - - return _data._image->empty(); - - } break; case _RID: { return *reinterpret_cast<const RID *>(_data._mem) == RID(); @@ -808,11 +793,6 @@ bool Variant::is_zero() const { return reinterpret_cast<const NodePath *>(_data._mem)->is_empty(); } break; - case INPUT_EVENT: { - - return _data._input_event->type == InputEvent::NONE; - - } break; case DICTIONARY: { return reinterpret_cast<const Dictionary *>(_data._mem)->empty(); @@ -1015,11 +995,6 @@ void Variant::reference(const Variant &p_variant) { memnew_placement(_data._mem, Color(*reinterpret_cast<const Color *>(p_variant._data._mem))); } break; - case IMAGE: { - - _data._image = memnew(Image(*p_variant._data._image)); - - } break; case _RID: { memnew_placement(_data._mem, RID(*reinterpret_cast<const RID *>(p_variant._data._mem))); @@ -1033,11 +1008,6 @@ void Variant::reference(const Variant &p_variant) { memnew_placement(_data._mem, NodePath(*reinterpret_cast<const NodePath *>(p_variant._data._mem))); } break; - case INPUT_EVENT: { - - _data._input_event = memnew(InputEvent(*p_variant._data._input_event)); - - } break; case DICTIONARY: { memnew_placement(_data._mem, Dictionary(*reinterpret_cast<const Dictionary *>(p_variant._data._mem))); @@ -1140,11 +1110,6 @@ void Variant::clear() { } break; // misc types - case IMAGE: { - - memdelete(_data._image); - - } break; case NODE_PATH: { reinterpret_cast<NodePath *>(_data._mem)->~NodePath(); @@ -1169,12 +1134,6 @@ void Variant::clear() { reinterpret_cast<Array *>(_data._mem)->~Array(); } break; - case INPUT_EVENT: { - - memdelete(_data._input_event); - - } break; - // arrays case POOL_BYTE_ARRAY: { @@ -1523,7 +1482,6 @@ Variant::operator String() const { } break; case TRANSFORM: return operator Transform(); case NODE_PATH: return operator NodePath(); - case INPUT_EVENT: return operator InputEvent(); case COLOR: return String::num(operator Color().r) + "," + String::num(operator Color().g) + "," + String::num(operator Color().b) + "," + String::num(operator Color().a); case DICTIONARY: { @@ -1759,13 +1717,6 @@ Variant::operator Color() const { else return Color(); } -Variant::operator Image() const { - - if (type == IMAGE) - return *_data._image; - else - return Image(); -} Variant::operator NodePath() const { @@ -1825,14 +1776,6 @@ Variant::operator Control *() const { return NULL; } -Variant::operator InputEvent() const { - - if (type == INPUT_EVENT) - return *reinterpret_cast<const InputEvent *>(_data._input_event); - else - return InputEvent(); -} - Variant::operator Dictionary() const { if (type == DICTIONARY) @@ -2305,11 +2248,6 @@ Variant::Variant(const Color &p_color) { type = COLOR; memnew_placement(_data._mem, Color(p_color)); } -Variant::Variant(const Image &p_image) { - - type = IMAGE; - _data._image = memnew(Image(p_image)); -} Variant::Variant(const NodePath &p_node_path) { @@ -2317,12 +2255,6 @@ Variant::Variant(const NodePath &p_node_path) { memnew_placement(_data._mem, NodePath(p_node_path)); } -Variant::Variant(const InputEvent &p_input_event) { - - type = INPUT_EVENT; - _data._input_event = memnew(InputEvent(p_input_event)); -} - Variant::Variant(const RefPtr &p_resource) { type = OBJECT; @@ -2617,8 +2549,8 @@ uint32_t Variant::hash() const { } break; case RECT2: { - uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->pos.x); - hash = hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->pos.y, hash); + uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->position.x); + hash = hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->position.y, hash); hash = hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->size.x, hash); return hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->size.y, hash); } break; @@ -2658,7 +2590,7 @@ uint32_t Variant::hash() const { uint32_t hash = 5831; for (int i = 0; i < 3; i++) { - hash = hash_djb2_one_float(_data._rect3->pos[i], hash); + hash = hash_djb2_one_float(_data._rect3->position[i], hash); hash = hash_djb2_one_float(_data._rect3->size[i], hash); } @@ -2710,11 +2642,6 @@ uint32_t Variant::hash() const { return hash_djb2_one_float(reinterpret_cast<const Color *>(_data._mem)->a, hash); } break; - case IMAGE: { - - return 0; - - } break; case _RID: { return hash_djb2_one_64(reinterpret_cast<const RID *>(_data._mem)->get_id()); @@ -2727,11 +2654,6 @@ uint32_t Variant::hash() const { return reinterpret_cast<const NodePath *>(_data._mem)->hash(); } break; - case INPUT_EVENT: { - - return hash_djb2_buffer((uint8_t *)_data._input_event, sizeof(InputEvent)); - - } break; case DICTIONARY: { return reinterpret_cast<const Dictionary *>(_data._mem)->hash(); @@ -2838,7 +2760,7 @@ uint32_t Variant::hash() const { } #define hash_compare_scalar(p_lhs, p_rhs) \ - ((p_lhs) == (p_rhs)) || (Math::is_nan(p_lhs) == Math::is_nan(p_rhs)) + ((p_lhs) == (p_rhs)) || (Math::is_nan(p_lhs) && Math::is_nan(p_rhs)) #define hash_compare_vector2(p_lhs, p_rhs) \ (hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \ @@ -2898,7 +2820,7 @@ bool Variant::hash_compare(const Variant &p_variant) const { const Rect2 *l = reinterpret_cast<const Rect2 *>(_data._mem); const Rect2 *r = reinterpret_cast<const Rect2 *>(p_variant._data._mem); - return (hash_compare_vector2(l->pos, r->pos)) && + return (hash_compare_vector2(l->position, r->position)) && (hash_compare_vector2(l->size, r->size)); } break; @@ -2933,7 +2855,7 @@ bool Variant::hash_compare(const Variant &p_variant) const { const Rect3 *l = _data._rect3; const Rect3 *r = p_variant._data._rect3; - return (hash_compare_vector3(l->pos, r->pos) && + return (hash_compare_vector3(l->position, r->position) && (hash_compare_vector3(l->size, r->size))); } break; |