Float4.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 4 float values. Convert to Vec4 to perform calculations.
  7. class [[nodiscard]] Float4
  8. {
  9. public:
  10. JPH_OVERRIDE_NEW_DELETE
  11. Float4() = default; ///< Intentionally not initialized for performance reasons
  12. Float4(const Float4 &inRHS) = default;
  13. Float4(float inX, float inY, float inZ, float inW) : x(inX), y(inY), z(inZ), w(inW) { }
  14. Float4 & operator = (const Float4 &inRHS) = default;
  15. float operator [] (int inCoordinate) const
  16. {
  17. JPH_ASSERT(inCoordinate < 4);
  18. return *(&x + inCoordinate);
  19. }
  20. bool operator == (const Float4 &inRHS) const
  21. {
  22. return x == inRHS.x && y == inRHS.y && z == inRHS.z && w == inRHS.w;
  23. }
  24. bool operator != (const Float4 &inRHS) const
  25. {
  26. return x != inRHS.x || y != inRHS.y || z != inRHS.z || w != inRHS.w;
  27. }
  28. float x;
  29. float y;
  30. float z;
  31. float w;
  32. };
  33. static_assert(std::is_trivial<Float4>(), "Is supposed to be a trivial type!");
  34. JPH_NAMESPACE_END