Browse Source

`Displacement#distance`: Use a naive hypot impl

`std::hypot` is much slower than a naive implementation.
It has the advantage of extra precision but we don't need that at all.
pull/6679/head
Gleb Mazovetskiy 2 years ago committed by Anders Jenbo
parent
commit
d5e5fdeffa
  1. 3
      Source/engine/displacement.hpp

3
Source/engine/displacement.hpp

@ -120,7 +120,8 @@ struct DisplacementOf {
float magnitude() const
{
return static_cast<float>(hypot(deltaX, deltaY));
// We do not use `std::hypot` here because it is slower and we do not need the extra precision.
return sqrtf(deltaX * deltaX + deltaY * deltaY);
}
/**

Loading…
Cancel
Save