HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
flattenedDataSourceProvider.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_FLATTENED_DATA_SOURCE_PROVIDER_H
8 #define PXR_IMAGING_HD_FLATTENED_DATA_SOURCE_PROVIDER_H
9 
10 #include "pxr/imaging/hd/api.h"
11 
15 #include "pxr/usd/sdf/path.h"
16 
18 
19 class HdSceneIndexBase;
21  std::shared_ptr<class HdFlattenedDataSourceProvider>;
22 
23 /// \class HdFlattenedDataSourceProvider.
24 ///
25 /// Given to HdFlatteningSceneIndex to determine how to compute the
26 /// flattened data source which is in the prim container data
27 /// source.
28 ///
30 {
31 public:
32  class Context
33  {
34  public:
36  const HdSceneIndexBase &flatteningSceneIndex,
37  const SdfPath &primPath,
38  const TfToken &name,
39  const HdSceneIndexPrim &inputPrim)
40  : _flatteningSceneIndex(flatteningSceneIndex)
41  , _primPath(primPath)
42  , _name(name)
43  , _inputPrim(inputPrim)
44  {
45  }
46 
47  // Returns data source of input scene index which is in
48  // the prim container data source.
49  HD_API
50  HdContainerDataSourceHandle GetInputDataSource() const;
51  // Returns flattened data source which is in the flattened
52  // container data source of the parent prim.
53  HD_API
54  HdContainerDataSourceHandle GetFlattenedDataSourceFromParentPrim() const;
55  // Returns the type of the prim from the input scene index.
56  HD_API
57  const TfToken &GetInputPrimType() const {
58  return _inputPrim.primType;
59  }
60 
61  private:
62  const HdSceneIndexBase &_flatteningSceneIndex;
63  const SdfPath &_primPath;
64  const TfToken &_name;
65  const HdSceneIndexPrim _inputPrim;
66  };
67 
68  HD_API
70 
71  /// Returns flattened data source.
72  virtual HdContainerDataSourceHandle GetFlattenedDataSource(
73  const Context &ctx) const = 0;
74 
75  /// If data source locators are dirtied in the input scene index, the
76  /// locators relevant for the input data source serving this provider
77  /// are extracted and made relative to the input data source.
78  ///
79  /// They are later used to invalidate the flattened data source of the
80  /// dirtied prim and its descendants and send prim dirtied messages to
81  /// the descendants.
82  ///
83  /// Example: If a prim dirtied for locator xform:matrix was received, the
84  /// flattening scene index will call the flattened data source provider
85  /// for xform. The locators given to ComputeDirtyLocatorsForDescendants
86  /// will be { matrix }. If ComputeDirtyLocatorsForDescendants sets it to
87  /// the universal set, the flatening scene index will emit a prim dirtied
88  /// locator xform for the descendants.
89  ///
90  /// The implementation of ComputeDirtyLocatorsForDescendants gives a chance
91  /// to drop locators or expand the locator set in between.
92  ///
93  /// Note that ComputeDirtyLocatorsForDescendants will never be called with
94  /// the empty or universal set as these cases are already handled by the
95  /// callee.
96  ///
98  HdDataSourceLocatorSet * locators) const = 0;
99 };
100 
101 namespace HdMakeDataSourceContainingFlattenedDataSourceProvider
102 {
103 
104 template<typename T>
107 {
108  using DataSource =
110  return DataSource::New(std::make_shared<T>());
111 }
112 
113 }
114 
116 
117 #endif
virtual HdContainerDataSourceHandle GetFlattenedDataSource(const Context &ctx) const =0
Returns flattened data source.
HdTypedSampledDataSource< HdFlattenedDataSourceProviderSharedPtr >::Handle Make()
TfToken primType
Definition: sceneIndex.h:36
HD_API HdContainerDataSourceHandle GetFlattenedDataSourceFromParentPrim() const
#define HD_API
Definition: api.h:23
HD_API HdContainerDataSourceHandle GetInputDataSource() const
std::shared_ptr< class HdFlattenedDataSourceProvider > HdFlattenedDataSourceProviderSharedPtr
Definition: token.h:70
Context(const HdSceneIndexBase &flatteningSceneIndex, const SdfPath &primPath, const TfToken &name, const HdSceneIndexPrim &inputPrim)
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:273
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Context provides a wrapper around the Core library context object.
Definition: ImfContext.h:30
virtual void ComputeDirtyLocatorsForDescendants(HdDataSourceLocatorSet *locators) const =0
virtual HD_API ~HdFlattenedDataSourceProvider()
HD_API const TfToken & GetInputPrimType() const