Allow orientation for user composite.

PiperOrigin-RevId: 740909723
Change-Id: Id38a55114d4257a461bbced57d35d6bb42a2597d
This commit is contained in:
Alessio Quaglino
2025-03-26 14:43:55 -07:00
committed by Copybara-Service
parent 644b42bee3
commit e8c67ca586
6 changed files with 27 additions and 9 deletions
+8 -4
View File
@@ -52,6 +52,7 @@ mjCComposite::mjCComposite(void) {
type = mjCOMPTYPE_PARTICLE;
count[0] = count[1] = count[2] = 1;
mjuu_setvec(offset, 0, 0, 0);
mjuu_setvec(quat, 1, 0, 0, 0);
frame = nullptr;
// plugin variables
@@ -260,19 +261,20 @@ bool mjCComposite::MakeCable(mjCModel* model, mjsBody* body, char* error, int er
// populate uservert if not specified
if (uservert.empty()) {
for (int ix=0; ix < count[0]; ix++) {
double v[3];
for (int k=0; k < 3; k++) {
switch (curve[k]) {
case mjCOMPSHAPE_LINE:
uservert.push_back(ix*size[0]/(count[0]-1));
v[k] = ix*size[0]/(count[0]-1);
break;
case mjCOMPSHAPE_COS:
uservert.push_back(size[1]*cos(mjPI*ix*size[2]/(count[0]-1)));
v[k] = size[1]*cos(mjPI*ix*size[2]/(count[0]-1));
break;
case mjCOMPSHAPE_SIN:
uservert.push_back(size[1]*sin(mjPI*ix*size[2]/(count[0]-1)));
v[k] = size[1]*sin(mjPI*ix*size[2]/(count[0]-1));
break;
case mjCOMPSHAPE_ZERO:
uservert.push_back(0);
v[k] = 0;
break;
default:
// SHOULD NOT OCCUR
@@ -280,6 +282,8 @@ bool mjCComposite::MakeCable(mjCModel* model, mjsBody* body, char* error, int er
break;
}
}
mjuu_rotVecQuat(v, v, quat);
uservert.insert(uservert.end(), v, v+3);
}
}
+2 -1
View File
@@ -73,7 +73,8 @@ class mjCComposite {
std::string prefix; // name prefix
mjtCompType type; // composite type
int count[3]; // geom count in each dimension
double offset[3]; // position offset for particle and grid
double offset[3]; // position offset
double quat[4]; // quaternion offset
// currently used only for cable
std::string initial; // root boundary type