AllowedDOFs.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2023 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. JPH_NAMESPACE_BEGIN
  6. /// Enum used in BodyCreationSettings and MotionProperties to indicate which degrees of freedom a body has
  7. enum class EAllowedDOFs : uint8
  8. {
  9. None = 0b000000, ///< No degrees of freedom are allowed. Note that this is not valid and will crash. Use a static body instead.
  10. All = 0b111111, ///< All degrees of freedom are allowed
  11. TranslationX = 0b000001, ///< Body can move in world space X axis
  12. TranslationY = 0b000010, ///< Body can move in world space Y axis
  13. TranslationZ = 0b000100, ///< Body can move in world space Z axis
  14. RotationX = 0b001000, ///< Body can rotate around world space X axis
  15. RotationY = 0b010000, ///< Body can rotate around world space Y axis
  16. RotationZ = 0b100000, ///< Body can rotate around world space Z axis
  17. Plane2D = TranslationX | TranslationY | RotationZ, ///< Body can only move in X and Y axis and rotate around Z axis
  18. };
  19. /// Bitwise OR operator for EAllowedDOFs
  20. constexpr EAllowedDOFs operator | (EAllowedDOFs inLHS, EAllowedDOFs inRHS)
  21. {
  22. return EAllowedDOFs(uint8(inLHS) | uint8(inRHS));
  23. }
  24. /// Bitwise AND operator for EAllowedDOFs
  25. constexpr EAllowedDOFs operator & (EAllowedDOFs inLHS, EAllowedDOFs inRHS)
  26. {
  27. return EAllowedDOFs(uint8(inLHS) & uint8(inRHS));
  28. }
  29. /// Bitwise XOR operator for EAllowedDOFs
  30. constexpr EAllowedDOFs operator ^ (EAllowedDOFs inLHS, EAllowedDOFs inRHS)
  31. {
  32. return EAllowedDOFs(uint8(inLHS) ^ uint8(inRHS));
  33. }
  34. /// Bitwise NOT operator for EAllowedDOFs
  35. constexpr EAllowedDOFs operator ~ (EAllowedDOFs inAllowedDOFs)
  36. {
  37. return EAllowedDOFs(~uint8(inAllowedDOFs));
  38. }
  39. /// Bitwise OR assignment operator for EAllowedDOFs
  40. constexpr EAllowedDOFs & operator |= (EAllowedDOFs &ioLHS, EAllowedDOFs inRHS)
  41. {
  42. ioLHS = ioLHS | inRHS;
  43. return ioLHS;
  44. }
  45. /// Bitwise AND assignment operator for EAllowedDOFs
  46. constexpr EAllowedDOFs & operator &= (EAllowedDOFs &ioLHS, EAllowedDOFs inRHS)
  47. {
  48. ioLHS = ioLHS & inRHS;
  49. return ioLHS;
  50. }
  51. /// Bitwise XOR assignment operator for EAllowedDOFs
  52. constexpr EAllowedDOFs & operator ^= (EAllowedDOFs &ioLHS, EAllowedDOFs inRHS)
  53. {
  54. ioLHS = ioLHS ^ inRHS;
  55. return ioLHS;
  56. }
  57. JPH_NAMESPACE_END