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 // Since the instancing schema is complicated:
49 //
50 // An instancer is a prim at a certain scenegraph location that causes other
51 // prims to be duplicated. The instancer can also hold instance-varying data
52 // like constant primvars or material relationships.
53 //
54 // The important things an instancer has is:
55 //
56 // 1.) Instancer topology, describing how exactly the prims are duplicated;
57 //
58 // 2.) Instance-rate data, meaning data that varies per instance, such as
59 // primvars or material bindings.
60 //
61 // If an instancer causes prims "/A" and "/B" to be duplicated, we encode that
62 // by setting prototypes = ["/A", "/B"]. Note that "/A" and "/B" can be
63 // subtrees, not direct gprims. instanceIndices encodes both multiplicity and
64 // position in arrays of instance-rate data, per prototype path; if
65 // instanceIndices = { [0,2], [1] }, then we draw /A twice (with instance
66 // primvar indices 0 and 2); and /B once (with instance primvar index 1). Mask
67 // is an auxiliary parameter that can be used to deactivate certain instances;
68 // mask = [true, true, false] would disable the second copy of "/A". An empty
69 // mask array is the same as all-true.
70 //
71 // Scenes generally specify instancing in one of two ways:
72 //
73 // 1.) Explicit instancing: prim /Instancer wants to draw its subtree at an
74 // array of locations. This is a data expansion form.
75 //
76 // 2.) Implicit instancing: prims /X and /Y are marked as being identical, and
77 // scene load replaces them with a single prim and an instancer. This is a
78 // data coalescing form.
79 //
80 // For implicit instancing, we want to know the original paths of /X and /Y,
81 // for doing things like resolving inheritance. This is encoded in the
82 // "instanceLocations" path, while the prototype prims (e.g. /_Prototype/Cube,
83 // the deduplicated version of /X/Cube and /Y/Cube) is encoded in the
84 // "prototypes" path.
85 //
86 // For explicit instancing, the "instanceLocations" attribute is meaningless
87 // and should be left null.
88 //
89 
91 {
92 public:
93  /// \name Schema retrieval
94  /// @{
95 
96  HdInstancerTopologySchema(HdContainerDataSourceHandle container)
97  : HdSchema(container) {}
98 
99  /// Retrieves a container data source with the schema's default name token
100  /// "instancerTopology" from the parent container and constructs a
101  /// HdInstancerTopologySchema instance.
102  /// Because the requested container data source may not exist, the result
103  /// should be checked with IsDefined() or a bool comparison before use.
104  HD_API
106  const HdContainerDataSourceHandle &fromParentContainer);
107 
108  /// @}
109 
110 // --(BEGIN CUSTOM CODE: Schema Methods)--
111 
112  HD_API
114 
115 // --(END CUSTOM CODE: Schema Methods)--
116 
117  /// \name Member accessor
118  /// @{
119 
120  HD_API
122 
123  HD_API
125 
126  HD_API
128 
129  HD_API
131 
132  /// @}
133 
134  /// \name Schema location
135  /// @{
136 
137  /// Returns a token where the container representing this schema is found in
138  /// a container by default.
139  HD_API
140  static const TfToken &GetSchemaToken();
141 
142  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
143  /// where the container representing this schema is found by default.
144  HD_API
145  static const HdDataSourceLocator &GetDefaultLocator();
146 
147  /// @}
148 
149  /// \name Schema construction
150  /// @{
151 
152  /// \deprecated Use Builder instead.
153  ///
154  /// Builds a container data source which includes the provided child data
155  /// sources. Parameters with nullptr values are excluded. This is a
156  /// low-level interface. For cases in which it's desired to define
157  /// the container with a sparse set of child fields, the Builder class
158  /// is often more convenient and readable.
159  HD_API
160  static HdContainerDataSourceHandle
162  const HdPathArrayDataSourceHandle &prototypes,
163  const HdVectorDataSourceHandle &instanceIndices,
165  const HdPathArrayDataSourceHandle &instanceLocations
166  );
167 
168  /// \class HdInstancerTopologySchema::Builder
169  ///
170  /// Utility class for setting sparse sets of child data source fields to be
171  /// filled as arguments into BuildRetained. Because all setter methods
172  /// return a reference to the instance, this can be used in the "builder
173  /// pattern" form.
174  class Builder
175  {
176  public:
177  HD_API
179  const HdPathArrayDataSourceHandle &prototypes);
180  HD_API
182  const HdVectorDataSourceHandle &instanceIndices);
183  HD_API
184  Builder &SetMask(
186  HD_API
188  const HdPathArrayDataSourceHandle &instanceLocations);
189 
190  /// Returns a container data source containing the members set thus far.
191  HD_API
192  HdContainerDataSourceHandle Build();
193 
194  private:
195  HdPathArrayDataSourceHandle _prototypes;
196  HdVectorDataSourceHandle _instanceIndices;
198  HdPathArrayDataSourceHandle _instanceLocations;
199 
200  };
201 
202  /// @}
203 };
204 
206 
207 #endif
HD_API Builder & SetPrototypes(const HdPathArrayDataSourceHandle &prototypes)
HdBoolArrayDataSource::Handle HdBoolArrayDataSourceHandle
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:153
Definition: path.h:273
HdInstancerTopologySchema(HdContainerDataSourceHandle container)
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
HD_API HdBoolArrayDataSourceHandle GetMask() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#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