Skip to content

Commit

Permalink
More robust fix for floating point imprecision. This should fix issue #…
Browse files Browse the repository at this point in the history
  • Loading branch information
namreeb committed Sep 19, 2023
1 parent 8875f94 commit 7142566
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion utility/MathHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ float Convert::ToRadians(float degrees)

void Convert::WorldToAdt(const Vector3& vertex, int& adtX, int& adtY)
{
auto constexpr mid = 32.0 * MeshSettings::AdtSize;
// FIXME: We can't use MeshSettings::AdtSize here because of floating point
// imprecision. Should consider changing MeshSettings:: values to double.
auto constexpr mid = 32.0 * (533.0 + (1.0 / 3.0));

adtX = static_cast<int>((mid - vertex.Y) / MeshSettings::AdtSize);
adtY = static_cast<int>((mid - vertex.X) / MeshSettings::AdtSize);
}
Expand Down

0 comments on commit 7142566

Please sign in to comment.