SuperDex Physics C++ API
Loading...
Searching...
No Matches
superdex::ContactParams Struct Reference

Parameters for contact mechanics simulation. More...

#include <contact_params.h>

Public Member Functions

 ContactParams ()=default
 ContactParams (real penaltyCoefficient, real penaltySmoothingHalfDistance, real penaltyThresholdDefault, real penaltyThresholdExtraPadding, real collidingPenaltyThresholdPadding, bool frictionWithColliderNormal, real maxAlignmentNormals, real alignmentSmoothingFraction, real viscousFrictionCoefficient, real coulombFrictionCoefficient, bool preferElastoPlasticFriction, real frictionFalloffVel, real preslidingDisplacement, real normalViscousDampingCoefficient, real distanceErrorBound, real objScale, real collidingPenaltyLengthScale)
 Construct ContactParams with all parameters explicitly specified.
real GetPenaltyThresholdDist (bool addPadding) const
 Get the total contact detection threshold.
bool operator== (ContactParams const &) const =default

Public Attributes

real alignmentSmoothingFraction = 0.1_r
 [Experimental] Width of the band of normal alignments, centered at maxAlignmentNormals, over which contact fades out, as a fraction of the range of alignments [-1, maxAlignmentNormals].
real collidingPenaltyLengthScale = 1_r
 [Experimental] Length scale [m] used to correct the penalty coefficient when the colliding body integrates contact traction over a lower-than-two-dimensional manifold, such as a rod or point mass.
real collidingPenaltyThresholdPadding = 0_r
 [Experimental] Padding [m] added to the collider's contact detection threshold when this actor is the colliding actor.
real coulombFrictionCoefficient = 0.5_r
 Coulomb friction coefficient (dimensionless).
real distanceErrorBound = 0_r
 [Experimental] Padding [m] added to the collider's bounding volume for collision culling.
real frictionFalloffVel = 0.01_r
 [Experimental] Velocity threshold for Coulomb friction smoothing [m/s].
bool frictionWithColliderNormal = true
 [Experimental] Use collider's normal (normalized SDF gradient) for friction direction if true, or the colliding's surface normal at the sample point if false.
real maxAlignmentNormals = 0_r
 [Experimental] Maximum normal alignment threshold.
real normalViscousDampingCoefficient = 0_r
 Normal viscous damping coefficient [s/m].
real objScale = 1_r
 [Experimental] Object scale relative to default size (dimensionless).
real penaltyCoefficient = 1e9_r
 Stiffness of the contact penalty force [Pa/m].
real penaltySmoothingHalfDistance = 0.005_r
 PolyReLU smoothing half-width [m].
real penaltyThresholdDefault = 0.001_r
 Default contact detection threshold [m].
real penaltyThresholdExtraPadding = 0_r
 [Experimental] Extra padding [m] added to the default contact detection threshold if the colliding actor has ColliderType::None or ColliderType::PointCloud.
bool preferElastoPlasticFriction = true
 [Experimental] Prefer elasto-plastic Coulomb friction to velocity-regularized Coulomb friction.
real preslidingDisplacement = 1e-4_r
 Presliding displacement of elasto-plastic Coulomb friction [m].
real viscousFrictionCoefficient = 0_r
 Viscous friction coefficient [s/m].

Detailed Description

Parameters for contact mechanics simulation.

Note
For each field without an actor-pair override, contact between a colliding actor and a collider uses the collider's contact parameter (not the colliding actor's). The exceptions are:
See also
Scene::SetContactPairParamsOverride

Definition at line 43 of file contact_params.h.

Constructor & Destructor Documentation

◆ ContactParams() [1/2]

superdex::ContactParams::ContactParams ( )
default

◆ ContactParams() [2/2]

superdex::ContactParams::ContactParams ( real penaltyCoefficient,
real penaltySmoothingHalfDistance,
real penaltyThresholdDefault,
real penaltyThresholdExtraPadding,
real collidingPenaltyThresholdPadding,
bool frictionWithColliderNormal,
real maxAlignmentNormals,
real alignmentSmoothingFraction,
real viscousFrictionCoefficient,
real coulombFrictionCoefficient,
bool preferElastoPlasticFriction,
real frictionFalloffVel,
real preslidingDisplacement,
real normalViscousDampingCoefficient,
real distanceErrorBound,
real objScale,
real collidingPenaltyLengthScale )
inline

Member Function Documentation

◆ GetPenaltyThresholdDist()

real superdex::ContactParams::GetPenaltyThresholdDist ( bool addPadding) const
inline

Get the total contact detection threshold.

