Cache island topology data

Store island topology in `mjData` so repeated island solves can reuse stable connect/weld equality partitions. Add cache invalidation checks for active equality changes and cover the fast path with an island regression test.

Signed-off-by: teerthsharma <teerths57@gmail.com>
This commit is contained in:
teerthsharma
2026-07-11 19:08:15 +05:30
committed by teerthsharma
parent 03203e2f32
commit bc32db7f25
5 changed files with 319 additions and 2 deletions
+5
View File
@@ -198,6 +198,11 @@ typedef struct mjData_ {
// sleep state
int* tree_asleep; // <0: awake; >=0: index cycle of sleeping trees (ntree x 1)
// opaque internal island topology cache; users must not modify
int* island_cache_tree; // tree and island topology (ntree x 28)
int* island_cache_dof; // DOF topology (nv x 8)
int* island_cache_eq; // equality topology (neq x 40)
// plugins
int* plugin; // copy of m->plugin, required for deletion (nplugin x 1)
uintptr_t* plugin_data; // pointer to plugin-managed data structure (nplugin x 1)
+5 -1
View File
@@ -929,7 +929,10 @@
X ( mjtNum, qfrc_inverse, nv, 1 ) \
X ( mjtNum, cacc, nbody, 6 ) \
X ( mjtNum, cfrc_int, nbody, 6 ) \
X ( mjtNum, cfrc_ext, nbody, 6 )
X ( mjtNum, cfrc_ext, nbody, 6 ) \
XIC ( int, island_cache_tree, ntree, 28 ) \
XIC ( int, island_cache_dof, nv, 8 ) \
XIC ( int, island_cache_eq, neq, 40 )
// macro for annotating that an array size in an X macro is a member of mjData
@@ -1080,5 +1083,6 @@
// to obtain only X macros for fields that are relevant for mjvScene creation,
// redefine XNV to expand to nothing
#define XNV X
#define XIC(type, name, nr, nc)
#endif // MUJOCO_MJXMACRO_H_