Repository navigation
fix: keep friction when the tangent effective-mass matrix is singular - #1048
Open
Quacky2200 wants to merge 1 commit into
Open
Quacky2200 wants to merge 1 commit into
Quacky2200 wants to merge 1 commit into
Conversation
The 3D friction solve inverts the 2x2 tangent effective-mass matrix K to solve both friction directions together. When one tangent has no effective mass, K is singular: a body whose z translation and x/y rotations are locked (kept in a plane, as 2D bodies in a 3D world are) has k22 = 0 and k12 = 0. simd_inv(det) then returns 0, so friction along both tangents was dropped and the body slid as if on ice. The shared solve moves into tangent_delta_impulse, used by both ContactConstraintTangentPart (Coulomb) and ContactConstraintTangentPartSlim (Simplified). When det(K) <= 1e-6 * k11 * k22, each tangent is solved on its own (dvel_i / k_ii, a no-op for a zero k_ii); otherwise the result is the same as before. The 2D build and the generic (multibody) constraints already solve per tangent and are unchanged. tests/plane_locked_friction.rs: a plane-locked cuboid shoved at 3 m/s now stops where a free one does (0.91 m); it slid 9 m before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1047
Description
The 3D friction solve inverts the 2x2 tangent effective-mass matrix K to solve both friction directions together. When one tangent has no effective mass, K is singular: a body whose z translation and x/y rotations are locked (kept in a plane, as 2D bodies in a 3D world are) has k22 = 0 and k12 = 0. simd_inv(det) then returns 0, so friction along both tangents was dropped and the body slid as if on ice.
The shared solve moves into tangent_delta_impulse, used by both ContactConstraintTangentPart (Coulomb) and ContactConstraintTangentPartSlim (Simplified). When det(K) <= 1e-6 * k11 * k22, each tangent is solved on its own (dvel_i / k_ii, a no-op for a zero k_ii); otherwise the result is the same as before. The 2D build and the generic (multibody) constraints already solve per tangent and are unchanged.
tests/plane_locked_friction.rs: a plane-locked cuboid shoved at 3 m/s now stops where a free one does (0.91 m); it slid 9 m before.
Edit: Uploaded gif