Fix symmetry autoclose/autofill

This commit is contained in:
manongjohn 2023-02-04 08:51:12 -05:00
parent b126cd86a6
commit 3d07164fd2

View file

@ -1177,8 +1177,13 @@ void ToonzVectorBrushTool::leftButtonUp(const TPointD &pos,
m_veryFirstFrameId = m_firstFrameId; m_veryFirstFrameId = m_firstFrameId;
} }
m_firstSymmetryStrokes.clear(); m_firstSymmetryStrokes.clear();
if (m_track.hasSymmetryBrushes()) if (m_track.hasSymmetryBrushes()) {
m_firstSymmetryStrokes = m_track.makeSymmetryStrokes(error); m_firstSymmetryStrokes = m_track.makeSymmetryStrokes(error);
if (m_autoClose.getValue()) {
for (int i = 0; i < m_firstSymmetryStrokes.size(); i++)
m_firstSymmetryStrokes[i]->setSelfLoop(true);
}
}
} else if (m_firstFrameId == getFrameId()) { } else if (m_firstFrameId == getFrameId()) {
if (m_firstStroke) { if (m_firstStroke) {
delete m_firstStroke; delete m_firstStroke;
@ -1189,8 +1194,13 @@ void ToonzVectorBrushTool::leftButtonUp(const TPointD &pos,
if (m_autoClose.getValue()) m_firstStroke->setSelfLoop(true); if (m_autoClose.getValue()) m_firstStroke->setSelfLoop(true);
m_rangeTrack = m_track; m_rangeTrack = m_track;
m_firstSymmetryStrokes.clear(); m_firstSymmetryStrokes.clear();
if (m_track.hasSymmetryBrushes()) if (m_track.hasSymmetryBrushes()) {
m_firstSymmetryStrokes = m_track.makeSymmetryStrokes(error); m_firstSymmetryStrokes = m_track.makeSymmetryStrokes(error);
if (m_autoClose.getValue()) {
for (int i = 0; i < m_firstSymmetryStrokes.size(); i++)
m_firstSymmetryStrokes[i]->setSelfLoop(true);
}
}
} else { } else {
TFrameId currentId = getFrameId(); TFrameId currentId = getFrameId();
int curCol = 0, curFrame = 0; int curCol = 0, curFrame = 0;
@ -1203,9 +1213,13 @@ void ToonzVectorBrushTool::leftButtonUp(const TPointD &pos,
if (m_autoClose.getValue()) stroke->setSelfLoop(true); if (m_autoClose.getValue()) stroke->setSelfLoop(true);
std::vector<TStroke *> lastStrokes; std::vector<TStroke *> lastStrokes;
if (m_track.hasSymmetryBrushes()) if (m_track.hasSymmetryBrushes()) {
lastStrokes = m_track.makeSymmetryStrokes(error); lastStrokes = m_track.makeSymmetryStrokes(error);
if (m_autoClose.getValue()) {
for (int i = 0; i < lastStrokes.size(); i++)
lastStrokes[i]->setSelfLoop(true);
}
}
bool success = doFrameRangeStrokes( bool success = doFrameRangeStrokes(
m_firstFrameId, m_firstStroke, getFrameId(), stroke, m_firstFrameId, m_firstStroke, getFrameId(), stroke,
m_frameRange.getIndex(), m_breakAngles.getValue(), m_frameRange.getIndex(), m_breakAngles.getValue(),
@ -1276,6 +1290,7 @@ void ToonzVectorBrushTool::leftButtonUp(const TPointD &pos,
std::vector<TStroke *> symmStrokes = m_track.makeSymmetryStrokes(error); std::vector<TStroke *> symmStrokes = m_track.makeSymmetryStrokes(error);
for (int i = 0; i < symmStrokes.size(); i++) { for (int i = 0; i < symmStrokes.size(); i++) {
symmStrokes[i]->setStyle(stroke->getStyle()); symmStrokes[i]->setStyle(stroke->getStyle());
if (m_autoClose.getValue()) symmStrokes[i]->setSelfLoop(true);
addStrokeToImage(getApplication(), vi, symmStrokes[i], addStrokeToImage(getApplication(), vi, symmStrokes[i],
m_breakAngles.getValue(), m_autoGroup.getValue(), m_breakAngles.getValue(), m_autoGroup.getValue(),
m_autoFill.getValue(), m_isFrameCreated, m_autoFill.getValue(), m_isFrameCreated,
@ -1364,13 +1379,19 @@ bool ToonzVectorBrushTool::doFrameRangeStrokes(
} }
firstImage->addStroke(first, false, sendToBack); firstImage->addStroke(first, false, sendToBack);
for (int i = 0; i < firstSymmetryStrokes.size(); i++) for (int i = 0; i < firstSymmetryStrokes.size(); i++) {
firstImage->addStroke( TStroke *stroke =
swapped ? lastSymmetryStrokes[i] : firstSymmetryStrokes[i], sendToBack); swapped ? lastSymmetryStrokes[i] : firstSymmetryStrokes[i];
if (m_autoClose.getValue()) stroke->setSelfLoop(true);
firstImage->addStroke(stroke, sendToBack);
}
lastImage->addStroke(last, false, sendToBack); lastImage->addStroke(last, false, sendToBack);
for (int i = 0; i < lastSymmetryStrokes.size(); i++) for (int i = 0; i < lastSymmetryStrokes.size(); i++) {
lastImage->addStroke( TStroke *stroke =
swapped ? firstSymmetryStrokes[i] : lastSymmetryStrokes[i], sendToBack); swapped ? firstSymmetryStrokes[i] : lastSymmetryStrokes[i];
if (m_autoClose.getValue()) stroke->setSelfLoop(true);
lastImage->addStroke(stroke, sendToBack);
}
assert(firstFrameId <= lastFrameId); assert(firstFrameId <= lastFrameId);
std::vector<TFrameId> allFids; std::vector<TFrameId> allFids;