From 1a37504b0956ee428516c67383ebb21ce504d32d Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Mon, 22 Jun 2015 14:50:43 +0100 Subject: [PATCH] Add 'saw' motion function --- Source/Ember/EmberDefines.h | 2 +- Source/Ember/EmberToXml.h | 2 ++ Source/Ember/Interpolate.h | 6 +++++- Source/Ember/XmlToEmber.h | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/Ember/EmberDefines.h b/Source/Ember/EmberDefines.h index 534f3a6..cd619be 100644 --- a/Source/Ember/EmberDefines.h +++ b/Source/Ember/EmberDefines.h @@ -114,7 +114,7 @@ enum eInterp : uint { EMBER_INTERP_LINEAR = 0, EMBER_INTERP_SMOOTH = 1 }; enum eAffineInterp : uint { INTERP_LINEAR = 0, INTERP_LOG = 1, INTERP_COMPAT = 2, INTERP_OLDER = 3 }; enum ePaletteMode : uint { PALETTE_STEP = 0, PALETTE_LINEAR = 1 }; enum ePaletteInterp : uint { INTERP_HSV = 0, INTERP_SWEEP = 1 }; -enum eMotion : uint { MOTION_SIN = 1, MOTION_TRIANGLE = 2, MOTION_HILL = 3 }; +enum eMotion : uint { MOTION_SIN = 1, MOTION_TRIANGLE = 2, MOTION_HILL = 3, MOTION_SAW = 4 }; enum eProcessAction : uint { NOTHING = 0, ACCUM_ONLY = 1, FILTER_AND_ACCUM = 2, KEEP_ITERATING = 3, FULL_RENDER = 4 }; enum eProcessState : uint { NONE = 0, ITER_STARTED = 1, ITER_DONE = 2, FILTER_DONE = 3, ACCUM_DONE = 4 }; enum eInteractiveFilter : uint { FILTER_LOG = 0, FILTER_DE = 1 }; diff --git a/Source/Ember/EmberToXml.h b/Source/Ember/EmberToXml.h index 9d6cbf1..b1febdd 100644 --- a/Source/Ember/EmberToXml.h +++ b/Source/Ember/EmberToXml.h @@ -488,6 +488,8 @@ private: os << "motion_function=\"triangle\" "; else if (xform.m_MotionFunc== MOTION_HILL) os << "motion_function=\"hill\" "; + else if (xform.m_MotionFunc== MOTION_SAW) + os << "motion_function=\"saw\" "; } else { diff --git a/Source/Ember/Interpolate.h b/Source/Ember/Interpolate.h index 23b16d2..950ca86 100644 --- a/Source/Ember/Interpolate.h +++ b/Source/Ember/Interpolate.h @@ -883,10 +883,14 @@ public: return fr; } - else//MOTION_HILL + else if (funcNum == MOTION_HILL) { return ((1 - cos(T(2.0) * T(M_PI) * timeVal)) * T(0.5)); } + else //MOTION_SAW + { + return (T(2.0) * fmod(timeVal - T(0.5), T(1.0)) - T(1.0)); + } } /* diff --git a/Source/Ember/XmlToEmber.h b/Source/Ember/XmlToEmber.h index 07ea62f..0a92ab4 100644 --- a/Source/Ember/XmlToEmber.h +++ b/Source/Ember/XmlToEmber.h @@ -1073,6 +1073,8 @@ private: xform.m_MotionFunc = MOTION_TRIANGLE; else if (!_stricmp("hill", attStr)) xform.m_MotionFunc = MOTION_HILL; + else if (!_stricmp("saw", attStr)) + xform.m_MotionFunc = MOTION_SAW; else { xform.m_MotionFunc = MOTION_SIN;