bool ValueAnimation::SetKeyFrame(float time, const Variant& value) { if (valueType_ == VAR_NONE) SetValueType(value.GetType()); else if (value.GetType() != valueType_) return false; VAnimKeyFrame keyFrame; keyFrame.time_ = time; keyFrame.value_ = value; if (keyFrames_.Empty() || time > keyFrames_.Back().time_) keyFrames_.Push(keyFrame); else { for (unsigned i = 0; i < keyFrames_.Size(); ++i) { // Guard against interpolation error caused by division by error due to 0 delta time between two key frames if (time == keyFrames_[i].time_) return false; if (time < keyFrames_[i].time_) { keyFrames_.Insert(i, keyFrame); break; } } } beginTime_ = Min(time, beginTime_); endTime_ = Max(time, endTime_); splineTangentsDirty_ = true; return true; }
/** * Private constructor that initializes storage and the specifies the type of * value * that will be stored in this instance */ Value::Value(const ValueType type) { ::memset(m_data, 0, 16); SetValueType(type); m_sourceInlined = true; m_cleanUp = true; }
/** * Public constructor that initializes to an Value that is unusable * with other Values. Useful for declaring storage for an Value. */ Value::Value() { ::memset(m_data, 0, 16); SetValueType(VALUE_TYPE_INVALID); m_sourceInlined = true; m_cleanUp = true; }
/** * Private constructor that initializes storage and the specifies the type of * value * that will be stored in this instance */ Value::Value(const ValueType type) { PL_MEMSET(m_data, 0, 16); SetValueType(type); m_sourceInlined = true; m_cleanUp = true; }
/** * Public constructor that initializes to an Value that is unusable * with other Values. Useful for declaring storage for an Value. */ Value::Value() { PL_MEMSET(m_data, 0, 16); SetValueType(VALUE_TYPE_INVALID); m_sourceInlined = true; m_cleanUp = true; }