Add material parsing path for colliders instead of strictly visual gprims.
PiperOrigin-RevId: 814692421 Change-Id: If92a36d0382f60e0d92c7d90320dec51c20ea739
This commit is contained in:
committed by
Copybara-Service
parent
709caa0628
commit
b5c35f87fc
@@ -1384,14 +1384,19 @@ void ParseUsdGeomGprim(mjSpec* spec, const pxr::UsdPrim& gprim,
|
||||
if (bound_material) {
|
||||
pxr::SdfPath material_path = bound_material.GetPrim().GetPath();
|
||||
mjsMaterial* material = nullptr;
|
||||
if (caches.parsed_materials.find(material_path) !=
|
||||
caches.parsed_materials.end()) {
|
||||
material = caches.parsed_materials[material_path];
|
||||
if (auto iter = caches.parsed_materials.find(material_path);
|
||||
iter != caches.parsed_materials.end()) {
|
||||
material = iter->second;
|
||||
} else {
|
||||
material = ParseMaterial(spec, bound_material);
|
||||
caches.parsed_materials[material_path] = material;
|
||||
// ParseMaterial may return a nullptr if the material is not supported.
|
||||
if (material) {
|
||||
caches.parsed_materials[material_path] = material;
|
||||
}
|
||||
}
|
||||
if (material) {
|
||||
mjs_setString(geom->material, mjs_getName(material->element)->c_str());
|
||||
}
|
||||
mjs_setString(geom->material, mjs_getName(material->element)->c_str());
|
||||
}
|
||||
|
||||
if (gprim.HasAPI<pxr::MjcPhysicsImageableAPI>()) {
|
||||
@@ -1438,6 +1443,21 @@ void ParseUsdPhysicsCollider(mjSpec* spec,
|
||||
ParseMjcPhysicsMaterialAPI(
|
||||
geom, pxr::MjcPhysicsMaterialAPI(bound_material_prim));
|
||||
}
|
||||
pxr::SdfPath material_path = bound_material_prim.GetPath();
|
||||
mjsMaterial* material = nullptr;
|
||||
if (auto iter = caches.parsed_materials.find(material_path);
|
||||
iter != caches.parsed_materials.end()) {
|
||||
material = iter->second;
|
||||
} else {
|
||||
material = ParseMaterial(spec, bound_material);
|
||||
// ParseMaterial may return a nullptr if the material is not supported.
|
||||
if (material) {
|
||||
caches.parsed_materials[material_path] = material;
|
||||
}
|
||||
}
|
||||
if (material) {
|
||||
mjs_setString(geom->material, mjs_getName(material->element)->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the Mass API after the physics material APIs since the density
|
||||
|
||||
Reference in New Issue
Block a user