Add nested keyframes attachment test.
This is a no-op change for keyframes but it shows an example of behavior. Also, fixed two bugs: - Missing namespace when attaching frames. - Incorrect body id and subtreedof when attaching a compiled spec. Fixes #2063. PiperOrigin-RevId: 680289467 Change-Id: I2ddaa7ad2226fa466ec3bbf74a7553d497bb4bb9
This commit is contained in:
committed by
Copybara-Service
parent
807ee852d0
commit
58a49bad96
@@ -119,6 +119,10 @@ mjModel* mj_compile(mjSpec* s, const mjVFS* vfs) {
|
||||
// attach body to a frame of the parent
|
||||
mjsBody* mjs_attachBody(mjsFrame* parent, const mjsBody* child,
|
||||
const char* prefix, const char* suffix) {
|
||||
if (!parent) {
|
||||
mju_error("parent frame is null");
|
||||
return nullptr;
|
||||
}
|
||||
mjCFrame* frame_parent = static_cast<mjCFrame*>(parent->element);
|
||||
mjCBody* child_body = static_cast<mjCBody*>(child->element);
|
||||
try {
|
||||
@@ -137,6 +141,10 @@ mjsBody* mjs_attachBody(mjsFrame* parent, const mjsBody* child,
|
||||
// attach frame to a parent body
|
||||
mjsFrame* mjs_attachFrame(mjsBody* parent, const mjsFrame* child,
|
||||
const char* prefix, const char* suffix) {
|
||||
if (!parent) {
|
||||
mju_error("parent body is null");
|
||||
return nullptr;
|
||||
}
|
||||
mjCBody* body_parent = static_cast<mjCBody*>(parent->element);
|
||||
mjCFrame* child_frame = static_cast<mjCFrame*>(child->element);
|
||||
try {
|
||||
|
||||
@@ -802,7 +802,8 @@ mjCBody& mjCBody::operator=(const mjCBody& other) {
|
||||
sites.clear();
|
||||
cameras.clear();
|
||||
lights.clear();
|
||||
id = other.id;
|
||||
id = -1;
|
||||
subtreedofs = 0;
|
||||
|
||||
// add elements to lists
|
||||
*this += other;
|
||||
@@ -1040,6 +1041,10 @@ void mjCBody::NameSpace_(const mjCModel* m, bool propagate) {
|
||||
for (auto& light : lights) {
|
||||
light->NameSpace(m);
|
||||
}
|
||||
|
||||
for (auto& frame : frames) {
|
||||
frame->NameSpace(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user