7#ifndef PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_ATTRIBUTE_H
8#define PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_ATTRIBUTE_H
10#include "pxr/usd/usd/attribute.h"
11#include "pxr/usd/usd/attributeQuery.h"
12#include "pxr/usdImaging/usdImaging/api.h"
13#include "pxr/usdImaging/usdImaging/dataSourceStageGlobals.h"
14#include "pxr/imaging/hd/dataSource.h"
15#include "pxr/imaging/hd/dataSourceTypeDefs.h"
19PXR_NAMESPACE_OPEN_SCOPE
30 HD_DECLARE_DATASOURCE(UsdImagingDataSourceAttribute<T>);
34 VtValue GetValue(HdSampledDataSource::Time shutterOffset)
override
36 return VtValue(GetTypedValue(shutterOffset));
41 T GetTypedValue(HdSampledDataSource::Time shutterOffset)
override
49 if (time.IsNumeric()) {
50 time =
UsdTimeCode(time.GetValue() + shutterOffset);
53 bool valueRetrieved = _usdAttrQuery.
Get<T>(&result, time);
71 bool GetContributingSampleTimesForInterval(
72 HdSampledDataSource::Time startTime,
73 HdSampledDataSource::Time endTime,
74 std::vector<HdSampledDataSource::Time> *outSampleTimes)
override
87 time.GetValue() + startTime,
88 time.GetValue() + endTime);
89 std::vector<double> timeSamples;
95 double first, ignore, last;
96 bool hasFirst, hasLast;
102 if (!hasFirst || first == ignore) {
103 first = interval.GetMin();
106 if (!hasLast || last == ignore ) {
107 last = interval.GetMax();
111 if (timeSamples.empty() || first < timeSamples.front()) {
112 timeSamples.insert(timeSamples.begin(), first);
114 if (last > timeSamples.back()) {
115 timeSamples.insert(timeSamples.end(), last);
120 outSampleTimes->resize(timeSamples.size());
121 for (
size_t i = 0; i < timeSamples.size(); ++i) {
122 (*outSampleTimes)[i] = timeSamples[i] - time.GetValue();
125 return outSampleTimes->size() > 1;
147 UsdImagingDataSourceAttribute(
155 UsdImagingDataSourceAttribute(
173HdSampledDataSourceHandle
174UsdImagingDataSourceAttributeNew(
183HdSampledDataSourceHandle
184UsdImagingDataSourceAttributeNew(
196UsdImagingDataSourceAttribute_RecordObjectInStageGlobals(
205UsdImagingDataSourceAttribute_RecordObjectInStageGlobals<SdfAssetPath>(
214UsdImagingDataSourceAttribute<T>::UsdImagingDataSourceAttribute(
219 : UsdImagingDataSourceAttribute(
221 sceneIndexPath, timeVaryingFlagLocator)
226UsdImagingDataSourceAttribute<T>::UsdImagingDataSourceAttribute(
231 : _usdAttrQuery(usdAttrQuery)
232 , _stageGlobals(stageGlobals)
234 if (!timeVaryingFlagLocator.IsEmpty()) {
235 if (_usdAttrQuery.ValueMightBeTimeVarying()) {
236 _stageGlobals.FlagAsTimeVarying(
237 sceneIndexPath, timeVaryingFlagLocator);
241 UsdImagingDataSourceAttribute_RecordObjectInStageGlobals<T>(
245PXR_NAMESPACE_CLOSE_SCOPE
A basic mathematical interval class.
Represents an object that can identify the location of a data source.
static HD_API const HdDataSourceLocator & EmptyLocator()
Returns a common empty locator.
A datasource representing a concretely-typed sampled value.
A path value used to locate objects in layers or scenegraphs.
static SDF_API const SdfPath & EmptyPath()
The empty path value, equivalent to SdfPath().
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Object for efficiently making repeated queries for attribute values.
USD_API bool GetBracketingTimeSamples(double desiredTime, double *lower, double *upper, bool *hasTimeSamples) const
Populate lower and upper with the next greater and lesser value relative to the desiredTime.
USD_API bool GetTimeSamplesInInterval(const GfInterval &interval, std::vector< double > *times) const
Populates a vector with authored sample times in interval.
USD_API const UsdAttribute & GetAttribute() const
Return the attribute associated with this query.
bool Get(T *value, UsdTimeCode time=UsdTimeCode::Default()) const
Perform value resolution to fetch the value of the attribute associated with this query at the reques...
bool GetFallbackValue(T *value) const
If this attribute is a builtin attribute with a fallback value provided by a schema,...
USD_API bool ValueMightBeTimeVarying() const
Return true if it is possible, but not certain, that this attribute's value changes over time,...
This class is used as a context object with global stage information, that gets passed down to dataso...
virtual void FlagAsAssetPathDependent(const SdfPath &usdPath) const =0
Flags the object at usdPath as dependent on an asset path.
virtual UsdTimeCode GetTime() const =0
Returns the current time represented in this instance.
SdfPath GetPath() const
Return the complete scene path to this object on its UsdStage, which may (UsdPrim) or may not (all ot...
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Provides a container which may hold any type, and provides introspection and iteration over array typ...