Add MeshCollisionAPI to collider Meshes with convexHull approximation.
PiperOrigin-RevId: 754014642 Change-Id: I44cff505a2b9b7120a38f8c896b2c6560ce51c43
This commit is contained in:
committed by
Copybara-Service
parent
ab63a7e824
commit
253abad210
@@ -883,6 +883,21 @@ class ModelWriter {
|
||||
model_->geom_conaffinity[geom_id] != 0)) {
|
||||
ApplyApiSchema(data_, geom_path,
|
||||
pxr::UsdPhysicsTokens->PhysicsCollisionAPI);
|
||||
// For meshes, also apply PhysicsMeshCollisionAPI and set the
|
||||
// approximation attribute.
|
||||
if (geom->type == mjGEOM_MESH) {
|
||||
ApplyApiSchema(data_, geom_path,
|
||||
pxr::UsdPhysicsTokens->PhysicsMeshCollisionAPI);
|
||||
|
||||
// Note: MuJoCo documentation states that for collision purposes, meshes
|
||||
// are always replaced with their convex hulls. Therefore, we set the
|
||||
// approximation attribute to convexHull explicitly.
|
||||
pxr::SdfPath approximation_attr = CreateAttributeSpec(
|
||||
data_, geom_path, pxr::UsdPhysicsTokens->physicsApproximation,
|
||||
pxr::SdfValueTypeNames->Token, pxr::SdfVariabilityUniform);
|
||||
SetAttributeDefault(data_, approximation_attr,
|
||||
pxr::UsdPhysicsTokens->convexHull);
|
||||
}
|
||||
}
|
||||
|
||||
mjsDefault *spec_default = mjs_getDefault(geom->element);
|
||||
|
||||
Reference in New Issue
Block a user