Loading...
Searching...
No Matches
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//
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
22
23#include "pxr/imaging/hd/api.h"
24#include "pxr/imaging/hd/schemaTypeDefs.h"
25
26#include "pxr/imaging/hd/schema.h"
27
28// --(BEGIN CUSTOM CODE: Includes)--
29// --(END CUSTOM CODE: Includes)--
30
31PXR_NAMESPACE_OPEN_SCOPE
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
43TF_DECLARE_PUBLIC_TOKENS(HdInstancerTopologySchemaTokens, HD_API,
44 HD_INSTANCER_TOPOLOGY_SCHEMA_TOKENS);
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
90class HdInstancerTopologySchema : public HdSchema
91{
92public:
95
96 HdInstancerTopologySchema(HdContainerDataSourceHandle container)
97 : HdSchema(container) {}
98
104 HD_API
105 static HdInstancerTopologySchema GetFromParent(
106 const HdContainerDataSourceHandle &fromParentContainer);
107
109
110// --(BEGIN CUSTOM CODE: Schema Methods)--
111
112 HD_API
113 VtArray<int> ComputeInstanceIndicesForProto(SdfPath const &path);
114
115// --(END CUSTOM CODE: Schema Methods)--
116
119
120 HD_API
121 HdPathArrayDataSourceHandle GetPrototypes() const;
122
123 HD_API
124 HdIntArrayVectorSchema GetInstanceIndices() const;
125
126 HD_API
127 HdBoolArrayDataSourceHandle GetMask() const;
128
129 HD_API
130 HdPathArrayDataSourceHandle GetInstanceLocations() const;
131
133
136
139 HD_API
140 static const TfToken &GetSchemaToken();
141
144 HD_API
145 static const HdDataSourceLocator &GetDefaultLocator();
146
148
151
159 HD_API
160 static HdContainerDataSourceHandle
161 BuildRetained(
162 const HdPathArrayDataSourceHandle &prototypes,
163 const HdVectorDataSourceHandle &instanceIndices,
164 const HdBoolArrayDataSourceHandle &mask,
165 const HdPathArrayDataSourceHandle &instanceLocations
166 );
167
175 {
176 public:
177 HD_API
178 Builder &SetPrototypes(
179 const HdPathArrayDataSourceHandle &prototypes);
180 HD_API
181 Builder &SetInstanceIndices(
182 const HdVectorDataSourceHandle &instanceIndices);
183 HD_API
184 Builder &SetMask(
185 const HdBoolArrayDataSourceHandle &mask);
186 HD_API
187 Builder &SetInstanceLocations(
188 const HdPathArrayDataSourceHandle &instanceLocations);
189
191 HD_API
192 HdContainerDataSourceHandle Build();
193
194 private:
195 HdPathArrayDataSourceHandle _prototypes;
196 HdVectorDataSourceHandle _instanceIndices;
197 HdBoolArrayDataSourceHandle _mask;
198 HdPathArrayDataSourceHandle _instanceLocations;
199
200 };
201
203};
204
205PXR_NAMESPACE_CLOSE_SCOPE
206
207#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:26
Template class wrapping a vector data source whose children are data source of an expected type.
Definition: vectorSchema.h:66
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:211
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:81