From 391ce81c5ea037ffcbc525434673f4edd55a7d7e Mon Sep 17 00:00:00 2001 From: Josh Grams Date: Wed, 17 Feb 2016 22:34:49 -0500 Subject: AnimationTreePlayer: blend value tracks (closes #2299) Variant: - zero() sets a Variant to the appropriate type of zero value - blend() blends part of one Variant on top of another. --- core/variant.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'core/variant.cpp') diff --git a/core/variant.cpp b/core/variant.cpp index 3bd8d80528..1fdbc9f753 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1115,6 +1115,21 @@ void Variant::reference(const Variant& p_variant) { } +} +void Variant::zero() { + switch(type) { + case NIL: break; + case BOOL: this->_data._bool = false; break; + case INT: this->_data._int = 0; break; + case REAL: this->_data._real = 0; break; + case VECTOR2: *reinterpret_cast(this->_data._mem) = Vector2(); break; + case RECT2: *reinterpret_cast(this->_data._mem) = Rect2(); break; + case VECTOR3: *reinterpret_cast(this->_data._mem) = Vector3(); break; + case PLANE: *reinterpret_cast(this->_data._mem) = Plane(); break; + case QUAT: *reinterpret_cast(this->_data._mem) = Quat(); break; + case COLOR: *reinterpret_cast(this->_data._mem) = Color(); break; + default: this->clear(); break; + } } void Variant::clear() { -- cgit v1.2.3