Remove the Shell plugin and integrate it into the engine.

PiperOrigin-RevId: 760688502
Change-Id: Ia70988d42b7edf571d7cb4a4f48f8fc50b51667d
This commit is contained in:
Alessio Quaglino
2025-05-19 10:50:27 -07:00
committed by Copybara-Service
parent 45fc15b844
commit 7edbdd0ad6
28 changed files with 90 additions and 291 deletions
-1
View File
@@ -238,7 +238,6 @@ void mjs_defaultFlex(mjsFlex* flex) {
flex->rgba[0] = flex->rgba[1] = flex->rgba[2] = 0.5f;
flex->rgba[3] = 1.0f;
flex->thickness = -1;
flex->elastic2d = 1;
}
+12 -5
View File
@@ -3382,9 +3382,13 @@ void mjCFlex::ResolveReferences(const mjCModel* m) {
vertbodyid.clear();
nodebodyid.clear();
for (const auto& vertbody : vertbody_) {
mjCBase* pbody = m->FindObject(mjOBJ_BODY, vertbody);
mjCBody* pbody = static_cast<mjCBody*>(m->FindObject(mjOBJ_BODY, vertbody));
if (pbody) {
vertbodyid.push_back(pbody->id);
if (pbody->joints.size() != 3 && dim == 2 && (elastic2d == 1 || elastic2d == 3)) {
// TODO(quaglino): add support for pins
throw mjCError(this, "pins are not supported for bending");
}
} else {
throw mjCError(this, "unknown body '%s' in flex", vertbody.c_str());
}
@@ -3658,7 +3662,10 @@ void mjCFlex::Compile(const mjVFS* vfs) {
}
// bending stiffness (2D only)
if (dim == 2 && (elastic2d == 1 || elastic2d == 3) && thickness > 0) {
if (dim == 2 && (elastic2d == 1 || elastic2d == 3)) {
if (thickness < 0) {
throw mjCError(this, "thickness must be positive for bending stiffness");
}
bending.assign(nedge*16, 0);
for (unsigned int e = 0; e < nedge; e++) {
@@ -3668,7 +3675,7 @@ void mjCFlex::Compile(const mjVFS* vfs) {
}
}
// add plugins
// placeholder for setting plugins parameters, currently not used
for (const auto& vbodyid : vertbodyid) {
if (vbodyid < 0) {
continue;
@@ -3676,8 +3683,8 @@ void mjCFlex::Compile(const mjVFS* vfs) {
if (model->Bodies()[vbodyid]->plugin.element) {
mjCPlugin* plugin_instance =
static_cast<mjCPlugin*>(model->Bodies()[vbodyid]->plugin.element);
if (damping > 0) {
plugin_instance->config_attribs["damping"] = std::to_string(damping);
if (!plugin_instance) {
throw mjCError(this, "plugin instance not found");
}
}
}
+1 -1
View File
@@ -3165,7 +3165,7 @@ void mjCModel::CopyObjects(mjModel* m) {
for (int k=0; k < pfl->nedge; k++) {
m->flex_edge[2*(edge_adr+k)] = pfl->edge[k].first;
m->flex_edge[2*(edge_adr+k)+1] = pfl->edge[k].second;
if (pfl->dim == 2) {
if (pfl->dim == 2 && (pfl->elastic2d == 1 || pfl->elastic2d == 3)) {
m->flex_edgeflap[2*(edge_adr+k)+0] = pfl->flaps[k].vertices[2];
m->flex_edgeflap[2*(edge_adr+k)+1] = pfl->flaps[k].vertices[3];
} else {