java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.PhysicsSettings
- All Implemented Interfaces:
ConstJoltPhysicsObject,ConstPhysicsSettings,AutoCloseable,Comparable<JoltPhysicsObject>
A component of a
PhysicsSystem, used to configure simulation
parameters.-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate default settings.PhysicsSettings(ConstPhysicsSettings original) Instantiate a copy of the specified settings. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTest whether objects can fall asleep.floatReturn the Baumgarte stabilization factor, the fraction of position error that is corrected in each iteration.floatReturn the maximum rotation for reusing collision results from the previous step.floatReturn the maximum translation for re-using collision results from the previous step.booleanTest whether collisions with non-active (shared) edges are checked.booleanTest whether warm starting is enabled for constraints.floatReturn the maximum angle between normals for which manifolds from different sub shapes of the same body pair will be combined.floatReturn the maximum translation of a contact point for warm starting.booleanTest whether physics simulation is deterministic.floatReturn the amount of penetration tolerated by aLinearCastcast.floatReturn the amount of translation that triggers casting forLinearCastmotion quality.floatReturn the tolerance used to determine whether 2 points are coplanar when calculating the contact manifold between 2 faces.intReturn the maximum number of in-flight body pairs.floatReturn the maximum distance to correct in a single iteration when solving position constraints.floatReturn the minimum normal speed for elastic collision.intReturn the number of solver position iterations per simulation step.intReturn the number of velocity iterations per simulation step.floatReturn the penetration slop.floatReturn the point-motion threshold, below which objects can fall asleep.floatReturn the speculative contact distance.intReturn the maximum number of step-listener batches notified by a single job.intReturn the maximum number of step listeners notified in a single batch.floatReturn the time interval before a body can fall asleep.booleanTest whether the body-pair cache is enabled.booleanTest whether island splitting is enabled.booleanTest whether manifold reduction is enabled.voidsetAllowSleeping(boolean allow) Alter whether objects can fall asleep.voidsetBaumgarte(float fraction) Alter the Baumgarte stabilization factor, the fraction of position error to correct in each update.voidsetBodyPairCacheCosMaxDeltaRotationDiv2(float cosineOfHalfAngle) Return the maximum rotation to reuse collision results from the previous step.voidsetBodyPairCacheMaxDeltaPositionSq(float squaredDistance) Alter the maximum translation to reuse collision results from the previous step.voidsetCheckActiveEdges(boolean check) Enable or disable collision checking with non-active (shared) edges.voidsetConstraintWarmStart(boolean enable) Alter whether warm starting for constraints (initially applying previous frames impulses) should be used.voidsetContactNormalCosMaxDeltaRotation(float cosine) Alter the maximum angle between normals to allow combining manifolds.voidsetContactPointPreserveLambdaMaxDistSq(float squaredDistance) Alter the maximum translation of a contact point for warm starting.voidsetDeterministicSimulation(boolean setting) Alter whether physics simulation is deterministic.voidsetLinearCastMaxPenetration(float distance) Alter the amount of penetration tolerated by aLinearCastcast.voidsetLinearCastThreshold(float threshold) Alter the amount of translation to activate casting forLinearCastmotion quality.voidsetManifoldTolerance(float tolerance) Alter the tolerance for 2 points to be considered coplanar when determining the contact manifold between two faces.voidsetMaxInFlightBodyPairs(int maxPairs) Alter the capacity of the in-flight body pairs array.voidsetMaxPenetrationDistance(float distance) Alter the maximum correction when solving position constraints.voidsetMinVelocityForRestitution(float speed) Alter the minimum normal speed for elastic collision.voidsetNumPositionSteps(int numSteps) Alter the number of solver position iterations per simulation step.voidsetNumVelocitySteps(int numSteps) Alter the number of velocity steps.voidsetPenetrationSlop(float slop) Alter the penetration slop.voidsetPointVelocitySleepThreshold(float speed) Alter the point-motion threshold, below which an object can fall asleep.voidsetSpeculativeContactDistance(float distance) Alter the speculative contact distance.voidsetStepListenerBatchesPerJob(int numBatches) Alter the number of step-listener batches that can be notified by a single job.voidsetStepListenersBatchSize(int numListeners) Alter the maximum number of step listeners notified in a single batch.voidsetTimeBeforeSleep(float interval) Alter the time interval before a body can fall asleep.voidsetUseBodyPairContactCache(boolean enable) Enable or disable the body-pair cache.voidsetUseLargeIslandSplitter(boolean setting) Enable or disable island splitting.voidsetUseManifoldReduction(boolean setting) Enable or disable manifold reduction.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, vaMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa
-
Constructor Details
-
PhysicsSettings
public PhysicsSettings()Instantiate default settings. -
PhysicsSettings
Instantiate a copy of the specified settings.- Parameters:
original- the settings to copy (notnull, unaffected)
-
-
Method Details
-
setAllowSleeping
public void setAllowSleeping(boolean allow) Alter whether objects can fall asleep. (native member: mAllowSleeping)- Parameters:
allow-trueto allow sleeping,falseto disallow it (default=true)
-
setBaumgarte
public void setBaumgarte(float fraction) Alter the Baumgarte stabilization factor, the fraction of position error to correct in each update. (native member: mBaumgarte)- Parameters:
fraction- the desired factor (≥0, ≤1, default=0.2)
-
setBodyPairCacheCosMaxDeltaRotationDiv2
public void setBodyPairCacheCosMaxDeltaRotationDiv2(float cosineOfHalfAngle) Return the maximum rotation to reuse collision results from the previous step. The settings are unaffected. (native member: mBodyPairCacheCosMaxDeltaRotationDiv2)- Parameters:
cosineOfHalfAngle- the cosine of half the desired maximum rotation angle (≥0, ≤1, default=cos(pi/180))
-
setBodyPairCacheMaxDeltaPositionSq
public void setBodyPairCacheMaxDeltaPositionSq(float squaredDistance) Alter the maximum translation to reuse collision results from the previous step. (native member: mBodyPairCacheMaxDeltaPositionSq)- Parameters:
squaredDistance- the desired squared distance (in square meters, ≥0, default=1e-6)
-
setCheckActiveEdges
public void setCheckActiveEdges(boolean check) Enable or disable collision checking with non-active (shared) edges. (native member: mCheckActiveEdges)- Parameters:
check-trueto enable checking, orfalseto disable it (default=true)
-
setConstraintWarmStart
public void setConstraintWarmStart(boolean enable) Alter whether warm starting for constraints (initially applying previous frames impulses) should be used. (native member: mConstraintWarmStart)- Parameters:
enable-trueto enable warm start, orfalseto disable it (default=true)
-
setContactNormalCosMaxDeltaRotation
public void setContactNormalCosMaxDeltaRotation(float cosine) Alter the maximum angle between normals to allow combining manifolds. (native member: mContactNormalCosMaxDeltaRotation)- Parameters:
cosine- the cosine of the desired rotation threshold (≥-1, ≤1, default=cos(pi/36))
-
setContactPointPreserveLambdaMaxDistSq
public void setContactPointPreserveLambdaMaxDistSq(float squaredDistance) Alter the maximum translation of a contact point for warm starting. (native member: mContactPointPreserveLambdaMaxDistSq)- Parameters:
squaredDistance- the square of the desired threshold distance (in meters squared, ≥0, default=1e-4)
-
setDeterministicSimulation
public void setDeterministicSimulation(boolean setting) Alter whether physics simulation is deterministic. (native member: mDeterministicSimulation)- Parameters:
setting-trueto be deterministic,falseto relax this policy (default=true)
-
setLinearCastMaxPenetration
public void setLinearCastMaxPenetration(float distance) Alter the amount of penetration tolerated by aLinearCastcast. (native member: mLinearCastMaxPenetration)- Parameters:
distance- the penetration distance to tolerate (as a fraction of the body's inner radius, ≥0, default=0.25)
-
setLinearCastThreshold
public void setLinearCastThreshold(float threshold) Alter the amount of translation to activate casting forLinearCastmotion quality. (native member: mLinearCastThreshold)- Parameters:
threshold- the desired translation threshold (as a fraction of the body's inner radius, ≥0, default=0.75)
-
setManifoldTolerance
public void setManifoldTolerance(float tolerance) Alter the tolerance for 2 points to be considered coplanar when determining the contact manifold between two faces. (native member: mManifoldTolerance)- Parameters:
tolerance- the distance (in meters, ≥0, default=1e-3)
-
setMaxInFlightBodyPairs
public void setMaxInFlightBodyPairs(int maxPairs) Alter the capacity of the in-flight body pairs array. (native member: mMaxInFlightBodyPairs)- Parameters:
maxPairs- the number of pairs to allocate (≥0, default=16384)
-
setMaxPenetrationDistance
public void setMaxPenetrationDistance(float distance) Alter the maximum correction when solving position constraints. (native member: mMaxPenetrationDistance)- Parameters:
distance- the desired distance threshold (in meters per iteration, ≥0, default=0.2)
-
setMinVelocityForRestitution
public void setMinVelocityForRestitution(float speed) Alter the minimum normal speed for elastic collision. (native member: mMinVelocityForRestitution)- Parameters:
speed- the desired threshold speed (in meters per second, ≥0, default=1)
-
setNumPositionSteps
public void setNumPositionSteps(int numSteps) Alter the number of solver position iterations per simulation step. (native member: mNumPositionSteps)- Parameters:
numSteps- the desired number (≥0, default=2)
-
setNumVelocitySteps
public void setNumVelocitySteps(int numSteps) Alter the number of velocity steps. (native member: mNumVelocitySteps)- Parameters:
numSteps- the desired number (≥0, default=10)
-
setPenetrationSlop
public void setPenetrationSlop(float slop) Alter the penetration slop. (native member: mPenetrationSlop)- Parameters:
slop- the desired slop distance (in meters, default=0.02)
-
setPointVelocitySleepThreshold
public void setPointVelocitySleepThreshold(float speed) Alter the point-motion threshold, below which an object can fall asleep. (native member: mPointVelocitySleepThreshold)- Parameters:
speed- the desired speed threshold (in meters per second, ≥0, default=0.03)
-
setSpeculativeContactDistance
public void setSpeculativeContactDistance(float distance) Alter the speculative contact distance. (native member: mSpeculativeContactDistance)- Parameters:
distance- the desired distance (in meters, ≥0, default=0.02)
-
setStepListenerBatchesPerJob
public void setStepListenerBatchesPerJob(int numBatches) Alter the number of step-listener batches that can be notified by a single job. (native member: mStepListenerBatchesPerJob)- Parameters:
numBatches- the desired number of batches, or INT_MAX to serialize step listeners (≥0, default=1)
-
setStepListenersBatchSize
public void setStepListenersBatchSize(int numListeners) Alter the maximum number of step listeners notified in a single batch. (native member: mStepListenersBatchSize)- Parameters:
numListeners- the desired number of listeners (≥0, default=8)
-
setTimeBeforeSleep
public void setTimeBeforeSleep(float interval) Alter the time interval before a body can fall asleep. (native member: mTimeBeforeSleep)- Parameters:
interval- the desired time interval (in seconds, ≥0, default=0.5)
-
setUseBodyPairContactCache
public void setUseBodyPairContactCache(boolean enable) Enable or disable the body-pair cache. (native member: mUseBodyPairContactCache)- Parameters:
enable-trueto enable the cache, orfalseto disable it (default=true)
-
setUseLargeIslandSplitter
public void setUseLargeIslandSplitter(boolean setting) Enable or disable island splitting. (native member: mUseLargeIslandSplitter)- Parameters:
setting-trueto enable splitting, orfalseto disable it (default=true)
-
setUseManifoldReduction
public void setUseManifoldReduction(boolean setting) Enable or disable manifold reduction. (native member: mUseManifoldReduction)- Parameters:
setting-trueto enable reduction, orfalseto disable it (default=true)
-
getAllowSleeping
public boolean getAllowSleeping()Test whether objects can fall asleep. The settings are unaffected. (native member: mAllowSleeping)- Specified by:
getAllowSleepingin interfaceConstPhysicsSettings- Returns:
trueif sleeping is allowed, otherwisefalse
-
getBaumgarte
public float getBaumgarte()Return the Baumgarte stabilization factor, the fraction of position error that is corrected in each iteration. The settings are unaffected. (native member: mBaumgarte)- Specified by:
getBaumgartein interfaceConstPhysicsSettings- Returns:
- the fraction (≥0, ≤1)
-
getBodyPairCacheCosMaxDeltaRotationDiv2
public float getBodyPairCacheCosMaxDeltaRotationDiv2()Return the maximum rotation for reusing collision results from the previous step. The settings are unaffected. (native member: mBodyPairCacheCosMaxDeltaRotationDiv2)- Specified by:
getBodyPairCacheCosMaxDeltaRotationDiv2in interfaceConstPhysicsSettings- Returns:
- the cosine of half the maximum rotation angle (≥0, ≤1)
-
getBodyPairCacheMaxDeltaPositionSq
public float getBodyPairCacheMaxDeltaPositionSq()Return the maximum translation for re-using collision results from the previous step. The settings are unaffected. (native member: mBodyPairCacheMaxDeltaPositionSq)- Specified by:
getBodyPairCacheMaxDeltaPositionSqin interfaceConstPhysicsSettings- Returns:
- the square of the maximum displacement (in square meters, ≥0)
-
getCheckActiveEdges
public boolean getCheckActiveEdges()Test whether collisions with non-active (shared) edges are checked. The settings are unaffected. (native member: mCheckActiveEdges)- Specified by:
getCheckActiveEdgesin interfaceConstPhysicsSettings- Returns:
trueif checked, otherwisefalse
-
getConstraintWarmStart
public boolean getConstraintWarmStart()Test whether warm starting is enabled for constraints. The settings are unaffected. (native member: mConstraintWarmStart)- Specified by:
getConstraintWarmStartin interfaceConstPhysicsSettings- Returns:
trueif enabled, otherwisefalse
-
getContactNormalCosMaxDeltaRotation
public float getContactNormalCosMaxDeltaRotation()Return the maximum angle between normals for which manifolds from different sub shapes of the same body pair will be combined. The settings are unaffected. (native member: mContactNormalCosMaxDeltaRotation)- Specified by:
getContactNormalCosMaxDeltaRotationin interfaceConstPhysicsSettings- Returns:
- the cosine of the threshold angle (≥-1, ≤1)
-
getContactPointPreserveLambdaMaxDistSq
public float getContactPointPreserveLambdaMaxDistSq()Return the maximum translation of a contact point for warm starting. The settings are unaffected. (native member: mContactPointPreserveLambdaMaxDistSq)- Specified by:
getContactPointPreserveLambdaMaxDistSqin interfaceConstPhysicsSettings- Returns:
- the square of the threshold distance (in meters squared, ≥0)
-
getDeterministicSimulation
public boolean getDeterministicSimulation()Test whether physics simulation is deterministic. The settings are unaffected. (native member: mDeterministicSimulation)- Specified by:
getDeterministicSimulationin interfaceConstPhysicsSettings- Returns:
trueif it is deterministic, otherwisefalse
-
getLinearCastMaxPenetration
public float getLinearCastMaxPenetration()Return the amount of penetration tolerated by aLinearCastcast. The settings are unaffected. (native member: mLinearCastMaxPenetration)- Specified by:
getLinearCastMaxPenetrationin interfaceConstPhysicsSettings- Returns:
- the penetration distance (as a fraction of the body's inner radius, ≥0)
-
getLinearCastThreshold
public float getLinearCastThreshold()Return the amount of translation that triggers casting forLinearCastmotion quality. The settings are unaffected. (native member: mLinearCastThreshold)- Specified by:
getLinearCastThresholdin interfaceConstPhysicsSettings- Returns:
- the translation distance per step (as a fraction of the body's inner radius, ≥0)
-
getManifoldTolerance
public float getManifoldTolerance()Return the tolerance used to determine whether 2 points are coplanar when calculating the contact manifold between 2 faces. The settings are unaffected. (native member: mManifoldTolerance)- Specified by:
getManifoldTolerancein interfaceConstPhysicsSettings- Returns:
- the distance (in meters, ≥0)
-
getMaxInFlightBodyPairs
public int getMaxInFlightBodyPairs()Return the maximum number of in-flight body pairs. The settings are unaffected. (native member: mMaxInFlightBodyPairs)- Specified by:
getMaxInFlightBodyPairsin interfaceConstPhysicsSettings- Returns:
- the limit (≥0)
-
getMaxPenetrationDistance
public float getMaxPenetrationDistance()Return the maximum distance to correct in a single iteration when solving position constraints. The settings are unaffected. (native member: mMaxPenetrationDistance)- Specified by:
getMaxPenetrationDistancein interfaceConstPhysicsSettings- Returns:
- the distance per iteration (in meters, ≥0)
-
getMinVelocityForRestitution
public float getMinVelocityForRestitution()Return the minimum normal speed for elastic collision. The settings are unaffected. (native member: mMinVelocityForRestitution)- Specified by:
getMinVelocityForRestitutionin interfaceConstPhysicsSettings- Returns:
- the speed threshold (in meters per second, ≥0)
-
getNumPositionSteps
public int getNumPositionSteps()Return the number of solver position iterations per simulation step. The settings are unaffected. (native member: mNumPositionSteps)- Specified by:
getNumPositionStepsin interfaceConstPhysicsSettings- Returns:
- the number (≥0)
-
getNumVelocitySteps
public int getNumVelocitySteps()Return the number of velocity iterations per simulation step. The settings are unaffected. (native member: mNumVelocitySteps)- Specified by:
getNumVelocityStepsin interfaceConstPhysicsSettings- Returns:
- the number (≥0)
-
getPenetrationSlop
public float getPenetrationSlop()Return the penetration slop. The settings are unaffected. (native member: mPenetrationSlop)- Specified by:
getPenetrationSlopin interfaceConstPhysicsSettings- Returns:
- the slop distance (in meters)
-
getPointVelocitySleepThreshold
public float getPointVelocitySleepThreshold()Return the point-motion threshold, below which objects can fall asleep. The settings are unaffected. (native member: mPointVelocitySleepThreshold)- Specified by:
getPointVelocitySleepThresholdin interfaceConstPhysicsSettings- Returns:
- the speed threshold (in meters per second, ≥0)
-
getSpeculativeContactDistance
public float getSpeculativeContactDistance()Return the speculative contact distance. The settings are unaffected. (native member: mSpeculativeContactDistance)- Specified by:
getSpeculativeContactDistancein interfaceConstPhysicsSettings- Returns:
- the distance (in meters, ≥0)
-
getStepListenerBatchesPerJob
public int getStepListenerBatchesPerJob()Return the maximum number of step-listener batches notified by a single job. The settings are unaffected. (native member: mStepListenerBatchesPerJob)- Specified by:
getStepListenerBatchesPerJobin interfaceConstPhysicsSettings- Returns:
- the number of batches per job (>0), or
INT_MAXto serialize step listeners
-
getStepListenersBatchSize
public int getStepListenersBatchSize()Return the maximum number of step listeners notified in a single batch. The settings are unaffected. (native member: mStepListenersBatchSize)- Specified by:
getStepListenersBatchSizein interfaceConstPhysicsSettings- Returns:
- the number of listeners (>0)
-
getTimeBeforeSleep
public float getTimeBeforeSleep()Return the time interval before a body can fall asleep. The settings are unaffected. (native member: mTimeBeforeSleep)- Specified by:
getTimeBeforeSleepin interfaceConstPhysicsSettings- Returns:
- the interval (in seconds, ≥0)
-
getUseBodyPairContactCache
public boolean getUseBodyPairContactCache()Test whether the body-pair cache is enabled. The settings are unaffected. (native member: mUseBodyPairContactCache)- Specified by:
getUseBodyPairContactCachein interfaceConstPhysicsSettings- Returns:
trueif it is enabled, otherwisefalse
-
getUseLargeIslandSplitter
public boolean getUseLargeIslandSplitter()Test whether island splitting is enabled. The settings are unaffected. (native member: mUseLargeIslandSplitter)- Specified by:
getUseLargeIslandSplitterin interfaceConstPhysicsSettings- Returns:
trueif enabled, otherwisefalse
-
getUseManifoldReduction
public boolean getUseManifoldReduction()Test whether manifold reduction is enabled. The settings are unaffected. (native member: mUseManifoldReduction)- Specified by:
getUseManifoldReductionin interfaceConstPhysicsSettings- Returns:
trueif enabled, otherwisefalse
-