diff --git a/Plugins/ZShell/Blobs/blobrect.cpp b/Plugins/ZShell/Blobs/blobrect.cpp index 9da0a49..578ed58 100644 --- a/Plugins/ZShell/Blobs/blobrect.cpp +++ b/Plugins/ZShell/Blobs/blobrect.cpp @@ -3,6 +3,7 @@ #include #include +#include BlobRect::BlobRect(QQuickItem* parent) : BlobShape(parent) { @@ -27,6 +28,17 @@ void BlobRect::updatePolish() { emit rawDeformMatrixChanged(); updateCenteredDeformMatrix(); m_physicsActive = false; + + if (m_group) { + QMetaObject::invokeMethod( + this, + [this]() { + if (m_group) + m_group->markDirty(); + }, + Qt::QueuedConnection + ); + } } else { QMetaObject::invokeMethod( this, @@ -289,9 +301,20 @@ void BlobRect::checkAtRest(float speed) { m_dmVel00 = 0.0f; m_dmVel01 = 0.0f; m_dmVel11 = 0.0f; - m_deformMatrix = QMatrix4x4(); // identity + m_deformMatrix = QMatrix4x4(); emit rawDeformMatrixChanged(); updateCenteredDeformMatrix(); m_physicsActive = false; + + if (m_group) { + QMetaObject::invokeMethod( + this, + [this]() { + if (m_group) + m_group->markDirty(); + }, + Qt::QueuedConnection + ); + } } } diff --git a/Plugins/ZShell/Blobs/blobshape.cpp b/Plugins/ZShell/Blobs/blobshape.cpp index e1626ca..128d4b1 100644 --- a/Plugins/ZShell/Blobs/blobshape.cpp +++ b/Plugins/ZShell/Blobs/blobshape.cpp @@ -76,9 +76,15 @@ void BlobShape::geometryChange(const QRectF& newGeometry, const QRectF& oldGeome if (m_group) { m_pendingDx += static_cast(newGeometry.x() - oldGeometry.x()); m_pendingDy += static_cast(newGeometry.y() - oldGeometry.y()); - const auto dw = std::abs(newGeometry.width() - oldGeometry.width()); - const auto dh = std::abs(newGeometry.height() - oldGeometry.height()); - if (std::abs(m_pendingDx) > 0.5f || std::abs(m_pendingDy) > 0.5f || dw > 0.5 || dh > 0.5) { + m_pendingDw += static_cast(newGeometry.width() - oldGeometry.width()); + m_pendingDh += static_cast(newGeometry.height() - oldGeometry.height()); + + const float deformMag = std::abs(m_deformMatrix(0, 0) - 1.0f) + std::abs(m_deformMatrix(0, 1)) + + std::abs(m_deformMatrix(1, 0)) + std::abs(m_deformMatrix(1, 1) - 1.0f); + const float syncThreshold = deformMag > 0.001f ? 0.05f : 0.5f; + + if (std::abs(m_pendingDx) > syncThreshold || std::abs(m_pendingDy) > syncThreshold || + std::abs(m_pendingDw) > syncThreshold || std::abs(m_pendingDh) > syncThreshold) { m_pendingDx = 0; m_pendingDy = 0; m_group->markShapeDirty(this); diff --git a/Plugins/ZShell/Blobs/blobshape.hpp b/Plugins/ZShell/Blobs/blobshape.hpp index e9542b7..517a477 100644 --- a/Plugins/ZShell/Blobs/blobshape.hpp +++ b/Plugins/ZShell/Blobs/blobshape.hpp @@ -84,6 +84,8 @@ float m_cachedPaddedX = 0; float m_cachedPaddedY = 0; float m_cachedPaddedW = 0; float m_cachedPaddedH = 0; +float m_pendingDw = 0; +float m_pendingDh = 0; QRectF m_localPaddedRect; QVector m_cachedRects; int m_cachedMyIndex = -2;