Add mujoco compiler settings to MjcSceneAPI in mjcPhysics.

PiperOrigin-RevId: 783729333
Change-Id: Ic1c3e4fb47a901de4eebdc2e987d276f4202d9ed
This commit is contained in:
Sam Haves
2025-07-16 06:08:38 -07:00
committed by Copybara-Service
parent 5069534a5c
commit ac0701d582
9 changed files with 1091 additions and 30 deletions
@@ -655,6 +655,72 @@ class ModelWriter {
for (const auto &[token, flag] : disable_flags) {
create_flag_attr(token, flag, false);
}
// Compiler attributes
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Bool,
MjcPhysicsTokens->mjcCompilerAutoLimits,
(bool)spec_->compiler.autolimits);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Double,
MjcPhysicsTokens->mjcCompilerBoundMass,
spec_->compiler.boundmass);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Double,
MjcPhysicsTokens->mjcCompilerBoundInertia,
spec_->compiler.boundinertia);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Double,
MjcPhysicsTokens->mjcCompilerSetTotalMass,
spec_->compiler.settotalmass);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Bool,
MjcPhysicsTokens->mjcCompilerUseThread,
(bool)spec_->compiler.usethread);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Bool,
MjcPhysicsTokens->mjcCompilerBalanceInertia,
(bool)spec_->compiler.balanceinertia);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Token,
MjcPhysicsTokens->mjcCompilerAngle,
spec_->compiler.degree ? MjcPhysicsTokens->degree:MjcPhysicsTokens->radian);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Bool,
MjcPhysicsTokens->mjcCompilerFitAABB,
(bool)spec_->compiler.fitaabb);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Bool,
MjcPhysicsTokens->mjcCompilerFuseStatic,
(bool)spec_->compiler.fusestatic);
pxr::TfToken inertiafromgeom_token = MjcPhysicsTokens->auto_;
if (spec_->compiler.inertiafromgeom ==
mjINERTIAFROMGEOM_TRUE) { // mjINERTIA_TRUE
inertiafromgeom_token = MjcPhysicsTokens->true_;
} else if (spec_->compiler.inertiafromgeom ==
mjINERTIAFROMGEOM_FALSE) { // mjINERTIA_FALSE
inertiafromgeom_token = MjcPhysicsTokens->false_;
}
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Token,
MjcPhysicsTokens->mjcCompilerInertiaFromGeom,
inertiafromgeom_token);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Bool,
MjcPhysicsTokens->mjcCompilerAlignFree,
(bool)spec_->compiler.alignfree);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Int,
MjcPhysicsTokens->mjcCompilerInertiaGroupRangeMin,
spec_->compiler.inertiagrouprange[0]);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Int,
MjcPhysicsTokens->mjcCompilerInertiaGroupRangeMax,
spec_->compiler.inertiagrouprange[1]);
WriteUniformAttribute(physics_scene_path, pxr::SdfValueTypeNames->Bool,
MjcPhysicsTokens->mjcCompilerSaveInertial,
(bool)spec_->compiler.saveinertial);
}
void WriteMeshes() {