diff --git a/es-app/src/FileFilterIndex.cpp b/es-app/src/FileFilterIndex.cpp index 7042e509b..cb8afb7e3 100644 --- a/es-app/src/FileFilterIndex.cpp +++ b/es-app/src/FileFilterIndex.cpp @@ -11,7 +11,6 @@ #include "FileData.h" #include "Log.h" #include "Settings.h" -#include "math/Misc.h" #include "utils/StringUtil.h" #include "views/UIModeController.h" diff --git a/es-app/src/MiximageGenerator.cpp b/es-app/src/MiximageGenerator.cpp index 5f9b5bf5a..1d52a78a4 100644 --- a/es-app/src/MiximageGenerator.cpp +++ b/es-app/src/MiximageGenerator.cpp @@ -12,7 +12,6 @@ #include "Log.h" #include "Settings.h" #include "SystemData.h" -#include "math/Misc.h" #include "utils/StringUtil.h" #include @@ -564,11 +563,11 @@ void MiximageGenerator::calculateMarqueeSize(const unsigned int& targetWidth, // an approximately equivalent amount of space on the miximage. float widthRatio = static_cast(width) / static_cast(height); - widthModifier = Math::clamp(widthModifier + widthRatio / 6.5f, 0.0f, 1.0f); + widthModifier = glm::clamp(widthModifier + widthRatio / 6.5f, 0.0f, 1.0f); // Hack to increase the size slightly for wider and shorter images. if (widthRatio >= 4) - widthModifier += Math::clamp(widthRatio / 40.0f, 0.0f, 0.3f); + widthModifier += glm::clamp(widthRatio / 40.0f, 0.0f, 0.3f); adjustedTargetWidth = static_cast(static_cast(targetWidth) * widthModifier); @@ -620,9 +619,9 @@ void MiximageGenerator::sampleFrameColor(CImg& screenshotImage, } } - unsigned char redC = Math::clamp(static_cast(redLine / 255), 0, 255); - unsigned char greenC = Math::clamp(static_cast(greenLine / 255), 0, 255); - unsigned char blueC = Math::clamp(static_cast(blueLine / 255), 0, 255); + unsigned char redC = glm::clamp(static_cast(redLine / 255), 0, 255); + unsigned char greenC = glm::clamp(static_cast(greenLine / 255), 0, 255); + unsigned char blueC = glm::clamp(static_cast(blueLine / 255), 0, 255); // Convert to the HSL color space to be able to modify saturation and lightness. CImg colorHSL = CImg<>(1, 1, 1, 3).fill(redC, greenC, blueC).RGBtoHSL(); @@ -635,8 +634,8 @@ void MiximageGenerator::sampleFrameColor(CImg& screenshotImage, // makes the end result look better than the raw average pixel value. Also clamp // the lightness to a low value so we don't get a frame that is nearly pitch black // if the screenshot mostly contains blacks or dark colors. - colorHSL(0, 0, 0, 1) = Math::clamp(saturation * 0.9f, 0.0f, 1.0f); - colorHSL(0, 0, 0, 2) = Math::clamp(lightness * 1.25f, 0.10f, 1.0f); + colorHSL(0, 0, 0, 1) = glm::clamp(saturation * 0.9f, 0.0f, 1.0f); + colorHSL(0, 0, 0, 2) = glm::clamp(lightness * 1.25f, 0.10f, 1.0f); const CImg colorRGB = colorHSL.HSLtoRGB(); diff --git a/es-app/src/SystemScreensaver.cpp b/es-app/src/SystemScreensaver.cpp index f27d25b5a..8d7fe8c64 100644 --- a/es-app/src/SystemScreensaver.cpp +++ b/es-app/src/SystemScreensaver.cpp @@ -291,13 +291,13 @@ void SystemScreensaver::renderScreensaver() 0x00000000 | mRectangleFadeIn, 0x00000000 | mRectangleFadeIn); } mRectangleFadeIn = - Math::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170); + glm::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170); mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn); if (mTextFadeIn > 50) mGameOverlayFont.at(0)->renderTextCache(mGameOverlay.get()); if (mTextFadeIn < 255) - mTextFadeIn = Math::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255); + mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255); } } else { @@ -344,13 +344,13 @@ void SystemScreensaver::renderScreensaver() 0x00000000 | mRectangleFadeIn, 0x00000000 | mRectangleFadeIn); } mRectangleFadeIn = - Math::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170); + glm::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170); mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn); if (mTextFadeIn > 50) mGameOverlayFont.at(0)->renderTextCache(mGameOverlay.get()); if (mTextFadeIn < 255) - mTextFadeIn = Math::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255); + mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255); } } else { @@ -364,11 +364,11 @@ void SystemScreensaver::renderScreensaver() dimParameters.fragmentDimValue = mDimValue; Renderer::shaderPostprocessing(Renderer::SHADER_DIM, dimParameters); if (mDimValue > 0.4) - mDimValue = Math::clamp(mDimValue - 0.021f, 0.4f, 1.0f); + mDimValue = glm::clamp(mDimValue - 0.021f, 0.4f, 1.0f); dimParameters.fragmentSaturation = mSaturationAmount; Renderer::shaderPostprocessing(Renderer::SHADER_DESATURATE, dimParameters); if (mSaturationAmount > 0.0) - mSaturationAmount = Math::clamp(mSaturationAmount - 0.035f, 0.0f, 1.0f); + mSaturationAmount = glm::clamp(mSaturationAmount - 0.035f, 0.0f, 1.0f); #else Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000A0, 0x000000A0); @@ -380,7 +380,7 @@ void SystemScreensaver::renderScreensaver() blackParameters.fragmentDimValue = mDimValue; Renderer::shaderPostprocessing(Renderer::SHADER_DIM, blackParameters); if (mDimValue > 0.0) - mDimValue = Math::clamp(mDimValue - 0.045f, 0.0f, 1.0f); + mDimValue = glm::clamp(mDimValue - 0.045f, 0.0f, 1.0f); #else Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF, 0x000000FF); diff --git a/es-app/src/VolumeControl.cpp b/es-app/src/VolumeControl.cpp index 4019b7754..0b24ff75d 100644 --- a/es-app/src/VolumeControl.cpp +++ b/es-app/src/VolumeControl.cpp @@ -212,13 +212,13 @@ int VolumeControl::getVolume() const } #endif - volume = Math::clamp(volume, 0, 100); + volume = glm::clamp(volume, 0, 100); return volume; } void VolumeControl::setVolume(int volume) { - volume = Math::clamp(volume, 0, 100); + volume = glm::clamp(volume, 0, 100); #if defined(__linux__) if (mixerElem != nullptr) { diff --git a/es-app/src/animations/MoveCameraAnimation.h b/es-app/src/animations/MoveCameraAnimation.h index c402cb7ca..bfaef9155 100644 --- a/es-app/src/animations/MoveCameraAnimation.h +++ b/es-app/src/animations/MoveCameraAnimation.h @@ -27,9 +27,9 @@ public: void apply(float t) override { t -= 1; - cameraPosition[3].x = -Math::lerp(-mCameraStart[3].x, mTarget.x, t * t * t + 1); - cameraPosition[3].y = -Math::lerp(-mCameraStart[3].y, mTarget.y, t * t * t + 1); - cameraPosition[3].z = -Math::lerp(-mCameraStart[3].z, mTarget.z, t * t * t + 1); + cameraPosition[3].x = -glm::mix(-mCameraStart[3].x, mTarget.x, t * t * t + 1); + cameraPosition[3].y = -glm::mix(-mCameraStart[3].y, mTarget.y, t * t * t + 1); + cameraPosition[3].z = -glm::mix(-mCameraStart[3].z, mTarget.z, t * t * t + 1); } private: diff --git a/es-app/src/guis/GuiGameScraper.cpp b/es-app/src/guis/GuiGameScraper.cpp index b50676029..9c2a2e59d 100644 --- a/es-app/src/guis/GuiGameScraper.cpp +++ b/es-app/src/guis/GuiGameScraper.cpp @@ -103,7 +103,7 @@ GuiGameScraper::GuiGameScraper(Window* window, // Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is // the 16:9 reference. float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); - float width = Math::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth(); + float width = glm::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth(); setSize(width, Renderer::getScreenHeight() * 0.747f); setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f, diff --git a/es-app/src/guis/GuiLaunchScreen.cpp b/es-app/src/guis/GuiLaunchScreen.cpp index 3ec4434ba..8164ae9e6 100644 --- a/es-app/src/guis/GuiLaunchScreen.cpp +++ b/es-app/src/guis/GuiLaunchScreen.cpp @@ -12,7 +12,6 @@ #include "SystemData.h" #include "components/ComponentGrid.h" #include "components/TextComponent.h" -#include "math/Misc.h" #include "utils/StringUtil.h" GuiLaunchScreen::GuiLaunchScreen(Window* window) @@ -104,8 +103,8 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game) // reference. float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); - float maxWidthModifier = Math::clamp(0.78f * aspectValue, 0.78f, 0.90f); - float minWidthModifier = Math::clamp(0.50f * aspectValue, 0.50f, 0.65f); + float maxWidthModifier = glm::clamp(0.78f * aspectValue, 0.78f, 0.90f); + float minWidthModifier = glm::clamp(0.50f * aspectValue, 0.50f, 0.65f); float maxWidth = static_cast(Renderer::getScreenWidth()) * maxWidthModifier; float minWidth = static_cast(Renderer::getScreenWidth()) * minWidthModifier; @@ -119,7 +118,7 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game) // Add a bit of width to compensate for the left and right spacers. fontWidth += static_cast(Renderer::getScreenWidth()) * 0.05f; - float width = Math::clamp(fontWidth, minWidth, maxWidth); + float width = glm::clamp(fontWidth, minWidth, maxWidth); if (mImagePath != "") setSize(width, static_cast(Renderer::getScreenHeight()) * 0.60f); @@ -219,7 +218,7 @@ void GuiLaunchScreen::update(int deltaTime) if (Settings::getInstance()->getString("MenuOpeningEffect") == "none") mScaleUp = 1.0f; else if (mScaleUp < 1.0f) - mScaleUp = Math::clamp(mScaleUp + 0.07f, 0.0f, 1.0f); + mScaleUp = glm::clamp(mScaleUp + 0.07f, 0.0f, 1.0f); } void GuiLaunchScreen::render() diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index 7206d5492..441c23353 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -107,7 +107,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window, // Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is // the 16:9 reference. float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); - float width = Math::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth(); + float width = glm::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth(); setSize(width, Renderer::getScreenHeight() * 0.849f); setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f, diff --git a/es-app/src/scrapers/ScreenScraper.cpp b/es-app/src/scrapers/ScreenScraper.cpp index 252388518..afdb9ea00 100644 --- a/es-app/src/scrapers/ScreenScraper.cpp +++ b/es-app/src/scrapers/ScreenScraper.cpp @@ -14,7 +14,6 @@ #include "PlatformId.h" #include "Settings.h" #include "SystemData.h" -#include "math/Misc.h" #include "utils/StringUtil.h" #include "utils/TimeUtil.h" diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 916ac0526..24dc2dd99 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -315,7 +315,7 @@ void SystemView::onCursorChanged(const CursorState& /*state*/) anim = new LambdaAnimation( [this, startExtrasFade, startPos, endPos, posMax](float t) { t -= 1; - float f = Math::lerp(startPos, endPos, t * t * t + 1); + float f = glm::mix(startPos, endPos, t * t * t + 1); if (f < 0) f += posMax; if (f >= posMax) @@ -325,11 +325,13 @@ void SystemView::onCursorChanged(const CursorState& /*state*/) t += 1; if (t < 0.3f) - this->mExtrasFadeOpacity = Math::lerp(0.0f, 1.0f, t / 0.2f + startExtrasFade); + this->mExtrasFadeOpacity = + glm::mix(0.0f, 1.0f, glm::clamp(t / 0.2f + startExtrasFade, 0.0f, 1.0f)); else if (t < 0.7f) this->mExtrasFadeOpacity = 1.0f; else - this->mExtrasFadeOpacity = Math::lerp(1.0f, 0.0f, (t - 0.6f) / 0.3f); + this->mExtrasFadeOpacity = + glm::mix(1.0f, 0.0f, glm::clamp((t - 0.6f) / 0.3f, 0.0f, 1.0f)); if (t > 0.5f) this->mExtrasCamOffset = endPos; @@ -345,7 +347,7 @@ void SystemView::onCursorChanged(const CursorState& /*state*/) anim = new LambdaAnimation( [this, startPos, endPos, posMax](float t) { t -= 1; - float f = Math::lerp(startPos, endPos, t * t * t + 1); + float f = glm::mix(startPos, endPos, t * t * t + 1); if (f < 0) f += posMax; if (f >= posMax) @@ -381,7 +383,7 @@ void SystemView::onCursorChanged(const CursorState& /*state*/) anim = new LambdaAnimation( [this, startPos, endPos, posMax](float t) { t -= 1; - float f = Math::lerp(startPos, endPos, t * t * t + 1); + float f = glm::mix(startPos, endPos, t * t * t + 1); if (f < 0) f += posMax; if (f >= posMax) diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index e4c337335..11640dac8 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -561,7 +561,7 @@ void ViewController::playViewTransition(bool instant) // Without this, a (much shorter) fade transition would still play as // finishedCallback is calling this function. if (!mCancelledTransition) - mFadeOpacity = Math::lerp(0.0f, 1.0f, t); + mFadeOpacity = glm::mix(0.0f, 1.0f, t); }; auto fadeCallback = [this]() { diff --git a/es-app/src/views/gamelist/DetailedGameListView.cpp b/es-app/src/views/gamelist/DetailedGameListView.cpp index cb18d2921..56a11c6b5 100644 --- a/es-app/src/views/gamelist/DetailedGameListView.cpp +++ b/es-app/src/views/gamelist/DetailedGameListView.cpp @@ -384,7 +384,7 @@ void DetailedGameListView::updateInfoPanel() // Fade in the game image. auto func = [this](float t) { mImage.setOpacity(static_cast( - Math::lerp(static_cast(FADE_IN_START_OPACITY), 1.0f, t) * 255)); + glm::mix(static_cast(FADE_IN_START_OPACITY), 1.0f, t) * 255)); }; mImage.setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false); @@ -432,7 +432,7 @@ void DetailedGameListView::updateInfoPanel() if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) || (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) { auto func = [comp](float t) { - comp->setOpacity(static_cast(Math::lerp(0.0f, 1.0f, t) * 255)); + comp->setOpacity(static_cast(glm::mix(0.0f, 1.0f, t) * 255)); }; comp->setAnimation(new LambdaAnimation(func, 150), 0, nullptr, fadingOut); } diff --git a/es-app/src/views/gamelist/GridGameListView.cpp b/es-app/src/views/gamelist/GridGameListView.cpp index 5744575f3..1d59d6c2a 100644 --- a/es-app/src/views/gamelist/GridGameListView.cpp +++ b/es-app/src/views/gamelist/GridGameListView.cpp @@ -444,7 +444,7 @@ void GridGameListView::updateInfoPanel() // Fade in the game image. auto func = [this](float t) { mImage.setOpacity(static_cast( - Math::lerp(static_cast(FADE_IN_START_OPACITY), 1.0f, t) * 255)); + glm::mix(static_cast(FADE_IN_START_OPACITY), 1.0f, t) * 255)); }; mImage.setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false); @@ -492,7 +492,7 @@ void GridGameListView::updateInfoPanel() (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) { auto func = [comp](float t) { // TEMPORARY - This does not seem to work, needs to be reviewed later. - // comp->setOpacity(static_cast(Math::lerp(0.0f, 1.0f, t) * 255)); + // comp->setOpacity(static_cast(glm::mix(0.0f, 1.0f, t) * 255)); }; comp->setAnimation(new LambdaAnimation(func, 150), 0, nullptr, fadingOut); } diff --git a/es-app/src/views/gamelist/VideoGameListView.cpp b/es-app/src/views/gamelist/VideoGameListView.cpp index 6f986f995..49547b409 100644 --- a/es-app/src/views/gamelist/VideoGameListView.cpp +++ b/es-app/src/views/gamelist/VideoGameListView.cpp @@ -424,7 +424,7 @@ void VideoGameListView::updateInfoPanel() // Fade in the game image. auto func = [this](float t) { mVideo->setOpacity(static_cast( - Math::lerp(static_cast(FADE_IN_START_OPACITY), 1.0f, t) * 255)); + glm::mix(static_cast(FADE_IN_START_OPACITY), 1.0f, t) * 255)); }; mVideo->setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false); @@ -472,7 +472,7 @@ void VideoGameListView::updateInfoPanel() if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) || (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) { auto func = [comp](float t) { - comp->setOpacity(static_cast(Math::lerp(0.0f, 1.0f, t) * 255)); + comp->setOpacity(static_cast(glm::mix(0.0f, 1.0f, t) * 255)); }; comp->setAnimation(new LambdaAnimation(func, 200), 0, nullptr, fadingOut); } diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index ce506cc2d..08da19546 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -13,7 +13,6 @@ #include "HelpStyle.h" #include "InputConfig.h" #include "animations/AnimationController.h" -#include "math/Misc.h" #include #include diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 352ba08f5..d7844cccc 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -18,7 +18,6 @@ #include "InputManager.h" #include "Log.h" #include "Sound.h" -#include "math/Misc.h" #include "resources/Font.h" #include @@ -465,7 +464,7 @@ void Window::render() if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") { mBackgroundOverlay->setOpacity(mBackgroundOverlayOpacity); if (mBackgroundOverlayOpacity < 255) - mBackgroundOverlayOpacity = Math::clamp(mBackgroundOverlayOpacity + 30, 0, 255); + mBackgroundOverlayOpacity = glm::clamp(mBackgroundOverlayOpacity + 30, 0, 255); } #endif // USE_OPENGL_21 @@ -474,7 +473,7 @@ void Window::render() // Scale-up menu opening effect. if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") { if (mTopScale < 1.0f) { - mTopScale = Math::clamp(mTopScale + 0.07f, 0.0f, 1.0f); + mTopScale = glm::clamp(mTopScale + 0.07f, 0.0f, 1.0f); glm::vec2 topCenter{top->getCenter()}; top->setOrigin({0.5f, 0.5f}); top->setPosition({topCenter.x, topCenter.y, 0.0f}); diff --git a/es-core/src/components/GridTileComponent.cpp b/es-core/src/components/GridTileComponent.cpp index 903520aaf..dbe914da5 100644 --- a/es-core/src/components/GridTileComponent.cpp +++ b/es-core/src/components/GridTileComponent.cpp @@ -190,7 +190,7 @@ void GridTileComponent::setSelected(bool selected, auto func = [this](float t) { t -= 1; - float pct = Math::lerp(0, 1, t * t * t + 1); + float pct = glm::mix(0.0f, 1.0f, t * t * t + 1.0f); this->setSelectedZoom(pct); }; @@ -216,7 +216,7 @@ void GridTileComponent::setSelected(bool selected, auto func = [this](float t) { t -= 1.0f; - float pct = Math::lerp(0, 1, t * t * t + 1.0f); + float pct = glm::mix(0.0f, 1.0f, t * t * t + 1.0f); this->setSelectedZoom(1.0f - pct); }; diff --git a/es-core/src/components/ImageGridComponent.h b/es-core/src/components/ImageGridComponent.h index 77ab6998b..9abbc8531 100644 --- a/es-core/src/components/ImageGridComponent.h +++ b/es-core/src/components/ImageGridComponent.h @@ -505,7 +505,7 @@ template void ImageGridComponent::onCursorChanged(const CursorSt return; t -= 1.0f; - float pct = Math::lerp(0, 1.0f, t * t * t + 1.0f); + float pct = glm::mix(0.0f, 1.0f, t * t * t + 1.0f); t = startPos * (1.0f - pct) + endPos * pct; mCamera = t; }; diff --git a/es-core/src/components/NinePatchComponent.cpp b/es-core/src/components/NinePatchComponent.cpp index 9d4abbde4..a90d52cb1 100644 --- a/es-core/src/components/NinePatchComponent.cpp +++ b/es-core/src/components/NinePatchComponent.cpp @@ -55,9 +55,9 @@ void NinePatchComponent::buildVertices() // (e.g. from 720p to 4K) will be within these boundaries though. float scaleFactor; if (Renderer::getScreenWidth() > Renderer::getScreenHeight()) - scaleFactor = Math::clamp(Renderer::getScreenHeightModifier(), 0.4f, 3.0f); + scaleFactor = glm::clamp(Renderer::getScreenHeightModifier(), 0.4f, 3.0f); else - scaleFactor = Math::clamp(Renderer::getScreenWidthModifier(), 0.4f, 3.0f); + scaleFactor = glm::clamp(Renderer::getScreenWidthModifier(), 0.4f, 3.0f); mTexture = TextureResource::get(mPath, false, false, true, scaleFactor); @@ -79,6 +79,7 @@ void NinePatchComponent::buildVertices() // The "1 +" in posY and "-" in sizeY is to deal with texture coordinates having a bottom // left corner origin vs. verticies having a top left origin. + // clang-format off const float texSizeX[3]{mCornerSize.x / texSize.x, (texSize.x - mCornerSize.x * 2.0f) / texSize.x, mCornerSize.x / texSize.x}; const float texSizeY[3]{-mCornerSize.y / texSize.y, -(texSize.y - mCornerSize.y * 2.0f) / texSize.y, -mCornerSize.y / texSize.y}; @@ -150,8 +151,8 @@ void NinePatchComponent::fitTo(glm::vec2 size, glm::vec3 position, glm::vec2 pad position[1] -= padding.y / 2.0f; setSize(size + mCornerSize * 2.0f); - setPosition(position.x + Math::lerp(-mCornerSize.x, mCornerSize.x, mOrigin.x), - position.y + Math::lerp(-mCornerSize.y, mCornerSize.y, mOrigin.y)); + setPosition(position.x + glm::mix(-mCornerSize.x, mCornerSize.x, mOrigin.x), + position.y + glm::mix(-mCornerSize.y, mCornerSize.y, mOrigin.y)); } void NinePatchComponent::setImagePath(const std::string& path) diff --git a/es-core/src/components/ScrollableContainer.cpp b/es-core/src/components/ScrollableContainer.cpp index 53c5e436d..8a342a641 100644 --- a/es-core/src/components/ScrollableContainer.cpp +++ b/es-core/src/components/ScrollableContainer.cpp @@ -134,7 +134,7 @@ void ScrollableContainer::update(int deltaTime) if (mAutoScrollResetAccumulator >= static_cast(mAutoScrollResetDelayConstant)) { // Fade in the text as it resets to the start position. auto func = [this](float t) { - this->setOpacity(static_cast(Math::lerp(0.0f, 1.0f, t) * 255)); + this->setOpacity(static_cast(glm::mix(0.0f, 1.0f, t) * 255)); mScrollPos = glm::vec2{}; mAutoScrollResetAccumulator = 0; mAutoScrollAccumulator = -mAutoScrollDelay + mAutoScrollSpeed; diff --git a/es-core/src/components/TextListComponent.h b/es-core/src/components/TextListComponent.h index 670c7b4ae..3f99b0143 100644 --- a/es-core/src/components/TextListComponent.h +++ b/es-core/src/components/TextListComponent.h @@ -12,7 +12,6 @@ #include "Log.h" #include "Sound.h" #include "components/IList.h" -#include "math/Misc.h" #include "resources/Font.h" #include "utils/StringUtil.h" diff --git a/es-core/src/components/VideoComponent.cpp b/es-core/src/components/VideoComponent.cpp index 3e4cb1700..78f6261dd 100644 --- a/es-core/src/components/VideoComponent.cpp +++ b/es-core/src/components/VideoComponent.cpp @@ -275,15 +275,15 @@ void VideoComponent::update(int deltaTime) // Fade in videos, the time period is a bit different between the screensaver, // media viewer and gamelist view. if (mScreensaverMode && mFadeIn < 1.0f) { - mFadeIn = Math::clamp(mFadeIn + (deltaTime / static_cast(SCREENSAVER_FADE_IN_TIME)), - 0.0f, 1.0f); + mFadeIn = glm::clamp(mFadeIn + (deltaTime / static_cast(SCREENSAVER_FADE_IN_TIME)), + 0.0f, 1.0f); } else if (mMediaViewerMode && mFadeIn < 1.0f) { - mFadeIn = Math::clamp(mFadeIn + (deltaTime / static_cast(MEDIA_VIEWER_FADE_IN_TIME)), - 0.0f, 1.0f); + mFadeIn = glm::clamp(mFadeIn + (deltaTime / static_cast(MEDIA_VIEWER_FADE_IN_TIME)), + 0.0f, 1.0f); } else if (mFadeIn < 1.0f) { - mFadeIn = Math::clamp(mFadeIn + 0.01f, 0.0f, 1.0f); + mFadeIn = glm::clamp(mFadeIn + 0.01f, 0.0f, 1.0f); } GuiComponent::update(deltaTime); diff --git a/es-core/src/guis/GuiComplexTextEditPopup.cpp b/es-core/src/guis/GuiComplexTextEditPopup.cpp index 15f16b781..802f544ee 100644 --- a/es-core/src/guis/GuiComplexTextEditPopup.cpp +++ b/es-core/src/guis/GuiComplexTextEditPopup.cpp @@ -91,8 +91,8 @@ GuiComplexTextEditPopup::GuiComplexTextEditPopup( // Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent // regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference. float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); - float infoWidth = Math::clamp(0.70f * aspectValue, 0.60f, 0.85f) * Renderer::getScreenWidth(); - float windowWidth = Math::clamp(0.75f * aspectValue, 0.65f, 0.90f) * Renderer::getScreenWidth(); + float infoWidth = glm::clamp(0.70f * aspectValue, 0.60f, 0.85f) * Renderer::getScreenWidth(); + float windowWidth = glm::clamp(0.75f * aspectValue, 0.65f, 0.90f) * Renderer::getScreenWidth(); mText->setSize(0, textHeight); mInfoString2->setSize(infoWidth, mInfoString2->getFont()->getHeight()); diff --git a/es-core/src/guis/GuiDetectDevice.cpp b/es-core/src/guis/GuiDetectDevice.cpp index 8159f9bb2..b2f4b51b0 100644 --- a/es-core/src/guis/GuiDetectDevice.cpp +++ b/es-core/src/guis/GuiDetectDevice.cpp @@ -85,7 +85,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window, // Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent // regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference. float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); - float width = Math::clamp(0.60f * aspectValue, 0.50f, 0.80f) * Renderer::getScreenWidth(); + float width = glm::clamp(0.60f * aspectValue, 0.50f, 0.80f) * Renderer::getScreenWidth(); setSize(width, Renderer::getScreenHeight() * 0.5f); setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f, diff --git a/es-core/src/guis/GuiInputConfig.cpp b/es-core/src/guis/GuiInputConfig.cpp index cac72bc45..78c212051 100644 --- a/es-core/src/guis/GuiInputConfig.cpp +++ b/es-core/src/guis/GuiInputConfig.cpp @@ -189,7 +189,7 @@ GuiInputConfig::GuiInputConfig(Window* window, // Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent // regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference. float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); - float width = Math::clamp(0.60f * aspectValue, 0.50f, 0.80f) * Renderer::getScreenWidth(); + float width = glm::clamp(0.60f * aspectValue, 0.50f, 0.80f) * Renderer::getScreenWidth(); setSize(width, Renderer::getScreenHeight() * 0.75f); setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f, diff --git a/es-core/src/guis/GuiMsgBox.cpp b/es-core/src/guis/GuiMsgBox.cpp index fa7dc2823..22261cfc4 100644 --- a/es-core/src/guis/GuiMsgBox.cpp +++ b/es-core/src/guis/GuiMsgBox.cpp @@ -37,9 +37,9 @@ GuiMsgBox::GuiMsgBox(Window* window, float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); float width = - floorf(Math::clamp(0.60f * aspectValue, 0.60f, 0.80f) * Renderer::getScreenWidth()); + floorf(glm::clamp(0.60f * aspectValue, 0.60f, 0.80f) * Renderer::getScreenWidth()); float minWidth = - floorf(Math::clamp(0.30f * aspectValue, 0.10f, 0.50f) * Renderer::getScreenWidth()); + floorf(glm::clamp(0.30f * aspectValue, 0.10f, 0.50f) * Renderer::getScreenWidth()); mMsg = std::make_shared(mWindow, text, Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); @@ -110,7 +110,7 @@ void GuiMsgBox::changeText(const std::string& newText) float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); float width = - floorf(Math::clamp(0.60f * aspectValue, 0.60f, 0.80f) * Renderer::getScreenWidth()); + floorf(glm::clamp(0.60f * aspectValue, 0.60f, 0.80f) * Renderer::getScreenWidth()); float minWidth = Renderer::getScreenWidth() * 0.3f; // Decide final width. diff --git a/es-core/src/guis/GuiTextEditPopup.cpp b/es-core/src/guis/GuiTextEditPopup.cpp index ffadf4ed7..d5f832a7c 100644 --- a/es-core/src/guis/GuiTextEditPopup.cpp +++ b/es-core/src/guis/GuiTextEditPopup.cpp @@ -67,7 +67,7 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window, // Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent // regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference. float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); - float width = Math::clamp(0.50f * aspectValue, 0.40f, 0.70f) * Renderer::getScreenWidth(); + float width = glm::clamp(0.50f * aspectValue, 0.40f, 0.70f) * Renderer::getScreenWidth(); setSize(width, mTitle->getFont()->getHeight() + textHeight + mButtonGrid->getSize().y + mButtonGrid->getSize().y / 2.0f); diff --git a/es-core/src/resources/TextureData.cpp b/es-core/src/resources/TextureData.cpp index 58b114c4e..32a301a15 100644 --- a/es-core/src/resources/TextureData.cpp +++ b/es-core/src/resources/TextureData.cpp @@ -13,7 +13,6 @@ #include "ImageIO.h" #include "Log.h" -#include "math/Misc.h" #include "renderers/Renderer.h" #include "resources/ResourceManager.h"