| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include <Jolt/Core/StreamIn.h> |
| 8 |
#include <Jolt/Core/StreamOut.h> |
| 9 |
|
| 10 |
JPH_NAMESPACE_BEGIN |
| 11 |
|
| 12 |
class Body; |
| 13 |
class Constraint; |
| 14 |
class BodyID; |
| 15 |
|
| 16 |
JPH_SUPPRESS_WARNING_PUSH |
| 17 |
JPH_GCC_SUPPRESS_WARNING("-Wshadow") // GCC complains about the 'Constraints' value conflicting with the 'Constraints' typedef |
| 18 |
|
| 19 |
|
| 20 |
enum class EStateRecorderState : uint8 |
| 21 |
{ |
| 22 |
None = 0, |
| 23 |
Global = 1, |
| 24 |
Bodies = 2, |
| 25 |
Contacts = 4, |
| 26 |
Constraints = 8, |
| 27 |
All = Global | Bodies | Contacts | Constraints |
| 28 |
}; |
| 29 |
|
| 30 |
JPH_SUPPRESS_WARNING_POP |
| 31 |
|
| 32 |
|
| 33 |
constexpr EStateRecorderState operator | (EStateRecorderState inLHS, EStateRecorderState inRHS) |
| 34 |
{ |
| 35 |
return EStateRecorderState(uint8(inLHS) | uint8(inRHS)); |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
constexpr EStateRecorderState operator & (EStateRecorderState inLHS, EStateRecorderState inRHS) |
| 40 |
{ |
| 41 |
return EStateRecorderState(uint8(inLHS) & uint8(inRHS)); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
constexpr EStateRecorderState operator ^ (EStateRecorderState inLHS, EStateRecorderState inRHS) |
| 46 |
{ |
| 47 |
return EStateRecorderState(uint8(inLHS) ^ uint8(inRHS)); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
constexpr EStateRecorderState operator ~ (EStateRecorderState inAllowedDOFs) |
| 52 |
{ |
| 53 |
return EStateRecorderState(~uint8(inAllowedDOFs)); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
constexpr EStateRecorderState & operator |= (EStateRecorderState &ioLHS, EStateRecorderState inRHS) |
| 58 |
{ |
| 59 |
ioLHS = ioLHS | inRHS; |
| 60 |
return ioLHS; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
constexpr EStateRecorderState & operator &= (EStateRecorderState &ioLHS, EStateRecorderState inRHS) |
| 65 |
{ |
| 66 |
ioLHS = ioLHS & inRHS; |
| 67 |
return ioLHS; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
constexpr EStateRecorderState & operator ^= (EStateRecorderState &ioLHS, EStateRecorderState inRHS) |
| 72 |
{ |
| 73 |
ioLHS = ioLHS ^ inRHS; |
| 74 |
return ioLHS; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
class JPH_EXPORT StateRecorderFilter |
| 79 |
{ |
| 80 |
public: |
| 81 |
|
| 82 |
virtual ~StateRecorderFilter() = default; |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
virtual bool ShouldSaveBody([[maybe_unused]] const Body &inBody) const { return true; } |
| 89 |
|
| 90 |
|
| 91 |
virtual bool ShouldSaveConstraint([[maybe_unused]] const Constraint &inConstraint) const { return true; } |
| 92 |
|
| 93 |
|
| 94 |
virtual bool ShouldSaveContact([[maybe_unused]] const BodyID &inBody1, [[maybe_unused]] const BodyID &inBody2) const { return true; } |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
virtual bool ShouldRestoreContact([[maybe_unused]] const BodyID &inBody1, [[maybe_unused]] const BodyID &inBody2) const { return true; } |
| 102 |
|
| 103 |
|
| 104 |
}; |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
class JPH_EXPORT StateRecorder : public StreamIn, public StreamOut |
| 110 |
{ |
| 111 |
public: |
| 112 |
|
| 113 |
StateRecorder() = default; |
| 114 |
StateRecorder(const StateRecorder &inRHS) : mIsValidating(inRHS.mIsValidating) { } |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
void SetValidating(bool inValidating) { mIsValidating = inValidating; } |
| 122 |
bool IsValidating() const { return mIsValidating; } |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
void SetIsLastPart(bool inIsLastPart) { mIsLastPart = inIsLastPart; } |
| 129 |
bool IsLastPart() const { return mIsLastPart; } |
| 130 |
|
| 131 |
private: |
| 132 |
bool mIsValidating = false; |
| 133 |
bool mIsLastPart = true; |
| 134 |
}; |
| 135 |
|
| 136 |
JPH_NAMESPACE_END |