Implement DirectionFlipXAxis

This commit is contained in:
ζeh Matt authored and GitHub committed 2021-08-24 22:57:13 +02:00
1 parent d2aca03ff6
commit 55add9883f
3 files changed
+11 -8

No files matched your search

+1 -3
View File
@@ -1148,11 +1148,9 @@ void rct_viewport::Invalidate() const
CoordsXY viewport_coord_to_map_coord(const ScreenCoordsXY& coords, int32_t z)
{
constexpr uint8_t inverseRotationMapping[NumOrthogonalDirections] = { 0, 3, 2, 1 };
// Reverse of translate_3d_to_2d_with_z
CoordsXY ret = { coords.y - coords.x / 2 + z, coords.y + coords.x / 2 + z };
auto inverseRotation = inverseRotationMapping[get_current_rotation()];
auto inverseRotation = DirectionFlipXAxis(get_current_rotation());
return ret.Rotate(inverseRotation);
}
+2 -5
View File
@@ -145,7 +145,7 @@ static paint_struct* CreateNormalPaintStruct(
return nullptr;
}
const uint8_t swappedRotation = (session->CurrentRotation * 3) % 4; // swaps 1 and 3
const auto swappedRotation = DirectionFlipXAxis(session->CurrentRotation);
auto swappedRotCoord = CoordsXYZ{ offset.Rotate(swappedRotation), offset.z };
swappedRotCoord += session->SpritePosition;
@@ -231,10 +231,7 @@ template<uint8_t direction> void PaintSessionGenerateRotate(paint_session* sessi
void PaintSessionGenerate(paint_session* session)
{
session->CurrentRotation = get_current_rotation();
// Extracted from viewport_coord_to_map_coord
constexpr uint8_t inverseRotationMapping[NumOrthogonalDirections] = { 0, 3, 2, 1 };
switch (inverseRotationMapping[session->CurrentRotation])
switch (DirectionFlipXAxis(session->CurrentRotation))
{
case 0:
PaintSessionGenerateRotate<0>(session);
+8
View File
@@ -545,6 +545,14 @@ constexpr Direction ALL_DIRECTIONS[] = { 0, 1, 2, 3 };
}
}
/*
* Flips the X axis so 1 and 3 are swapped 0 and 2 will stay the same.
*/
inline constexpr Direction DirectionFlipXAxis(Direction direction)
{
return (direction * 3) % 4;
}
struct CoordsXYZD : public CoordsXYZ
{
Direction direction{};