Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
SoftBodyUpdateContext.h
Go to the documentation of this file.
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
9
11
12class Body;
15
18{
19public:
20 static constexpr uint cVertexCollisionBatch = 64;
21 static constexpr uint cEdgeConstraintBatch = 256;
22
23 // Input
30 float mDeltaTime;
32
34 enum class EState
35 {
38 Done
39 };
40
42 static inline uint64 sGetEdgeGroupStart(uint32 inGroup)
43 {
44 return uint64(inGroup) << 32;
45 }
46
48 static inline void sGetEdgeGroupAndStartIdx(uint64 inNextEdgeConstraint, uint32 &outGroup, uint32 &outStartIdx)
49 {
50 outGroup = uint32(inNextEdgeConstraint >> 32);
51 outStartIdx = uint32(inNextEdgeConstraint);
52 }
53
54 // State of the update
56 atomic<uint> mNextCollisionVertex { 0 };
57 atomic<uint> mNumCollisionVerticesProcessed { 0 };
58 atomic<uint> mNextIteration { 0 };
59 atomic<uint64> mNextEdgeConstraint { 0 };
60 atomic<uint> mNumEdgeConstraintsProcessed { 0 };
61
62 // Output
65};
66
std::uint64_t uint64
Definition: Core.h:443
unsigned int uint
Definition: Core.h:439
#define JPH_NAMESPACE_END
Definition: Core.h:367
std::uint32_t uint32
Definition: Core.h:442
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
ECanSleep
Enum that determines if an object can go to sleep.
Definition: MotionProperties.h:22
Definition: Body.h:35
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition: Mat44.h:13
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11
Definition: SoftBodyContactListener.h:33
This class contains the runtime information of a soft body.
Definition: SoftBodyMotionProperties.h:33
Temporary data used by the update of a soft body.
Definition: SoftBodyUpdateContext.h:18
atomic< uint > mNextCollisionVertex
Next vertex to process for DetermineCollisionPlanes.
Definition: SoftBodyUpdateContext.h:56
float mSubStepDeltaTime
Delta time for each sub step.
Definition: SoftBodyUpdateContext.h:31
atomic< uint > mNumEdgeConstraintsProcessed
Number of edge constraints processed by ApplyEdgeConstraints, used to determine if we can go to the n...
Definition: SoftBodyUpdateContext.h:60
atomic< EState > mState
Current state of the update.
Definition: SoftBodyUpdateContext.h:55
SoftBodyContactListener * mContactListener
Contact listener to fire callbacks to.
Definition: SoftBodyUpdateContext.h:26
atomic< uint > mNumCollisionVerticesProcessed
Number of vertices processed by DetermineCollisionPlanes, used to determine if we can start simulatin...
Definition: SoftBodyUpdateContext.h:57
static void sGetEdgeGroupAndStartIdx(uint64 inNextEdgeConstraint, uint32 &outGroup, uint32 &outStartIdx)
Get the group and start index from the edge constraint iterator.
Definition: SoftBodyUpdateContext.h:48
atomic< uint > mNextIteration
Next simulation iteration to process.
Definition: SoftBodyUpdateContext.h:58
static uint64 sGetEdgeGroupStart(uint32 inGroup)
Construct the edge constraint iterator starting at a new group.
Definition: SoftBodyUpdateContext.h:42
Vec3 mDeltaPosition
Delta position of the body in the current time step, should be applied after the update.
Definition: SoftBodyUpdateContext.h:63
float mDeltaTime
Delta time for the current time step.
Definition: SoftBodyUpdateContext.h:30
static constexpr uint cEdgeConstraintBatch
Number of edge constraints to process in a batch in ApplyEdgeConstraints.
Definition: SoftBodyUpdateContext.h:21
RMat44 mCenterOfMassTransform
Transform of the body relative to the soft body.
Definition: SoftBodyUpdateContext.h:27
atomic< uint64 > mNextEdgeConstraint
Next edge constraint group and start index to process.
Definition: SoftBodyUpdateContext.h:59
Body * mBody
Body that is being updated.
Definition: SoftBodyUpdateContext.h:24
SoftBodyMotionProperties * mMotionProperties
Motion properties of that body.
Definition: SoftBodyUpdateContext.h:25
Vec3 mGravity
Gravity vector in local space of the soft body.
Definition: SoftBodyUpdateContext.h:28
Vec3 mDisplacementDueToGravity
Displacement of the center of mass due to gravity in the current time step.
Definition: SoftBodyUpdateContext.h:29
EState
Describes progress in the current update.
Definition: SoftBodyUpdateContext.h:35
@ DetermineCollisionPlanes
Determine collision planes for vertices in parallel.
@ ApplyEdgeConstraints
Apply edge constraints in parallel.
@ Done
Update is finished.
static constexpr uint cVertexCollisionBatch
Number of vertices to process in a batch in DetermineCollisionPlanes.
Definition: SoftBodyUpdateContext.h:20
ECanSleep mCanSleep
Can the body sleep? Should be applied after the update.
Definition: SoftBodyUpdateContext.h:64
Definition: Vec3.h:16