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>);
41 T
GetTypedValue(HdSampledDataSource::Time shutterOffset)
override
49 _usdAttrQuery.Get<T>(&result, time);
57 HdSampledDataSource::Time startTime,
58 HdSampledDataSource::Time endTime,
59 std::vector<HdSampledDataSource::Time> *outSampleTimes)
override
62 if (!_usdAttrQuery.ValueMightBeTimeVarying() ||
70 std::vector<double> timeSamples;
73 _usdAttrQuery.GetTimeSamplesInInterval(interval, &timeSamples);
76 double first, ignore, last;
77 bool hasFirst, hasLast;
82 _usdAttrQuery.GetBracketingTimeSamples(interval.GetMin(), &first, &ignore, &hasFirst);
83 if (!hasFirst || first == ignore) {
84 first = interval.GetMin();
86 _usdAttrQuery.GetBracketingTimeSamples(interval.GetMax(), &ignore, &last, &hasLast);
87 if (!hasLast || last == ignore ) {
88 last = interval.GetMax();
92 if (timeSamples.empty() || first < timeSamples.front()) {
93 timeSamples.insert(timeSamples.begin(), first);
95 if (last > timeSamples.back()) {
96 timeSamples.insert(timeSamples.end(), last);
101 outSampleTimes->resize(timeSamples.size());
102 for (
size_t i = 0; i < timeSamples.size(); ++i) {
103 (*outSampleTimes)[i] = timeSamples[i] - time.
GetValue();
106 return outSampleTimes->size() > 1;
125 UsdImagingDataSourceAttribute(
133 UsdImagingDataSourceAttribute(
152HdSampledDataSourceHandle
153UsdImagingDataSourceAttributeNew(
162HdSampledDataSourceHandle
163UsdImagingDataSourceAttributeNew(
175UsdImagingDataSourceAttribute_RecordObjectInStageGlobals(
184UsdImagingDataSourceAttribute_RecordObjectInStageGlobals<SdfAssetPath>(
193UsdImagingDataSourceAttribute<T>::UsdImagingDataSourceAttribute(
198 : UsdImagingDataSourceAttribute(
200 sceneIndexPath, timeVaryingFlagLocator)
205UsdImagingDataSourceAttribute<T>::UsdImagingDataSourceAttribute(
210 : _usdAttrQuery(usdAttrQuery)
211 , _stageGlobals(stageGlobals)
213 if (!timeVaryingFlagLocator.IsEmpty()) {
214 if (_usdAttrQuery.ValueMightBeTimeVarying()) {
215 _stageGlobals.FlagAsTimeVarying(
216 sceneIndexPath, timeVaryingFlagLocator);
220 UsdImagingDataSourceAttribute_RecordObjectInStageGlobals<T>(
224PXR_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.
virtual bool GetContributingSampleTimesForInterval(Time startTime, Time endTime, std::vector< Time > *outSampleTimes)=0
Given a shutter window of interest (startTime and endTime relative to the current frame),...
virtual VtValue GetValue(Time shutterOffset)=0
Returns the value of this data source at frame-relative time shutterOffset.
A datasource representing a concretely-typed sampled value.
virtual T GetTypedValue(Time shutterOffset)=0
Returns the value of this data source at frame-relative time shutterOffset, as type T.
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 const UsdAttribute & GetAttribute() const
Return the attribute associated with this query.
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.
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...
double GetValue() const
Return the numeric value for this time.
bool IsNumeric() const
Return true if this time represents a numeric value, false otherwise.
Provides a container which may hold any type, and provides introspection and iteration over array typ...