From cc2d78bf16760f81fa455a330b47685a4487cf6a Mon Sep 17 00:00:00 2001 From: Jonathan Embley-Riches Date: Wed, 22 Apr 2026 22:50:25 +0100 Subject: [PATCH] Add per-articulation SimOptions priority and conflict resolver --- .../Private/MuJoCo/Core/MjArticulation.cpp | 5 +- .../Private/MuJoCo/Core/MjPhysicsEngine.cpp | 21 + .../Private/MuJoCo/Core/MjSimOptions.cpp | 391 +++++++++++++++++- .../URLab/Public/MuJoCo/Core/MjArticulation.h | 6 + .../URLab/Public/MuJoCo/Core/MjSimOptions.h | 9 + Source/URLab/URLab.Build.cs | 3 +- .../Tests/MjSimOptionsResolverTests.cpp | 293 +++++++++++++ docs/getting_started.md | 6 + docs/guides/sim_options_priority.md | 160 +++++++ docs/index.md | 1 + mkdocs.yml | 1 + 11 files changed, 891 insertions(+), 5 deletions(-) create mode 100644 Source/URLabEditor/Private/Tests/MjSimOptionsResolverTests.cpp create mode 100644 docs/guides/sim_options_priority.md diff --git a/Source/URLab/Private/MuJoCo/Core/MjArticulation.cpp b/Source/URLab/Private/MuJoCo/Core/MjArticulation.cpp index 2a0865f..d296198 100644 --- a/Source/URLab/Private/MuJoCo/Core/MjArticulation.cpp +++ b/Source/URLab/Private/MuJoCo/Core/MjArticulation.cpp @@ -246,9 +246,8 @@ void AMjArticulation::Setup(mjSpec* Spec, mjVFS* VFS) m_ChildSpec = mj_makeSpec(); m_ChildSpec->compiler.degree = false; - // Apply this articulation's simulation options to the child spec. - // mjs_attach will merge these into the root spec at compile time. - SimOptions.ApplyToSpec(m_ChildSpec); + // SimOptions get folded into the parent spec by FMuJoCoOptions::Resolve; + // writing to m_ChildSpec here would be discarded by mjs_attach. m_prefix = GetName() + TEXT("_"); diff --git a/Source/URLab/Private/MuJoCo/Core/MjPhysicsEngine.cpp b/Source/URLab/Private/MuJoCo/Core/MjPhysicsEngine.cpp index a639ed6..6f18369 100644 --- a/Source/URLab/Private/MuJoCo/Core/MjPhysicsEngine.cpp +++ b/Source/URLab/Private/MuJoCo/Core/MjPhysicsEngine.cpp @@ -172,6 +172,27 @@ void UMjPhysicsEngine::PreCompile() m_heightfieldActors.Add(HFA); } } + + // mjs_attach above drops each articulation's