HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dataSourceMaterial.h
Go to the documentation of this file.
1 //
2 // Copyright 2022 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_USD_IMAGING_USD_IMAGING_DATA_SOURCE_MATERIAL_H
8 #define PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_MATERIAL_H
9 
11 
12 #include "pxr/usd/usd/prim.h"
13 
16 
18 
19 #include <tbb/concurrent_unordered_map.h>
20 
22 
23 // ----------------------------------------------------------------------------
24 
25 /// \class UsdImagingDataSourceMaterial
26 ///
27 /// A data source mapping for data source material.
28 ///
29 /// Creates HdMaterialSchema from a UsdShadeMaterial prim
30 ///
32 {
33 public:
35 
36  TfTokenVector GetNames() override;
37  HdDataSourceBaseHandle Get(const TfToken &name) override;
38 
40 
41 private:
42 
43  /// If \p fixedTerminalName is specified, the provided \p usdPrim will be
44  /// treated as the terminal shader node in the graph rather than as a
45  /// material (with relationships to the prims serving as terminal shader
46  /// nodes). This is relevant for light and light filter cases.
48  const UsdPrim &usdPrim,
49  const UsdImagingDataSourceStageGlobals &stageGlobals,
50  const TfToken &fixedTerminalName = TfToken()
51  );
52 
53 
54 private:
55 
56  const UsdPrim _usdPrim;
57  const UsdImagingDataSourceStageGlobals &_stageGlobals;
58 
59  // Cache the networks by context name.
60  using _ContextMap = tbb::concurrent_unordered_map<
61  TfToken, HdDataSourceBaseHandle, TfToken::HashFunctor>;
62 
63 
64  const TfToken _fixedTerminalName;
65  _ContextMap _networks;
66 };
67 
69 
70 // ----------------------------------------------------------------------------
71 
72 /// \class UsdImagingDataSourceMaterial
73 ///
74 /// A prim data source mapping for a UsdShadeMaterial prim
75 ///
77 {
78 public:
80 
81  TfTokenVector GetNames() override;
82  HdDataSourceBaseHandle Get(const TfToken &name) override;
83 
85 
87  const UsdPrim &prim,
88  const TfToken &subprim,
89  const TfTokenVector &properties,
90  UsdImagingPropertyInvalidationType invalidationType);
91 
92 private:
95  const SdfPath &sceneIndexPath,
96  const UsdPrim &usdPrim,
97  const UsdImagingDataSourceStageGlobals &stageGlobals);
98 };
99 
101 
103 
104 #endif //PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_MATERIAL_H
HD_DECLARE_DATASOURCE(UsdImagingDataSourceMaterialPrim)
#define USDIMAGING_API
Definition: api.h:23
HD_DECLARE_DATASOURCE(UsdImagingDataSourceMaterial)
TfTokenVector GetNames() override
Functor to use for hash maps from tokens to other things.
Definition: token.h:149
HdDataSourceBaseHandle Get(const TfToken &name) override
~UsdImagingDataSourceMaterial() override
Definition: token.h:70
static HdDataSourceLocatorSet Invalidate(const UsdPrim &prim, const TfToken &subprim, const TfTokenVector &properties, UsdImagingPropertyInvalidationType invalidationType)
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:273
HD_DECLARE_DATASOURCE_HANDLES(UsdImagingDataSourceMaterial)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
TfTokenVector GetNames() override
HdDataSourceBaseHandle Get(const TfToken &name) override
UsdImagingPropertyInvalidationType
Definition: types.h:17