Skip to content

Commit e5ba46e

Browse files
committed
#assistants: pressure
1 parent f4d253a commit e5ba46e

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

toonz/sources/tnztools/fullcolorbrushtool.cpp

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

@@ -836,7 +845,7 @@ void FullColorBrushTool::applyClassicToonzBrushSettings(
836845
}
837846
}
838847

839-
void FullColorBrushTool::applyToonzBrushSettings(mypaint::Brush &mypaintBrush) {
848+
bool FullColorBrushTool::applyToonzBrushSettings(mypaint::Brush &mypaintBrush) {
840849
TMyPaintBrushStyle *mypaintStyle = getBrushStyle();
841850

842851
if (mypaintStyle) {
@@ -874,9 +883,12 @@ void FullColorBrushTool::applyToonzBrushSettings(mypaint::Brush &mypaintBrush) {
874883
// lock-alpha already disables eraser
875884
mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_LOCK_ALPHA, 1.0);
876885
}
877-
} else {
878-
applyClassicToonzBrushSettings(mypaintBrush);
886+
887+
return true;
879888
}
889+
890+
applyClassicToonzBrushSettings(mypaintBrush);
891+
return false;
880892
}
881893

882894
//==========================================================================================================

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);

0 commit comments

Comments
 (0)