Float2.h 950 B

1234567891011121314151617181920212223242526272829303132333435
  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(float inX, float inY) : x(inX), y(inY) { }
  14. bool operator == (const Float2 &inRHS) const { return x == inRHS.x && y == inRHS.y; }
  15. bool operator != (const Float2 &inRHS) const { return x != inRHS.x || y != inRHS.y; }
  16. /// To String
  17. friend ostream & operator << (ostream &inStream, const Float2 &inV)
  18. {
  19. inStream << inV.x << ", " << inV.y;
  20. return inStream;
  21. }
  22. float x;
  23. float y;
  24. };
  25. static_assert(is_trivial<Float2>(), "Is supposed to be a trivial type!");
  26. JPH_NAMESPACE_END