mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-10 22:49:49 +01:00
animationmgr: fixup stack-use-after-return
This commit is contained in:
parent
e06b520427
commit
b9f82e9968
3 changed files with 15 additions and 15 deletions
|
@ -43,14 +43,14 @@ void CBezierCurve::setup(std::vector<Vector2D>* pVec) {
|
||||||
ELAPSEDUS, ELAPSEDCALCAVG);
|
ELAPSEDUS, ELAPSEDCALCAVG);
|
||||||
}
|
}
|
||||||
|
|
||||||
float CBezierCurve::getXForT(float const& t) {
|
float CBezierCurve::getXForT(float const& t) const {
|
||||||
float t2 = t * t;
|
float t2 = t * t;
|
||||||
float t3 = t2 * t;
|
float t3 = t2 * t;
|
||||||
|
|
||||||
return 3 * t * (1 - t) * (1 - t) * m_vPoints[1].x + 3 * t2 * (1 - t) * m_vPoints[2].x + t3 * m_vPoints[3].x;
|
return 3 * t * (1 - t) * (1 - t) * m_vPoints[1].x + 3 * t2 * (1 - t) * m_vPoints[2].x + t3 * m_vPoints[3].x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CBezierCurve::getYForT(float const& t) {
|
float CBezierCurve::getYForT(float const& t) const {
|
||||||
float t2 = t * t;
|
float t2 = t * t;
|
||||||
float t3 = t2 * t;
|
float t3 = t2 * t;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ float CBezierCurve::getYForT(float const& t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Todo: this probably can be done better and faster
|
// Todo: this probably can be done better and faster
|
||||||
float CBezierCurve::getYForPoint(float const& x) {
|
float CBezierCurve::getYForPoint(float const& x) const {
|
||||||
if (x >= 1.f)
|
if (x >= 1.f)
|
||||||
return 1.f;
|
return 1.f;
|
||||||
if (x <= 0.f)
|
if (x <= 0.f)
|
||||||
|
|
|
@ -16,9 +16,9 @@ class CBezierCurve {
|
||||||
// this EXCLUDES the 0,0 and 1,1 points,
|
// this EXCLUDES the 0,0 and 1,1 points,
|
||||||
void setup(std::vector<Vector2D>* points);
|
void setup(std::vector<Vector2D>* points);
|
||||||
|
|
||||||
float getYForT(float const& t);
|
float getYForT(float const& t) const;
|
||||||
float getXForT(float const& t);
|
float getXForT(float const& t) const;
|
||||||
float getYForPoint(float const& x);
|
float getYForPoint(float const& x) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// this INCLUDES the 0,0 and 1,1 points.
|
// this INCLUDES the 0,0 and 1,1 points.
|
||||||
|
|
|
@ -156,9 +156,9 @@ void CAnimationManager::tick() {
|
||||||
// beziers are with a switch unforto
|
// beziers are with a switch unforto
|
||||||
// TODO: maybe do something cleaner
|
// TODO: maybe do something cleaner
|
||||||
|
|
||||||
static const auto updateVariable = [&]<Animable T>(CAnimatedVariable<T>& av) {
|
static const auto updateVariable = [this]<Animable T>(CAnimatedVariable<T>& av, const float SPENT, const CBezierCurve& DEFAULTBEZIER, const bool DISABLED) {
|
||||||
// for disabled anims just warp
|
// for disabled anims just warp
|
||||||
if (av.m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
|
if (av.m_pConfig->pValues->internalEnabled == 0 || DISABLED) {
|
||||||
av.warp(false);
|
av.warp(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ void CAnimationManager::tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto BEZIER = m_mBezierCurves.find(av.m_pConfig->pValues->internalBezier);
|
const auto BEZIER = m_mBezierCurves.find(av.m_pConfig->pValues->internalBezier);
|
||||||
const auto POINTY = BEZIER != m_mBezierCurves.end() ? BEZIER->second.getYForPoint(SPENT) : DEFAULTBEZIER->second.getYForPoint(SPENT);
|
const auto POINTY = BEZIER != m_mBezierCurves.end() ? BEZIER->second.getYForPoint(SPENT) : DEFAULTBEZIER.getYForPoint(SPENT);
|
||||||
|
|
||||||
const auto DELTA = av.m_Goal - av.m_Begun;
|
const auto DELTA = av.m_Goal - av.m_Begun;
|
||||||
|
|
||||||
|
@ -179,9 +179,9 @@ void CAnimationManager::tick() {
|
||||||
av.m_Value = av.m_Begun + DELTA * POINTY;
|
av.m_Value = av.m_Begun + DELTA * POINTY;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const auto updateColorVariable = [&](CAnimatedVariable<CHyprColor>& av) {
|
static const auto updateColorVariable = [this](CAnimatedVariable<CHyprColor>& av, const float SPENT, const CBezierCurve& DEFAULTBEZIER, const bool DISABLED) {
|
||||||
// for disabled anims just warp
|
// for disabled anims just warp
|
||||||
if (av.m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
|
if (av.m_pConfig->pValues->internalEnabled == 0 || DISABLED) {
|
||||||
av.warp(false);
|
av.warp(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ void CAnimationManager::tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto BEZIER = m_mBezierCurves.find(av.m_pConfig->pValues->internalBezier);
|
const auto BEZIER = m_mBezierCurves.find(av.m_pConfig->pValues->internalBezier);
|
||||||
const auto POINTY = BEZIER != m_mBezierCurves.end() ? BEZIER->second.getYForPoint(SPENT) : DEFAULTBEZIER->second.getYForPoint(SPENT);
|
const auto POINTY = BEZIER != m_mBezierCurves.end() ? BEZIER->second.getYForPoint(SPENT) : DEFAULTBEZIER.getYForPoint(SPENT);
|
||||||
|
|
||||||
// convert both to OkLab, then lerp that, and convert back.
|
// convert both to OkLab, then lerp that, and convert back.
|
||||||
// This is not as fast as just lerping rgb, but it's WAY more precise...
|
// This is not as fast as just lerping rgb, but it's WAY more precise...
|
||||||
|
@ -217,17 +217,17 @@ void CAnimationManager::tick() {
|
||||||
switch (av->m_Type) {
|
switch (av->m_Type) {
|
||||||
case AVARTYPE_FLOAT: {
|
case AVARTYPE_FLOAT: {
|
||||||
auto typedAv = dynamic_cast<CAnimatedVariable<float>*>(av);
|
auto typedAv = dynamic_cast<CAnimatedVariable<float>*>(av);
|
||||||
updateVariable(*typedAv);
|
updateVariable(*typedAv, SPENT, DEFAULTBEZIER->second, animationsDisabled);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AVARTYPE_VECTOR: {
|
case AVARTYPE_VECTOR: {
|
||||||
auto typedAv = dynamic_cast<CAnimatedVariable<Vector2D>*>(av);
|
auto typedAv = dynamic_cast<CAnimatedVariable<Vector2D>*>(av);
|
||||||
updateVariable(*typedAv);
|
updateVariable(*typedAv, SPENT, DEFAULTBEZIER->second, animationsDisabled);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AVARTYPE_COLOR: {
|
case AVARTYPE_COLOR: {
|
||||||
auto typedAv = dynamic_cast<CAnimatedVariable<CHyprColor>*>(av);
|
auto typedAv = dynamic_cast<CAnimatedVariable<CHyprColor>*>(av);
|
||||||
updateColorVariable(*typedAv);
|
updateColorVariable(*typedAv, SPENT, DEFAULTBEZIER->second, animationsDisabled);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: UNREACHABLE();
|
default: UNREACHABLE();
|
||||||
|
|
Loading…
Reference in a new issue