diff --git a/src/common/Vec2.h b/src/common/Vec2.h index 34133f785..c09055a78 100644 --- a/src/common/Vec2.h +++ b/src/common/Vec2.h @@ -380,6 +380,18 @@ public: return point.X >= pos.X && point.X < pos.X + size.X && point.Y >= pos.Y && point.Y < pos.Y + size.Y; } + template>> + inline Vec2 TopLeft() const + { + return pos; + } + + template>> + inline Vec2 BottomRight() const + { + return pos + size - Vec2(1, 1); + } + template Rect() + std::declval())> Inset(S delta) const { diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index bab82c77a..9767137e4 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -312,7 +312,7 @@ void Simulation::Load(const GameSave *save, bool includePressure, Vec2 bloc std::unique_ptr Simulation::Save(bool includePressure, Rect partR) // particle coordinates { - auto blockR = RectBetween(partR.pos / CELL, (partR.pos + partR.size) / CELL); + auto blockR = RectBetween(partR.TopLeft() / CELL, partR.BottomRight() / CELL); auto blockP = blockR.pos; auto newSave = std::make_unique(blockR.size);