Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
StateRecorder.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
9
11
12class Body;
13class Constraint;
14class BodyID;
15
18{
19 None = 0,
20 Global = 1,
21 Bodies = 2,
22 Contacts = 4,
23 Constraints = 8,
25};
26
29{
30public:
32 virtual ~StateRecorderFilter() = default;
33
35 virtual bool ShouldSaveBody([[maybe_unused]] const Body &inBody) const { return true; }
36
38 virtual bool ShouldSaveConstraint([[maybe_unused]] const Constraint &inConstraint) const { return true; }
39
41 virtual bool ShouldSaveContact([[maybe_unused]] const BodyID &inBody1, [[maybe_unused]] const BodyID &inBody2) const { return true; }
42};
43
48{
49public:
51 StateRecorder() = default;
52 StateRecorder(const StateRecorder &inRHS) : mIsValidating(inRHS.mIsValidating) { }
53
59 void SetValidating(bool inValidating) { mIsValidating = inValidating; }
60 bool IsValidating() const { return mIsValidating; }
61
62private:
63 bool mIsValidating = false;
64};
65
std::uint8_t uint8
Definition: Core.h:453
#define JPH_EXPORT
Definition: Core.h:236
#define JPH_NAMESPACE_END
Definition: Core.h:378
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
EStateRecorderState
A bit field that determines which aspects of the simulation to save.
Definition: StateRecorder.h:18
@ Bodies
Save the state of bodies.
@ Global
Save global physics system state (delta time, gravity, etc.)
@ None
Save nothing.
@ Contacts
Save the state of contacts.
@ All
Save all state.
Definition: Body.h:35
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition: BodyID.h:13
Base class for all physics constraints. A constraint removes one or more degrees of freedom for a rig...
Definition: Constraint.h:103
User callbacks that allow determining which parts of the simulation should be saved by a StateRecorde...
Definition: StateRecorder.h:29
virtual bool ShouldSaveConstraint(const Constraint &inConstraint) const
If the state of a specific constraint should be saved.
Definition: StateRecorder.h:38
virtual bool ShouldSaveContact(const BodyID &inBody1, const BodyID &inBody2) const
If the state of a specific contact should be saved.
Definition: StateRecorder.h:41
virtual ~StateRecorderFilter()=default
Destructor.
virtual bool ShouldSaveBody(const Body &inBody) const
If the state of a specific body should be saved.
Definition: StateRecorder.h:35
Definition: StateRecorder.h:48
bool IsValidating() const
Definition: StateRecorder.h:60
StateRecorder(const StateRecorder &inRHS)
Definition: StateRecorder.h:52
void SetValidating(bool inValidating)
Definition: StateRecorder.h:59
StateRecorder()=default
Constructor.
Simple binary input stream.
Definition: StreamIn.h:13
Simple binary output stream.
Definition: StreamOut.h:13