From f3ad0eff2b30dd198b51165a39b9f583402cc083 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Wed, 14 Jan 2026 06:05:55 -0800 Subject: [PATCH] Fix body category check for mocap body descendants in visualization. PiperOrigin-RevId: 856179240 Change-Id: I29f4758fee0ff3b16d0b9f452c28e640b5558993 --- src/engine/engine_vis_visualize.c | 4 ++-- test/engine/testdata/vis_visualize/mocap.xml | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 test/engine/testdata/vis_visualize/mocap.xml diff --git a/src/engine/engine_vis_visualize.c b/src/engine/engine_vis_visualize.c index 3bd9f1a2..a9985c26 100644 --- a/src/engine/engine_vis_visualize.c +++ b/src/engine/engine_vis_visualize.c @@ -153,9 +153,9 @@ static void mixcolor(float rgba[4], const float ref[4], int flg1, int flg2) { } -// a body is static if it is welded to the world and is not a mocap body +// a body is static if it is welded to the world and is not a mocap body or descendant thereof static int bodycategory(const mjModel* m, int bodyid) { - if (m->body_weldid[bodyid] == 0 && m->body_mocapid[bodyid] == -1) { + if (m->body_weldid[bodyid] == 0 && m->body_mocapid[m->body_rootid[bodyid]] == -1) { return mjCAT_STATIC; } else { return mjCAT_DYNAMIC; diff --git a/test/engine/testdata/vis_visualize/mocap.xml b/test/engine/testdata/vis_visualize/mocap.xml new file mode 100644 index 00000000..f1675e00 --- /dev/null +++ b/test/engine/testdata/vis_visualize/mocap.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + +