Require prefix for the attach tag.
For `mjs_attachFrame` and `mjs_attachBody`, require either a prefix or suffix. It is tempting for users to not use a prefix (see #2162), but this causes issues. For example, it creates a duplicate "main" default class in the parent as a child of the already existing "main" default. PiperOrigin-RevId: 688535755 Change-Id: I653181ca35943f1e4eb89c70fca8b5289818324e
This commit is contained in:
committed by
Copybara-Service
parent
94e9912d28
commit
bfa78614c8
@@ -850,6 +850,10 @@ mjCBody& mjCBody::operator+=(const mjCFrame& other) {
|
||||
other.model->suffix = other.suffix;
|
||||
other.model->StoreKeyframes(model);
|
||||
|
||||
if (other.prefix.empty() && other.suffix.empty()) {
|
||||
throw mjCError(this, "either prefix or suffix must be non-empty");
|
||||
}
|
||||
|
||||
// attach defaults
|
||||
if (other.model != model) {
|
||||
mjCDef* subdef = new mjCDef(*other.model->Default());
|
||||
@@ -1812,6 +1816,10 @@ mjCFrame& mjCFrame::operator+=(const mjCBody& other) {
|
||||
other.model->prefix = "";
|
||||
other.model->suffix = "";
|
||||
|
||||
if (other.prefix.empty() && other.suffix.empty()) {
|
||||
throw mjCError(this, "either prefix or suffix must be non-empty");
|
||||
}
|
||||
|
||||
mjCBody* subtree = new mjCBody(other, model);
|
||||
other.ForgetKeyframes();
|
||||
other.model->prefix = subtree->prefix;
|
||||
|
||||
Reference in New Issue
Block a user