Float3.h 1.1 KB

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