Skip to content

Commit

Permalink
Bug fix undefined projections
Browse files Browse the repository at this point in the history
Add checks if projection exists
  • Loading branch information
ewoudwijma committed Jun 23, 2024
1 parent 9f49e6a commit e525582
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
13 changes: 8 additions & 5 deletions src/App/LedFixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,15 @@ void Fixture::projectAndMap() {
if (sizeAdjusted.y > 1) leds->projectionDimension++;
if (sizeAdjusted.z > 1) leds->projectionDimension++;

Projection *projection = projections[leds->projectionNr];
Projection *projection = nullptr;
if (leds->projectionNr < projections.size())
projection = projections[leds->projectionNr];

mdl->getValueRowNr = rowNr; //run projection functions in the right rowNr context

Coord3D proCenter = mdl->getValue("proCenter", rowNr);

projection->adjustSizeAndPixel(sizeAdjusted, pixelAdjusted, proCenter);
if (projection) projection->adjustSizeAndPixel(sizeAdjusted, pixelAdjusted, proCenter);

if (leds->size == Coord3D{0,0,0}) { // first
ppf("projectAndMap first leds[%d] size:%d,%d,%d s:%d,%d,%d e:%d,%d,%d\n", rowNr, sizeAdjusted.x, sizeAdjusted.y, sizeAdjusted.z, startPosAdjusted.x, startPosAdjusted.y, startPosAdjusted.z, endPosAdjusted.x, endPosAdjusted.y, endPosAdjusted.z);
Expand All @@ -127,7 +130,7 @@ void Fixture::projectAndMap() {

mapped = pixelAdjusted;

projection->adjustMapped(mapped, sizeAdjusted, (pixel - startPosAdjusted)/10);
if (projection) projection->adjustMapped(mapped, sizeAdjusted, (pixel - startPosAdjusted)/10);

mapped.x = mapped.distance(proCenter);
mapped.y = 0;
Expand Down Expand Up @@ -185,7 +188,7 @@ void Fixture::projectAndMap() {
break;
}

projection->adjustMapped(mapped, sizeAdjusted, (pixel - startPosAdjusted)/10);
if (projection) projection->adjustMapped(mapped, sizeAdjusted, (pixel - startPosAdjusted)/10);

indexV = leds->XYZUnprojected(mapped);
break;
Expand Down Expand Up @@ -216,7 +219,7 @@ void Fixture::projectAndMap() {
break;
}

projection->adjustMapped(mapped, sizeAdjusted, (pixel - startPosAdjusted)/10);
if (projection) projection->adjustMapped(mapped, sizeAdjusted, (pixel - startPosAdjusted)/10);

indexV = leds->XYZUnprojected(mapped);

Expand Down
2 changes: 1 addition & 1 deletion src/App/LedLeds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ unsigned16 Leds::XYZ(Coord3D pixel) {
//as this is a call to a virtual function it reduces the theoretical (no show) speed by half, even if XYZ is not implemented
// the real speed is hardly affected, but room for improvement!
// so as a workaround we list them here explicetly
if (projectionNr == p_TiltPanRoll || projectionNr == p_Preset1)
if ((projectionNr == p_TiltPanRoll || projectionNr == p_Preset1) && projectionNr < fixture->projections.size())
fixture->projections[projectionNr]->adjustXYZ(*this, pixel);

return XYZUnprojected(pixel);
Expand Down
12 changes: 7 additions & 5 deletions src/App/LedModEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,14 @@ class LedModEffects:public SysModule {

stackUnsigned8 proValue = mdl->getValue(var, rowNr);
leds->projectionNr = proValue;
Projection* projection = fixture.projections[proValue];

mdl->varPreDetails(var, rowNr); //set all positive var N orders to negative
projection->controls(*leds, var);
mdl->varPostDetails(var, rowNr);

if (proValue < fixture.projections.size()) {
Projection* projection = fixture.projections[proValue];

mdl->varPreDetails(var, rowNr); //set all positive var N orders to negative
projection->controls(*leds, var);
mdl->varPostDetails(var, rowNr);
}
// ppf("chFun pro[%d] <- %d (%d)\n", rowNr, proValue, fixture.listOfLeds.size());

fixture.doMap = true;
Expand Down

0 comments on commit e525582

Please sign in to comment.