mjcPhysics MjcTendon path now has an indices attribute to allow repeated sites in tendon path.

Since relationships in USD can only contain a single instance of a path, it was previously impossible to have a tendon path that visits the same wrap target more than once. This is a fairly common occurence when dealing with tendons that have pulleys.

With this change, if mjc:path:indices is not defined then the behaviour is as it was and the mjc:path is considered to be ordered. If it is authored then the parser will use the indices into mjc:path as the order. This mirrors other similar concepts in USD such as face vertex indices.

PiperOrigin-RevId: 856339887
Change-Id: I6b9503973de377acdb0689be168c16e4aa19b70b
This commit is contained in:
Sam Haves
2026-01-14 13:23:41 -08:00
committed by Copybara-Service
parent 42c565d860
commit d816b38f4c
7 changed files with 69 additions and 12 deletions
@@ -158,6 +158,31 @@ class MjcPhysicsTendon : public UsdTyped {
UsdAttribute CreateTypeAttr(VtValue const& defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCPATHINDICES
// --------------------------------------------------------------------- //
/// This list represents the order in which the tendon wraps the sites in
/// mjc:path.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform int[] mjc:path:indices = []` |
/// | C++ Type | VtArray<int> |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcPathIndicesAttr() const;
/// See GetMjcPathIndicesAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
MJCPHYSICS_API
UsdAttribute CreateMjcPathIndicesAttr(VtValue const& defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCSIDESITESINDICES
@@ -771,8 +796,8 @@ class MjcPhysicsTendon : public UsdTyped {
// --------------------------------------------------------------------- //
// MJCPATH
// --------------------------------------------------------------------- //
/// For spatial tendons, this describes a list of sites and geoms the tendon
/// wraps. For fixed tendons, this is instead a list of joints.
/// For spatial tendons, this describes a list of unique of sites and geoms
/// the tendon wraps. For fixed tendons, this is instead a list of joints.
///
MJCPHYSICS_API
UsdRelationship GetMjcPathRel() const;
@@ -572,6 +572,10 @@ struct MjcPhysicsTokensType {
///
/// MjcPhysicsTendon
const TfToken mjcPathDivisors;
/// \brief "mjc:path:indices"
///
/// MjcPhysicsTendon
const TfToken mjcPathIndices;
/// \brief "mjc:path:segments"
///
/// MjcPhysicsTendon