Raise warning when attaching a spec with pending keyframes to a different spec.
PiperOrigin-RevId: 685677622 Change-Id: Iba522c523ebd2afe64d6ab28c6b6b4b3cd399cf8
This commit is contained in:
committed by
Copybara-Service
parent
c84f35b425
commit
1e7c109887
@@ -463,7 +463,7 @@ mjCModel& mjCModel::operator-=(const mjCBody& subtree) {
|
||||
}
|
||||
|
||||
// all keyframes are now pending and they will be resized
|
||||
StoreKeyframes();
|
||||
StoreKeyframes(this);
|
||||
DeleteAll(keys_);
|
||||
|
||||
// remove body from tree
|
||||
@@ -3142,9 +3142,15 @@ template void mjCModel::RestoreState<mjtNum>(
|
||||
|
||||
|
||||
// resolve keyframe references
|
||||
void mjCModel::StoreKeyframes() {
|
||||
void mjCModel::StoreKeyframes(mjCModel* dest) {
|
||||
bool resetlists = false;
|
||||
|
||||
if (this != dest && !key_pending_.empty()) {
|
||||
mju_warning(
|
||||
"Child model has pending keyframes. They will not be namespaced correctly. "
|
||||
"To prevent this, compile the child model before attaching it again.");
|
||||
}
|
||||
|
||||
// create tree lists if they are empty, occurs if an uncompiled model is attached
|
||||
if (bodies_.size() == 1 && geoms_.empty() && sites_.empty() && joints_.empty() &&
|
||||
cameras_.empty() && lights_.empty() && frames_.empty()) {
|
||||
@@ -3172,7 +3178,7 @@ void mjCModel::StoreKeyframes() {
|
||||
info.ctrl = !key->spec_ctrl_.empty();
|
||||
info.mpos = !key->spec_mpos_.empty();
|
||||
info.mquat = !key->spec_mquat_.empty();
|
||||
key_pending_.push_back(info);
|
||||
dest->key_pending_.push_back(info);
|
||||
ResizeKeyframe(key, qpos0.data(), body_pos0.data(), body_quat0.data());
|
||||
SaveState(info.name, key->spec_qpos_.data(), key->spec_qvel_.data(),
|
||||
key->spec_act_.data(), key->spec_ctrl_.data(),
|
||||
|
||||
@@ -297,7 +297,7 @@ class mjCModel : public mjCModel_, private mjSpec {
|
||||
void MakeData(const mjModel* m, mjData** dest);
|
||||
|
||||
// resolve keyframe references
|
||||
void StoreKeyframes();
|
||||
void StoreKeyframes(mjCModel* dest);
|
||||
|
||||
// map from default class name to default class pointer
|
||||
std::unordered_map<std::string, mjCDef*> def_map;
|
||||
|
||||
@@ -848,7 +848,7 @@ mjCBody& mjCBody::operator+=(const mjCFrame& other) {
|
||||
mjCBody* subtree = other.body;
|
||||
other.model->prefix = other.prefix;
|
||||
other.model->suffix = other.suffix;
|
||||
other.model->StoreKeyframes();
|
||||
other.model->StoreKeyframes(model);
|
||||
|
||||
// attach defaults
|
||||
if (other.model != model) {
|
||||
@@ -1808,7 +1808,7 @@ mjCFrame& mjCFrame::operator=(const mjCFrame& other) {
|
||||
mjCFrame& mjCFrame::operator+=(const mjCBody& other) {
|
||||
other.model->prefix = other.prefix;
|
||||
other.model->suffix = other.suffix;
|
||||
other.model->StoreKeyframes();
|
||||
other.model->StoreKeyframes(model);
|
||||
other.model->prefix = "";
|
||||
other.model->suffix = "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user