Blob bounciness #67
@@ -14,6 +14,8 @@ BlobRect::~BlobRect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BlobRect::updatePolish() {
|
void BlobRect::updatePolish() {
|
||||||
|
BlobShape::updatePolish();
|
||||||
|
|
||||||
if (m_physicsActive) {
|
if (m_physicsActive) {
|
||||||
// Check if deformation is visually imperceptible
|
// Check if deformation is visually imperceptible
|
||||||
float totalDelta = std::abs(m_dm00 - 1.0f) + std::abs(m_dm01) + std::abs(m_dm11 - 1.0f);
|
float totalDelta = std::abs(m_dm00 - 1.0f) + std::abs(m_dm01) + std::abs(m_dm11 - 1.0f);
|
||||||
@@ -39,8 +41,6 @@ void BlobRect::updatePolish() {
|
|||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlobShape::updatePolish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlobRect::updatePhysics() {
|
void BlobRect::updatePhysics() {
|
||||||
|
|||||||
@@ -68,9 +68,22 @@ void BlobShape::componentComplete() {
|
|||||||
void BlobShape::geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) {
|
void BlobShape::geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) {
|
||||||
QQuickItem::geometryChange(newGeometry, oldGeometry);
|
QQuickItem::geometryChange(newGeometry, oldGeometry);
|
||||||
updateCenteredDeformMatrix();
|
updateCenteredDeformMatrix();
|
||||||
if (m_group && newGeometry != oldGeometry) {
|
if (m_group) {
|
||||||
|
// Accumulate sub-pixel drift so slow movements don't desync the shader
|
||||||
|
m_pendingDx += static_cast<float>(newGeometry.x() - oldGeometry.x());
|
||||||
|
m_pendingDy += static_cast<float>(newGeometry.y() - oldGeometry.y());
|
||||||
|
m_pendingDw += static_cast<float>(newGeometry.width() - oldGeometry.width());
|
||||||
|
m_pendingDh += static_cast<float>(newGeometry.height() - oldGeometry.height());
|
||||||
|
|
||||||
|
if (std::abs(m_pendingDx) > 0.5f || std::abs(m_pendingDy) > 0.5f ||
|
||||||
|
std::abs(m_pendingDw) > 0.5f || std::abs(m_pendingDh) > 0.5f) {
|
||||||
|
m_pendingDx = 0;
|
||||||
|
m_pendingDy = 0;
|
||||||
|
m_pendingDw = 0;
|
||||||
|
m_pendingDh = 0;
|
||||||
m_group->markShapeDirty(this);
|
m_group->markShapeDirty(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlobShape::updateCenteredDeformMatrix() {
|
void BlobShape::updateCenteredDeformMatrix() {
|
||||||
|
|||||||
@@ -82,9 +82,13 @@ float m_cachedPaddedW = 0;
|
|||||||
float m_cachedPaddedH = 0;
|
float m_cachedPaddedH = 0;
|
||||||
QRectF m_localPaddedRect;
|
QRectF m_localPaddedRect;
|
||||||
QVector<BlobRectData> m_cachedRects;
|
QVector<BlobRectData> m_cachedRects;
|
||||||
int m_cachedMyIndex = -2;
|
int m_cachedMyIndex = -2;
|
||||||
bool m_cachedHasInverted = false;
|
float m_pendingDx = 0;
|
||||||
float m_cachedInvertedRadius = 0;
|
float m_pendingDy = 0;
|
||||||
|
float m_pendingDw = 0;
|
||||||
|
float m_pendingDh = 0;
|
||||||
|
bool m_cachedHasInverted = false;
|
||||||
|
float m_cachedInvertedRadius = 0;
|
||||||
float m_cachedInvertedOuter[4] = {};
|
float m_cachedInvertedOuter[4] = {};
|
||||||
float m_cachedInvertedInner[4] = {};
|
float m_cachedInvertedInner[4] = {};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user