Check that spacing is greater than geometry size for Composite particles and grid.

PiperOrigin-RevId: 491858371
Change-Id: I03a669286c283a72947705463426badcfc9b0bfd
This commit is contained in:
Alessio Quaglino
2022-11-30 02:17:09 -08:00
committed by Copybara-Service
parent df25d7d602
commit 26f71e2f6c
2 changed files with 49 additions and 2 deletions
+10 -1
View File
@@ -241,11 +241,20 @@ bool mjCComposite::Make(mjCModel* model, mjCBody* body, char* error, int error_s
}
// check spacing
if (type==mjCOMPTYPE_GRID || type==mjCOMPTYPE_PARTICLE) {
if (spacing < mju_max(def[0].geom.size[0],
mju_max(def[0].geom.size[1], def[0].geom.size[2]))) {
return comperr(error, "Spacing must be larger than geometry size",
error_sz);
}
}
// check cable sizes are nonzero if vertices are not prescribed
if (mjuu_dot3(size, size)<mjMINVAL && uservert.empty()) {
return comperr(error, "Positive spacing or length expected in composite", error_sz);
}
// check either spacing or length
// check spacing is not used by cable
if (spacing && type==mjCOMPTYPE_CABLE) {
return comperr(error, "Spacing is not supported by cable composite", error_sz);
}