usdrt::UsdGeomPrimvarsAPI

Defined in usdrt/scenegraph/usd/usdGeom/primvarsAPI.h

class UsdGeomPrimvarsAPI : public usdrt::UsdAPISchemaBase

UsdGeomPrimvarsAPI encodes geometric “primitive variables”, as UsdGeomPrimvar, which interpolate across a primitive’s topology, can override shader inputs, and inherit down namespace.

Which Method to Use to Retrieve Primvars

While creating primvars is unambiguous (CreatePrimvar()), there are quite a few methods available for retrieving primvars, making it potentially confusing knowing which one to use. Here are some guidelines:

  • If you are populating a GUI with the primvars already available for authoring values on a prim, use GetPrimvars().

  • If you want all of the “useful” (e.g. to a renderer) primvars available at a prim, including those inherited from ancestor prims, use FindPrimvarsWithInheritance(). Note that doing so individually for many prims will be inefficient.

  • To find a particular primvar defined directly on a prim, which may or may not provide a value, use GetPrimvar().

  • To find a particular primvar defined on a prim or inherited from ancestors, which may or may not provide a value, use FindPrimvarWithInheritance().

  • To efficiently query for primvars using the overloads of FindPrimvarWithInheritance() and FindPrimvarsWithInheritance(), one must first cache the results of FindIncrementallyInheritablePrimvars() for each non-leaf prim on the stage.

Public Functions

inline explicit UsdGeomPrimvarsAPI(const UsdPrim &prim = UsdPrim())

Construct a UsdGeomPrimvarsAPI on UsdPrim prim. Equivalent to UsdGeomPrimvarsAPI::Get(prim.GetStage(), prim.GetPath()) for a valid prim , but will not immediately throw an error for an invalid prim.

inline explicit UsdGeomPrimvarsAPI(const UsdSchemaBase &schemaObj)

Construct a UsdGeomPrimvarsAPI on the prim held by schemaObj . Should be preferred over UsdGeomPrimvarsAPI(schemaObj.GetPrim()), as it preserves SchemaBase state.

inline virtual ~UsdGeomPrimvarsAPI()

Destructor.

UsdPrim GetPrim() const

Return this schema object’s held prim.

SdfPath GetPath() const

Return the SdfPath to this schema object’s held prim.

inline explicit operator bool() const

Check if this schema object is compatible with it’s held prim and that the prim is valid.

A typed schema object is compatible if the held prim’s type is or is a subtype of the schema’s type. Based on prim.IsA().

An API schema object is compatible if the API is of type SingleApplyAPI or UsdSchemaType::MultipleApplyAPI, and the schema has been applied to the prim. Based on prim.HasAPI.

This method invokes polymorphic behaviour.

Returns

True if the help prim is valid, and the schema object is compatible with its held prim.

Public Static Attributes

static const UsdSchemaType schemaType = UsdSchemaType::NonAppliedAPI

Compile time constant representing what kind of schema this class is.

See also

UsdSchemaType

Protected Functions

inline const TfToken &_GetInstanceName() const

Returns the instance name of the API schema object belonging to a multiple-apply API schema.

The returned instance name will be empty for non-applied and single-apply API schemas.

inline virtual bool _IsCompatible() const

Check whether this APISchema object is valid for the currently held prim.

If this is an applied API schema, this returns true if the held prim is valid and already has the API schema applied to it, along with the instanceName (in the case of multiple-apply). The instanceName should not be empty in the case of a multiple-apply API schema.

This check is performed when clients invoke the explicit bool conversion operator, implemented in UsdSchemaBase.

inline const TfToken _GetType() const

Helper for subclasses to get this schema’s type token.

Note

This diverges from Usd and returns a TfToken, since we don’t implements TfType.

Returns

The token representing the schema’s TfType.