Skip to content

Commit 4a7fcfe

Browse files
committed
Core/Entities: Fixed relative position calculation formula in Position::GetPositionOffsetTo
(cherry picked from commit 069449c5018f72287c20d5962ae64a42602d5d7e)
1 parent 67d7734 commit 4a7fcfe

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/server/game/Entities/Object/Position.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ void Position::GetPositionOffsetTo(Position const& endPos, Position& retOffset)
5151
float dx = endPos.GetPositionX() - GetPositionX();
5252
float dy = endPos.GetPositionY() - GetPositionY();
5353

54-
retOffset.m_positionX = dx * std::cos(GetOrientation()) + dy * std::sin(GetOrientation());
55-
retOffset.m_positionY = dy * std::cos(GetOrientation()) - dx * std::sin(GetOrientation());
54+
retOffset.m_positionX = (dx + dy * std::tan(GetOrientation())) / (std::cos(GetOrientation()) + std::sin(GetOrientation()) * std::tan(GetOrientation()));
55+
retOffset.m_positionY = (dy - dx * std::tan(GetOrientation())) / (std::cos(GetOrientation()) + std::sin(GetOrientation()) * std::tan(GetOrientation()));
5656
retOffset.m_positionZ = endPos.GetPositionZ() - GetPositionZ();
5757
retOffset.SetOrientation(endPos.GetOrientation() - GetOrientation());
5858
}

0 commit comments

Comments
 (0)