Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cross system glissando bug #14890

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/engraving/libmscore/glissando.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ void Glissando::layout()
}
double y0 = segm1->ipos().y();
double yTot = segm2->ipos().y() + segm2->ipos2().y() - y0;
yTot -= yStaffDifference(segm2->system(), segm2->staffIdx(), segm1->system(), segm1->staffIdx());
double ratio = yTot / xTot;
// interpolate y-coord of intermediate points across total width and height
double xCurr = 0.0;
Expand All @@ -338,8 +339,10 @@ void Glissando::layout()
xCurr += segm->ipos2().x();
yCurr = y0 + ratio * xCurr;
segm->rypos2() = yCurr - segm->ipos().y(); // position segm. end point at yCurr
// next segment shall start where this segment stopped
segm = segmentAt(i + 1);
// next segment shall start where this segment stopped, corrected for the staff y-difference
SpannerSegment* nextSeg = segmentAt(i + 1);
yCurr += yStaffDifference(nextSeg->system(), nextSeg->staffIdx(), segm->system(), segm->staffIdx());
segm = nextSeg;
segm->rypos2() += segm->ipos().y() - yCurr; // adjust next segm. vertical length
segm->setPosY(yCurr); // position next segm. start point at yCurr
}
Expand Down
13 changes: 13 additions & 0 deletions src/engraving/libmscore/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,4 +1137,17 @@ Fraction actualTicks(Fraction duration, Tuplet* tuplet, Fraction timeStretch)
}
return f;
}

double yStaffDifference(const System* system1, staff_idx_t staffIdx1, const System* system2, staff_idx_t staffIdx2)
{
if (!system1 || !system2) {
return 0.0;
}
const SysStaff* staff1 = system1->staff(staffIdx1);
const SysStaff* staff2 = system2->staff(staffIdx2);
if (!staff1 || !staff2) {
return 0.0;
}
return staff1->y() - staff2->y();
}
}
2 changes: 2 additions & 0 deletions src/engraving/libmscore/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@ int chromaticPitchSteps(const Note* noteL, const Note* noteR, const int nominalD
extern Segment* skipTuplet(Tuplet* tuplet);
extern SymIdList timeSigSymIdsFromString(const String&);
extern Fraction actualTicks(Fraction duration, Tuplet* tuplet, Fraction timeStretch);

extern double yStaffDifference(const System* system1, staff_idx_t staffIdx1, const System* system2, staff_idx_t staffIdx2);
} // namespace mu::engraving
#endif
Binary file added vtest/scores/gliss-3.mscz
Binary file not shown.