Float2.h 846 B

1234567891011121314151617181920212223242526272829303132
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. namespace JPH {
  5. /// Class that holds 2 floats, used as a storage class mainly.
  6. class [[nodiscard]] Float2
  7. {
  8. public:
  9. Float2() = default; ///< Intentionally not initialized for performance reasons
  10. Float2(const Float2 &inRHS) = default;
  11. Float2(float inX, float inY) : x(inX), y(inY) { }
  12. bool operator == (const Float2 &inRHS) const { return x == inRHS.x && y == inRHS.y; }
  13. bool operator != (const Float2 &inRHS) const { return x != inRHS.x || y != inRHS.y; }
  14. /// To String
  15. friend ostream & operator << (ostream &inStream, const Float2 &inV)
  16. {
  17. inStream << inV.x << ", " << inV.y;
  18. return inStream;
  19. }
  20. float x;
  21. float y;
  22. };
  23. static_assert(is_trivial<Float2>(), "Is supposed to be a trivial type!");
  24. } // JPH