Float2.h 1006 B

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