From 0a2c440a773831883b75ce909903345b61ce8caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 16 Oct 2017 08:41:05 -0700 Subject: [PATCH] Added step and smoothstep. --- include/bx/easing.h | 55 ++++++++++++++++++++++++++++++++++++ include/bx/inline/easing.inl | 10 +++++++ src/easing.cpp | 2 ++ 3 files changed, 67 insertions(+) diff --git a/include/bx/easing.h b/include/bx/easing.h index 5c34918..9684903 100644 --- a/include/bx/easing.h +++ b/include/bx/easing.h @@ -20,6 +20,8 @@ namespace bx enum Enum { Linear, + Step, + SmoothStep, InQuad, OutQuad, InOutQuad, @@ -97,6 +99,57 @@ namespace bx /// float easeLinear(float _t); + /// Step. + /// + /// ^ + /// | + /// | + /// | + /// | + /// | ******************************** + /// | + /// | + /// | + /// | + /// | + /// | + /// | + /// | + /// | + /// +********************************--------------------------------> + /// | + /// | + /// | + /// | + /// | + /// + float easeStep(float _t); + + /// Smooth step. + /// + /// | + /// | + /// | + /// | + /// | + /// | ************* + /// | ******* + /// | ****** + /// | ***** + /// | ***** + /// | ***** + /// | ***** + /// | ****** + /// | ******* + /// +*************---------------------------------------------------> + /// | + /// | + /// | + /// | + /// | + /// + float easeSmoothStep(float _t); + /// Quad. /// /// ^ @@ -1137,6 +1190,8 @@ namespace bx /// float easeOutInBounce(float _t); + float easeInOutLinear(float _t); + } // namespace bx #include "inline/easing.inl" diff --git a/include/bx/inline/easing.inl b/include/bx/inline/easing.inl index a422d73..d1e64ed 100644 --- a/include/bx/inline/easing.inl +++ b/include/bx/inline/easing.inl @@ -29,6 +29,16 @@ namespace bx return _t; } + inline float easeStep(float _t) + { + return _t < 0.5f ? 0.0f : 1.0f; + } + + inline float easeSmoothStep(float _t) + { + return fsq(_t)*(3.0f - 2.0f*_t); + } + inline float easeInQuad(float _t) { return fsq(_t); diff --git a/src/easing.cpp b/src/easing.cpp index 1f82fce..2c37025 100644 --- a/src/easing.cpp +++ b/src/easing.cpp @@ -10,6 +10,8 @@ namespace bx static const EaseFn s_easeFunc[] = { easeLinear, + easeStep, + easeSmoothStep, easeInQuad, easeOutQuad, easeInOutQuad,