Remove box, cylinder and ellipsoid composite types.

Also, fix a bug with Flex textures that was causing an incorrect allocation of the textures in mjModel. Fixes #2013.

PiperOrigin-RevId: 692510858
Change-Id: If781716216974e085244da27bc3aa57d91c3458c
This commit is contained in:
Alessio Quaglino
2024-11-02 11:13:16 -07:00
committed by Copybara-Service
parent ebe60b9ad5
commit 831d9881d3
12 changed files with 54 additions and 547 deletions
+25
View File
@@ -763,6 +763,7 @@ bool mjCFlexcomp::MakeSquare(char* error, int error_sz) {
// make 3d box, ellipsoid or cylinder
bool mjCFlexcomp::MakeBox(char* error, int error_sz) {
double pos[3];
bool needtex = texcoord.empty() && !std::string(mjs_getString(def.spec.flex->material)).empty();
// set 3D
def.spec.flex->dim = 3;
@@ -772,6 +773,12 @@ bool mjCFlexcomp::MakeBox(char* error, int error_sz) {
point.push_back(0);
point.push_back(0);
// add texture coordinates, if not specified explicitly
if (needtex) {
texcoord.push_back(0);
texcoord.push_back(0);
}
// iz=0/max
for (int iz=0; iz < count[2]; iz+=count[2]-1) {
for (int ix=0; ix < count[0]; ix++) {
@@ -782,6 +789,12 @@ bool mjCFlexcomp::MakeBox(char* error, int error_sz) {
point.push_back(pos[1]);
point.push_back(pos[2]);
// add texture coordinates, if not specified explicitly
if (needtex) {
texcoord.push_back(ix/(float)std::max(count[0]-1, 1));
texcoord.push_back(iy/(float)std::max(count[1]-1, 1));
}
// add elements
if (ix < count[0]-1 && iy < count[1]-1) {
element.push_back(0);
@@ -808,6 +821,12 @@ bool mjCFlexcomp::MakeBox(char* error, int error_sz) {
point.push_back(pos[0]);
point.push_back(pos[1]);
point.push_back(pos[2]);
// add texture coordinates
if (needtex) {
texcoord.push_back(ix/(float)std::max(count[0]-1, 1));
texcoord.push_back(iz/(float)std::max(count[2]-1, 1));
}
}
// add elements
@@ -836,6 +855,12 @@ bool mjCFlexcomp::MakeBox(char* error, int error_sz) {
point.push_back(pos[0]);
point.push_back(pos[1]);
point.push_back(pos[2]);
// add texture coordinates
if (needtex) {
texcoord.push_back(iy/(float)std::max(count[1]-1, 1));
texcoord.push_back(iz/(float)std::max(count[2]-1, 1));
}
}
// add elements