Track authored flags for global attributes

PiperOrigin-RevId: 931585539
Change-Id: Ifdc8c59de6c5a553daf6e0af09d8192aff6b0610
This commit is contained in:
Yuval Tassa
2026-06-13 02:57:52 -07:00
committed by Copybara-Service
parent 0ea9c7cb3a
commit 67a1ea6dca
21 changed files with 823 additions and 195 deletions
+26
View File
@@ -20,19 +20,24 @@
#include <mujoco/mjplugin.h>
#include <mujoco/mjrender.h>
#include <mujoco/mjspec.h>
#include <mujoco/mjspecmacro.h>
#include <mujoco/mjtype.h>
#include <mujoco/mjui.h>
#include <mujoco/mjvisualize.h>
#include <mujoco/mjxmacro.h>
#if defined(__cplusplus)
#define MJ_ASSERT_SIZE(type, size) \
static_assert(sizeof(type) == (size), #type " must be " #size " bytes for MuJoCo ABI stability")
#define MJ_STATIC_ASSERT(expr) static_assert(expr)
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define MJ_ASSERT_SIZE(type, size) \
_Static_assert(sizeof(type) == (size), #type " must be " #size " bytes for MuJoCo ABI stability")
#define MJ_STATIC_ASSERT(expr) _Static_assert(expr, #expr)
#else
#define MJ_ASSERT_SIZE(type, size) \
typedef char mj_assert_##type[sizeof(type) == (size) ? 1 : -1]
#define MJ_STATIC_ASSERT(expr)
#endif
// primitive types
@@ -125,6 +130,27 @@ MJ_ASSERT_SIZE(mjtSection, 4);
// mjplugin.h
MJ_ASSERT_SIZE(mjtPluginCapabilityBit, 4);
// authored bitmask field count assertions
// each authored bitmask is uint64_t, so each FIELDS macro must have <= 64 entries
#define X(type, name, dim) +1
#define XVEC(type, name, dim) +1
// mjsCompiler
MJ_STATIC_ASSERT((0 MJSCOMPILER_FIELDS) <= 64);
// mjOption and mjVisual
MJ_STATIC_ASSERT((0 MJOPTION_FIELDS) <= 64);
MJ_STATIC_ASSERT((0 MJVISUAL_GLOBAL_FIELDS) <= 64);
MJ_STATIC_ASSERT((0 MJVISUAL_QUALITY_FIELDS) <= 64);
MJ_STATIC_ASSERT((0 MJVISUAL_HEADLIGHT_FIELDS) <= 64);
MJ_STATIC_ASSERT((0 MJVISUAL_MAP_FIELDS) <= 64);
MJ_STATIC_ASSERT((0 MJVISUAL_SCALE_FIELDS) <= 64);
MJ_STATIC_ASSERT((0 MJVISUAL_RGBA_FIELDS) <= 64);
#undef X
#undef XVEC
#undef MJ_ASSERT_SIZE
#undef MJ_STATIC_ASSERT
#endif // MUJOCO_MJASSERT_H_
+18
View File
@@ -174,9 +174,24 @@ typedef struct mjsCompiler_ { // compiler options
mjLROpt LRopt; // options for lengthrange computation
mjString* meshdir; // mesh and hfield directory
mjString* texturedir; // texture directory
uint64_t authored; // bitmask of authored compiler fields
} mjsCompiler;
typedef struct mjsAuthored_ { // authored tracking bitmasks for mjModel structs
uint64_t option; // authored mjOption fields
int disableflags; // individual authored disable flags
int enableflags; // individual authored enable flags
int disableactuator; // individual authored actuator groups
uint64_t visual_global; // authored visual.global fields
uint64_t visual_quality; // authored visual.quality fields
uint64_t visual_headlight; // authored visual.headlight fields
uint64_t visual_map; // authored visual.map fields
uint64_t visual_scale; // authored visual.scale fields
uint64_t visual_rgba; // authored visual.rgba fields
} mjsAuthored;
typedef struct mjSpec_ { // model specification
mjsElement* element; // element type
mjString* modelname; // model name
@@ -213,6 +228,9 @@ typedef struct mjSpec_ { // model specification
// other
mjtByte hasImplicitPluginElem; // already encountered an implicit plugin sensor/actuator
// authored tracking bitmasks for mjModel structs
mjsAuthored authored;
} mjSpec;
+2 -1
View File
@@ -43,7 +43,8 @@
X ( int, alignfree, 1 ) \
X ( mjLROpt, LRopt, 1 ) \
X ( mjString*, meshdir, 1 ) \
X ( mjString*, texturedir, 1 )
X ( mjString*, texturedir, 1 ) \
X ( uint64_t, authored, 1 )
//-------------------------------- mjSpec ----------------------------------------------------------