Float2.h 886 B

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