HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lightAdapter.h
Go to the documentation of this file.
1 //
2 // Copyright 2017 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_IMAGING_USD_IMAGING_LIGHT_ADAPTER_H
25 #define PXR_USD_IMAGING_USD_IMAGING_LIGHT_ADAPTER_H
26 
27 /// \file usdImaging/lightAdapter.h
28 
29 #include "pxr/pxr.h"
32 
34 
35 
36 class UsdPrim;
37 
38 /// \class UsdImagingLightAdapter
39 ///
40 /// Base class for all lights.
41 ///
43 public:
45 
47  static bool IsEnabledSceneLights();
48 
51  {}
52 
54  ~UsdImagingLightAdapter() override;
55 
56  // ---------------------------------------------------------------------- //
57  /// \name Scene Index Support
58  // ---------------------------------------------------------------------- //
59 
61  HdContainerDataSourceHandle GetImagingSubprimData(
62  UsdPrim const& prim,
63  TfToken const& subprim,
64  const UsdImagingDataSourceStageGlobals &stageGlobals) override;
65 
68  UsdPrim const& prim,
69  TfToken const& subprim,
70  TfTokenVector const& properties,
71  UsdImagingPropertyInvalidationType invalidationType) override;
72 
73  // ---------------------------------------------------------------------- //
74  /// \name Initialization
75  // ---------------------------------------------------------------------- //
76 
78  SdfPath Populate(UsdPrim const& prim,
80  UsdImagingInstancerContext const* instancerContext = NULL) override;
81 
83  bool IsSupported(UsdImagingIndexProxy const* index) const override;
84 
85  // ---------------------------------------------------------------------- //
86  /// \name Parallel Setup and Resolve
87  // ---------------------------------------------------------------------- //
88 
89  /// Thread Safe.
91  void TrackVariability(UsdPrim const& prim,
92  SdfPath const& cachePath,
93  HdDirtyBits* timeVaryingBits,
95  instancerContext = NULL) const override;
96 
97 
98  /// Thread Safe.
100  void UpdateForTime(UsdPrim const& prim,
101  SdfPath const& cachePath,
103  HdDirtyBits requestedBits,
105  instancerContext = NULL) const override;
106 
107  // ---------------------------------------------------------------------- //
108  /// \name Change Processing
109  // ---------------------------------------------------------------------- //
110 
111  /// Returns a bit mask of attributes to be udpated, or
112  /// HdChangeTracker::AllDirty if the entire prim must be resynchronized.
115  SdfPath const& cachePath,
116  TfToken const& propertyName) override;
117 
119  void MarkDirty(UsdPrim const& prim,
120  SdfPath const& cachePath,
121  HdDirtyBits dirty,
122  UsdImagingIndexProxy* index) override;
123 
125  void MarkTransformDirty(UsdPrim const& prim,
126  SdfPath const& cachePath,
127  UsdImagingIndexProxy* index) override;
128 
130  void MarkVisibilityDirty(UsdPrim const& prim,
131  SdfPath const& cachePath,
132  UsdImagingIndexProxy* index) override;
133 
135  void MarkLightParamsDirty(UsdPrim const& prim,
136  SdfPath const& cachePath,
137  UsdImagingIndexProxy* index) override;
138 
140  virtual void MarkCollectionsDirty(UsdPrim const& prim,
141  SdfPath const& cachePath,
142  UsdImagingIndexProxy* index) override;
143 
144  // ---------------------------------------------------------------------- //
145  /// \name Utilities
146  // ---------------------------------------------------------------------- //
147 
149  VtValue GetMaterialResource(UsdPrim const &prim,
150  SdfPath const& cachePath,
151  UsdTimeCode time) const override;
152 
153  // Helper function: map USD path to UsdImaging cache path,
154  // applying any name-encoding required by the instancerContext.
156  static SdfPath
158  const SdfPath& usdPath,
159  const UsdImagingInstancerContext* instancerContext);
160 
161  // Helper function: add a given type of sprim, potentially with instancer
162  // name mangling
164  SdfPath
165  _AddSprim(
166  const TfToken& primType,
167  const UsdPrim& usdPrim,
169  const UsdImagingInstancerContext* instancerContext = nullptr);
170 
172  void
173  _RemoveSprim(
174  const TfToken& primType,
175  const SdfPath& cachePath,
177 
178 protected:
179  void _RemovePrim(SdfPath const& cachePath,
180  UsdImagingIndexProxy* index) override;
181 
182  // To be called from the Light Populate method
183  void _UnregisterLightCollections(SdfPath const& cachePath);
184 
185  // To be called from the Light _RemovePrim method
186  void _RegisterLightCollections(UsdPrim const& prim);
187 
188 private:
189  /// Updates the collection cache content
190  /// Checks for collection hash change and returns true if they are different
191  bool _UpdateCollectionsChanged(UsdPrim const& prim) const;
192 
193 
194 };
195 
196 
198 
199 #endif // PXR_USD_IMAGING_USD_IMAGING_LIGHT_ADAPTER_H
#define USDIMAGING_API
Definition: api.h:40
GT_API const UT_StringHolder time
uint32_t HdDirtyBits
Definition: types.h:158
USDIMAGING_API SdfPath _AddSprim(const TfToken &primType, const UsdPrim &usdPrim, UsdImagingIndexProxy *index, const UsdImagingInstancerContext *instancerContext=nullptr)
USDIMAGING_API SdfPath Populate(UsdPrim const &prim, UsdImagingIndexProxy *index, UsdImagingInstancerContext const *instancerContext=NULL) override
USDIMAGING_API HdContainerDataSourceHandle GetImagingSubprimData(UsdPrim const &prim, TfToken const &subprim, const UsdImagingDataSourceStageGlobals &stageGlobals) override
static USDIMAGING_API bool IsEnabledSceneLights()
USDIMAGING_API void MarkDirty(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits dirty, UsdImagingIndexProxy *index) override
USDIMAGING_API void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
Thread Safe.
Definition: token.h:87
USDIMAGING_API ~UsdImagingLightAdapter() override
void _UnregisterLightCollections(SdfPath const &cachePath)
USDIMAGING_API void MarkTransformDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
USDIMAGING_API HdDirtyBits ProcessPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &propertyName) override
Definition: prim.h:133
USDIMAGING_API void MarkLightParamsDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457
static USDIMAGING_API SdfPath _ResolveCachePath(const SdfPath &usdPath, const UsdImagingInstancerContext *instancerContext)
void _RegisterLightCollections(UsdPrim const &prim)
Definition: path.h:290
void _RemovePrim(SdfPath const &cachePath, UsdImagingIndexProxy *index) override
USDIMAGING_API HdDataSourceLocatorSet InvalidateImagingSubprim(UsdPrim const &prim, TfToken const &subprim, TfTokenVector const &properties, UsdImagingPropertyInvalidationType invalidationType) override
virtual USDIMAGING_API void MarkCollectionsDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
GLuint index
Definition: glcorearb.h:786
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
USDIMAGING_API void MarkVisibilityDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
USDIMAGING_API bool IsSupported(UsdImagingIndexProxy const *index) const override
Returns true if the adapter can be populated into the target index.
USDIMAGING_API void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
Thread Safe.
UsdImagingPrimAdapter BaseAdapter
Definition: lightAdapter.h:44
USDIMAGING_API VtValue GetMaterialResource(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Definition: value.h:164
UsdImagingPropertyInvalidationType
Definition: types.h:34
USDIMAGING_API void _RemoveSprim(const TfToken &primType, const SdfPath &cachePath, UsdImagingIndexProxy *index)