skip to content

In physics middleware, what do the contact distance and the penetration slop control, and what symptoms show each is set too small or too large?

level: seniorimportance: should knowfreq 33%

answer

  1. two lengths in world units
  2. create contacts before touching
  3. overlap left uncorrected on purpose
  4. flicker versus visible sinking
  5. thin objects versus the slop

basics

~20 s

Contact distance is how far apart shapes may be when a contact is already created; penetration slop is overlap that correction deliberately leaves alone. Too small gives late contacts and jitter; too large gives sinking, snags and extra cost.

solid answer

~50 s

Both are lengths in world units. The **contact distance** (also called contact offset or speculative margin) makes the middleware create a contact while shapes are still slightly apart, so the solver can stop an approaching body at the surface instead of fixing an overlap afterwards; too small and contacts arrive late, bodies bounce or pop on landing and fast ones overlap deeply; too large and there are more pairs and contact points to solve, and bodies can snag on edges they would have missed. The **penetration slop** is overlap that position correction ignores, so a resting contact stays touching from step to step; too small and correction pushes bodies fully apart, contacts flicker on and off and small props jitter and never sleep; too large and bodies visibly sink into floors, and a coin thinner than the slop sinks half into the table. Check both against the smallest moving object.

go deeper

for a junior

Recall that contacts can be created just before shapes touch and that a little overlap is allowed on purpose.

for a middle

Explain why leaving some overlap keeps resting contacts stable and why early contacts stop landings at the surface.

for a senior

Map jitter, sinking, landing bounce and snags to the tolerance responsible, and size each one against the smallest moving object.

for a principal

Decide global defaults versus per-body overrides for a game mixing tiny and huge props, weighing contact cost against artefacts.

## Two lengths that every rigid-body middleware exposes Whatever the names in a given library, two tolerances shape every resting and landing contact. Both are **absolute lengths in world units**, so they must be judged against the size of the objects in the scene, not as abstract quality sliders. - **Contact distance**, also called contact offset, skin or speculative margin: the separation below which the narrow phase already reports a contact, even though the shapes do not yet touch. Some middleware grow this margin with the body's speed. - **Penetration slop**, also called allowed penetration or linear slop: the overlap depth that position correction leaves in place on purpose. A third knob usually sits beside them: the **position correction rate or maximum correction speed**, which decides how fast overlap beyond the slop is removed. ## Why a contact is created before the shapes touch A contact with a small positive separation `d` lets the solver allow the bodies to close that gap and no more during the step: the relative normal velocity may be at most `d / stepLength` towards each other. A box falling onto a table therefore stops at the surface on the step it arrives, instead of first sinking in and then being pushed out. Without that margin, a contact appears only once shapes already overlap, and the response is always one step late. ## Why some overlap is left on purpose If position correction removed every bit of overlap, a resting box would end each step exactly touching or slightly apart. On the next step gravity pulls it down, it overlaps again, the contact reappears, correction pushes it out again. Contacts flicker between existing and not existing, and the box buzzes. Leaving a small overlap uncorrected keeps the contact alive and the box still. The method that corrects beyond the slop, a bias in the velocity pass or a separate position pass, belongs to how the solver works; here it matters only as a knob. ## The symptom table | Setting | Too small | Too large | |---|---|---| | Contact distance | contacts arrive after overlap: bodies pop or bounce on landing, fast bodies overlap deeply, resting contacts flicker | more pairs and contact points to solve, bodies stop short or snag on edges they would have missed | | Penetration slop | contacts flicker, small props jitter and never sleep | bodies visibly sink into floors and each other; thin objects sink through part of their thickness | | Correction speed cap | overlaps linger and bodies stay sunk after a hard landing | bodies spawned overlapping shoot apart; stacks gain energy and bounce | ## Diagnosing from the symptom 1. **Check the unit scale first.** All three settings are lengths or speeds; a scene in centimetres makes metre-tuned values a hundred times too tight and produces exactly the flicker row of the table. 2. **Compare with the smallest moving object.** The slop should be a small fraction of the thinnest thing that rests on something. A playing card or coin thinner than the slop will sink into the table by roughly that slop. 3. **Debug-draw contact points and penetration depth.** Contacts blinking from step to step mean slop or contact distance too small; a steady deep overlap means slop too large or correction too weak. 4. **Watch landings, not just resting.** A crate that bounces slightly although its restitution is zero is a late contact, so raise the contact distance before touching restitution. 5. **Watch snags.** A rolling barrel that hops at the seam between two floor tiles, or a body that stops just short of a wall it was sliding past, points at a contact distance large enough to create contacts that should never have acted. ## Per-body and per-scene values Some middleware let a body override the global tolerances, which is useful when a level mixes 5 cm bottles with 3 m crates. A common pattern is to keep global values tuned for the typical prop and give tiny or very fast bodies their own, rather than shrinking every tolerance and paying for it everywhere. Two related subjects are not tuning knobs and are treated separately: how a convex collision margin is used to compute contacts, and how speculative contacts compare with swept tests for fast projectiles.

  • Why can a box with zero restitution still bounce slightly when it lands?
    Its contact was created only after the shapes overlapped, so position correction pushed it out, and a correction applied as velocity can leave the box moving upwards for a step. Raising the contact distance lets the solver stop it at the surface on arrival, and capping the correction speed limits the pop.
  • Why should slop be judged against the thinnest resting object rather than the average one?
    Slop is overlap the solver tolerates, measured in world units. A coin or playing card thinner than that tolerance can rest with most of its thickness inside the table, which looks broken, while a large crate sinking by the same few millimetres goes unnoticed.

  • Slop should be zero so bodies never overlap at all
  • Contact distance only affects performance, never behaviour
  • A bigger contact distance can only make collision more accurate
  • Tolerances are percentages, so units do not matter
  • A zero-restitution box that bounces means restitution is broken