Remove redundant rotate function (#1046)

This commit is contained in:
Duncan 2021-07-09 13:54:06 +01:00 committed by GitHub
parent 6a4e022af8
commit ee83e9f53c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 37 deletions

View File

@ -219,31 +219,4 @@ namespace OpenLoco::Map
return coordinate_2d;
}
Pos2 rotate2dCoordinate(Pos2 pos, uint8_t rotation)
{
Pos2 coordinate2D;
switch (rotation)
{
default:
case 0:
coordinate2D = pos;
break;
case 1:
coordinate2D.x = pos.y;
coordinate2D.y = -pos.x;
break;
case 2:
coordinate2D.x = -pos.x;
coordinate2D.y = -pos.y;
break;
case 3:
coordinate2D.x = -pos.y;
coordinate2D.y = pos.x;
break;
}
return coordinate2D;
}
}

View File

@ -31,7 +31,6 @@ namespace OpenLoco::Map
constexpr Pos2 offsets[4] = { { 0, 0 }, { 0, 32 }, { 32, 32 }, { 32, 0 } };
Ui::viewport_pos coordinate3dTo2d(int16_t x, int16_t y, int16_t z, int rotation);
Pos2 rotate2dCoordinate(Pos2 pos, uint8_t rotation);
enum class ElementType
{

View File

@ -462,8 +462,8 @@ namespace OpenLoco
Pos2 minPos(airportObject->min_x * 32, airportObject->min_y * 32);
Pos2 maxPos(airportObject->max_x * 32, airportObject->max_y * 32);
minPos = rotate2dCoordinate(minPos, stationElement->rotation());
maxPos = rotate2dCoordinate(maxPos, stationElement->rotation());
minPos = Math::Vector::rotate(minPos, stationElement->rotation());
maxPos = Math::Vector::rotate(maxPos, stationElement->rotation());
minPos.x += pos.x;
minPos.y += pos.y;

View File

@ -314,7 +314,7 @@ namespace OpenLoco::Ui::Windows::Construction::Construction
Pos2 pos = { roadPart.x, roadPart.y };
pos = rotate2dCoordinate(pos, rotation);
pos = Math::Vector::rotate(pos, rotation);
pos.x += x;
pos.y += y;
@ -507,7 +507,7 @@ namespace OpenLoco::Ui::Windows::Construction::Construction
}
Pos2 pos = { trackPart.x, trackPart.y };
pos = rotate2dCoordinate(pos, rotation);
pos = Math::Vector::rotate(pos, rotation);
pos.x += x;
pos.y += y;
@ -2031,7 +2031,7 @@ namespace OpenLoco::Ui::Windows::Construction::Construction
pos3D.y = 0;
}
auto rotatedPos = rotate2dCoordinate({ pos3D.x, pos3D.y }, _byte_1136078 & 3);
auto rotatedPos = Math::Vector::rotate(pos3D, _byte_1136078 & 3);
pos3D.x = rotatedPos.x / 2;
pos3D.y = rotatedPos.y / 2;
pos3D.x += 0x2010;
@ -2081,7 +2081,7 @@ namespace OpenLoco::Ui::Windows::Construction::Construction
pos3D.y = 0;
}
auto rotatedPos = rotate2dCoordinate({ pos3D.x, pos3D.y }, _byte_1136078 & 3);
auto rotatedPos = Math::Vector::rotate(pos3D, _byte_1136078 & 3);
pos3D.x = rotatedPos.x / 2;
pos3D.y = rotatedPos.y / 2;
pos3D.x += 0x2010;

View File

@ -251,7 +251,7 @@ namespace OpenLoco::Ui::Windows::Construction::Overhead
coord_t x = 0x2010;
coord_t y = 0x2010;
auto rotCoord = rotate2dCoordinate({ x, y }, gCurrentRotation);
auto rotCoord = Math::Vector::rotate(Pos2{ x, y }, gCurrentRotation);
Gfx::point_t screenPos = { static_cast<int16_t>(rotCoord.y - rotCoord.x), static_cast<int16_t>(((rotCoord.x + rotCoord.y) >> 1) - 460) };
screenPos.x -= (self->widgets[widx::image].width() / 2);

View File

@ -2666,7 +2666,7 @@ namespace OpenLoco::Ui::Windows::Vehicle
const auto& trackPiece = Map::TrackData::getTrackPiece(trackId);
const auto& trackPart = trackPiece[trackElement->sequenceIndex()];
auto offsetToFirstTile = Map::rotate2dCoordinate({ trackPart.x, trackPart.y }, trackElement->unkDirection());
auto offsetToFirstTile = Math::Vector::rotate(Pos2{ trackPart.x, trackPart.y }, trackElement->unkDirection());
auto firstTilePos = args.pos - offsetToFirstTile;
TilePos2 tPos{ firstTilePos };
height -= trackPart.z;
@ -2714,7 +2714,7 @@ namespace OpenLoco::Ui::Windows::Vehicle
const auto& roadPiece = Map::TrackData::getRoadPiece(roadId);
const auto& roadPart = roadPiece[roadElement->sequenceIndex()];
auto offsetToFirstTile = Map::rotate2dCoordinate({ roadPart.x, roadPart.y }, roadElement->unkDirection());
auto offsetToFirstTile = Math::Vector::rotate(Pos2{ roadPart.x, roadPart.y }, roadElement->unkDirection());
auto firstTilePos = args.pos - offsetToFirstTile;
TilePos2 tPos{ firstTilePos };
height -= roadPart.z;