@@ -90,10 +90,29 @@ namespace Kaixo::Processing {
9090 int rotated = nextRotation (direction);
9191
9292 if (!rotations.contains (rotated)) {
93- auto [from, dir] = getMostEfficientRotationTo (direction);
94- rotations[rotated].buffer = std::move (rotator.rotate (rotations[from].buffer , dir, originalBuffer));
95- rotations[rotated].path = " " ; // Buffer changed, so file path no longer valid
96- rotations[rotated].changed = true ; // Signal that it has changed
93+ if (rotated == d180f) {
94+ if (rotations.contains (d000r)) {
95+ rotations[d180f].buffer = std::move (rotator.rotate (rotations[d000r].buffer , Rotation::Flip, originalBuffer));
96+ rotations[d180f].path = " " ;
97+ rotations[d180f].changed = true ;
98+ } else {
99+ rotations[d000r].buffer = std::move (rotator.rotate (rotations[d000f].buffer , Rotation::Reverse, originalBuffer));
100+ rotations[d000r].path = " " ;
101+ rotations[d000r].changed = true ;
102+ rotations[d180f].buffer = std::move (rotator.rotate (rotations[d000r].buffer , Rotation::Flip, originalBuffer));
103+ rotations[d180f].path = " " ;
104+ rotations[d180f].changed = true ;
105+ }
106+ } else if (rotated == d180r) {
107+ rotations[d180r].buffer = std::move (rotator.rotate (rotations[d000f].buffer , Rotation::Flip, originalBuffer));
108+ rotations[d180r].path = " " ;
109+ rotations[d180r].changed = true ;
110+ } else {
111+ auto [from, dir] = getMostEfficientRotationTo (direction);
112+ rotations[rotated].buffer = std::move (rotator.rotate (rotations[from].buffer , dir, originalBuffer));
113+ rotations[rotated].path = " " ;
114+ rotations[rotated].changed = true ;
115+ }
97116 }
98117
99118 currentRotation = rotated;
0 commit comments