Parameters
addPaddingIf true, includes penaltyThresholdExtraPadding.
Returns
Total contact detection threshold [m].

Definition at line 60 of file contact_params_inl.h.

◆ operator==()

bool superdex::ContactParams::operator== ( ContactParams const & ) const
default

Member Data Documentation

◆ alignmentSmoothingFraction

real superdex::ContactParams::alignmentSmoothingFraction = 0.1_r

[Experimental] Width of the band of normal alignments, centered at maxAlignmentNormals, over which contact fades out, as a fraction of the range of alignments [-1, maxAlignmentNormals].

The penalty force of a contact is scaled by a C1 smoothstep of its normal alignment, from 1 at an alignment of m - w / 2 to 0 at m + w / 2, with m = maxAlignmentNormals and w = alignmentSmoothingFraction * (m + 1). Contacts at m keep half their force. This removes the jump of the penalty force when contact is disabled. Contacts beyond the band are disabled, and friction fading (ExperimentalEvalParams::fadeFriction) ends at its top.

Warning
This is an experimental feature. It may be changed or removed in the future. Use at your own risk.
Note
Must be in [0, 1]. 0 disables contact abruptly at maxAlignmentNormals.
With the default 0.1 and the default maxAlignmentNormals = 0, contact between unit normals fades out between angles of 92.9 and 87.1 degrees (a 5.7-degree band).
Applies only with implicit normals (ExperimentalEvalParams::explicitNormals = false). With explicit normals, contact is disabled abruptly at maxAlignmentNormals.
For co-dimensional colliding actors with ambiguous normals, the scale is 1 (normal alignment cannot be computed).
See also
maxAlignmentNormals

Definition at line 229 of file contact_params.h.

◆ collidingPenaltyLengthScale

real superdex::ContactParams::collidingPenaltyLengthScale = 1_r

[Experimental] Length scale [m] used to correct the penalty coefficient when the colliding body integrates contact traction over a lower-than-two-dimensional manifold, such as a rod or point mass.

E.g., the penalty is scaled by this value if the colliding body lumps contact tractions on a line, or this value squared if lumping contact forces on a point.

Warning
Contact with lower-dimensional bodies is an experimental feature. It may be changed or removed in the future. Use at your own risk.
Note
Must be finite and strictly positive.
This value is not used in the most common case, where contact traction is integrated over a two-dimensional surface.
The colliding body's value is always used in a contact pair, because the colliding body determines the dimension of the contact traction integral.

Definition at line 387 of file contact_params.h.

◆ collidingPenaltyThresholdPadding

real superdex::ContactParams::collidingPenaltyThresholdPadding = 0_r

[Experimental] Padding [m] added to the collider's contact detection threshold when this actor is the colliding actor.

Warning
This is an experimental feature. It may be changed or removed in the future. Use at your own risk.
Note
Must be finite and not negative.
Unlike penaltyThresholdExtraPadding, which the collider applies to some colliding actors, this padding is applied by the colliding actor to any collider, except colliders with ColliderType::PointCloud and SDF colliders of soft actors, which ignore it.
Padding is useful to avoid tunneling of thin or coarsely sampled colliding actors.
See also
penaltyThresholdDefault, penaltyThresholdExtraPadding

Definition at line 168 of file contact_params.h.

◆ coulombFrictionCoefficient

real superdex::ContactParams::coulombFrictionCoefficient = 0.5_r

Coulomb friction coefficient (dimensionless).

Note
Must be finite and not negative.
Both viscousFrictionCoefficient and coulombFrictionCoefficient can be >0.
Without an actor-pair override for this field, the value used in a collision is the geometric mean of the colliding and collider's coefficients. This disables Coulomb friction if either of them does.

Definition at line 252 of file contact_params.h.

◆ distanceErrorBound

real superdex::ContactParams::distanceErrorBound = 0_r

[Experimental] Padding [m] added to the collider's bounding volume for collision culling.

Warning
This is an experimental feature. It may be changed or removed in the future. Use at your own risk.
Note
Must be finite.
Useful, for example, with approximate SDFs (e.g., deep flow map) to compensate for potentially overestimating the true distance.

Definition at line 359 of file contact_params.h.

◆ frictionFalloffVel

real superdex::ContactParams::frictionFalloffVel = 0.01_r

[Experimental] Velocity threshold for Coulomb friction smoothing [m/s].

The Coulomb friction force smoothly transitions from 0 to full strength as tangential velocity increases from 0 to frictionFalloffVel.

