Path: blob/master/thirdparty/jolt_physics/Jolt/Physics/SoftBody/SoftBodyUpdateContext.h
9912 views
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)1// SPDX-FileCopyrightText: 2023 Jorrit Rouwe2// SPDX-License-Identifier: MIT34#pragma once56#include <Jolt/Core/NonCopyable.h>7#include <Jolt/Physics/Body/MotionProperties.h>89JPH_NAMESPACE_BEGIN1011class Body;12class SoftBodyMotionProperties;13class SoftBodyContactListener;14class SimShapeFilter;1516/// Temporary data used by the update of a soft body17class SoftBodyUpdateContext : public NonCopyable18{19public:20static constexpr uint cVertexCollisionBatch = 64; ///< Number of vertices to process in a batch in DetermineCollisionPlanes21static constexpr uint cVertexConstraintBatch = 256; ///< Number of vertices to group for processing batches of constraints in ApplyEdgeConstraints2223// Input24Body * mBody; ///< Body that is being updated25SoftBodyMotionProperties * mMotionProperties; ///< Motion properties of that body26SoftBodyContactListener * mContactListener; ///< Contact listener to fire callbacks to27const SimShapeFilter * mSimShapeFilter; ///< Shape filter to use for collision detection28RMat44 mCenterOfMassTransform; ///< Transform of the body relative to the soft body29Vec3 mGravity; ///< Gravity vector in local space of the soft body30Vec3 mDisplacementDueToGravity; ///< Displacement of the center of mass due to gravity in the current time step31float mDeltaTime; ///< Delta time for the current time step32float mSubStepDeltaTime; ///< Delta time for each sub step3334/// Describes progress in the current update35enum class EState36{37DetermineCollisionPlanes, ///< Determine collision planes for vertices in parallel38DetermineSensorCollisions, ///< Determine collisions with sensors in parallel39ApplyConstraints, ///< Apply constraints in parallel40Done ///< Update is finished41};4243// State of the update44atomic<EState> mState { EState::DetermineCollisionPlanes };///< Current state of the update45atomic<uint> mNextCollisionVertex { 0 }; ///< Next vertex to process for DetermineCollisionPlanes46atomic<uint> mNumCollisionVerticesProcessed { 0 }; ///< Number of vertices processed by DetermineCollisionPlanes, used to determine if we can go to the next step47atomic<uint> mNextSensorIndex { 0 }; ///< Next sensor to process for DetermineCollisionPlanes48atomic<uint> mNumSensorsProcessed { 0 }; ///< Number of sensors processed by DetermineSensorCollisions, used to determine if we can go to the next step49atomic<uint> mNextIteration { 0 }; ///< Next simulation iteration to process50atomic<uint> mNextConstraintGroup { 0 }; ///< Next constraint group to process51atomic<uint> mNumConstraintGroupsProcessed { 0 }; ///< Number of groups processed, used to determine if we can go to the next iteration5253// Output54Vec3 mDeltaPosition; ///< Delta position of the body in the current time step, should be applied after the update55ECanSleep mCanSleep; ///< Can the body sleep? Should be applied after the update56};5758JPH_NAMESPACE_END596061