brush enhancement (#1877)

This commit is contained in:
shun-iwasawa 2018-03-23 12:44:45 +09:00 committed by Jeremy Bullock
parent 4ce9539416
commit d6e7990556
2 changed files with 84 additions and 65 deletions

View file

@ -752,6 +752,19 @@ void SmoothStroke::generatePoints() {
if (n == 0) {
return;
}
// if m_smooth = 0, then skip whole smoothing process
if (m_smooth == 0) {
for (int i = m_outputIndex; i < (int)m_outputPoints.size(); ++i) {
if (m_outputPoints[i] != m_rawPoints[i]) {
break;
}
++m_outputIndex;
}
m_outputPoints = m_rawPoints;
return;
}
std::vector<TThickPoint> smoothedPoints;
// Add more stroke samples before applying the smoothing
// This is because the raw inputs points are too few to support smooth result,
@ -869,21 +882,20 @@ BrushTool::BrushTool(std::string name, int targetType)
m_preset.addValue(CUSTOM_WSTR);
m_pressure.setId("PressureSensitivity");
if (targetType & TTool::Vectors) {
m_capStyle.addValue(BUTT_WSTR);
m_capStyle.addValue(ROUNDC_WSTR);
m_capStyle.addValue(PROJECTING_WSTR);
m_capStyle.setId("Cap");
m_prop[1].bind(m_capStyle);
m_joinStyle.addValue(MITER_WSTR);
m_joinStyle.addValue(ROUNDJ_WSTR);
m_joinStyle.addValue(BEVEL_WSTR);
m_joinStyle.setId("Join");
m_prop[1].bind(m_joinStyle);
m_miterJoinLimit.setId("Miter");
if (targetType & TTool::Vectors) {
m_prop[1].bind(m_capStyle);
m_prop[1].bind(m_joinStyle);
m_prop[1].bind(m_miterJoinLimit);
}
}
@ -1096,17 +1108,21 @@ void BrushTool::onActivate() {
TDoublePairProperty::Value(VectorBrushMinSize, VectorBrushMaxSize));
m_rasThickness.setValue(
TDoublePairProperty::Value(RasterBrushMinSize, RasterBrushMaxSize));
if (m_targetType & TTool::Vectors) {
m_capStyle.setIndex(VectorCapStyle);
m_joinStyle.setIndex(VectorJoinStyle);
m_miterJoinLimit.setValue(VectorMiterValue);
if (m_targetType & TTool::ToonzImage) m_drawOrder.setIndex(BrushDrawOrder);
m_breakAngles.setValue(BrushBreakSharpAngles ? 1 : 0);
m_accuracy.setValue(BrushAccuracy);
}
if (m_targetType & TTool::ToonzImage) {
m_drawOrder.setIndex(BrushDrawOrder);
m_pencil.setValue(RasterBrushPencilMode ? 1 : 0);
m_hardness.setValue(RasterBrushHardness);
}
m_pressure.setValue(BrushPressureSensitivity ? 1 : 0);
m_firstTime = false;
m_accuracy.setValue(BrushAccuracy);
m_smooth.setValue(BrushSmooth);
m_hardness.setValue(RasterBrushHardness);
if (m_targetType & TTool::Vectors) {
m_frameRange.setIndex(VectorBrushFrameRange);
m_snap.setValue(VectorBrushSnap);
@ -2000,9 +2016,10 @@ void BrushTool::mouseMove(const TPointD &pos, const TMouseEvent &e) {
(m_targetType & TTool::ToonzImage) ? m_rasThickness : m_thickness, min,
max);
} else {
m_mousePos = pos;
m_brushPos = pos;
m_mousePos = pos;
if (m_targetType & TTool::Vectors) {
m_firstSnapPoint = pos;
m_foundFirstSnap = false;
@ -2010,6 +2027,8 @@ void BrushTool::mouseMove(const TPointD &pos, const TMouseEvent &e) {
checkGuideSnapping(true);
m_brushPos = m_firstSnapPoint;
}
}
// TODO: this can be partial update for toonz raster brush
invalidate();
if (m_minThick == 0 && m_maxThick == 0) {
@ -2157,7 +2176,8 @@ void BrushTool::draw() {
// snapping
TVectorImageP vi = img;
if ((m_targetType & TTool::Vectors) && m_snap.getValue()) {
if (m_targetType & TTool::Vectors) {
if (m_snap.getValue()) {
m_pixelSize = getPixelSize();
double thick = 6.0 * m_pixelSize;
if (m_foundFirstSnap) {
@ -2186,6 +2206,7 @@ void BrushTool::draw() {
tglDrawSegment(topLeftCorner, bottomRightCorner);
tglDrawSegment(topRightCorner, bottomLeftCorner);
}
}
if (getApplication()->getCurrentObject()->isSpline()) return;

View file

@ -507,6 +507,8 @@ SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent)
grabGesture(Qt::PanGesture);
grabGesture(Qt::PinchGesture);
setUpdateBehavior(QOpenGLWidget::PartialUpdate);
if (Preferences::instance()->isColorCalibrationEnabled())
m_lutCalibrator = new LutCalibrator();
}
@ -1357,11 +1359,13 @@ static void drawFpsGraph(int t0, int t1) {
//#define FPS_HISTOGRAM
void SceneViewer::paintGL() {
#ifdef _DEBUG
if (!check_framebuffer_status()) {
/* QGLWidget の widget 生成/削除のタイミングで(platform によって?)
* GL_FRAMEBUFFER_UNDEFINED paintGL() */
return;
}
#endif
#ifdef MACOSX
// followin lines are necessary to solve a problem on iMac20
// It seems that for some errors in the openGl implementation, buffers are not
@ -1419,19 +1423,14 @@ void SceneViewer::paintGL() {
drawBuildVars();
check_framebuffer_status();
copyFrontBufferToBackBuffer();
// This seems not to be necessary for now.
// copyFrontBufferToBackBuffer();
check_framebuffer_status();
drawEnableScissor();
check_framebuffer_status();
drawBackground();
check_framebuffer_status();
if (m_previewMode != FULL_PREVIEW) {
check_framebuffer_status();
drawCameraStand();
check_framebuffer_status();
}
if (isPreviewEnabled()) drawPreview();
@ -1714,7 +1713,6 @@ void SceneViewer::GLInvalidateAll() {
void SceneViewer::GLInvalidateRect(const TRectD &rect) {
m_clipRect = rect;
update();
m_clipRect.empty();
if (m_vRuler) m_vRuler->update();
if (m_hRuler) m_hRuler->update();
}