Skip to content

Commit f9c78ef

Browse files
committed
Merge branch 'feature08_assistants' from blackwarthog
2 parents 1781461 + e5ba46e commit f9c78ef

File tree

5 files changed

+47
-21
lines changed

5 files changed

+47
-21
lines changed

toonz/sources/include/tgeometry.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,12 @@ class DVAPI TAngleRangeSet {
12591259
static double toDouble(Type a) {
12601260
return ((double)a / (double)max - 0.5) * M_2PI;
12611261
}
1262+
static List::const_iterator empty_iterator() {
1263+
static List list;
1264+
return list.end();
1265+
}
12621266

1267+
12631268
struct Range {
12641269
Type a0, a1;
12651270
Range() : a0(), a1() {}
@@ -1291,7 +1296,7 @@ class DVAPI TAngleRangeSet {
12911296
inline Iterator &set(bool full) {
12921297
m_flip = full;
12931298
m_lapped = !m_flip;
1294-
m_current = m_prebegin = m_begin = m_end = List::const_iterator();
1299+
m_current = m_prebegin = m_begin = m_end = empty_iterator();
12951300
return *this;
12961301
}
12971302

toonz/sources/tnztools/fullcolorbrushtool.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,16 @@ void FullColorBrushTool::paintTrackPoint(const TTrackPoint &point,
412412
TrackHandler *handler;
413413
if (track.size() == track.pointsAdded && !track.toolHandler && m_workRaster) {
414414
mypaint::Brush mypaintBrush;
415-
applyToonzBrushSettings(mypaintBrush);
416-
handler = new TrackHandler(m_workRaster, *this, mypaintBrush);
415+
bool mypaintStyle = applyToonzBrushSettings(mypaintBrush);
416+
double overridePressure = -1.0;
417+
if (!m_enabledPressure && mypaintStyle)
418+
overridePressure = 0.5;
419+
if (!m_enabledPressure && !mypaintStyle)
420+
overridePressure = 1.0;
421+
if (!track.hasPressure && !mypaintStyle)
422+
overridePressure = 1.0;
423+
424+
handler = new TrackHandler(m_workRaster, *this, mypaintBrush, overridePressure);
417425
handler->brush.beginStroke();
418426
track.toolHandler = handler;
419427
}
@@ -423,7 +431,8 @@ void FullColorBrushTool::paintTrackPoint(const TTrackPoint &point,
423431
// paint stroke
424432
m_strokeSegmentRect.empty();
425433
handler->brush.strokeTo(point.position + rasCenter,
426-
m_enabledPressure ? point.pressure : 0.5, point.tilt,
434+
handler->overridePressure >= 0.0 ? handler->overridePressure : point.pressure,
435+
point.tilt,
427436
point.time - track.previous().time);
428437
if (track.pointsAdded == 1 && track.finished()) handler->brush.endStroke();
429438

@@ -835,7 +844,7 @@ void FullColorBrushTool::applyClassicToonzBrushSettings(
835844
}
836845
}
837846

838-
void FullColorBrushTool::applyToonzBrushSettings(mypaint::Brush &mypaintBrush) {
847+
bool FullColorBrushTool::applyToonzBrushSettings(mypaint::Brush &mypaintBrush) {
839848
TMyPaintBrushStyle *mypaintStyle = getBrushStyle();
840849

841850
if (mypaintStyle) {
@@ -873,9 +882,12 @@ void FullColorBrushTool::applyToonzBrushSettings(mypaint::Brush &mypaintBrush) {
873882
// lock-alpha already disables eraser
874883
mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_LOCK_ALPHA, 1.0);
875884
}
876-
} else {
877-
applyClassicToonzBrushSettings(mypaintBrush);
885+
886+
return true;
878887
}
888+
889+
applyClassicToonzBrushSettings(mypaintBrush);
890+
return false;
879891
}
880892

881893
//==========================================================================================================

toonz/sources/tnztools/fullcolorbrushtool.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@ class FullColorBrushTool final : public TTool, public RasterController {
3434
class TrackHandler : public TTrackToolHandler {
3535
public:
3636
MyPaintToonzBrush brush;
37+
double overridePressure;
3738

3839
TrackHandler(const TRaster32P &ras, RasterController &controller,
39-
const mypaint::Brush &brush)
40-
: brush(ras, controller, brush) {}
40+
const mypaint::Brush &brush, double overridePressure = -1.0)
41+
: brush(ras, controller, brush), overridePressure(overridePressure) {}
4142
};
4243

4344
private:
4445
void updateCurrentStyle();
4546
void applyClassicToonzBrushSettings(mypaint::Brush &mypaintBrush);
46-
void applyToonzBrushSettings(mypaint::Brush &mypaintBrush);
47+
bool applyToonzBrushSettings(mypaint::Brush &mypaintBrush);
4748

4849
public:
4950
FullColorBrushTool(std::string name);

toonz/sources/tnztools/tooloptions.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,28 +2721,35 @@ ToolOptions::~ToolOptions() {}
27212721

27222722
void ToolOptions::showEvent(QShowEvent *) {
27232723
TTool::Application *app = TTool::getApplication();
2724-
ToolHandle *currTool = app->getCurrentTool();
2725-
if (currTool) {
2724+
2725+
if (ToolHandle *currTool = app->getCurrentTool())
2726+
currTool->disconnect(this);
2727+
if (TObjectHandle *currObject = app->getCurrentObject())
2728+
currObject->disconnect(this);
2729+
if (TXshLevelHandle *currLevel = app->getCurrentLevel())
2730+
currLevel->disconnect(this);
2731+
2732+
if (ToolHandle *currTool = app->getCurrentTool()) {
2733+
currTool->disconnect(this);
27262734
onToolSwitched();
27272735
connect(currTool, SIGNAL(toolSwitched()), SLOT(onToolSwitched()));
27282736
connect(currTool, SIGNAL(toolOptionsBoxChanged()),
27292737
SLOT(onToolOptionsBoxChanged()));
27302738
connect(currTool, SIGNAL(toolChanged()), SLOT(onToolChanged()));
27312739
}
27322740

2733-
TObjectHandle *currObject = app->getCurrentObject();
2734-
if (currObject) {
2741+
if (TObjectHandle *currObject = app->getCurrentObject()) {
2742+
currObject->disconnect(this);
27352743
onStageObjectChange();
27362744
connect(currObject, SIGNAL(objectSwitched()), SLOT(onStageObjectChange()));
27372745
connect(currObject, SIGNAL(objectChanged(bool)),
27382746
SLOT(onStageObjectChange()));
27392747
}
27402748

2741-
TXshLevelHandle *currLevel = app->getCurrentLevel();
2742-
2743-
if (currLevel)
2749+
if (TXshLevelHandle *currLevel = app->getCurrentLevel()) {
27442750
connect(currLevel, SIGNAL(xshLevelSwitched(TXshLevel *)), this,
27452751
SLOT(onStageObjectChange()));
2752+
}
27462753
}
27472754

27482755
//-----------------------------------------------------------------------------

toonz/sources/toonz/drawingdata.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,12 @@ bool DrawingData::getLevelFrames(TXshSimpleLevel *sl,
304304
}
305305

306306
// Merge Palette :
307-
TPalette *slPlt = sl->getPalette();
308-
bool styleAdded = mergePalette_Overlap(slPlt, imgPlt, keepOriginalPalette);
309-
307+
bool styleAdded = false;
310308
std::map<int, int> styleTable;
311-
for (int s = 0; s < slPlt->getStyleCount(); s++) styleTable[s] = s;
309+
if (TPalette *slPlt = sl->getPalette()) {
310+
styleAdded = mergePalette_Overlap(slPlt, imgPlt, keepOriginalPalette);
311+
for (int s = 0; s < slPlt->getStyleCount(); s++) styleTable[s] = s;
312+
}
312313

313314
// Merge Image
314315
for (auto const &image : usedImageSet) {

0 commit comments

Comments
 (0)