Always try to find the skybox texture, even if there are no materials in the MJCF. Fixes #2412
Before the fix this only occured if the MJCF contained 0 materials. PiperOrigin-RevId: 795510952 Change-Id: I0a36c275e6006f80dc9a5ba6b9c6040ce21187c9
This commit is contained in:
committed by
Copybara-Service
parent
b566ef2883
commit
931036adda
+14
-16
@@ -1303,23 +1303,7 @@ static void makeMaterial(const mjModel* m, mjrContext* con) {
|
||||
memset(con->mat_texid, -1, sizeof(con->mat_texid));
|
||||
memset(con->mat_texuniform, 0, sizeof(con->mat_texuniform));
|
||||
memset(con->mat_texrepeat, 0, sizeof(con->mat_texrepeat));
|
||||
if (!m->nmat || !m->ntex) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m->nmat >= mjMAXMATERIAL-1) {
|
||||
mju_error("Maximum number of materials is %d, got %d", mjMAXMATERIAL, m->nmat);
|
||||
}
|
||||
for (int i=0; i < m->nmat; i++) {
|
||||
if (m->mat_texid[i*mjNTEXROLE + mjTEXROLE_RGB] >= 0) {
|
||||
for (int j=0; j < mjNTEXROLE; j++) {
|
||||
con->mat_texid[i*mjNTEXROLE + j] = m->mat_texid[i*mjNTEXROLE + j];
|
||||
}
|
||||
con->mat_texuniform[i] = m->mat_texuniform[i];
|
||||
con->mat_texrepeat[2*i] = m->mat_texrepeat[2*i];
|
||||
con->mat_texrepeat[2*i+1] = m->mat_texrepeat[2*i+1];
|
||||
}
|
||||
}
|
||||
// find skybox texture
|
||||
for (int i=0; i < m->ntex; i++) {
|
||||
if (m->tex_type[i] == mjTEXTURE_SKYBOX) {
|
||||
@@ -1335,6 +1319,20 @@ static void makeMaterial(const mjModel* m, mjrContext* con) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m->nmat >= mjMAXMATERIAL-1) {
|
||||
mju_error("Maximum number of materials is %d, got %d", mjMAXMATERIAL, m->nmat);
|
||||
}
|
||||
for (int i=0; i < m->nmat; i++) {
|
||||
if (m->mat_texid[i*mjNTEXROLE + mjTEXROLE_RGB] >= 0) {
|
||||
for (int j=0; j < mjNTEXROLE; j++) {
|
||||
con->mat_texid[i*mjNTEXROLE + j] = m->mat_texid[i*mjNTEXROLE + j];
|
||||
}
|
||||
con->mat_texuniform[i] = m->mat_texuniform[i];
|
||||
con->mat_texrepeat[2*i] = m->mat_texrepeat[2*i];
|
||||
con->mat_texrepeat[2*i+1] = m->mat_texrepeat[2*i+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user