HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
instancedBySchema.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 //
24 ////////////////////////////////////////////////////////////////////////
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_INSTANCED_BY_SCHEMA_H
32 #define PXR_IMAGING_HD_INSTANCED_BY_SCHEMA_H
33 
34 #include "pxr/imaging/hd/api.h"
35 
36 #include "pxr/imaging/hd/schema.h"
37 
39 
40 //-----------------------------------------------------------------------------
41 
42 #define HDINSTANCEDBY_SCHEMA_TOKENS \
43  (instancedBy) \
44  (paths) \
45  (prototypeRoots) \
46 
47 TF_DECLARE_PUBLIC_TOKENS(HdInstancedBySchemaTokens, HD_API,
49 
50 //-----------------------------------------------------------------------------
51 
52 // A schema marking a prim as instanced by another prim.
53 //
54 // Many renderers need to know not what prototypes an instancer has, but
55 // rather what instancers a prototype has; this is encoded in
56 // "instancedBy". A prim is "instancedBy" /Instancer if /Instancer has
57 // a prototype path that's a parent of the prim. A complicating exception is
58 // if /A instances /A/B, which instances /A/B/C, we don't consider /A to be
59 // instancing /A/B/C directly; this is to support nested explicit instancing
60 // of things like leaves/trees/forests.
61 //
62 // This value is computed based on the instancer topology of instancer prims in
63 // the scene.
64 //
65 // Note: if multiple instancers reference a prototype, it's possible for
66 // instancedBy to contain multiple entries. Some renderers may be able to
67 // read this directly, but some may need to duplicate prims with an op so that
68 // each prim has a single instancer, depending on how the renderer exposes
69 // instancing.
70 
71 
73 {
74 public:
75  HdInstancedBySchema(HdContainerDataSourceHandle container)
76  : HdSchema(container) {}
77 
78  //ACCESSORS
79 
80  HD_API
82  HD_API
84 
85  // RETRIEVING AND CONSTRUCTING
86 
87  /// Builds a container data source which includes the provided child data
88  /// sources. Parameters with nullptr values are excluded. This is a
89  /// low-level interface. For cases in which it's desired to define
90  /// the container with a sparse set of child fields, the Builder class
91  /// is often more convenient and readable.
92  HD_API
93  static HdContainerDataSourceHandle
95  const HdPathArrayDataSourceHandle &paths,
96  const HdPathArrayDataSourceHandle &prototypeRoots
97  );
98 
99  /// \class HdInstancedBySchema::Builder
100  ///
101  /// Utility class for setting sparse sets of child data source fields to be
102  /// filled as arguments into BuildRetained. Because all setter methods
103  /// return a reference to the instance, this can be used in the "builder
104  /// pattern" form.
105  class Builder
106  {
107  public:
108  HD_API
109  Builder &SetPaths(
110  const HdPathArrayDataSourceHandle &paths);
111  HD_API
113  const HdPathArrayDataSourceHandle &prototypeRoots);
114 
115  /// Returns a container data source containing the members set thus far.
116  HD_API
117  HdContainerDataSourceHandle Build();
118 
119  private:
121  HdPathArrayDataSourceHandle _prototypeRoots;
122  };
123 
124  /// Retrieves a container data source with the schema's default name token
125  /// "instancedBy" from the parent container and constructs a
126  /// HdInstancedBySchema instance.
127  /// Because the requested container data source may not exist, the result
128  /// should be checked with IsDefined() or a bool comparison before use.
129  HD_API
131  const HdContainerDataSourceHandle &fromParentContainer);
132 
133  /// Returns a token where the container representing this schema is found in
134  /// a container by default.
135  HD_API
136  static const TfToken &GetSchemaToken();
137 
138  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
139  /// where the container representing this schema is found by default.
140  HD_API
141  static const HdDataSourceLocator &GetDefaultLocator();
142 
143 };
144 
146 
147 #endif
static HD_API const TfToken & GetSchemaToken()
HdPathArrayDataSource::Handle HdPathArrayDataSourceHandle
#define HD_API
Definition: api.h:40
Definition: token.h:87
static HD_API const HdDataSourceLocator & GetDefaultLocator()
HD_API HdPathArrayDataSourceHandle GetPaths()
#define HDINSTANCEDBY_SCHEMA_TOKENS
HD_API Builder & SetPaths(const HdPathArrayDataSourceHandle &paths)
static HD_API HdInstancedBySchema GetFromParent(const HdContainerDataSourceHandle &fromParentContainer)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
HdInstancedBySchema(HdContainerDataSourceHandle container)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
static HD_API HdContainerDataSourceHandle BuildRetained(const HdPathArrayDataSourceHandle &paths, const HdPathArrayDataSourceHandle &prototypeRoots)
HD_API Builder & SetPrototypeRoots(const HdPathArrayDataSourceHandle &prototypeRoots)
TF_DECLARE_PUBLIC_TOKENS(HdInstancedBySchemaTokens, HD_API, HDINSTANCEDBY_SCHEMA_TOKENS)
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
HD_API HdPathArrayDataSourceHandle GetPrototypeRoots()