Enable attaching plugins not instantiated in the extension section.
Fixes #2217. PiperOrigin-RevId: 695766524 Change-Id: I534b63400810bd6ef888f39f6665213280fd93ac
This commit is contained in:
committed by
Copybara-Service
parent
eb77d5b933
commit
45f908c165
@@ -789,6 +789,7 @@ mjCBody::mjCBody(const mjCBody& other, mjCModel* _model) {
|
||||
mjSpec* origin = model->FindSpec(mjs_getString(other.model->spec.modelname));
|
||||
compiler = origin ? &origin->compiler : &model->spec.compiler;
|
||||
*this = other;
|
||||
CopyPlugin();
|
||||
}
|
||||
|
||||
|
||||
@@ -942,6 +943,7 @@ void mjCBody::CopyList(std::vector<T*>& dst, const std::vector<T*>& src,
|
||||
dst.back()->model = model;
|
||||
dst.back()->compiler = origin ? &origin->compiler : &model->spec.compiler;
|
||||
dst.back()->id = -1;
|
||||
dst.back()->CopyPlugin();
|
||||
dst.back()->classname = src[i]->classname;
|
||||
|
||||
// assign dst frame to src frame
|
||||
@@ -992,6 +994,12 @@ void mjCBody::CopyFromSpec() {
|
||||
|
||||
|
||||
|
||||
void mjCBody::CopyPlugin() {
|
||||
model->CopyExplicitPlugin(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// destructor
|
||||
mjCBody::~mjCBody() {
|
||||
// delete objects allocated here
|
||||
@@ -1011,7 +1019,7 @@ mjCBody::~mjCBody() {
|
||||
cameras.clear();
|
||||
lights.clear();
|
||||
|
||||
if (spec.plugin.active && spec.plugin.name->empty()) {
|
||||
if (spec.plugin.active && spec.plugin.name->empty() && model) {
|
||||
model->DeleteElement(spec.plugin.element);
|
||||
}
|
||||
}
|
||||
@@ -2221,7 +2229,7 @@ mjCGeom::mjCGeom(const mjCGeom& other) {
|
||||
|
||||
|
||||
mjCGeom::~mjCGeom() {
|
||||
if (spec.plugin.active && spec.plugin.name->empty()) {
|
||||
if (spec.plugin.active && spec.plugin.name->empty() && model) {
|
||||
model->DeleteElement(spec.plugin.element);
|
||||
}
|
||||
}
|
||||
@@ -2273,6 +2281,12 @@ void mjCGeom::CopyFromSpec() {
|
||||
|
||||
|
||||
|
||||
void mjCGeom::CopyPlugin() {
|
||||
model->CopyExplicitPlugin(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void mjCGeom::NameSpace(const mjCModel* m) {
|
||||
mjCBase::NameSpace(m);
|
||||
if (!spec_material_.empty() && model != m) {
|
||||
@@ -5636,7 +5650,7 @@ mjCActuator::mjCActuator(const mjCActuator& other) {
|
||||
|
||||
|
||||
mjCActuator::~mjCActuator() {
|
||||
if (spec.plugin.active && spec.plugin.name->empty()) {
|
||||
if (spec.plugin.active && spec.plugin.name->empty() && model) {
|
||||
model->DeleteElement(spec.plugin.element);
|
||||
}
|
||||
}
|
||||
@@ -5731,6 +5745,12 @@ void mjCActuator::CopyFromSpec() {
|
||||
|
||||
|
||||
|
||||
void mjCActuator::CopyPlugin() {
|
||||
model->CopyExplicitPlugin(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void mjCActuator::ResolveReferences(const mjCModel* m) {
|
||||
switch (trntype) {
|
||||
case mjTRN_JOINT:
|
||||
@@ -6000,7 +6020,7 @@ mjCSensor::mjCSensor(const mjCSensor& other) {
|
||||
|
||||
|
||||
mjCSensor::~mjCSensor() {
|
||||
if (spec.plugin.active && spec.plugin.name->empty()) {
|
||||
if (spec.plugin.active && spec.plugin.name->empty() && model) {
|
||||
model->DeleteElement(spec.plugin.element);
|
||||
}
|
||||
}
|
||||
@@ -6063,6 +6083,12 @@ void mjCSensor::CopyFromSpec() {
|
||||
|
||||
|
||||
|
||||
void mjCSensor::CopyPlugin() {
|
||||
model->CopyExplicitPlugin(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void mjCSensor::ResolveReferences(const mjCModel* m) {
|
||||
objname_ = prefix + objname_ + suffix;
|
||||
refname_ = prefix + refname_ + suffix;
|
||||
|
||||
Reference in New Issue
Block a user