HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
instancerTopologySchema.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 ////////////////////////////////////////////////////////////////////////
8 
9 /* ************************************************************************** */
10 /* ** ** */
11 /* ** This file is generated by a script. ** */
12 /* ** ** */
13 /* ** Do not edit it directly (unless it is within a CUSTOM CODE section)! ** */
14 /* ** Edit hdSchemaDefs.py instead to make changes. ** */
15 /* ** ** */
16 /* ************************************************************************** */
17 
18 #ifndef PXR_IMAGING_HD_INSTANCER_TOPOLOGY_SCHEMA_H
19 #define PXR_IMAGING_HD_INSTANCER_TOPOLOGY_SCHEMA_H
20 
21 /// \file
22 
23 #include "pxr/imaging/hd/api.h"
25 
26 #include "pxr/imaging/hd/schema.h"
27 
28 // --(BEGIN CUSTOM CODE: Includes)--
29 // --(END CUSTOM CODE: Includes)--
30 
32 
33 // --(BEGIN CUSTOM CODE: Declares)--
34 // --(END CUSTOM CODE: Declares)--
35 
36 #define HD_INSTANCER_TOPOLOGY_SCHEMA_TOKENS \
37  (instancerTopology) \
38  (prototypes) \
39  (instanceIndices) \
40  (mask) \
41  (instanceLocations) \
42 
43 TF_DECLARE_PUBLIC_TOKENS(HdInstancerTopologySchemaTokens, HD_API,
45 
46 //-----------------------------------------------------------------------------
47 
48 
49 /// \class HdInstancerTopologySchema
50 ///
51 /// Since the instancing schema is complicated:
52 ///
53 /// An instancer is a prim at a certain scenegraph location that causes other
54 /// prims to be duplicated. The instancer can also hold instance-varying data
55 /// like constant primvars or material relationships.
56 ///
57 /// The important things an instancer has is:
58 ///
59 /// 1.) Instancer topology, describing how exactly the prims are duplicated;
60 ///
61 /// 2.) Instance-rate data, meaning data that varies per instance, such as
62 /// primvars or material bindings.
63 ///
64 /// If an instancer causes prims "/A" and "/B" to be duplicated, we encode that
65 /// by setting prototypes = ["/A", "/B"]. Note that "/A" and "/B" can be
66 /// subtrees, not direct gprims. instanceIndices encodes both multiplicity and
67 /// position in arrays of instance-rate data, per prototype path; if
68 /// instanceIndices = { [0,2], [1] }, then we draw /A twice (with instance
69 /// primvar indices 0 and 2); and /B once (with instance primvar index 1). Mask
70 /// is an auxiliary parameter that can be used to deactivate certain instances;
71 /// mask = [true, true, false] would disable the second copy of "/A". An empty
72 /// mask array is the same as all-true.
73 ///
74 /// Scenes generally specify instancing in one of two ways:
75 ///
76 /// 1.) Explicit instancing: prim /Instancer wants to draw its subtree at an
77 /// array of locations. This is a data expansion form.
78 ///
79 /// 2.) Implicit instancing: prims /X and /Y are marked as being identical, and
80 /// scene load replaces them with a single prim and an instancer. This is a
81 /// data coalescing form.
82 ///
83 /// For implicit instancing, we want to know the original paths of /X and /Y,
84 /// for doing things like resolving inheritance. This is encoded in the
85 /// "instanceLocations" path, while the prototype prims (e.g. /_Prototype/Cube,
86 /// the deduplicated version of /X/Cube and /Y/Cube) is encoded in the
87 /// "prototypes" path.
88 ///
89 /// For explicit instancing, the "instanceLocations" attribute is meaningless
90 /// and should be left null.
91 ///
93 {
94 public:
95  /// \name Schema retrieval
96  /// @{
97 
98  HdInstancerTopologySchema(HdContainerDataSourceHandle container)
99  : HdSchema(container) {}
100 
101  /// Retrieves a container data source with the schema's default name token
102  /// "instancerTopology" from the parent container and constructs a
103  /// HdInstancerTopologySchema instance.
104  /// Because the requested container data source may not exist, the result
105  /// should be checked with IsDefined() or a bool comparison before use.
106  HD_API
108  const HdContainerDataSourceHandle &fromParentContainer);
109 
110  /// @}
111 
112 // --(BEGIN CUSTOM CODE: Schema Methods)--
113 
114  HD_API
116 
117 // --(END CUSTOM CODE: Schema Methods)--
118 
119  /// \name Member accessor
120  /// @{
121 
122  HD_API
124 
125  HD_API
127 
128  HD_API
130 
131  HD_API
133 
134  /// @}
135 
136  /// \name Schema location
137  /// @{
138 
139  /// Returns a token where the container representing this schema is found in
140  /// a container by default.
141  HD_API
142  static const TfToken &GetSchemaToken();
143 
144  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
145  /// where the container representing this schema is found by default.
146  HD_API
147  static const HdDataSourceLocator &GetDefaultLocator();
148 
149  /// @}
150 
151  /// \name Schema construction
152  /// @{
153 
154  /// \deprecated Use Builder instead.
155  ///
156  /// Builds a container data source which includes the provided child data
157  /// sources. Parameters with nullptr values are excluded. This is a
158  /// low-level interface. For cases in which it's desired to define
159  /// the container with a sparse set of child fields, the Builder class
160  /// is often more convenient and readable.
161  HD_API
162  static HdContainerDataSourceHandle
164  const HdPathArrayDataSourceHandle &prototypes,
165  const HdVectorDataSourceHandle &instanceIndices,
167  const HdPathArrayDataSourceHandle &instanceLocations
168  );
169 
170  /// \class HdInstancerTopologySchema::Builder
171  ///
172  /// Utility class for setting sparse sets of child data source fields to be
173  /// filled as arguments into BuildRetained. Because all setter methods
174  /// return a reference to the instance, this can be used in the "builder
175  /// pattern" form.
176  class Builder
177  {
178  public:
179  HD_API
181  const HdPathArrayDataSourceHandle &prototypes);
182  HD_API
184  const HdVectorDataSourceHandle &instanceIndices);
185  HD_API
186  Builder &SetMask(
188  HD_API
190  const HdPathArrayDataSourceHandle &instanceLocations);
191 
192  /// Returns a container data source containing the members set thus far.
193  HD_API
194  HdContainerDataSourceHandle Build();
195 
196  private:
197  HdPathArrayDataSourceHandle _prototypes;
198  HdVectorDataSourceHandle _instanceIndices;
200  HdPathArrayDataSourceHandle _instanceLocations;
201 
202  };
203 
204  /// @}
205 };
206 
208 
209 #endif
HD_API Builder & SetPrototypes(const HdPathArrayDataSourceHandle &prototypes)
HdBoolArrayDataSource::Handle HdBoolArrayDataSourceHandle
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
HdPathArrayDataSource::Handle HdPathArrayDataSourceHandle
static HD_API HdContainerDataSourceHandle BuildRetained(const HdPathArrayDataSourceHandle &prototypes, const HdVectorDataSourceHandle &instanceIndices, const HdBoolArrayDataSourceHandle &mask, const HdPathArrayDataSourceHandle &instanceLocations)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
#define HD_API
Definition: api.h:23
TF_DECLARE_PUBLIC_TOKENS(HdInstancerTopologySchemaTokens, HD_API, HD_INSTANCER_TOPOLOGY_SCHEMA_TOKENS)
HD_API Builder & SetInstanceIndices(const HdVectorDataSourceHandle &instanceIndices)
static HD_API HdInstancerTopologySchema GetFromParent(const HdContainerDataSourceHandle &fromParentContainer)
HD_API Builder & SetInstanceLocations(const HdPathArrayDataSourceHandle &instanceLocations)
HD_API Builder & SetMask(const HdBoolArrayDataSourceHandle &mask)
Definition: token.h:70
HD_API VtArray< int > ComputeInstanceIndicesForProto(SdfPath const &path)
HD_API HdPathArrayDataSourceHandle GetPrototypes() const
HD_API HdPathArrayDataSourceHandle GetInstanceLocations() const
static HD_API const TfToken & GetSchemaToken()
GLint GLuint mask
Definition: glcorearb.h:124
Definition: types.h:152
Definition: path.h:280
HdInstancerTopologySchema(HdContainerDataSourceHandle container)
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
HD_API HdBoolArrayDataSourceHandle GetMask() const
#define HD_INSTANCER_TOPOLOGY_SCHEMA_TOKENS
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
static HD_API const HdDataSourceLocator & GetDefaultLocator()
HD_API HdIntArrayVectorSchema GetInstanceIndices() const