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