From 74f11eb70b5692eb1b0bca523cf709ab39250747 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 2 Aug 2016 10:50:31 -0700 Subject: [PATCH] try a different easing function --- libraries/render-utils/src/MeshPartPayload.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index 9f107bd3e1..63068f7796 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -353,9 +353,13 @@ void ModelMeshPartPayload::initCache() { } float ModelMeshPartPayload::calculateFadeRatio() const { - const float FADE_TIME = 0.5f; - float t = std::min(((float)(usecTimestampNow() - _fadeStartTime)) / ((float)(FADE_TIME * USECS_PER_SECOND)), 1.0f); - return -(cosf((float)M_PI_2 * t) - 1.0f); + const float FADE_TIME = 1.0f; + float t = 2.0f * std::min(((float)(usecTimestampNow() - _fadeStartTime)) / ((float)(FADE_TIME * USECS_PER_SECOND)), 1.0f); + float fadeRatio = (t < 1.0f) ? 0.5f * powf(2.0f, 10.0f * (t - 1.0f)) : 0.5f * (-pow(2.0f, -10.0f * (t - 1.0f)) + 2.0f); + + // The easing function isn't exactly 1 at t = 2, so we need to scale the whole function up slightly + const float EASING_SCALE = 1.001f; + return std::min(EASING_SCALE * fadeRatio, 1.0f); } void ModelMeshPartPayload::notifyLocationChanged() {