Permalink
Browse files

engine: use a single intensity parameter in ChaserRunner

Fix switch between manual/automatic crossfade. Function fade out time was not restored.
  • Loading branch information...
mcallegari committed Dec 15, 2018
1 parent 2d1379c commit 94f684fa1071469e0f557519c07c590ec4571adb
@@ -42,7 +42,6 @@ ChaserRunner::ChaserRunner(const Doc *doc, const Chaser *chaser, quint32 startTi
, m_lastRunStepIdx(-1)
, m_roundTime(new QElapsedTimer())
, m_order()
, m_intensity(1.0)
{
Q_ASSERT(chaser != NULL);

@@ -422,10 +421,9 @@ void ChaserRunner::adjustStepIntensity(qreal fraction, int requestedStepIndex, i
if (stepIndex == -1)
{
stepIndex = m_lastRunStepIdx;
// stepIndex == -1 means that the "global" intensity
// of the chaser has to be changed
m_intensity = fraction;
m_pendingAction.m_intensity = 1.0;
// store the intensity to be applied
// at the next step startup
m_pendingAction.m_intensity = fraction;
}

foreach(ChaserRunnerStep *step, m_runnerSteps)
@@ -460,8 +458,9 @@ void ChaserRunner::clearRunningList()
{
if (step->m_function)
{
// restore the original Function blend mode
// restore the original Function blend mode and fade out time
step->m_function->setBlendMode(step->m_blendMode);
step->m_function->setOverrideFadeOutSpeed(stepFadeOut(step->m_index));
step->m_function->stop(functionParent());
}
delete step;
@@ -694,7 +693,7 @@ bool ChaserRunner::write(MasterTimer *timer, QList<Universe *> universes)
clearRunningList();
m_lastRunStepIdx = m_pendingAction.m_stepIndex;
qDebug() << "Starting from step" << m_lastRunStepIdx << "@ offset" << m_startOffset;
startNewStep(m_lastRunStepIdx, timer, m_intensity * m_pendingAction.m_intensity, m_pendingAction.m_fadeMode);
startNewStep(m_lastRunStepIdx, timer, m_pendingAction.m_intensity, m_pendingAction.m_fadeMode);
emit currentStepChanged(m_lastRunStepIdx);
}
break;
@@ -749,9 +748,8 @@ bool ChaserRunner::write(MasterTimer *timer, QList<Universe *> universes)
if (m_lastRunStepIdx != -1)
{
int blend = m_pendingAction.m_action == ChaserNoAction ? Chaser::FromFunction : m_pendingAction.m_fadeMode;
qreal intensity = m_intensity * m_pendingAction.m_intensity;

startNewStep(m_lastRunStepIdx, timer, intensity, blend, prevStepRoundElapsed);
startNewStep(m_lastRunStepIdx, timer, m_pendingAction.m_intensity, blend, prevStepRoundElapsed);
emit currentStepChanged(m_lastRunStepIdx);
}
else
@@ -161,14 +161,9 @@ private slots:
* Intensity
************************************************************************/
public:
/**
* Adjust the intensities of chaser steps.
*/
/** Adjust the intensities of chaser steps */
void adjustStepIntensity(qreal fraction, int stepIndex = -1, int fadeControl = 0);

private:
qreal m_intensity;

/************************************************************************
* Running
************************************************************************/
@@ -954,13 +954,13 @@ void Chaser_Test::adjustIntensity()

c->preRun(&timer);
c->adjustAttribute(0.5, Function::Intensity);
QCOMPARE(c->m_runner->m_intensity, qreal(0.5));
QCOMPARE(c->m_runner->m_pendingAction.m_intensity, qreal(0.5));
c->adjustAttribute(0.8, Function::Intensity);
QCOMPARE(c->m_runner->m_intensity, qreal(0.8));
QCOMPARE(c->m_runner->m_pendingAction.m_intensity, qreal(0.8));
c->adjustAttribute(1.5, Function::Intensity);
QCOMPARE(c->m_runner->m_intensity, qreal(1.0));
QCOMPARE(c->m_runner->m_pendingAction.m_intensity, qreal(1.0));
c->adjustAttribute(-0.1, Function::Intensity);
QCOMPARE(c->m_runner->m_intensity, qreal(0.0));
QCOMPARE(c->m_runner->m_pendingAction.m_intensity, qreal(0.0));
c->postRun(&timer, ua);

// Mustn't crash after postRun
@@ -117,7 +117,6 @@ void ChaserRunner_Test::initial()
QCOMPARE(cr.m_pendingAction.m_stepIndex, -1);
QCOMPARE(cr.m_pendingAction.m_fadeMode, (int)Chaser::FromFunction);
QCOMPARE(cr.m_lastRunStepIdx, -1);
QCOMPARE(cr.m_intensity, qreal(1.0));
}

void ChaserRunner_Test::nextPrevious()

0 comments on commit 94f684f

Please sign in to comment.