Warning
This is an experimental feature. It may be changed or removed in the future. Use at your own risk.
Note
Must be finite and not negative. Zero gives unsmoothed Coulomb friction.
Used only by contacts with velocity-regularized friction (see preferElastoPlasticFriction).
Smaller velocity thresholds improve physical accuracy but may degrade stability.
Without an actor-pair override for this field, the value used in a collision is the geometric mean of the colliding and collider's thresholds. The exception is if the collider is static, in which case the colliding's threshold is used.

Definition at line 297 of file contact_params.h.

◆ frictionWithColliderNormal

bool superdex::ContactParams::frictionWithColliderNormal = true

[Experimental] Use collider's normal (normalized SDF gradient) for friction direction if true, or the colliding's surface normal at the sample point if false.

Warning
This is an experimental feature. It may be changed or removed in the future. Use at your own risk.
Note
For co-dimensional colliding actors with ambiguous normals, the collider's normal is always used regardless of frictionWithColliderNormal.

Definition at line 182 of file contact_params.h.

◆ maxAlignmentNormals

real superdex::ContactParams::maxAlignmentNormals = 0_r

[Experimental] Maximum normal alignment threshold.

Normal alignment is defined as the dot product between colliding and collider normals. Contact is disabled for sample points whose normal alignment exceeds this threshold, abruptly or over a band centered at it (see alignmentSmoothingFraction). This prevents sample points from being trapped inside the collider when penetration is large.

Warning
This is an experimental feature. It may be changed or removed in the future. Use at your own risk.
Note
Must be in [-1, 1]. -1 allows contact only for perfectly opposing normals. 1 with alignmentSmoothingFraction = 0 allows all contacts with unit normals. With a smooth band, contacts at alignment 1 keep half their force.
For co-dimensional colliding actors with ambiguous normals, contact is not disabled regardless of maxAlignmentNormals (normal alignment cannot be computed).
See also
alignmentSmoothingFraction

Definition at line 203 of file contact_params.h.

◆ normalViscousDampingCoefficient

real superdex::ContactParams::normalViscousDampingCoefficient = 0_r

Normal viscous damping coefficient [s/m].

Damping force in the normal direction, proportional to the elastic normal contact force and the normal velocity. Analogous to viscousFrictionCoefficient but acting in the normal direction instead of tangentially.

Warning
The calibration diverges as CoR approaches zero, which may cause numerical problems when approaching fully-inelastic collisions.
Note
Must be finite and not negative.
Without an actor-pair override for this field, the value used in a collision is the geometric mean of the colliding and collider's coefficients. This disables normal damping if either of them does.
The resulting coefficient of restitution (CoR) is velocity-dependent. For a characteristic impact velocity, experimental::CalibrateNormalViscousDampingCoefficient computes the coefficient that approximates a target CoR, while experimental::EffectiveCoefficientOfRestitution recovers the CoR produced by a coefficient.
Because the damping force depends on the normal velocity at each contact point, it also introduces rolling resistance: a body rolling on a surface dissipates energy through the differing normal velocities across its contacting region.

Definition at line 344 of file contact_params.h.

◆ objScale

real superdex::ContactParams::objScale = 1_r

[Experimental] Object scale relative to default size (dimensionless).

Used by deep flow only.

Warning
Deep flow is an experimental feature. It may be changed or removed in the future. Use at your own risk.
Note
Must be finite and strictly positive.

Definition at line 370 of file contact_params.h.

◆ penaltyCoefficient

real superdex::ContactParams::penaltyCoefficient = 1e9_r

Stiffness of the contact penalty force [Pa/m].

Note
Must be finite and strictly positive.
Higher penalties create stiffer contacts and reduce penetration.
Arbitrarily large penalties may degrade stability.
The default penalty is appropriate for actors with default density. For actors with much higher/lower density than the default density, the penalty coefficient may need to be increased/decreased accordingly.
Without an actor-pair override for this field, the value used in a collision is the geometric mean of the colliding and collider's coefficients. The exception is if the collider is static, in which case the colliding's penalty is used.
The penalty coefficient is additionally scaled by length-scale corrections when the colliding or collider integrates contact over a non-2D manifold (e.g., rod, shell). See collidingPenaltyLengthScale.

Definition at line 107 of file contact_params.h.

◆ penaltySmoothingHalfDistance

real superdex::ContactParams::penaltySmoothingHalfDistance = 0.005_r

PolyReLU smoothing half-width [m].

The penalty force transitions from 0 to linear over the decreasing distance range (penaltyThreshold, penaltyThreshold - 2 * penaltySmoothingHalfDistance).

Note
Must be finite and not negative.
Larger smoothing distances improve stability but may increase penetration.
Smoothing distance is expected to be small relative to the collider geometry.

