diff options
author | P-Kito <kito@vortexirc.com> | 2016-07-13 16:41:33 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2016-07-13 16:41:33 +0200 |
commit | 0aad705f95a4cead2e083396beead46c6e2446df (patch) | |
tree | 6195c95943e12698840e3dbb727a7aa49200d003 /src | |
parent | 01dba54c12777c337d916493889bb92ae93c12be (diff) |
Game/Entities: Fix math problem "Disk Point Picking" in GetRandomPoint (#17577)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index e389af1f636..9f8420d14b9 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1403,7 +1403,8 @@ void WorldObject::GetRandomPoint(const Position &pos, float distance, float &ran // angle to face `obj` to `this` float angle = (float)rand_norm()*static_cast<float>(2*M_PI); - float new_dist = (float)rand_norm()*static_cast<float>(distance); + float new_dist = (float)rand_norm() + (float)rand_norm(); + new_dist = distance * (new_dist > 1 ? new_dist - 2 : new_dist); rand_x = pos.m_positionX + new_dist * std::cos(angle); rand_y = pos.m_positionY + new_dist * std::sin(angle); |