#3612·mujoco

Make `mjs_setDefault` copy the default/class values instead of just setting name

Author: davidhozicCreated Sep 21, 2026Updated Sep 23, 2026
Labelsenhancement

The feature, motivation and pitch

The problem:

Currently, mjs_setDefault only sets the class name, without copying the actual class's attribute values. This is not a problem by itself for C code, as C code can use the def parameter of mjs_addX (e.g., mjs_addGeom), which is a pointer to the default.

In any case mjs_setDefault is misleading and makes users think that the default attributes get copied over, despite them not being copied over. As a result, compiling the model in memory does not result in actual inheritance at all.

The feature request: What I'd like, is for mjs_setDefault to copy the parameters over, the same way functions such as mjs_addGeom do when def is given.

Alternatives

No response

Additional context

No response