std::uint8_t uint8
Definition: Core.h:453
#define JPH_CACHE_LINE_SIZE
Definition: Core.h:492
unsigned int uint
Definition: Core.h:452
#define JPH_NAMESPACE_END
Definition: Core.h:378
std::uint32_t uint32
Definition: Core.h:455
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
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
Keeps track of connected bodies and builds islands for multithreaded velocity/position update.
Definition: IslandBuilder.h:19
A job barrier keeps track of a number of jobs and allows waiting until they are all completed.
Definition: JobSystem.h:123
Definition: JobSystem.h:80
Definition: JobSystem.h:70
virtual int GetMaxConcurrency() const =0
Get maximum number of concurrently executing jobs.
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11
Definition: PhysicsSystem.h:29
Information used during the Update call.
Definition: PhysicsUpdateContext.h:24
~PhysicsUpdateContext()
Definition: PhysicsUpdateContext.cpp:17
SoftBodyUpdateContext * mSoftBodyUpdateContexts
Contexts for updating soft bodies.
Definition: PhysicsUpdateContext.h:168
Constraint ** mActiveConstraints
Constraints that were active at the start of the physics update step (activating bodies can activate ...
Definition: PhysicsUpdateContext.h:159
PhysicsSystem * mPhysicsSystem
The physics system we belong to.
Definition: PhysicsUpdateContext.h:150
JobSystem::Barrier * mBarrier
Barrier used to wait for all physics jobs to complete.
Definition: PhysicsUpdateContext.h:153
int GetMaxConcurrency() const
Maximum amount of concurrent jobs on this machine.
Definition: PhysicsUpdateContext.h:148
Steps mSteps
Definition: PhysicsUpdateContext.h:165
float mStepDeltaTime
Delta time for a simulation step (collision step)
Definition: PhysicsUpdateContext.h:155
float mWarmStartImpulseRatio
Ratio of this step delta time vs last step.
Definition: PhysicsUpdateContext.h:156
uint32 JobMask
A mask that has as many bits as we can have concurrent jobs.
Definition: PhysicsUpdateContext.h:47
atomic< uint32 > mErrors
Errors that occurred during the update, actual type is EPhysicsUpdateError.
Definition: PhysicsUpdateContext.h:157
JobSystem * mJobSystem
Job system that processes jobs.
Definition: PhysicsUpdateContext.h:152
TempAllocator * mTempAllocator
Temporary allocator used during the update.
Definition: PhysicsUpdateContext.h:151
BodyPair * mBodyPairs
A list of body pairs found by the broadphase.
Definition: PhysicsUpdateContext.h:161
static constexpr int cMaxConcurrency
Maximum supported amount of concurrent jobs.
Definition: PhysicsUpdateContext.h:30
atomic< uint > mSoftBodyToCollide
Next soft body to take when running SoftBodyCollide jobs.
Definition: PhysicsUpdateContext.h:169
uint mNumSoftBodies
Number of active soft bodies in the simulation.
Definition: PhysicsUpdateContext.h:167
IslandBuilder * mIslandBuilder
Keeps track of connected bodies and builds islands for multithreaded velocity/position update.
Definition: PhysicsUpdateContext.h:163
Temporary data used by the update of a soft body.
Definition: SoftBodyUpdateContext.h:18
A sub shape id contains a path to an element (usually a triangle or other primitive type) of a compou...
Definition: SubShapeID.h:23
Definition: TempAllocator.h:16
Structure that holds a body pair.
Definition: BodyPair.h:14
Context used during broadphase update.
Definition: BroadPhase.h:44
Definition: PhysicsUpdateContext.h:37
atomic< uint32 > mReadIdx
Next index to read in mBodyPair array (need to add thread index * mMaxBodyPairsPerQueue and modulo mM...
Definition: PhysicsUpdateContext.h:41
uint8 mPadding1[JPH_CACHE_LINE_SIZE - sizeof(atomic< uint32 >)]
Moved to own cache line to avoid conflicts with consumer jobs.
Definition: PhysicsUpdateContext.h:39
uint8 mPadding2[JPH_CACHE_LINE_SIZE - sizeof(atomic< uint32 >)]
Moved to own cache line to avoid conflicts with producer/consumer jobs.
Definition: PhysicsUpdateContext.h:42
atomic< uint32 > mWriteIdx
Next index to write in mBodyPair array (need to add thread index * mMaxBodyPairsPerQueue and modulo m...
Definition: PhysicsUpdateContext.h:38
Contains the information needed to cast a body through the scene to do continuous collision detection...
Definition: PhysicsUpdateContext.h:97
float mMaxPenetration
Maximum allowed penetration (determined by inner radius of shape)
Definition: PhysicsUpdateContext.h:109
RVec3 mContactPointOn2
World space contact point on body 2 of closest hit (only valid if mFractionPlusSlop < 1)
Definition: PhysicsUpdateContext.h:102
float mLinearCastThresholdSq
Maximum allowed squared movement before doing a linear cast (determined by inner radius of shape)
Definition: PhysicsUpdateContext.h:108
Vec3 mDeltaPosition
Desired rotation step.
Definition: PhysicsUpdateContext.h:100
SubShapeID mSubShapeID2
Sub shape of body 2 that was hit (only valid if mFractionPlusSlop < 1)
Definition: PhysicsUpdateContext.h:105
BodyID mBodyID2
Body 2 (the body of the closest hit, only valid if mFractionPlusSlop < 1)
Definition: PhysicsUpdateContext.h:104
Vec3 mContactNormal
World space normal of closest hit (only valid if mFractionPlusSlop < 1)
Definition: PhysicsUpdateContext.h:101
ContactSettings mContactSettings
The contact settings for this contact.
Definition: PhysicsUpdateContext.h:110
CCDBody(BodyID inBodyID1, Vec3Arg inDeltaPosition, float inLinearCastThresholdSq, float inMaxPenetration)
Definition: PhysicsUpdateContext.h:98
float mFraction
Fraction at which the hit occurred.
Definition: PhysicsUpdateContext.h:106
float mFractionPlusSlop
Fraction at which the hit occurred + extra delta to allow body to penetrate by mMaxPenetration.
Definition: PhysicsUpdateContext.h:107
BodyID mBodyID1
Body 1 (the body that is performing collision detection)
Definition: PhysicsUpdateContext.h:103
Structure that contains data needed for each collision step.
Definition: PhysicsUpdateContext.h:52
JobHandleArray mFindCollisions
Find all collisions between active bodies an the world.
Definition: PhysicsUpdateContext.h:125
uint8 mPadding4[JPH_CACHE_LINE_SIZE - sizeof(atomic< uint32 >)]
Padding to avoid sharing cache line with the next atomic.
Definition: PhysicsUpdateContext.h:75
atomic< uint32 > mSolveVelocityConstraintsNextIsland
Next island that needs to be processed for the solve velocity constraints step (doesn't need own cach...
Definition: PhysicsUpdateContext.h:92
uint32 mNumActiveBodyToCCDBody
Number of indices in mActiveBodyToCCDBody.
Definition: PhysicsUpdateContext.h:118
bool mIsLast
If this is the last step.
Definition: PhysicsUpdateContext.h:59
JobHandleArray mSoftBodyCollide
Finds all colliding shapes for soft bodies.
Definition: PhysicsUpdateContext.h:139
uint8 mPadding6[JPH_CACHE_LINE_SIZE - sizeof(atomic< uint32 >)]
Padding to avoid sharing cache line with the next atomic.
Definition: PhysicsUpdateContext.h:81
uint8 mPadding3[JPH_CACHE_LINE_SIZE - sizeof(atomic< uint32 >)]
Padding to avoid sharing cache line with the next atomic.
Definition: PhysicsUpdateContext.h:72
JobHandleArray mSolveVelocityConstraints
Solve the constraints in the velocity domain.
Definition: PhysicsUpdateContext.h:131
JobHandle mPostIntegrateVelocity
Finalize integration of all body positions.
Definition: PhysicsUpdateContext.h:134
JobHandle mPreIntegrateVelocity
Setup integration of all body positions.
Definition: PhysicsUpdateContext.h:132
atomic< uint32 > mNumCCDBodies
Number of CCD bodies in mCCDBodies.
Definition: PhysicsUpdateContext.h:115
atomic< uint32 > mStepListenerReadIdx
Next step listener to call.
Definition: PhysicsUpdateContext.h:74
uint32 mCCDBodiesCapacity
Capacity of the mCCDBodies list.
Definition: PhysicsUpdateContext.h:114
atomic< uint > mNumBodyPairs
The number of body pairs found in this step (used to size the contact cache in the next step)
Definition: PhysicsUpdateContext.h:89
JobHandle mContactRemovedCallbacks
Calls the contact removed callbacks.
Definition: PhysicsUpdateContext.h:137
JobHandle mBuildIslandsFromConstraints
Go over all constraints and assign the bodies they're attached to to an island.
Definition: PhysicsUpdateContext.h:128
JobHandleArray mSolvePositionConstraints
Solve all constraints in the position domain.
Definition: PhysicsUpdateContext.h:136
uint8 mPadding2[JPH_CACHE_LINE_SIZE - sizeof(atomic< uint32 >)]
Padding to avoid sharing cache line with the next atomic.
Definition: PhysicsUpdateContext.h:69
JobHandle mSoftBodyFinalize
Finalizes the soft body update.
Definition: PhysicsUpdateContext.h:141
atomic< uint32 > mActiveBodyReadIdx
Index of fist active body that has not yet been processed by the broadphase.
Definition: PhysicsUpdateContext.h:80
atomic< uint32 > mSolvePositionConstraintsNextIsland
Next island that needs to be processed for the solve position constraints step (doesn't need own cach...
Definition: PhysicsUpdateContext.h:93
atomic< uint > mNumManifolds
The number of manifolds found in this step (used to size the contact cache in the next step)
Definition: PhysicsUpdateContext.h:90
uint32 mNumActiveBodiesAtStepStart
Number of bodies that were active at the start of the physics update step. Only these bodies will rec...
Definition: PhysicsUpdateContext.h:63
JobHandleArray mIntegrateVelocity
Integrate all body positions.
Definition: PhysicsUpdateContext.h:133
JobHandle mResolveCCDContacts
Updates the positions and velocities for all bodies that need continuous collision detection.
Definition: PhysicsUpdateContext.h:135
atomic< uint32 > mSetupVelocityConstraintsReadIdx
Next constraint for setting up velocity constraints.
Definition: PhysicsUpdateContext.h:71
JobHandleArray mApplyGravity
Update velocities of bodies with gravity.
Definition: PhysicsUpdateContext.h:124
uint8 mPadding1[JPH_CACHE_LINE_SIZE - sizeof(atomic< uint32 >)]
Padding to avoid sharing cache line with the next atomic.
Definition: PhysicsUpdateContext.h:66
uint8 mPadding5[JPH_CACHE_LINE_SIZE - sizeof(atomic< uint32 >)]
Padding to avoid sharing cache line with the next atomic.
Definition: PhysicsUpdateContext.h:78
Step(const Step &)
Definition: PhysicsUpdateContext.h:54
JobHandle mStartNextStep
Job that kicks the next step (empty for the last step)
Definition: PhysicsUpdateContext.h:142
bool mIsFirst
If this is the first step.
Definition: PhysicsUpdateContext.h:58
CCDBody * mCCDBodies
List of bodies that need to do continuous collision detection.
Definition: PhysicsUpdateContext.h:113
JobHandleArray mSetupVelocityConstraints
Calculate properties for all constraints in the constraint manager.
Definition: PhysicsUpdateContext.h:127
atomic< JobMask > mActiveFindCollisionJobs
A bitmask that indicates which jobs are still active.
Definition: PhysicsUpdateContext.h:87
JobHandle mBodySetIslandIndex
Set the current island index on each body (not used by the simulation, only for drawing purposes)
Definition: PhysicsUpdateContext.h:130
JobHandle mFinalizeIslands
Finalize calculation simulation islands.
Definition: PhysicsUpdateContext.h:129
JobHandleArray mStepListeners
Listeners to notify of the beginning of a physics step.
Definition: PhysicsUpdateContext.h:122
JobHandle mUpdateBroadphaseFinalize
Swap the newly built tree with the current tree.
Definition: PhysicsUpdateContext.h:126
JobHandleArray mSoftBodySimulate
Simulates all particles.
Definition: PhysicsUpdateContext.h:140
PhysicsUpdateContext * mContext
The physics update context.
Definition: PhysicsUpdateContext.h:56
atomic< uint32 > mNextCCDBody
Next unprocessed body index in mCCDBodies.
Definition: PhysicsUpdateContext.h:116
atomic< uint32 > mApplyGravityReadIdx
Next body to apply gravity to.
Definition: PhysicsUpdateContext.h:77
uint32 mMaxBodyPairsPerQueue
Amount of body pairs that we can queue per queue.
Definition: PhysicsUpdateContext.h:85
atomic< uint32 > mIntegrateVelocityReadIdx
Next active body index to take when integrating velocities.
Definition: PhysicsUpdateContext.h:112
JobHandleArray mDetermineActiveConstraints
Determine which constraints will be active during this step.
Definition: PhysicsUpdateContext.h:123
int * mActiveBodyToCCDBody
A mapping between an index in BodyManager::mActiveBodies and the index in mCCDBodies.
Definition: PhysicsUpdateContext.h:117
atomic< uint32 > mNumActiveConstraints
Number of constraints in the mActiveConstraints array.
Definition: PhysicsUpdateContext.h:68
atomic< uint32 > mDetermineActiveConstraintReadIdx
Next constraint for determine active constraints.
Definition: PhysicsUpdateContext.h:65
BroadPhase::UpdateState mBroadPhaseUpdateState
Handle returned by Broadphase::UpdatePrepare.
Definition: PhysicsUpdateContext.h:61
BodyPairQueues mBodyPairQueues
Queues in which to put body pairs that need to be tested by the narrowphase.
Definition: PhysicsUpdateContext.h:83
JobHandle mSoftBodyPrepare
Prepares updating the soft bodies.
Definition: PhysicsUpdateContext.h:138
JobHandle mBroadPhasePrepare
Prepares the new tree in the background.
Definition: PhysicsUpdateContext.h:121