From bbeb0b95a7eea722dbc5273750f0a84b1460becc Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Mon, 13 Oct 2025 06:17:41 -0700 Subject: [PATCH] Reset contact `efc_address` in `mj_clearEfc`, fixes #2869 The truth is that all these solver-related values should be moved out of `mjContact` altogether, but that can be done in a future followup. PiperOrigin-RevId: 818624976 Change-Id: I5b9e63927098cdf26b9f8acfdd9d86e75d6ce331 --- src/engine/engine_memory.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/engine/engine_memory.h b/src/engine/engine_memory.h index c232b20f..3202353d 100644 --- a/src/engine/engine_memory.h +++ b/src/engine/engine_memory.h @@ -75,6 +75,11 @@ static inline void mj_clearEfc(mjData* d) { d->nefc = 0; d->nisland = 0; d->contact = (mjContact*) d->arena; + + // if any contacts are allocated, clear their efc_address + for (int i=0; i < d->ncon; i++) { + d->contact[i].efc_address = -1; + } } #ifdef __cplusplus