From 01aa96c3bd44ccbbecd5f7dc53b186dfa6906355 Mon Sep 17 00:00:00 2001 From: huxingyi Date: Wed, 18 Nov 2020 21:46:03 +0930 Subject: [PATCH] Fix unsaved state for texture painter --- resources/model-dog.ds3 | 536 ++++++++++++++++---------------- resources/model-screwdriver.ds3 | Bin 483693 -> 483679 bytes src/document.cpp | 12 +- src/document.h | 1 - src/texturepainter.cpp | 18 +- src/texturepainter.h | 2 +- 6 files changed, 280 insertions(+), 289 deletions(-) diff --git a/resources/model-dog.ds3 b/resources/model-dog.ds3 index cbc62b27..e1ea57a4 100644 --- a/resources/model-dog.ds3 +++ b/resources/model-dog.ds3 @@ -1,287 +1,287 @@ DUST3D 1.0 xml 0000000194 - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + diff --git a/resources/model-screwdriver.ds3 b/resources/model-screwdriver.ds3 index a22625f98c442be3fbb2189ffef7aab9d1436e5f..0ab45b5ab392befb228dfff8468fa18c81730a3b 100644 GIT binary patch delta 1898 zcmb7FJ!lj`6z2ARau@H;cp4ME-BXT3ZV3akw=*}pg@T-lt%dOlh0N~Gkc+_}93&zk zClf`**6p=Ri#>ST-(ni08R6WEJcc!;+52bf(6GuF-?B`{TOKE4i4$D>r-j{FT zJ|LA(E@oObo9BmXa4GA;wdxQjy2mw3#}T`!^c`0 z={rRi-kwBCUq3a*MO>Xl62Hx+F`Fs5@cHx*7xB^@(!+&$B=Prr8ngEcF8n-$Om^e! zE8MLv*XOdUgBWhtU*dj6!+y7@X~)-Ec|?TFEC@x-+F|D8dt6AB2$k@_4ASc0-rXy5 zC@(f2Vnz@4oO7^k+py#`7n9J}GU*1yVRf$at3*W!iRQa>T2&l_|zCZ delta 1904 zcmb7_L1+^}6o$!WlO{EZO|-U}-6$aliwtaLXJ&T}3K9`df(L6rL}z9<*j8F40Tn5Y zc<`#edX*ATJgOHjo_f)vh|rVOgGYs4g@SI6-rgSmJ^lN?Z~ooKeBW|^Z@EwIT1-B@ ze`^2vYNw+F=e`z#&@c=LW10~y6Q8hHb(26wK^zNsog3qfk18HE_dWcJXo=1)+RR=EHF)sC+y^b@E3&`=EBGR~5cHn0b$+>^1 zKXwH+rusPEnGzDCpJIG2Au;-8Wa=K)xH-L!`%!ua)^NsM%XwBA;9A<8Zo*Bg3hydc za4(SRM-Q_tYwZ)GRXCIP;CyX_i{7bCGDKg>dGO^RGJ0udg6qz&XJPo;@SxK`GJI%c ziN03y;LRaq^o7F{T*b9nr19%)7T8?bgHK0BxQcJgAsJ52BaOf2v%uaddhp{Yve|pb zUgA!5wmE07B*P(GZN9*L3)gwOz?7j;Ai9M5G9*lBNu;0&VLIZGpep1_q?>eWab@|O z8mZIm2bkT1ZTC2AI1XHQ+Y7$YB9@6EJiX%55xyashKjImlxWSB1nSz_c6;{i d)nW3e-g;bb &nodeIds) diff --git a/src/document.h b/src/document.h index bd13f025..7cb2c634 100644 --- a/src/document.h +++ b/src/document.h @@ -701,7 +701,6 @@ private: // need initialize bool m_isMouseTargetResultObsolete; PaintMode m_paintMode; float m_mousePickRadius; - bool m_saveNextPaintSnapshot; GeneratedCacheContext *m_generatedCacheContext; TexturePainterContext *m_texturePainterContext; private: diff --git a/src/texturepainter.cpp b/src/texturepainter.cpp index 9472e2a4..b9fcfcf9 100644 --- a/src/texturepainter.cpp +++ b/src/texturepainter.cpp @@ -73,7 +73,7 @@ void TexturePainter::collectNearbyTriangles(size_t triangleIndex, std::unordered } */ -void TexturePainter::paintStroke(QPainter &painter, const TexturePainterStroke &stroke) +bool TexturePainter::paintStroke(QPainter &painter, const TexturePainterStroke &stroke) { size_t targetTriangleIndex = 0; if (!intersectRayAndPolyhedron(stroke.mouseRayNear, @@ -83,32 +83,32 @@ void TexturePainter::paintStroke(QPainter &painter, const TexturePainterStroke & m_context->object->triangleNormals, &m_targetPosition, &targetTriangleIndex)) { - return; + return false; } if (PaintMode::None == m_paintMode) - return; + return false; if (nullptr == m_context->colorImage) { qDebug() << "TexturePainter paint color image is null"; - return; + return false; } const std::vector> *uvs = m_context->object->triangleVertexUvs(); if (nullptr == uvs) { qDebug() << "TexturePainter paint uvs is null"; - return; + return false; } const std::vector> *sourceNodes = m_context->object->triangleSourceNodes(); if (nullptr == sourceNodes) { qDebug() << "TexturePainter paint source nodes is null"; - return; + return false; } const std::map> *uvRects = m_context->object->partUvRects(); if (nullptr == uvRects) - return; + return false; const auto &triangle = m_context->object->triangles[targetTriangleIndex]; QVector3D coordinates = barycentricCoordinates(m_context->object->vertices[triangle[0]], @@ -175,6 +175,7 @@ void TexturePainter::paintStroke(QPainter &painter, const TexturePainterStroke & radius + radius, radius + radius, gradient); + return true; } void TexturePainter::paint() @@ -188,7 +189,8 @@ void TexturePainter::paint() painter.setPen(Qt::NoPen); TexturePainterStroke stroke = {m_mouseRayNear, m_mouseRayFar}; - paintStroke(painter, stroke); + if (!paintStroke(painter, stroke)) + return; m_colorImage = new QImage(*m_context->colorImage); } diff --git a/src/texturepainter.h b/src/texturepainter.h index 0b22c6b6..1582cfaf 100644 --- a/src/texturepainter.h +++ b/src/texturepainter.h @@ -67,7 +67,7 @@ private: //void buildFaceAroundVertexMap(); //void collectNearbyTriangles(size_t triangleIndex, std::unordered_set *triangleIndices); - void paintStroke(QPainter &painter, const TexturePainterStroke &stroke); + bool paintStroke(QPainter &painter, const TexturePainterStroke &stroke); }; #endif