Make 3 the default number of channels in mjsTexture.
PiperOrigin-RevId: 679521155 Change-Id: Ie6c962e75983c8bf8323170338b3d480be3a1117
This commit is contained in:
committed by
Copybara-Service
parent
6a415da267
commit
bb6da503dc
@@ -274,6 +274,7 @@ void mjs_defaultTexture(mjsTexture* texture) {
|
|||||||
texture->rgb2[0] = texture->rgb2[1] = texture->rgb2[2] = 0.5;
|
texture->rgb2[0] = texture->rgb2[1] = texture->rgb2[2] = 0.5;
|
||||||
texture->random = 0.01;
|
texture->random = 0.01;
|
||||||
texture->gridsize[0] = texture->gridsize[1] = 1;
|
texture->gridsize[0] = texture->gridsize[1] = 1;
|
||||||
|
texture->nchannel = 3;
|
||||||
char defaultlayout[sizeof(texture->gridlayout)] = "............";
|
char defaultlayout[sizeof(texture->gridlayout)] = "............";
|
||||||
strncpy(texture->gridlayout, defaultlayout, sizeof(texture->gridlayout));
|
strncpy(texture->gridlayout, defaultlayout, sizeof(texture->gridlayout));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3236,9 +3236,7 @@ void mjXReader::Asset(XMLElement* section, const mjVFS* vfs) {
|
|||||||
}
|
}
|
||||||
ReadAttrInt(elem, "width", &texture->width);
|
ReadAttrInt(elem, "width", &texture->width);
|
||||||
ReadAttrInt(elem, "height", &texture->height);
|
ReadAttrInt(elem, "height", &texture->height);
|
||||||
if (!ReadAttrInt(elem, "nchannel", &texture->nchannel)) {
|
ReadAttrInt(elem, "nchannel", &texture->nchannel);
|
||||||
texture->nchannel = 3;
|
|
||||||
}
|
|
||||||
ReadAttr(elem, "rgb1", 3, texture->rgb1, text);
|
ReadAttr(elem, "rgb1", 3, texture->rgb1, text);
|
||||||
ReadAttr(elem, "rgb2", 3, texture->rgb2, text);
|
ReadAttr(elem, "rgb2", 3, texture->rgb2, text);
|
||||||
ReadAttr(elem, "markrgb", 3, texture->markrgb, text);
|
ReadAttr(elem, "markrgb", 3, texture->markrgb, text);
|
||||||
|
|||||||
@@ -1254,5 +1254,35 @@ TEST_F(MujocoTest, AttachUnnamedAssets) {
|
|||||||
mj_deleteModel(model);
|
mj_deleteModel(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(MujocoTest, InitTexture) {
|
||||||
|
mjSpec* spec = mj_makeSpec();
|
||||||
|
EXPECT_THAT(spec, NotNull());
|
||||||
|
|
||||||
|
mjsTexture* texture = mjs_addTexture(spec);
|
||||||
|
mjs_setString(texture->name, "checker");
|
||||||
|
texture->type = mjTEXTURE_CUBE;
|
||||||
|
texture->builtin = mjBUILTIN_CHECKER;
|
||||||
|
texture->width = 300;
|
||||||
|
texture->height = 300;
|
||||||
|
|
||||||
|
mjsMaterial* material = mjs_addMaterial(spec, 0);
|
||||||
|
mjs_setString(material->name, "floor");
|
||||||
|
mjs_setInStringVec(material->textures, mjTEXROLE_RGB, "checker");
|
||||||
|
|
||||||
|
mjsGeom* floor = mjs_addGeom(mjs_findBody(spec, "world"), 0);
|
||||||
|
mjs_setString(floor->material, "floor");
|
||||||
|
floor->type = mjGEOM_PLANE;
|
||||||
|
floor->size[0] = 1;
|
||||||
|
floor->size[1] = 1;
|
||||||
|
floor->size[2] = 0.01;
|
||||||
|
mjs_setString(floor->material, "floor");
|
||||||
|
|
||||||
|
mjModel* model = mj_compile(spec, 0);
|
||||||
|
EXPECT_THAT(model, NotNull());
|
||||||
|
|
||||||
|
mj_deleteModel(model);
|
||||||
|
mj_deleteSpec(spec);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace mujoco
|
} // namespace mujoco
|
||||||
|
|||||||
Reference in New Issue
Block a user