From 6cd399820567c412dbbc82aaa30a2484f45e792b Mon Sep 17 00:00:00 2001 From: Patric Schmitz <bzk0711@aol.com> Date: Thu, 7 Mar 2024 13:06:55 +0100 Subject: [PATCH] allow zero camera smoothing, more assertions API change: rename to *SmoothingHalfTimeMillis --- viewer/glow-extras/viewer/CameraController.cc | 12 ++++++++++-- viewer/glow-extras/viewer/CameraController.hh | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/viewer/glow-extras/viewer/CameraController.cc b/viewer/glow-extras/viewer/CameraController.cc index b20c28ef..d09602f5 100644 --- a/viewer/glow-extras/viewer/CameraController.cc +++ b/viewer/glow-extras/viewer/CameraController.cc @@ -337,9 +337,17 @@ void CameraController::update(float elapsedSeconds) mRight = normalize(cross(mFwd, mUp)); mUp = normalize(cross(mRight, mFwd)); + TG_ASSERT(s.TranslationalSmoothingHalfTimeMillis >= 0); + TG_ASSERT(s.RotationalSmoothingHalfTimeMillis >= 0); + // smoothing - auto alphaTranslational = tg::pow(0.5f, 1000 * elapsedSeconds / s.TranslationalSmoothingHalfTime); - auto alphaRotational = tg::pow(0.5f, 1000 * elapsedSeconds / s.RotationalSmoothingHalfTime); + auto alphaTranslational = 0.f; + auto alphaRotational = 0.f; + if (s.TranslationalSmoothingHalfTimeMillis > 0) + alphaTranslational = tg::pow(0.5f, 1000 * elapsedSeconds / s.TranslationalSmoothingHalfTimeMillis); + if (s.RotationalSmoothingHalfTimeMillis > 0) + alphaRotational = tg::pow(0.5f, 1000 * elapsedSeconds / s.RotationalSmoothingHalfTimeMillis); + mSmoothedTargetDistance = tg::mix(mTargetDistance, mSmoothedTargetDistance, alphaTranslational); mSmoothedTargetPos = mix(mTargetPos, mSmoothedTargetPos, alphaTranslational); mSmoothedPos = mix(mPos, mSmoothedPos, alphaTranslational); diff --git a/viewer/glow-extras/viewer/CameraController.hh b/viewer/glow-extras/viewer/CameraController.hh index e5bcef53..a3c2592c 100644 --- a/viewer/glow-extras/viewer/CameraController.hh +++ b/viewer/glow-extras/viewer/CameraController.hh @@ -16,8 +16,8 @@ struct CameraSettings tg::angle NumpadRotateDegree = 30_deg; // smoothing halftimes in ms - float TranslationalSmoothingHalfTime = 40; - float RotationalSmoothingHalfTime = 30; + float TranslationalSmoothingHalfTimeMillis = 40; + float RotationalSmoothingHalfTimeMillis = 30; float FocusRefDistance = 30 * 1000; -- GitLab