Skip to content

Commit

Permalink
engine: more cross universe fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Nov 29, 2024
1 parent 980250c commit 2505a8b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
19 changes: 14 additions & 5 deletions engine/src/genericdmxsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "universe.h"
#include "doc.h"

#include <cmath>

GenericDMXSource::GenericDMXSource(Doc* doc)
: m_doc(doc)
, m_outputEnabled(false)
Expand Down Expand Up @@ -116,15 +118,22 @@ void GenericDMXSource::writeDMX(MasterTimer* timer, QList<Universe *> ua)
if (fixture == NULL)
continue;

quint32 universe = fixture->universe();
QSharedPointer<GenericFader> fader = m_fadersMap.value(universe, QSharedPointer<GenericFader>());
quint32 channelIndex = it.key().second;
int universeIndex = floor((fixture->universeAddress() + channelIndex) / 512);

if (universeIndex >= ua.count())
continue;

Universe *universe = ua[universeIndex];

QSharedPointer<GenericFader> fader = m_fadersMap.value(universe->id(), QSharedPointer<GenericFader>());
if (fader.isNull())
{
fader = ua[universe]->requestFader();
m_fadersMap[universe] = fader;
fader = universe->requestFader();
m_fadersMap[universe->id()] = fader;
}

FadeChannel *fc = fader->getChannelFader(m_doc, ua[universe], fixture->id(), it.key().second);
FadeChannel *fc = fader->getChannelFader(m_doc, universe, fixture->id(), channelIndex);
fc->setCurrent(it.value());
fc->setTarget(it.value());
}
Expand Down
15 changes: 9 additions & 6 deletions engine/src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QDebug>
#include <cmath>
#include <QList>
#include <QFile>

Expand Down Expand Up @@ -711,24 +712,26 @@ void Scene::processValue(MasterTimer *timer, QList<Universe*> ua, uint fadeIn, S
if (fixture == NULL)
return;

quint32 universe = fixture->universe();
if (universe == Universe::invalid())
int universeIndex = floor((fixture->universeAddress() + scv.channel) / 512);
if (universeIndex >= ua.count())
return;

QSharedPointer<GenericFader> fader = m_fadersMap.value(universe, QSharedPointer<GenericFader>());
Universe *universe = ua.at(universeIndex);

QSharedPointer<GenericFader> fader = m_fadersMap.value(universe->id(), QSharedPointer<GenericFader>());
if (fader.isNull())
{
fader = ua[universe]->requestFader();
fader = universe->requestFader();
fader->adjustIntensity(getAttributeValue(Intensity));
fader->setBlendMode(blendMode());
fader->setName(name());
fader->setParentFunctionID(id());
fader->setParentIntensity(getAttributeValue(ParentIntensity));
fader->setHandleSecondary(true);
m_fadersMap[universe] = fader;
m_fadersMap[universe->id()] = fader;
}

FadeChannel *fc = fader->getChannelFader(doc(), ua[universe], scv.fxi, scv.channel);
FadeChannel *fc = fader->getChannelFader(doc(), universe, scv.fxi, scv.channel);
int chIndex = fc->channelIndex(scv.channel);

/** If a blend Function has been set, check if this channel needs to
Expand Down
12 changes: 11 additions & 1 deletion ui/src/simpledeskengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,20 @@ void SimpleDeskEngine::writeDMX(MasterTimer *timer, QList<Universe *> ua)
FadeChannel fc = it.value();
Fixture *fixture = m_doc->fixture(fc.fixture());
quint32 chIndex = fc.channel();

if (fixture != NULL)
{
const QLCChannel *ch = fixture->channel(chIndex);
if (ch != NULL)
{
qDebug() << "Restoring default value of fixture" << fixture->id()
<< "channel" << chIndex << "value" << ch->defaultValue();
ua[universe]->setChannelDefaultValue(fixture->address() + chIndex, ch->defaultValue());
chIndex += fixture->address();

if (fixture->crossUniverse() && chIndex > 511)
chIndex -= 512;

ua[universe]->setChannelDefaultValue(chIndex, ch->defaultValue());
}
}
}
Expand All @@ -344,6 +350,10 @@ void SimpleDeskEngine::writeDMX(MasterTimer *timer, QList<Universe *> ua)
Fixture *fixture = m_doc->fixture(fc.fixture());
quint32 chIndex = fc.channel();
fader->remove(&fc);

if (fixture->crossUniverse() && channel > 511)
channel -= 512;

ua[universe]->reset(channel & 0x01FF, 1);
if (fixture != NULL)
{
Expand Down

0 comments on commit 2505a8b

Please sign in to comment.