instanceSchema.h
1 //
2 // Copyright 2022 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 /* ** This file is generated by a script. Do not edit directly. Edit ** */
28 /* ** defs.py or the (*)Schema.template.h files to make changes. ** */
29 /* ************************************************************************** */
30 
31 #ifndef PXR_IMAGING_HD_INSTANCE_SCHEMA_H
32 #define PXR_IMAGING_HD_INSTANCE_SCHEMA_H
33 
34 #include "pxr/imaging/hd/api.h"
35 
36 #include "pxr/imaging/hd/schema.h"
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 //-----------------------------------------------------------------------------
41 
42 #define HDINSTANCE_SCHEMA_TOKENS \
43  (instance) \
44  (instancer) \
45  (prototypeIndex) \
46  (instanceIndex) \
47 
48 TF_DECLARE_PUBLIC_TOKENS(HdInstanceSchemaTokens, HD_API,
49  HDINSTANCE_SCHEMA_TOKENS);
50 
51 //-----------------------------------------------------------------------------
52 
53 // This schema can be considered the opposite of instancerTopology's
54 // "instanceLocations". When the scene coalesces scene prims into multiple
55 // instances of a single prototype, it inserts "instance" prims at the site
56 // of de-duplication. The instancer prim added to manage the prototype
57 // uses "instanceLocations" to point back to all of these instance prims.
58 //
59 // The instance prims aren't directly useful for rendering but can be useful
60 // for scene processing and data aggregation.
61 
62 
63 class HdInstanceSchema : public HdSchema
64 {
65 public:
66  HdInstanceSchema(HdContainerDataSourceHandle container)
67  : HdSchema(container) {}
68 
69  //ACCESSORS
70 
71 
72  // Path to instancer for which a (sub-)entry was added to its
73  // instancerTopology's instanceIndices during instance aggregation to
74  // account for this instance. Note that instanceIndices is nested, that
75  // is a vector data source containing integer arrays, one for each
76  // prototype the instancer is instancing. Thus, we need two indices to
77  // identify the entry: prototypeIndex is the outer index and
78  // instanceIndex the inner index.
79  HD_API
80  HdPathDataSourceHandle GetInstancer();
81 
82  // Index into vector data source at instancer's instancerTopology's
83  // instanceIndices to find entry corresponding to this instance.
84  HD_API
85  HdIntDataSourceHandle GetPrototypeIndex();
86 
87  // Index into int array within the vector data source at instancer's
88  // instancerTopology's instanceIndices to find entry corresponding to
89  // this instance.
90  HD_API
91  HdIntDataSourceHandle GetInstanceIndex();
92 
93  // RETRIEVING AND CONSTRUCTING
94 
100  HD_API
101  static HdContainerDataSourceHandle
102  BuildRetained(
103  const HdPathDataSourceHandle &instancer,
104  const HdIntDataSourceHandle &prototypeIndex,
105  const HdIntDataSourceHandle &instanceIndex
106  );
107 
114  class Builder
115  {
116  public:
117  HD_API
118  Builder &SetInstancer(
119  const HdPathDataSourceHandle &instancer);
120  HD_API
121  Builder &SetPrototypeIndex(
122  const HdIntDataSourceHandle &prototypeIndex);
123  HD_API
124  Builder &SetInstanceIndex(
125  const HdIntDataSourceHandle &instanceIndex);
126 
128  HD_API
129  HdContainerDataSourceHandle Build();
130 
131  private:
132  HdPathDataSourceHandle _instancer;
133  HdIntDataSourceHandle _prototypeIndex;
134  HdIntDataSourceHandle _instanceIndex;
135  };
136 
142  HD_API
143  static HdInstanceSchema GetFromParent(
144  const HdContainerDataSourceHandle &fromParentContainer);
145 
148  HD_API
149  static const HdDataSourceLocator &GetDefaultLocator();
150 
151 };
152 
153 PXR_NAMESPACE_CLOSE_SCOPE
154 
155 #endif
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
Represents an object that can identify the location of a data source.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:118
Utility class for setting sparse sets of child data source fields to be filled as arguments into Buil...
Schema classes represent a structured view of the inherently unstructured container data source passe...
Definition: schema.h:43