fix: blobs now allow to be drawn in device pixels to stay sharp
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 9s
JS/TS / lint (pull_request) Successful in 25s
Python / static (pull_request) Successful in 34s
Rust / build (pull_request) Successful in 51s
Python / verify (pull_request) Failing after 1m25s
Rust / fmt (pull_request) Successful in 39s
Rust / clippy (pull_request) Successful in 59s
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 9s
JS/TS / lint (pull_request) Successful in 25s
Python / static (pull_request) Successful in 34s
Rust / build (pull_request) Successful in 51s
Python / verify (pull_request) Failing after 1m25s
Rust / fmt (pull_request) Successful in 39s
Rust / clippy (pull_request) Successful in 59s
This commit is contained in:
@@ -2,7 +2,17 @@
|
||||
#include "blobinvertedrect.hpp"
|
||||
#include "blobshape.hpp"
|
||||
|
||||
BlobGroup::BlobGroup(QObject* parent) : QObject(parent) {}
|
||||
#include <algorithm>
|
||||
|
||||
namespace {
|
||||
constexpr int k_pumpMs = 16;
|
||||
} // namespace
|
||||
|
||||
BlobGroup::BlobGroup(QObject* parent) : QObject(parent) {
|
||||
m_physicsPump.setInterval(k_pumpMs);
|
||||
m_physicsPump.setTimerType(Qt::CoarseTimer);
|
||||
connect(&m_physicsPump, &QTimer::timeout, this, &BlobGroup::pumpPhysics);
|
||||
}
|
||||
|
||||
BlobGroup::~BlobGroup() {
|
||||
for (auto* shape : std::as_const(m_shapes))
|
||||
@@ -12,6 +22,7 @@ BlobGroup::~BlobGroup() {
|
||||
}
|
||||
|
||||
void BlobGroup::setSmoothing(qreal s) {
|
||||
if (s < 0.5) s = 0.5;
|
||||
if (qFuzzyCompare(m_smoothing, s)) return;
|
||||
m_smoothing = s;
|
||||
emit smoothingChanged();
|
||||
@@ -73,7 +84,6 @@ void BlobGroup::markShapeDirty(BlobShape* source) {
|
||||
source->polish();
|
||||
source->update();
|
||||
|
||||
// Use cached padded rects to find spatial neighbors
|
||||
const float pad = static_cast<float>(m_smoothing) * 2.0f;
|
||||
const QRectF srcRect(
|
||||
static_cast<double>(source->m_cachedPaddedX - pad),
|
||||
@@ -103,6 +113,33 @@ void BlobGroup::markShapeDirty(BlobShape* source) {
|
||||
void BlobGroup::ensurePhysicsUpdated() {
|
||||
if (m_physicsUpdated) return;
|
||||
m_physicsUpdated = true;
|
||||
for (auto* shape : std::as_const(m_shapes)) {
|
||||
shape->updatePhysics();
|
||||
if (shape->needsFrame()) {
|
||||
shape->polish();
|
||||
shape->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlobGroup::requestPhysics() {
|
||||
if (!m_physicsPump.isActive()) m_physicsPump.start();
|
||||
}
|
||||
|
||||
void BlobGroup::pumpPhysics() {
|
||||
for (auto* shape : std::as_const(m_shapes))
|
||||
shape->updatePhysics();
|
||||
|
||||
const bool anyMoving = std::any_of(
|
||||
m_shapes.cbegin(), m_shapes.cend(), [](const BlobShape* shape) {
|
||||
return shape->needsFrame();
|
||||
});
|
||||
|
||||
if (!anyMoving) {
|
||||
m_physicsPump.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
markDirty();
|
||||
m_physicsUpdated = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user