Path: blob/master/thirdparty/jolt_physics/Jolt/Physics/PhysicsSettings.h
9906 views
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)1// SPDX-FileCopyrightText: 2021 Jorrit Rouwe2// SPDX-License-Identifier: MIT34#pragma once56JPH_NAMESPACE_BEGIN78/// If objects are closer than this distance, they are considered to be colliding (used for GJK) (unit: meter)9constexpr float cDefaultCollisionTolerance = 1.0e-4f;1011/// A factor that determines the accuracy of the penetration depth calculation. If the change of the squared distance is less than tolerance * current_penetration_depth^2 the algorithm will terminate. (unit: dimensionless)12constexpr float cDefaultPenetrationTolerance = 1.0e-4f; ///< Stop when there's less than 1% change1314/// How much padding to add around objects15constexpr float cDefaultConvexRadius = 0.05f;1617/// Used by (Tapered)CapsuleShape to determine when supporting face is an edge rather than a point (unit: meter)18static constexpr float cCapsuleProjectionSlop = 0.02f;1920/// Maximum amount of jobs to allow21constexpr int cMaxPhysicsJobs = 2048;2223/// Maximum amount of barriers to allow24constexpr int cMaxPhysicsBarriers = 8;2526struct PhysicsSettings27{28JPH_OVERRIDE_NEW_DELETE2930/// Size of body pairs array, corresponds to the maximum amount of potential body pairs that can be in flight at any time.31/// Setting this to a low value will use less memory but slow down simulation as threads may run out of narrow phase work.32int mMaxInFlightBodyPairs = 16384;3334/// How many PhysicsStepListeners to notify in 1 batch35int mStepListenersBatchSize = 8;3637/// How many step listener batches are needed before spawning another job (set to INT_MAX if no parallelism is desired)38int mStepListenerBatchesPerJob = 1;3940/// Baumgarte stabilization factor (how much of the position error to 'fix' in 1 update) (unit: dimensionless, 0 = nothing, 1 = 100%)41float mBaumgarte = 0.2f;4243/// Radius around objects inside which speculative contact points will be detected. Note that if this is too big44/// you will get ghost collisions as speculative contacts are based on the closest points during the collision detection45/// step which may not be the actual closest points by the time the two objects hit (unit: meters)46float mSpeculativeContactDistance = 0.02f;4748/// How much bodies are allowed to sink into each other (unit: meters)49float mPenetrationSlop = 0.02f;5051/// Fraction of its inner radius a body must move per step to enable casting for the LinearCast motion quality52float mLinearCastThreshold = 0.75f;5354/// Fraction of its inner radius a body may penetrate another body for the LinearCast motion quality55float mLinearCastMaxPenetration = 0.25f;5657/// Max distance to use to determine if two points are on the same plane for determining the contact manifold between two shape faces (unit: meter)58float mManifoldTolerance = 1.0e-3f;5960/// Maximum distance to correct in a single iteration when solving position constraints (unit: meters)61float mMaxPenetrationDistance = 0.2f;6263/// Maximum relative delta position for body pairs to be able to reuse collision results from last frame (units: meter^2)64float mBodyPairCacheMaxDeltaPositionSq = Square(0.001f); ///< 1 mm6566/// Maximum relative delta orientation for body pairs to be able to reuse collision results from last frame, stored as cos(max angle / 2)67float mBodyPairCacheCosMaxDeltaRotationDiv2 = 0.99984769515639123915701155881391f; ///< cos(2 degrees / 2)6869/// Maximum angle between normals that allows manifolds between different sub shapes of the same body pair to be combined70float mContactNormalCosMaxDeltaRotation = 0.99619469809174553229501040247389f; ///< cos(5 degree)7172/// Maximum allowed distance between old and new contact point to preserve contact forces for warm start (units: meter^2)73float mContactPointPreserveLambdaMaxDistSq = Square(0.01f); ///< 1 cm7475/// Number of solver velocity iterations to run76/// Note that this needs to be >= 2 in order for friction to work (friction is applied using the non-penetration impulse from the previous iteration)77uint mNumVelocitySteps = 10;7879/// Number of solver position iterations to run80uint mNumPositionSteps = 2;8182/// Minimal velocity needed before a collision can be elastic. If the relative velocity between colliding objects83/// in the direction of the contact normal is lower than this, the restitution will be zero regardless of the configured84/// value. This lets an object settle sooner. Must be a positive number. (unit: m)85float mMinVelocityForRestitution = 1.0f;8687/// Time before object is allowed to go to sleep (unit: seconds)88float mTimeBeforeSleep = 0.5f;8990/// To detect if an object is sleeping, we use 3 points:91/// - The center of mass.92/// - The centers of the faces of the bounding box that are furthest away from the center.93/// The movement of these points is tracked and if the velocity of all 3 points is lower than this value,94/// the object is allowed to go to sleep. Must be a positive number. (unit: m/s)95float mPointVelocitySleepThreshold = 0.03f;9697/// By default the simulation is deterministic, it is possible to turn this off by setting this setting to false. This will make the simulation run faster but it will no longer be deterministic.98bool mDeterministicSimulation = true;99100///@name These variables are mainly for debugging purposes, they allow turning on/off certain subsystems. You probably want to leave them alone.101///@{102103/// Whether or not to use warm starting for constraints (initially applying previous frames impulses)104bool mConstraintWarmStart = true;105106/// Whether or not to use the body pair cache, which removes the need for narrow phase collision detection when orientation between two bodies didn't change107bool mUseBodyPairContactCache = true;108109/// Whether or not to reduce manifolds with similar contact normals into one contact manifold (see description at Body::SetUseManifoldReduction)110bool mUseManifoldReduction = true;111112/// If we split up large islands into smaller parallel batches of work (to improve performance)113bool mUseLargeIslandSplitter = true;114115/// If objects can go to sleep or not116bool mAllowSleeping = true;117118/// When false, we prevent collision against non-active (shared) edges. Mainly for debugging the algorithm.119bool mCheckActiveEdges = true;120121///@}122};123124JPH_NAMESPACE_END125126127