Double3.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Jolt/Core/HashCombine.h>
  5. JPH_NAMESPACE_BEGIN
  6. /// Class that holds 3 doubles. Used as a storage class. Convert to DVec3 for calculations.
  7. class [[nodiscard]] Double3
  8. {
  9. public:
  10. JPH_OVERRIDE_NEW_DELETE
  11. Double3() = default; ///< Intentionally not initialized for performance reasons
  12. Double3(const Double3 &inRHS) = default;
  13. Double3(double inX, double inY, double inZ) : x(inX), y(inY), z(inZ) { }
  14. double operator [] (int inCoordinate) const
  15. {
  16. JPH_ASSERT(inCoordinate < 3);
  17. return *(&x + inCoordinate);
  18. }
  19. bool operator == (const Double3 &inRHS) const
  20. {
  21. return x == inRHS.x && y == inRHS.y && z == inRHS.z;
  22. }
  23. bool operator != (const Double3 &inRHS) const
  24. {
  25. return x != inRHS.x || y != inRHS.y || z != inRHS.z;
  26. }
  27. double x;
  28. double y;
  29. double z;
  30. };
  31. static_assert(is_trivial<Double3>(), "Is supposed to be a trivial type!");
  32. JPH_NAMESPACE_END
  33. // Create a std::hash for Double3
  34. JPH_MAKE_HASHABLE(JPH::Double3, t.x, t.y, t.z)