Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
BodyAccess.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#ifdef JPH_ENABLE_ASSERTS
8
10
11class BodyAccess
12{
13public:
15 enum class EAccess : uint8
16 {
17 None = 0,
18 Read = 1,
19 ReadWrite = 3,
20 };
21
23 class Grant
24 {
25 public:
26 inline Grant(EAccess inVelocity, EAccess inPosition)
27 {
28 JPH_ASSERT(sVelocityAccess == EAccess::ReadWrite);
29 JPH_ASSERT(sPositionAccess == EAccess::ReadWrite);
30
31 sVelocityAccess = inVelocity;
32 sPositionAccess = inPosition;
33 }
34
35 inline ~Grant()
36 {
37 sVelocityAccess = EAccess::ReadWrite;
38 sPositionAccess = EAccess::ReadWrite;
39 }
40 };
41
43 static bool sCheckRights(EAccess inRights, EAccess inDesiredRights)
44 {
45 return (uint8(inRights) & uint8(inDesiredRights)) == uint8(inDesiredRights);
46 }
47
48 // Various permissions that can be granted
49 static thread_local EAccess sVelocityAccess;
50 static thread_local EAccess sPositionAccess;
51};
52
54
55#endif // JPH_ENABLE_ASSERTS
@ None
No degrees of freedom are allowed. Note that this is not valid and will crash. Use a static body inst...
std::uint8_t uint8
Definition: Core.h:440
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33