instancedBySchema.h
1 //
2 // Copyright 2021 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 // This file is generated by a script. Do not edit directly. Edit the
26 // schema.template.h file to make changes.
27 
28 #ifndef PXR_IMAGING_HD_INSTANCED_BY_SCHEMA_H
29 #define PXR_IMAGING_HD_INSTANCED_BY_SCHEMA_H
30 
31 #include "pxr/imaging/hd/api.h"
32 
33 #include "pxr/imaging/hd/schema.h"
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 //-----------------------------------------------------------------------------
38 
39 #define HDINSTANCEDBY_SCHEMA_TOKENS \
40  (instancedBy) \
41  (paths) \
42  (prototypeRoots) \
43 
44 TF_DECLARE_PUBLIC_TOKENS(HdInstancedBySchemaTokens, HD_API,
45  HDINSTANCEDBY_SCHEMA_TOKENS);
46 
47 //-----------------------------------------------------------------------------
48 
49 // A schema marking a prim as instanced by another prim.
50 //
51 // Many renderers need to know not what prototypes an instancer has, but
52 // rather what instancers a prototype has; this is encoded in
53 // "instancedBy". A prim is "instancedBy" /Instancer if /Instancer has
54 // a prototype path that's a parent of the prim. A complicating exception is
55 // if /A instances /A/B, which instances /A/B/C, we don't consider /A to be
56 // instancing /A/B/C directly; this is to support nested explicit instancing
57 // of things like leaves/trees/forests.
58 //
59 // This value is computed based on the instancer topology of instancer prims in
60 // the scene.
61 //
62 // Note: if multiple instancers reference a prototype, it's possible for
63 // instancedBy to contain multiple entries. Some renderers may be able to
64 // read this directly, but some may need to duplicate prims with an op so that
65 // each prim has a single instancer, depending on how the renderer exposes
66 // instancing.
67 
68 
69 class HdInstancedBySchema : public HdSchema
70 {
71 public:
72  HdInstancedBySchema(HdContainerDataSourceHandle container)
73  : HdSchema(container) {}
74 
75  //ACCESSORS
76 
77  HD_API
78  HdPathArrayDataSourceHandle GetPaths();
79  HD_API
80  HdPathArrayDataSourceHandle GetPrototypeRoots();
81 
82  // RETRIEVING AND CONSTRUCTING
83 
89  HD_API
90  static HdContainerDataSourceHandle
91  BuildRetained(
92  const HdPathArrayDataSourceHandle &paths,
93  const HdPathArrayDataSourceHandle &prototypeRoots
94  );
95 
102  class Builder
103  {
104  public:
105  HD_API
106  Builder &SetPaths(
107  const HdPathArrayDataSourceHandle &paths);
108  HD_API
109  Builder &SetPrototypeRoots(
110  const HdPathArrayDataSourceHandle &prototypeRoots);
111 
113  HD_API
114  HdContainerDataSourceHandle Build();
115 
116  private:
117  HdPathArrayDataSourceHandle _paths;
118  HdPathArrayDataSourceHandle _prototypeRoots;
119  };
120 
126  HD_API
127  static HdInstancedBySchema GetFromParent(
128  const HdContainerDataSourceHandle &fromParentContainer);
129 
132  HD_API
133  static const HdDataSourceLocator &GetDefaultLocator();
134 
135 };
136 
137 PXR_NAMESPACE_CLOSE_SCOPE
138 
139 #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