Skip to content

Commit 2ce28bd

Browse files
committed
RenderedTarget: Exclude the target from touching candidates
1 parent 10f535c commit 2ce28bd

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/renderedtarget.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ QRectF RenderedTarget::touchingBounds() const
804804
return bounds;
805805
}
806806

807-
QRectF RenderedTarget::candidatesBounds(const QRectF &targetRect, const std::vector<Target *> &candidates, std::vector<IRenderedTarget *> &dst)
807+
QRectF RenderedTarget::candidatesBounds(const QRectF &targetRect, const std::vector<Target *> &candidates, std::vector<IRenderedTarget *> &dst) const
808808
{
809809
QRectF united;
810810
dst.clear();
@@ -833,16 +833,18 @@ QRectF RenderedTarget::candidatesBounds(const QRectF &targetRect, const std::vec
833833
target = model->renderedTarget();
834834
}
835835

836-
united = united.united(candidateIntersection(targetRect, target));
836+
Q_ASSERT(target);
837837

838-
if (target)
838+
if (target && target != this) {
839+
united = united.united(candidateIntersection(targetRect, target));
839840
dst.push_back(target);
841+
}
840842
}
841843

842844
return united;
843845
}
844846

845-
QRectF RenderedTarget::candidatesBounds(const QRectF &targetRect, const std::vector<libscratchcpp::Sprite *> &candidates, std::vector<IRenderedTarget *> &dst)
847+
QRectF RenderedTarget::candidatesBounds(const QRectF &targetRect, const std::vector<libscratchcpp::Sprite *> &candidates, std::vector<IRenderedTarget *> &dst) const
846848
{
847849
QRectF united;
848850
dst.clear();
@@ -860,10 +862,12 @@ QRectF RenderedTarget::candidatesBounds(const QRectF &targetRect, const std::vec
860862
if (model)
861863
target = model->renderedTarget();
862864

863-
united = united.united(candidateIntersection(targetRect, target));
865+
Q_ASSERT(target);
864866

865-
if (target)
867+
if (target && target != this) {
868+
united = united.united(candidateIntersection(targetRect, target));
866869
dst.push_back(target);
870+
}
867871
}
868872

869873
return united;

src/renderedtarget.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ class RenderedTarget : public IRenderedTarget
125125
QPointF mapFromScratchToLocal(const QPointF &point) const;
126126
CpuTextureManager *textureManager();
127127
QRectF touchingBounds() const;
128-
static QRectF candidatesBounds(const QRectF &targetRect, const std::vector<libscratchcpp::Target *> &candidates, std::vector<IRenderedTarget *> &dst);
129-
static QRectF candidatesBounds(const QRectF &targetRect, const std::vector<libscratchcpp::Sprite *> &candidates, std::vector<IRenderedTarget *> &dst);
128+
QRectF candidatesBounds(const QRectF &targetRect, const std::vector<libscratchcpp::Target *> &candidates, std::vector<IRenderedTarget *> &dst) const;
129+
QRectF candidatesBounds(const QRectF &targetRect, const std::vector<libscratchcpp::Sprite *> &candidates, std::vector<IRenderedTarget *> &dst) const;
130130
static QRectF candidateIntersection(const QRectF &targetRect, IRenderedTarget *target);
131131
static void clampRect(libscratchcpp::Rect &rect, double left, double right, double bottom, double top);
132132

0 commit comments

Comments
 (0)