Permalink
Browse files

engine: finally, handle LTP channels crossfade

  • Loading branch information...
mcallegari committed Dec 9, 2018
1 parent c2860df commit 3be4b59112912fc7cd320d6807edc7af5c5f85f7
Showing with 19 additions and 6 deletions.
  1. +2 −2 engine/src/fadechannel.cpp
  2. +17 −4 engine/src/genericfader.cpp
@@ -206,7 +206,7 @@ void FadeChannel::setStart(uchar value)

uchar FadeChannel::start() const
{
return m_start;
return uchar(m_start);
}

void FadeChannel::setTarget(uchar value)
@@ -216,7 +216,7 @@ void FadeChannel::setTarget(uchar value)

uchar FadeChannel::target() const
{
return m_target;
return uchar(m_target);
}

void FadeChannel::setCurrent(uchar value)
@@ -160,11 +160,24 @@ void GenericFader::write(Universe *universe)
else
value = fc.nextStep(MasterTimer::tick());

// Apply intensity to HTP channels
if ((channelType & FadeChannel::Intensity) && fc.canFade())
value = fc.current(intensity());
// Apply intensity to channels that can fade
if (fc.canFade())
{
if (channelType & FadeChannel::Intensity)
{
value = fc.current(intensity());
}
else if (blendMode != Universe::NormalBlend &&
fc.fadeTime() == 0 && (channelType & FadeChannel::LTP))
{
// this translates into: LTP + crossfade.
// Value is proportional between start and target, depending on intensity
value = uchar((qreal(fc.target() - fc.start()) * intensity()) + fc.start());
}
}

// LTP non intensity channels must use normal blending
// LTP non intensity channels must use normal blending, otherwise they
// will be added up in case of additive blending
if ((channelType & FadeChannel::LTP) && (channelType & FadeChannel::Intensity) == 0)
blendMode = Universe::NormalBlend;

0 comments on commit 3be4b59

Please sign in to comment.