Clear body subtreedofs when compiling. Fixes issue when attaching previously compiled model.

PiperOrigin-RevId: 738906593
Change-Id: I74875b4d07c422e397358dff5daf6682ec1bd655
This commit is contained in:
Tom Power
2025-03-20 12:51:33 -07:00
committed by Copybara-Service
parent 2e11afa2de
commit 8d92a0fbe6
2 changed files with 60 additions and 3 deletions
+5 -3
View File
@@ -4008,9 +4008,6 @@ static void warninghandler(const char* msg) {
mjModel* mjCModel::Compile(const mjVFS* vfs, mjModel** m) {
if (compiled) {
// clear kinematic tree
for (int i=0; i < bodies_.size(); i++) {
bodies_[i]->subtreedofs = 0;
}
mjCBody* world = bodies_[0];
ResetTreeLists();
Clear();
@@ -4313,6 +4310,11 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
// make lists of objects created in kinematic tree
MakeLists(bodies_[0]);
// clear subtreedofs
for (int i=0; i < bodies_.size(); i++) {
bodies_[i]->subtreedofs = 0;
}
// fill missing names and check that they are all filled
for (const auto& asset : meshes_) asset->CopyFromSpec();
for (const auto& asset : skins_) asset->CopyFromSpec();