Skip to content

Commit aa18f7f

Browse files
authored
contact constraint dof traversal early termination (google-deepmind#1209)
1 parent 2dabafc commit aa18f7f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

mujoco_warp/_src/constraint.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,9 @@ def _contact_pyramidal(
18391839
da2 = dof_parentid[da2]
18401840
da = wp.max(da1, da2)
18411841
if is_sparse:
1842+
# early termination: remaining DOFs have zero Jacobian difference
1843+
if da1 == da2 and da1 >= 0:
1844+
break
18421845
dofid = da
18431846
else:
18441847
dofid -= 1
@@ -2061,6 +2064,9 @@ def _contact_elliptic(
20612064
da2 = dof_parentid[da2]
20622065
da = wp.max(da1, da2)
20632066
if is_sparse:
2067+
# early termination: remaining DOFs have zero Jacobian difference
2068+
if da1 == da2 and da1 >= 0:
2069+
break
20642070
dofid = da
20652071
else:
20662072
dofid -= 1

0 commit comments

Comments
 (0)