Skip to content

Conversation

@erikaharrison-adsk
Copy link
Contributor

Description of Change(s)

Add template class support for the macro HD_DECLARE_DATASOURCE.

Add two classes UsdImagingDataSourceConvertedAttribute and UsdImagingDataSourceConvertedPrimvar for the primvar which doesn't directly get value from an attribute, but will do a conversion from the value of an attribute.

Link to proposal (if applicable)

  • N/A

Fixes Issue(s)

  • N/A

Checklist

…DataSourceConvertedPrimvar for the primvar which doesn't directly get value from an attribute, but will do a conversion.

And add template class support for HD_DECLARE_DATASOURCE.
@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-11110

(This is an automated message. See here for more information.)

@unhyperbolic
Copy link
Member

unhyperbolic commented Jun 24, 2025

UsdImagingDataSourceConvertedAttribute<A,B> is ultimately a subclass of HdTypedSampledDataSource<B> even though its GetValue returns a VtValue holding type A - violating the semantics.

This is a composition vs inheritance issue. Typically, a conversion data source subclasses from the appropriate HdTypedSampledDataSource and is instantiated from another HdTypedSampledDataSource. An example is the _ScalingTypedSampledDataSource in usdImaging/dataSourceCamera.cpp. This means we ultimately allocate two data sources, but that doesn't seem to be too much of overhead in the overall schema.

About HD_DECLARE_DATASOURCE_TEMPLATE: it is unfortunate, that the preprocessor thinks that HD_DECLARE_DATASOURCE(MySource<Arg1, Arg2>) has two arguments. UsdImagingDataSourceImplicitsPrim (in usdImaging/dataSourceImplicits-Impl.h) uses the following workaround:

using This = UsdImagingDataSourceImplicitsPrim<UsdSchemaType, HdSchemaType>;
HD_DECLARE_DATASOURCE(This);

I think that is an ok work-around and the amount of code duplication for HD_DECLARE_DATASOURCE_TEMPLATE isn't worth the merit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants