Loading...
Searching...
No Matches
instancerTopologySchema.h
Go to the documentation of this file.
1//
2// Copyright 2023 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//
25
26/* ************************************************************************** */
27/* ** ** */
28/* ** This file is generated by a script. ** */
29/* ** ** */
30/* ** Do not edit it directly (unless it is within a CUSTOM CODE section)! ** */
31/* ** Edit hdSchemaDefs.py instead to make changes. ** */
32/* ** ** */
33/* ************************************************************************** */
34
35#ifndef PXR_IMAGING_HD_INSTANCER_TOPOLOGY_SCHEMA_H
36#define PXR_IMAGING_HD_INSTANCER_TOPOLOGY_SCHEMA_H
37
39
40#include "pxr/imaging/hd/api.h"
41#include "pxr/imaging/hd/schemaTypeDefs.h"
42
43#include "pxr/imaging/hd/schema.h"
44
45// --(BEGIN CUSTOM CODE: Includes)--
46// --(END CUSTOM CODE: Includes)--
47
48PXR_NAMESPACE_OPEN_SCOPE
49
50// --(BEGIN CUSTOM CODE: Declares)--
51// --(END CUSTOM CODE: Declares)--
52
53#define HD_INSTANCER_TOPOLOGY_SCHEMA_TOKENS \
54 (instancerTopology) \
55 (prototypes) \
56 (instanceIndices) \
57 (mask) \
58 (instanceLocations) \
59
60TF_DECLARE_PUBLIC_TOKENS(HdInstancerTopologySchemaTokens, HD_API,
61 HD_INSTANCER_TOPOLOGY_SCHEMA_TOKENS);
62
63//-----------------------------------------------------------------------------
64
65// Since the instancing schema is complicated:
66//
67// An instancer is a prim at a certain scenegraph location that causes other
68// prims to be duplicated. The instancer can also hold instance-varying data
69// like constant primvars or material relationships.
70//
71// The important things an instancer has is:
72//
73// 1.) Instancer topology, describing how exactly the prims are duplicated;
74//
75// 2.) Instance-rate data, meaning data that varies per instance, such as
76// primvars or material bindings.
77//
78// If an instancer causes prims "/A" and "/B" to be duplicated, we encode that
79// by setting prototypes = ["/A", "/B"]. Note that "/A" and "/B" can be
80// subtrees, not direct gprims. instanceIndices encodes both multiplicity and
81// position in arrays of instance-rate data, per prototype path; if
82// instanceIndices = { [0,2], [1] }, then we draw /A twice (with instance
83// primvar indices 0 and 2); and /B once (with instance primvar index 1). Mask
84// is an auxiliary parameter that can be used to deactivate certain instances;
85// mask = [true, true, false] would disable the second copy of "/A". An empty
86// mask array is the same as all-true.
87//
88// Scenes generally specify instancing in one of two ways:
89//
90// 1.) Explicit instancing: prim /Instancer wants to draw its subtree at an
91// array of locations. This is a data expansion form.
92//
93// 2.) Implicit instancing: prims /X and /Y are marked as being identical, and
94// scene load replaces them with a single prim and an instancer. This is a
95// data coalescing form.
96//
97// For implicit instancing, we want to know the original paths of /X and /Y,
98// for doing things like resolving inheritance. This is encoded in the
99// "instanceLocations" path, while the prototype prims (e.g. /_Prototype/Cube,
100// the deduplicated version of /X/Cube and /Y/Cube) is encoded in the
101// "prototypes" path.
102//
103// For explicit instancing, the "instanceLocations" attribute is meaningless
104// and should be left null.
105//
106
107class HdInstancerTopologySchema : public HdSchema
108{
109public:
112
113 HdInstancerTopologySchema(HdContainerDataSourceHandle container)
114 : HdSchema(container) {}
115
121 HD_API
122 static HdInstancerTopologySchema GetFromParent(
123 const HdContainerDataSourceHandle &fromParentContainer);
124
126
127// --(BEGIN CUSTOM CODE: Schema Methods)--
128
129 HD_API
130 VtArray<int> ComputeInstanceIndicesForProto(SdfPath const &path);
131
132// --(END CUSTOM CODE: Schema Methods)--
133
136
137 HD_API
138 HdPathArrayDataSourceHandle GetPrototypes() const;
139
140 HD_API
141 HdIntArrayVectorSchema GetInstanceIndices() const;
142
143 HD_API
144 HdBoolArrayDataSourceHandle GetMask() const;
145
146 HD_API
147 HdPathArrayDataSourceHandle GetInstanceLocations() const;
148
150
153
156 HD_API
157 static const TfToken &GetSchemaToken();
158
161 HD_API
162 static const HdDataSourceLocator &GetDefaultLocator();
163
165
168
176 HD_API
177 static HdContainerDataSourceHandle
178 BuildRetained(
179 const HdPathArrayDataSourceHandle &prototypes,
180 const HdVectorDataSourceHandle &instanceIndices,
181 const HdBoolArrayDataSourceHandle &mask,
182 const HdPathArrayDataSourceHandle &instanceLocations
183 );
184
192 {
193 public:
194 HD_API
195 Builder &SetPrototypes(
196 const HdPathArrayDataSourceHandle &prototypes);
197 HD_API
198 Builder &SetInstanceIndices(
199 const HdVectorDataSourceHandle &instanceIndices);
200 HD_API
201 Builder &SetMask(
202 const HdBoolArrayDataSourceHandle &mask);
203 HD_API
204 Builder &SetInstanceLocations(
205 const HdPathArrayDataSourceHandle &instanceLocations);
206
208 HD_API
209 HdContainerDataSourceHandle Build();
210
211 private:
212 HdPathArrayDataSourceHandle _prototypes;
213 HdVectorDataSourceHandle _instanceIndices;
214 HdBoolArrayDataSourceHandle _mask;
215 HdPathArrayDataSourceHandle _instanceLocations;
216
217 };
218
220};
221
222PXR_NAMESPACE_CLOSE_SCOPE
223
224#endif
Represents an object that can identify the location of a data source.
Utility class for setting sparse sets of child data source fields to be filled as arguments into Buil...
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
Schema classes represent a structured view of the inherently unstructured container data source passe...
Definition: schema.h:43
Template class wrapping a vector data source whose children are data source of an expected type.
Definition: vectorSchema.h:83
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:228
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:98