From ffb50b7b67a58610a429c874c386d83205eb68b2 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Thu, 18 Jul 2024 06:42:41 -0700 Subject: [PATCH] Improve readability of body transmission code. (code block mentioned in #1790) PiperOrigin-RevId: 653601254 Change-Id: Ibee727ab668b690c3b9a55c39110c6219cca17fa --- src/engine/engine_core_smooth.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/engine_core_smooth.c b/src/engine/engine_core_smooth.c index 4016df97..57afead3 100644 --- a/src/engine/engine_core_smooth.c +++ b/src/engine/engine_core_smooth.c @@ -1168,14 +1168,18 @@ void mj_transmission(const mjModel* m, mjData* d) { for (int j=0; j < d->ncon; j++) { const mjContact* con = d->contact+j; + // get geom ids + int g1 = con->geom[0]; + int g2 = con->geom[1]; + // contact involving flex, continue - if (con->geom[0] < 0 || con->geom[1] < 0) { + if (g1 < 0 || g2 < 0) { continue; } // get body ids - int b1 = m->geom_bodyid[con->geom[0]]; - int b2 = m->geom_bodyid[con->geom[1]]; + int b1 = m->geom_bodyid[g1]; + int b2 = m->geom_bodyid[g2]; // irrelevant contact, continue if (b1 != id && b2 != id) {