mirror of https://github.com/OpenRCT2/OpenRCT2.git
Implement DirectionFlipXAxis
This commit is contained in:
parent
d2aca03ff6
commit
55add9883f
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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{};
|
||||
|
|
Loading…
Reference in New Issue