Definition at line 119 of file contact_params.h.

◆ penaltyThresholdDefault

real superdex::ContactParams::penaltyThresholdDefault = 0.001_r

Default contact detection threshold [m].

The penalty force transitions from 0 to linear over the decreasing distance range (penaltyThreshold, penaltyThreshold - 2 * penaltySmoothingHalfDistance).

Note
Must be finite. Negative values are legal.
If the colliding actor has ColliderType::None or ColliderType::PointCloud, penaltyThreshold = penaltyThresholdDefault + penaltyThresholdExtraPadding. Otherwise, penaltyThreshold = penaltyThresholdDefault.
The colliding actor's collidingPenaltyThresholdPadding, if applicable, is added to penaltyThreshold.
See also
penaltyThresholdExtraPadding, collidingPenaltyThresholdPadding, GetPenaltyThresholdDist

Definition at line 136 of file contact_params.h.

◆ penaltyThresholdExtraPadding

real superdex::ContactParams::penaltyThresholdExtraPadding = 0_r

[Experimental] Extra padding [m] added to the default contact detection threshold if the colliding actor has ColliderType::None or ColliderType::PointCloud.

Warning
This is an experimental feature. It may be changed or removed in the future. Use at your own risk.
Note
Must be finite and not negative.
Extra padding is useful to avoid tunneling through thin actors when the other actor has ColliderType::None or ColliderType::PointCloud.
See also
penaltyThresholdDefault, GetPenaltyThresholdDist

Definition at line 151 of file contact_params.h.

◆ preferElastoPlasticFriction

bool superdex::ContactParams::preferElastoPlasticFriction = true

[Experimental] Prefer elasto-plastic Coulomb friction to velocity-regularized Coulomb friction.

Elasto-plastic friction measures the tangential displacement of each contact from its anchor, a point of the collider, so a contact holds a tangential load below the Coulomb limit without slip (see preslidingDisplacement). Velocity-regularized friction acts only through slip, so held objects creep (see frictionFalloffVel).

Warning
This is an experimental feature. It may be changed or removed in the future. Use at your own risk.
Note
Contacts that prefer elasto-plastic friction use it where it is supported: with rigid colliders, static or dynamic, including articulated links, and with an integration method whose step ends at its last stage (IntegrationMethod::BackwardEuler, IntegrationMethod::BDF2, IntegrationMethod::BDF3, IntegrationMethod::DIRK22 or IntegrationMethod::DIRK33). The other contacts use velocity-regularized friction.
Friction preload is part of the actor history (see Actor). A static actor given a velocity every step, like a conveyor belt, never builds preload, so contacts on it creep, as with velocity-regularized friction whose falloff velocity is preslidingDisplacement over the stage step (the time step with IntegrationMethod::BackwardEuler).
Without an actor-pair override for this field, a collision prefers elasto-plastic friction only if both the colliding and the collider do, even if the collider is static.

Definition at line 278 of file contact_params.h.

◆ preslidingDisplacement

real superdex::ContactParams::preslidingDisplacement = 1e-4_r

Presliding displacement of elasto-plastic Coulomb friction [m].

With elasto-plastic friction (see preferElastoPlasticFriction), the Coulomb friction force smoothly transitions from 0 to full strength as the tangential displacement of a contact from its anchor increases from 0 to preslidingDisplacement, and beyond it the anchor follows the contact. A held contact springs back by up to preslidingDisplacement once the load is removed.

Note
Smaller values reduce presliding motion and spring-back, but stiffen the tangential response.
Within the presliding displacement, the friction force is elastic: it stores energy and adds no damping. Tangential damping comes only from viscousFrictionCoefficient, zero by default, and from the time integration (normalViscousDampingCoefficient acts along the normal).
Must be finite and strictly positive.
Without an actor-pair override for this field, the value used in a collision is the geometric mean of the colliding and collider's displacements. The exception is if the collider is static, in which case the colliding's displacement is used.

Definition at line 319 of file contact_params.h.

◆ viscousFrictionCoefficient

real superdex::ContactParams::viscousFrictionCoefficient = 0_r

Viscous friction coefficient [s/m].

Note
Friction force is proportional to contact force and tangential velocity.
Must be finite and not negative.
Both viscousFrictionCoefficient and coulombFrictionCoefficient can be >0.
Without an actor-pair override for this field, the value used in a collision is the geometric mean of the colliding and collider's coefficients. This disables viscous friction if either of them does.

Definition at line 241 of file contact_params.h.


The documentation for this struct was generated from the following files: