public float GetSpeedMod(float a_startTime, MotionTimingPresets a_presets, IMxMAnim a_mxmAnim) { MotionPreset motionDef = null; if (a_presets != null) motionDef = a_presets.GetDefenition(MotionPresetId); if (motionDef == null || !UsePresets) //Raw { switch (ModType) { case EMotionModType.PlaybackSpeed: { return 1f / RawModValue; } case EMotionModType.Duration: { return RawModValue / ((EndTime - a_startTime)); } case EMotionModType.LinearSpeed: { if (a_mxmAnim != null) { float averageSpeedOriginal = a_mxmAnim.GetAverageRootSpeed(a_startTime, EndTime); return averageSpeedOriginal / RawModValue; } return 1f / RawModValue; } } } else //from Database { switch (motionDef.MotionType) { case EMotionModType.PlaybackSpeed: { return 1f / motionDef.MotionTiming; } case EMotionModType.Duration: { return motionDef.MotionTiming / (EndTime - a_startTime); } case EMotionModType.LinearSpeed: { if (a_mxmAnim != null) { float averageSpeedOriginal = a_mxmAnim.GetAverageRootSpeed(a_startTime, EndTime); return averageSpeedOriginal / motionDef.MotionTiming; } return 1f / motionDef.MotionTiming; } } } return RawModValue; }
//============================================================================================ /** * @brief * *********************************************************************************************/ public void AddDefenition(string a_name, float a_timing, EMotionModType a_motionType) { MotionPreset newDefenition = new MotionPreset(a_name, a_timing, a_motionType); m_defenitions.Add(newDefenition); EditorUtility.SetDirty(this); }
//============================================================================================ /** * @brief * *********************************************************************************************/ public void RemoveDefenition(MotionPreset a_defenition) { m_defenitions.Remove(a_defenition); EditorUtility.SetDirty(this); }