Game/Entities: Fix math problem "Disk Point Picking" in GetRandomPoint (#17577)

This commit is contained in:
P-Kito
2016-07-13 16:41:33 +02:00
committed by Aokromes
parent 615e3115ef
commit 33afe2d927

View File

@@ -1593,7 +1593,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);