Skip to content

Commit ac91469

Browse files
committed
Optimised DislodgePixelRing to skip past most ignored pixels
1 parent f3ed256 commit ac91469

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Source/Managers/SceneMan.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,10 +960,21 @@ std::vector<MovableObject*>* SceneMan::DislodgePixelRing(const Vector& centre, f
960960
}
961961

962962
std::vector<MovableObject*>* pixelList = new std::vector<MovableObject*>();
963-
for (int x = 0; x <= static_cast<int>(outerRadius) * 2; x++) {
964-
for (int y = 0; y <= static_cast<int>(outerRadius) * 2; y++) {
963+
int limit = static_cast<int>(outerRadius) * 2;
964+
for (int x = 0; x <= limit; x++) {
965+
for (int y = 0; y <= limit; y++) {
965966
Vector checkPos = Vector(static_cast<float>(x) - outerRadius, static_cast<float>(y) - outerRadius) + centre;
966967
Vector distance = ShortestDistance(centre, checkPos, true);
968+
969+
if (distance.MagnitudeIsLessThan(innerRadius) && y < limit - y) {
970+
y = limit - y;
971+
continue;
972+
}
973+
974+
if (distance.MagnitudeIsGreaterThan(outerRadius) && y > limit / 2) {
975+
break;
976+
}
977+
967978
if (!distance.MagnitudeIsGreaterThan(outerRadius) && !distance.MagnitudeIsLessThan(innerRadius)) {
968979
MovableObject* px = DislodgePixelBool(checkPos.m_X, checkPos.m_Y, deletePixels);
969980
if (px) {

0 commit comments

Comments
 (0)