mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Updated the built-in Math::clamp() argument order to behave as the C++17 std::clamp().
This commit is contained in:
parent
cbe86909f6
commit
a6c8f8034e
|
@ -151,7 +151,8 @@ void VideoVlcComponent::render(const Transform4x4f& parentTrans)
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
if (mIsPlaying && mContext.valid) {
|
if (mIsPlaying && mContext.valid) {
|
||||||
const unsigned int fadeIn = (unsigned int)(Math::clamp(0.0f, mFadeIn, 1.0f) * 255.0f);
|
// This fade in is only used by the video screensaver.
|
||||||
|
const unsigned int fadeIn = (unsigned int)(Math::clamp(mFadeIn, 0.0f, 1.0f) * 255.0f);
|
||||||
const unsigned int color =
|
const unsigned int color =
|
||||||
Renderer::convertColor((fadeIn << 24) | (fadeIn << 16) | (fadeIn << 8) | 255);
|
Renderer::convertColor((fadeIn << 24) | (fadeIn << 16) | (fadeIn << 8) | 255);
|
||||||
Renderer::Vertex vertices[4];
|
Renderer::Vertex vertices[4];
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace Math
|
||||||
return (_num1 > _num2) ? _num1 : _num2;
|
return (_num1 > _num2) ? _num1 : _num2;
|
||||||
}
|
}
|
||||||
|
|
||||||
float clamp(const float _min, const float _max, const float _num)
|
float clamp(const float _num, const float _min, const float _max)
|
||||||
{
|
{
|
||||||
return max(min(_num, _max), _min);
|
return max(min(_num, _max), _min);
|
||||||
}
|
}
|
||||||
|
@ -63,18 +63,18 @@ namespace Math
|
||||||
|
|
||||||
float lerp(const float _start, const float _end, const float _fraction)
|
float lerp(const float _start, const float _end, const float _fraction)
|
||||||
{
|
{
|
||||||
return (_start + ((_end - _start) * clamp(0, 1, _fraction)));
|
return (_start + ((_end - _start) * clamp(_fraction, 0, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
float smoothStep(const float _left, const float _right, const float _x)
|
float smoothStep(const float _left, const float _right, const float _x)
|
||||||
{
|
{
|
||||||
const float x = clamp(0, 1, (_x - _left)/(_right - _left));
|
const float x = clamp((_x - _left)/(_right - _left), 0, 1);
|
||||||
return x * x * (3 - (2 * x));
|
return x * x * (3 - (2 * x));
|
||||||
}
|
}
|
||||||
|
|
||||||
float smootherStep(const float _left, const float _right, const float _x)
|
float smootherStep(const float _left, const float _right, const float _x)
|
||||||
{
|
{
|
||||||
const float x = clamp(0, 1, (_x - _left)/(_right - _left));
|
const float x = clamp((_x - _left)/(_right - _left), 0, 1);
|
||||||
return x * x * x * (x * ((x * 6) - 15) + 10);
|
return x * x * x * (x * ((x * 6) - 15) + 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue