HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
listAPI.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef USDLUX_GENERATED_LISTAPI_H
8 #define USDLUX_GENERATED_LISTAPI_H
9 
10 /// \file usdLux/listAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdLux/api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
17 #include "pxr/usd/usdLux/tokens.h"
18 
19 #include "pxr/base/vt/value.h"
20 
21 #include "pxr/base/gf/vec3d.h"
22 #include "pxr/base/gf/vec3f.h"
23 #include "pxr/base/gf/matrix4d.h"
24 
25 #include "pxr/base/tf/token.h"
26 #include "pxr/base/tf/type.h"
27 
29 
30 class SdfAssetPath;
31 
32 // -------------------------------------------------------------------------- //
33 // LISTAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdLuxListAPI
37 ///
38 ///
39 /// \deprecated
40 /// Use LightListAPI instead
41 ///
42 ///
43 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
44 /// that are text/tokens, the actual token is published and defined in \ref UsdLuxTokens.
45 /// So to set an attribute to the value "rightHanded", use UsdLuxTokens->rightHanded
46 /// as the value.
47 ///
49 {
50 public:
51  /// Compile time constant representing what kind of schema this class is.
52  ///
53  /// \sa UsdSchemaKind
55 
56  /// Construct a UsdLuxListAPI on UsdPrim \p prim .
57  /// Equivalent to UsdLuxListAPI::Get(prim.GetStage(), prim.GetPath())
58  /// for a \em valid \p prim, but will not immediately throw an error for
59  /// an invalid \p prim
60  explicit UsdLuxListAPI(const UsdPrim& prim=UsdPrim())
61  : UsdAPISchemaBase(prim)
62  {
63  }
64 
65  /// Construct a UsdLuxListAPI on the prim held by \p schemaObj .
66  /// Should be preferred over UsdLuxListAPI(schemaObj.GetPrim()),
67  /// as it preserves SchemaBase state.
68  explicit UsdLuxListAPI(const UsdSchemaBase& schemaObj)
69  : UsdAPISchemaBase(schemaObj)
70  {
71  }
72 
73  /// Destructor.
75  virtual ~UsdLuxListAPI();
76 
77  /// Return a vector of names of all pre-declared attributes for this schema
78  /// class and all its ancestor classes. Does not include attributes that
79  /// may be authored by custom/extended methods of the schemas involved.
81  static const TfTokenVector &
82  GetSchemaAttributeNames(bool includeInherited=true);
83 
84  /// Return a UsdLuxListAPI holding the prim adhering to this
85  /// schema at \p path on \p stage. If no prim exists at \p path on
86  /// \p stage, or if the prim at that path does not adhere to this schema,
87  /// return an invalid schema object. This is shorthand for the following:
88  ///
89  /// \code
90  /// UsdLuxListAPI(stage->GetPrimAtPath(path));
91  /// \endcode
92  ///
94  static UsdLuxListAPI
95  Get(const UsdStagePtr &stage, const SdfPath &path);
96 
97 
98  /// Returns true if this <b>single-apply</b> API schema can be applied to
99  /// the given \p prim. If this schema can not be a applied to the prim,
100  /// this returns false and, if provided, populates \p whyNot with the
101  /// reason it can not be applied.
102  ///
103  /// Note that if CanApply returns false, that does not necessarily imply
104  /// that calling Apply will fail. Callers are expected to call CanApply
105  /// before calling Apply if they want to ensure that it is valid to
106  /// apply a schema.
107  ///
108  /// \sa UsdPrim::GetAppliedSchemas()
109  /// \sa UsdPrim::HasAPI()
110  /// \sa UsdPrim::CanApplyAPI()
111  /// \sa UsdPrim::ApplyAPI()
112  /// \sa UsdPrim::RemoveAPI()
113  ///
114  USDLUX_API
115  static bool
116  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
117 
118  /// Applies this <b>single-apply</b> API schema to the given \p prim.
119  /// This information is stored by adding "ListAPI" to the
120  /// token-valued, listOp metadata \em apiSchemas on the prim.
121  ///
122  /// \return A valid UsdLuxListAPI object is returned upon success.
123  /// An invalid (or empty) UsdLuxListAPI object is returned upon
124  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
125  /// resulting in failure.
126  ///
127  /// \sa UsdPrim::GetAppliedSchemas()
128  /// \sa UsdPrim::HasAPI()
129  /// \sa UsdPrim::CanApplyAPI()
130  /// \sa UsdPrim::ApplyAPI()
131  /// \sa UsdPrim::RemoveAPI()
132  ///
133  USDLUX_API
134  static UsdLuxListAPI
135  Apply(const UsdPrim &prim);
136 
137 protected:
138  /// Returns the kind of schema this class belongs to.
139  ///
140  /// \sa UsdSchemaKind
141  USDLUX_API
142  UsdSchemaKind _GetSchemaKind() const override;
143 
144 private:
145  // needs to invoke _GetStaticTfType.
146  friend class UsdSchemaRegistry;
147  USDLUX_API
148  static const TfType &_GetStaticTfType();
149 
150  static bool _IsTypedSchema();
151 
152  // override SchemaBase virtuals.
153  USDLUX_API
154  const TfType &_GetTfType() const override;
155 
156 public:
157  // --------------------------------------------------------------------- //
158  // LIGHTLISTCACHEBEHAVIOR
159  // --------------------------------------------------------------------- //
160  ///
161  /// Controls how the lightList should be interpreted.
162  /// Valid values are:
163  /// - consumeAndHalt: The lightList should be consulted,
164  /// and if it exists, treated as a final authoritative statement
165  /// of any lights that exist at or below this prim, halting
166  /// recursive discovery of lights.
167  /// - consumeAndContinue: The lightList should be consulted,
168  /// but recursive traversal over nameChildren should continue
169  /// in case additional lights are added by descendants.
170  /// - ignore: The lightList should be entirely ignored. This
171  /// provides a simple way to temporarily invalidate an existing
172  /// cache. This is the fallback behavior.
173  ///
174  ///
175  /// | ||
176  /// | -- | -- |
177  /// | Declaration | `token lightList:cacheBehavior` |
178  /// | C++ Type | TfToken |
179  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
180  /// | \ref UsdLuxTokens "Allowed Values" | consumeAndHalt, consumeAndContinue, ignore |
181  USDLUX_API
183 
184  /// See GetLightListCacheBehaviorAttr(), and also
185  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
186  /// If specified, author \p defaultValue as the attribute's default,
187  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
188  /// the default for \p writeSparsely is \c false.
189  USDLUX_API
190  UsdAttribute CreateLightListCacheBehaviorAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
191 
192 public:
193  // --------------------------------------------------------------------- //
194  // LIGHTLIST
195  // --------------------------------------------------------------------- //
196  /// Relationship to lights in the scene.
197  ///
198  USDLUX_API
200 
201  /// See GetLightListRel(), and also
202  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
203  USDLUX_API
205 
206 public:
207  // ===================================================================== //
208  // Feel free to add custom code below this line, it will be preserved by
209  // the code generator.
210  //
211  // Just remember to:
212  // - Close the class declaration with };
213  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
214  // - Close the include guard with #endif
215  // ===================================================================== //
216  // --(BEGIN CUSTOM CODE)--
217 
218  /// Runtime control over whether to consult stored lightList caches.
219  enum ComputeMode {
220  /// Consult any caches found on the model hierarchy.
221  /// Do not traverse beneath the model hierarchy.
223  /// Ignore any caches found, and do a full prim traversal.
225  };
226 
227  /// Computes and returns the list of lights and light filters in
228  /// the stage, optionally consulting a cached result.
229  ///
230  /// In ComputeModeIgnoreCache mode, caching is ignored, and this
231  /// does a prim traversal looking for prims that have a UsdLuxLightAPI
232  /// or are of type UsdLuxLightFilter.
233  ///
234  /// In ComputeModeConsultModelHierarchyCache, this does a traversal
235  /// only of the model hierarchy. In this traversal, any lights that
236  /// live as model hierarchy prims are accumulated, as well as any
237  /// paths stored in lightList caches. The lightList:cacheBehavior
238  /// attribute gives further control over the cache behavior; see the
239  /// class overview for details.
240  ///
241  /// When instances are present, ComputeLightList(ComputeModeIgnoreCache)
242  /// will return the instance-uniqiue paths to any lights discovered
243  /// within those instances. Lights within a UsdGeomPointInstancer
244  /// will not be returned, however, since they cannot be referred to
245  /// solely via paths.
246  USDLUX_API
248 
249  /// Store the given paths as the lightlist for this prim.
250  /// Paths that do not have this prim's path as a prefix
251  /// will be silently ignored.
252  /// This will set the listList:cacheBehavior to "consumeAndContinue".
253  USDLUX_API
254  void StoreLightList(const SdfPathSet &) const;
255 
256  /// Mark any stored lightlist as invalid, by setting the
257  /// lightList:cacheBehavior attribute to ignore.
258  USDLUX_API
259  void InvalidateLightList() const;
260 };
261 
263 
264 #endif
static USDLUX_API UsdLuxListAPI Apply(const UsdPrim &prim)
UsdLuxListAPI(const UsdPrim &prim=UsdPrim())
Definition: listAPI.h:60
Single Apply API schema.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
#define USDLUX_API
Definition: api.h:23
virtual USDLUX_API ~UsdLuxListAPI()
Destructor.
static USDLUX_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
USDLUX_API void InvalidateLightList() const
USDLUX_API UsdSchemaKind _GetSchemaKind() const override
USDLUX_API SdfPathSet ComputeLightList(ComputeMode mode) const
static USDLUX_API UsdLuxListAPI Get(const UsdStagePtr &stage, const SdfPath &path)
ComputeMode
Runtime control over whether to consult stored lightList caches.
Definition: listAPI.h:219
Definition: prim.h:116
USDLUX_API UsdAttribute GetLightListCacheBehaviorAttr() const
static USDLUX_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
GLenum mode
Definition: glcorearb.h:99
std::set< class SdfPath > SdfPathSet
A set of SdfPaths.
Definition: path.h:192
UsdSchemaKind
Definition: common.h:112
Ignore any caches found, and do a full prim traversal.
Definition: listAPI.h:224
USDLUX_API UsdRelationship CreateLightListRel() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDLUX_API UsdRelationship GetLightListRel() const
USDLUX_API UsdAttribute CreateLightListCacheBehaviorAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
static const UsdSchemaKind schemaKind
Definition: listAPI.h:54
UsdLuxListAPI(const UsdSchemaBase &schemaObj)
Definition: listAPI.h:68
USDLUX_API void StoreLightList(const SdfPathSet &) const
Definition: value.h:146