Add ability to specify a material assignment to a mesh asset.

This extends both the spec and the XML definition to allow specification of a material name on a mesh. This material acts as a fallback in the case that the referencing geom element does not specify a material of it's own.

PiperOrigin-RevId: 798232378
Change-Id: Iaf300c727732744ea1b613e64334ee505ac6e209
This commit is contained in:
Sam Haves
2025-08-22 09:10:35 -07:00
committed by Copybara-Service
parent 42d8454555
commit 1fb1810b07
13 changed files with 120 additions and 29 deletions
+3
View File
@@ -278,6 +278,7 @@ void mjCMesh::PointToLocal() {
spec.userface = &spec_face_;
spec.usertexcoord = &spec_texcoord_;
spec.userfacetexcoord = &spec_facetexcoord_;
spec.material = &spec_material_;
spec.plugin.plugin_name = &plugin_name;
spec.plugin.name = &plugin_instance_name;
spec.info = &info;
@@ -317,6 +318,7 @@ void mjCMesh::CopyFromSpec() {
content_type_ = spec_content_type_;
normal_ = spec_normal_;
face_ = spec_face_;
material_ = spec_material_;
ProcessVertices(spec_vert_);
texcoord_ = spec_texcoord_;
facetexcoord_ = spec_facetexcoord_;
@@ -476,6 +478,7 @@ void mjCMesh::CacheMesh(mjCCache* cache, const mjResource* resource) {
mesh->polygon_map_ = polygon_map_;
mesh->surface_ = surface_;
mesh->volume_ = volume_;
mesh->material_ = material_;
std::copy(boxsz_, boxsz_ + 3, mesh->boxsz_);
std::copy(aamm_, aamm_ + 6, mesh->aamm_);
std::copy(pos_, pos_ + 3, mesh->pos_);