HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
instanceAdapter.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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 #ifndef PXR_USD_IMAGING_USD_IMAGING_INSTANCE_ADAPTER_H
25 #define PXR_USD_IMAGING_USD_IMAGING_INSTANCE_ADAPTER_H
26 
27 /// \file usdImaging/instanceAdapter.h
28 
29 #include "pxr/pxr.h"
31 
32 #include "pxr/base/tf/hashmap.h"
33 
34 #include <mutex>
35 
37 
38 
39 /// \class UsdImagingInstanceAdapter
40 ///
41 /// Delegate support for instanced prims.
42 ///
43 /// In addition to prim schemas that support instancing, like the point
44 /// instancer, USD has a built in instancing feature that will allow prims
45 /// composed from the same assets, with compatible attributes, to be
46 /// de-duplicated inside of USD.
47 ///
48 /// When these prims are found during scene load, the prim location is
49 /// marked as an instance (meaning prim.IsInstance() == true), and its
50 /// descendants are added to a new hidden scene root. There can be
51 /// multiple prototype scene roots, and each one can be pointed to by
52 /// many instance prims, and these prototype sub-scenes can themselves
53 /// contain instances.
54 ///
55 /// We handle this by sending all instance prims to the instance adapter. In
56 /// order to preserve USD's native instancing work during rendering, for each
57 /// prototype scene root, we insert one hydra gprim per prototype USD gprim,
58 /// and we insert a hydra instancer that computes all of the places these gprims
59 /// (and any child instancers) are referenced in the scene, adjusting the
60 /// instancing count accordingly.
61 ///
62 /// The instance adapter is responsible for computing and passing down a
63 /// small amount of inheritable data that we allow to vary per-instance:
64 /// for example, transform and visibility state, and inherited constant
65 /// primvars. Otherwise, prototypes have no knowledge of the instance prims
66 /// that refer to them.
67 ///
68 /// Just like the scene root, the root of the prototype tree isn't allowed to
69 /// have attributes or a prim type; those are set on the instance prim instead.
70 /// This means if a gprim is directly instanced, USD won't actually de-duplicate
71 /// it. The instance adapter could theoretically bucket such gprims together,
72 /// but the difficulty of doing so is the same as the difficulty of
73 /// deduplicating arbitrary prims in the scene. Instead, the instance adapter
74 /// refuses to image directly-instanced gprims, and the recommended authoring
75 /// guidelines is to only enable USD instancing on enclosing scopes or xforms.
76 ///
77 /// There's a small set of extremely-special-case prims that are allowed to be
78 /// directly instanced, including cards and support prims that designate e.g.
79 /// skinning buffers. These prim adapters opt-in via CanPopulateUsdInstance,
80 /// and generally require very careful coding and support in the instance
81 /// adapter; but they are useful for restricted schemas where we know how to
82 /// vary the data per-instance or know how to efficiently aggregate instances.
83 ///
84 /// Finally, there's a small (hopefully shrinking) set of inherited attributes
85 /// that we need to respect, but don't know how to vary per-instance; for
86 /// example, material bindings. If two instances point to the same USD proto
87 /// root, but have different material bindings, we currently populate two
88 /// hydra instancers with two sets of hydra prototypes. This cuts into the
89 /// efficiency of instancing, so we try to minimize it.
90 ///
92 {
93 public:
95 
98 
99  virtual SdfPath Populate(
100  UsdPrim const& prim,
102  UsdImagingInstancerContext const* instancerContext = nullptr) override;
103 
104  virtual bool ShouldCullChildren() const override;
105 
106  virtual bool IsInstancerAdapter() const override;
107 
108  // ---------------------------------------------------------------------- //
109  /// \name Parallel Setup and Resolve
110  // ---------------------------------------------------------------------- //
111 
112  virtual void TrackVariability(UsdPrim const& prim,
113  SdfPath const& cachePath,
114  HdDirtyBits* timeVaryingBits,
116  instancerContext = NULL) const override;
117 
118  virtual void UpdateForTime(UsdPrim const& prim,
119  SdfPath const& cachePath,
121  HdDirtyBits requestedBits,
123  instancerContext = NULL) const override;
124 
125  // ---------------------------------------------------------------------- //
126  /// \name Change Processing
127  // ---------------------------------------------------------------------- //
128 
129  virtual HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
130  SdfPath const& cachePath,
131  TfToken const& propertyName)
132  override;
133 
134  virtual void ProcessPrimResync(SdfPath const& cachePath,
135  UsdImagingIndexProxy* index) override;
136 
137  virtual void ProcessPrimRemoval(SdfPath const& cachePath,
138  UsdImagingIndexProxy* index) override;
139 
140 
141  virtual void MarkDirty(UsdPrim const& prim,
142  SdfPath const& cachePath,
143  HdDirtyBits dirty,
144  UsdImagingIndexProxy* index) override;
145 
146  // As this adapter hijacks the adapter for the child prim
147  // We need to forward these messages on, in case the child
148  // adapter needs them
149  virtual void MarkRefineLevelDirty(UsdPrim const& prim,
150  SdfPath const& cachePath,
151  UsdImagingIndexProxy* index) override;
152 
153  virtual void MarkReprDirty(UsdPrim const& prim,
154  SdfPath const& cachePath,
155  UsdImagingIndexProxy* index) override;
156 
157  virtual void MarkCullStyleDirty(UsdPrim const& prim,
158  SdfPath const& cachePath,
159  UsdImagingIndexProxy* index) override;
160 
161  virtual void MarkRenderTagDirty(UsdPrim const& prim,
162  SdfPath const& cachePath,
163  UsdImagingIndexProxy* index) override;
164 
165  virtual void MarkTransformDirty(UsdPrim const& prim,
166  SdfPath const& cachePath,
167  UsdImagingIndexProxy* index) override;
168 
169  virtual void MarkVisibilityDirty(UsdPrim const& prim,
170  SdfPath const& cachePath,
171  UsdImagingIndexProxy* index) override;
172 
173  // ---------------------------------------------------------------------- //
174  /// \name Instancing
175  // ---------------------------------------------------------------------- //
176 
177  std::vector<VtArray<TfToken>> GetInstanceCategories(
178  UsdPrim const& prim) override;
179 
180  GfMatrix4d GetInstancerTransform(UsdPrim const& instancerPrim,
181  SdfPath const& instancerPath,
182  UsdTimeCode time) const override;
183 
185  UsdPrim const& usdPrim,
186  SdfPath const& cachePath) const override;
187 
189  UsdPrim const& usdPrim,
190  SdfPath const& cachePath) const override;
191 
192  size_t SampleInstancerTransform(UsdPrim const& instancerPrim,
193  SdfPath const& instancerPath,
195  size_t maxSampleCount,
196  float *sampleTimes,
197  GfMatrix4d *sampleValues) override;
198 
199  size_t SampleTransform(UsdPrim const& prim,
200  SdfPath const& cachePath,
201  UsdTimeCode time,
202  size_t maxNumSamples,
203  float *sampleTimes,
204  GfMatrix4d *sampleValues) override;
205 
206  size_t SamplePrimvar(UsdPrim const& usdPrim,
207  SdfPath const& cachePath,
208  TfToken const& key,
210  size_t maxNumSamples,
211  float *sampleTimes,
212  VtValue *sampleValues,
213  VtIntArray *sampleIndices) override;
214 
216  UsdPrim const& usdPrim,
217  SdfPath const& cachePath,
218  TfToken const& instanceInheritablePurpose) const override;
219 
220  PxOsdSubdivTags GetSubdivTags(UsdPrim const& usdPrim,
221  SdfPath const& cachePath,
222  UsdTimeCode time) const override;
223 
224  VtValue GetTopology(UsdPrim const& prim,
225  SdfPath const& cachePath,
226  UsdTimeCode time) const override;
227 
228  HdCullStyle GetCullStyle(UsdPrim const& prim,
229  SdfPath const& cachePath,
230  UsdTimeCode time) const override;
231 
232  GfRange3d GetExtent(UsdPrim const& usdPrim,
233  SdfPath const& cachePath,
234  UsdTimeCode time) const override;
235 
236  bool GetVisible(UsdPrim const& usdPrim,
237  SdfPath const& cachePath,
238  UsdTimeCode time) const override;
239 
240  bool GetDoubleSided(UsdPrim const& prim,
241  SdfPath const& cachePath,
242  UsdTimeCode time) const override;
243 
244  GfMatrix4d GetTransform(UsdPrim const& prim,
245  SdfPath const& cachePath,
247  bool ignoreRootTransform = false) const override;
248 
249  SdfPath GetMaterialId(UsdPrim const& prim,
250  SdfPath const& cachePath,
251  UsdTimeCode time) const override;
252 
254  const UsdPrim& prim,
255  const SdfPath& cachePath,
256  const TfToken& paramName,
257  UsdTimeCode time) const override;
258 
260  const UsdPrim& prim,
261  const SdfPath& cachePath,
262  UsdTimeCode time) const override;
263 
265  GetExtComputationInputs(UsdPrim const& prim,
266  SdfPath const& cachePath,
267  const UsdImagingInstancerContext* instancerContext)
268  const override;
269 
270 
272  GetExtComputationOutputs(UsdPrim const& prim,
273  SdfPath const& cachePath,
274  const UsdImagingInstancerContext* instancerContext)
275  const override;
276 
279  UsdPrim const& prim,
280  SdfPath const& cachePath,
281  HdInterpolation interpolation,
282  const UsdImagingInstancerContext* instancerContext) const override;
283 
284  VtValue
286  UsdPrim const& prim,
287  SdfPath const& cachePath,
288  TfToken const& name,
290  const UsdImagingInstancerContext* instancerContext) const override;
291 
292  std::string
294  UsdPrim const& prim,
295  SdfPath const& cachePath,
296  const UsdImagingInstancerContext* instancerContext) const override;
297 
298  VtValue
299  GetInstanceIndices(UsdPrim const& instancerPrim,
300  SdfPath const& instancerCachePath,
301  SdfPath const& prototypeCachePath,
302  UsdTimeCode time) const override;
303 
304  VtValue Get(UsdPrim const& prim,
305  SdfPath const& cachePath,
306  TfToken const& key,
308  VtIntArray *outIndices) const override;
309 
310  // ---------------------------------------------------------------------- //
311  /// \name Nested instancing support
312  // ---------------------------------------------------------------------- //
313 
315  SdfPath const &parentInstancerPath,
316  SdfPath const &instancerPath,
317  UsdTimeCode time) const override;
318 
319  // ---------------------------------------------------------------------- //
320  /// \name Picking & selection
321  // ---------------------------------------------------------------------- //
322 
323  virtual SdfPath GetScenePrimPath(
324  SdfPath const& cachePath,
325  int instanceIndex,
326  HdInstancerContext *instancerContext) const override;
327 
329  SdfPath const& cachePath,
330  std::vector<int> const& instanceIndices,
331  std::vector<HdInstancerContext> *instancerCtxs) const override;
332 
333  virtual SdfPath GetDataSharingId(
334  SdfPath const& cachePath) const override;
335 
336  virtual bool PopulateSelection(
337  HdSelection::HighlightMode const& highlightMode,
338  SdfPath const &cachePath,
339  UsdPrim const &usdPrim,
340  int const hydraInstanceIndex,
341  VtIntArray const &parentInstanceIndices,
342  HdSelectionSharedPtr const &result) const override;
343 
344  // ---------------------------------------------------------------------- //
345  /// \name Volume field information
346  // ---------------------------------------------------------------------- //
347 
349  GetVolumeFieldDescriptors(UsdPrim const& usdPrim, SdfPath const &id,
350  UsdTimeCode time) const override;
351 
352 protected:
353  virtual void _RemovePrim(SdfPath const& cachePath,
354  UsdImagingIndexProxy* index) override final;
355 
356 private:
357 
358  SdfPath _Populate(UsdPrim const& prim,
360  UsdImagingInstancerContext const* instancerContext,
361  SdfPath const& parentProxyPath);
362 
363  struct _ProtoPrim;
364  struct _ProtoGroup;
365  struct _InstancerData;
366 
367  bool _IsChildPrim(UsdPrim const& prim,
368  SdfPath const& cachePath) const;
369 
370  // Returns true if the given prim serves as an instancer.
371  bool _PrimIsInstancer(UsdPrim const& prim) const;
372 
373  // Inserts prototype prims for the given \p usdPrim into the \p index.
374  // Any inserted gprims will be inserted under a special path combining
375  // \p instancerPath and \p protoName.
376  SdfPath
377  _InsertProtoPrim(UsdPrimRange::iterator *iter,
378  const TfToken& protoName,
379  SdfPath materialId,
380  TfToken drawMode,
381  TfToken inheritablePurpose,
382  SdfPath instancerPath,
383  UsdImagingPrimAdapterSharedPtr const& primAdapter,
384  UsdImagingPrimAdapterSharedPtr const& instancerAdapter,
386  bool *isLeafInstancer);
387 
388  // For a usd path, collects the instancers to resync.
389  void _ResyncPath(SdfPath const& cachePath,
391  bool reload);
392  // Removes and optionally reloads all instancer data, both locally and
393  // from the render index.
394  void _ResyncInstancer(SdfPath const& instancerPath,
396 
397  // Computes per-frame data in the instancer map. This is primarily used
398  // during update to send new instance indices out to Hydra.
399  struct _ComputeInstanceMapFn;
400  VtIntArray _ComputeInstanceMap(UsdPrim const& instancerPrim,
401  _InstancerData const& instrData,
402  UsdTimeCode time) const;
403 
404  // Precomputes the instancer visibility data (as visible, invis, varying
405  // per-node), and returns whether the instance map is variable.
406  // Note: this function assumes the instancer data is already locked by
407  // the caller...
408  struct _ComputeInstanceMapVariabilityFn;
409  bool _ComputeInstanceMapVariability(UsdPrim const& instancerPrim,
410  _InstancerData const& instrData) const;
411 
412  // Gets the associated _ProtoPrim and instancer context for the given
413  // instancer and cache path.
414  _ProtoPrim const& _GetProtoPrim(SdfPath const& instancerPath,
415  SdfPath const& cachePath,
416  UsdImagingInstancerContext* ctx) const;
417 
418  // Gets the associated _ProtoPrim and instancerContext if cachePath is a
419  // child path and returns \c true, otherwise returns \c false.
420  bool _GetProtoPrimForChild(
421  UsdPrim const& usdPrim,
422  SdfPath const& cachePath,
423  _ProtoPrim const** proto,
424  UsdImagingInstancerContext* ctx) const;
425 
426  // Computes the transforms for all instances corresponding to the given
427  // instancer.
428  struct _ComputeInstanceTransformFn;
429  bool _ComputeInstanceTransforms(UsdPrim const& instancer,
430  VtMatrix4dArray* transforms,
431  UsdTimeCode time) const;
432 
433  // Gathers the authored transforms time samples given an instancer.
434  struct _GatherInstanceTransformTimeSamplesFn;
435  bool _GatherInstanceTransformsTimeSamples(UsdPrim const& instancer,
436  GfInterval interval,
437  std::vector<double>* outTimes)
438  const;
439 
440  // Gathers the specified primvar time samples given an instancer.
441  struct _GatherInstancePrimvarTimeSamplesFn;
442  bool _GatherInstancePrimvarTimeSamples(UsdPrim const& instancer,
443  TfToken const& key,
444  GfInterval interval,
445  std::vector<double>* outTimes)
446  const;
447 
448  // Returns true if any of the instances corresponding to the given
449  // instancer has a varying transform.
450  struct _IsInstanceTransformVaryingFn;
451  bool _IsInstanceTransformVarying(UsdPrim const& instancer) const;
452 
453  // Computes the value of a primvar for all instances corresponding to the
454  // given instancer. The templated version runs the templated functor,
455  // and the un-templated version does type dispatch.
456  template<typename T> struct _ComputeInheritedPrimvarFn;
457 
458  template<typename T>
459  bool _ComputeInheritedPrimvar(UsdPrim const& instancer,
460  TfToken const& primvarName,
461  VtValue *result,
462  UsdTimeCode time) const;
463 
464  bool _ComputeInheritedPrimvar(UsdPrim const& instancer,
465  TfToken const& primvarName,
466  SdfValueTypeName const& type,
467  VtValue *result,
468  UsdTimeCode time) const;
469 
470  // Returns true if any of the instances corresponding to the given
471  // instancer has varying inherited primvars.
472  struct _IsInstanceInheritedPrimvarVaryingFn;
473  bool _IsInstanceInheritedPrimvarVarying(UsdPrim const& instancer) const;
474 
475  struct _PopulateInstanceSelectionFn;
476  struct _GetScenePrimPathsFn;
477  struct _GetInstanceCategoriesFn;
478 
479  // Helper functions for dealing with "actual" instances to be drawn.
480  //
481  // Suppose we have:
482  // /Root
483  // Instance_A (prototype: /__Prototype_1)
484  // Instance_B (prototype: /__Prototype_1)
485  // /__Prototype_1
486  // AnotherInstance_A (prototype: /__Prototype_2)
487  // /__Prototype_2
488  //
489  // /__Prototype_2 has only one associated instance in the Usd scenegraph:
490  // /__Prototype_1/AnotherInstance_A. However, imaging actually needs to draw
491  // two instances of /__Prototype_2, because AnotherInstance_A is a nested
492  // instance beneath /__Prototype_1, and there are two instances of
493  // /__Prototype_1.
494  //
495  // Each instance to be drawn is addressed by the chain of instances
496  // that caused it to be drawn. In the above example, the two instances
497  // of /__Prototype_2 to be drawn are:
498  //
499  // [ /Root/Instance_A, /__Prototype_1/AnotherInstance_A ],
500  // [ /Root/Instance_B, /__Prototype_1/AnotherInstance_A ]
501  //
502  // This "instance context" describes the chain of opinions that
503  // ultimately affect the final drawn instance. For example, the
504  // transform of each instance to draw is the combined transforms
505  // of the prims in each context.
506  template <typename Functor>
507  void _RunForAllInstancesToDraw(UsdPrim const& instancer, Functor* fn) const;
508  template <typename Functor>
509  bool _RunForAllInstancesToDrawImpl(UsdPrim const& instancer,
510  std::vector<UsdPrim>* instanceContext,
511  size_t* instanceIdx,
512  Functor* fn) const;
513 
515  size_t _CountAllInstancesToDraw(UsdPrim const& instancer) const;
516  size_t _CountAllInstancesToDrawImpl(UsdPrim const& instancer,
517  _InstancerDrawCounts* drawCounts) const;
518 
519  // A proto prim represents a single adapter under a prototype root declared
520  // on the instancer.
521  struct _ProtoPrim {
522  _ProtoPrim() {}
523  // Each prim will become a prototype "child" under the instancer. This
524  // path is the path to the prim on the Usd Stage (the path to a single
525  // mesh, for example).
526  SdfPath path;
527  // The prim adapter for the actual prototype prim.
529  };
530 
531  // Indexed by prototype cachePath (each prim has one entry)
533 
534  // All data associated with a given instancer prim. PrimMap could
535  // technically be split out to avoid two lookups, however it seems cleaner
536  // to keep everything bundled up under the instancer path.
537  struct _InstancerData {
538  _InstancerData() : numInstancesToDraw(0), refresh(false) { }
539 
540  // The prototype prim path associated with this instancer.
541  SdfPath prototypePath;
542 
543  // The USD material path associated with this instancer.
544  SdfPath materialUsdPath;
545 
546  // The drawmode associated with this instancer.
547  TfToken drawMode;
548 
549  // The purpose value associated with this instance that can be inherited
550  // by proto prims that need to inherit ancestor purpose.
551  TfToken inheritablePurpose;
552 
553  // Inherited primvar
554  struct PrimvarInfo {
557  bool operator==(const PrimvarInfo& rhs) const;
558  bool operator<(const PrimvarInfo& rhs) const;
559  };
560  std::vector<PrimvarInfo> inheritedPrimvars;
561 
562  // Paths to Usd instance prims. Note that this is not necessarily
563  // equivalent to all the instances that will be drawn. See below.
564  SdfPathSet instancePaths;
565 
566  // Number of actual instances of this instancer that will be
567  // drawn. See comment on _RunForAllInstancesToDraw.
568  // XXX: This is mutable so that we can precache it in TrackVariability;
569  // it's inappropriate to track it in _Populate since not all instances
570  // will have been populated.
571  mutable size_t numInstancesToDraw;
572 
573  // Cached visibility. This vector contains an entry for each instance
574  // that will be drawn (i.e., visibility.size() == numInstancesToDraw).
575  enum Visibility {
576  Invisible, //< Invisible over all time
577  Visible, //< Visible over all time
578  Varying, //< Visibility varies over time
579  Unknown //< Visibility has not yet been checked
580  };
581  // XXX: This is mutable so that we can precache visibility per-instance
582  // in TrackVariability(). Can we replace this with some kind of usage
583  // of an inherited cache?
584  mutable std::vector<Visibility> visibility;
585 
586  // Map of all rprims for this instancer prim.
587  _PrimMap primMap;
588 
589  // This is a set of reference paths, where this instancer needs
590  // to deferer to another instancer. While refered to here as a child
591  // instancer, the actual relationship is more like a directed graph.
592  SdfPathSet childPointInstancers;
593 
594  // Nested (child) native instances.
595  SdfPathVector nestedInstances;
596 
597  // Parent native instances.
598  SdfPathVector parentInstances;
599 
600  // Flag indicating we've asked the delegate to refresh this instancer
601  // (via TrackVariability/UpdateForTime). We record this so we don't
602  // do it multiple times.
603  mutable bool refresh;
604  };
605 
606  // Map from hydra instancer cache path to the various instancer state we
607  // need to answer adapter queries.
608  // Note: this map is modified in multithreaded code paths and must be
609  // locked.
610  typedef std::unordered_map<SdfPath, _InstancerData, SdfPath::Hash>
611  _InstancerDataMap;
612  _InstancerDataMap _instancerData;
613 
614  // Map from USD instance prim paths to the cache path of the hydra instancer
615  // they are assigned to (which will typically be the path to the first
616  // instance of this instance group we run across).
617  // XXX: consider to move this forwarding map into HdRenderIndex.
619  _InstanceToInstancerMap;
620  _InstanceToInstancerMap _instanceToInstancerMap;
621 
622  // Hd and UsdImaging think of instancing in terms of an 'instancer' that
623  // specifies a list of 'prototype' prims that are shared per instance.
624  //
625  // For Usd scenegraph instancing, a prototype prim and its descendents
626  // roughly correspond to the instancer and prototype prims. However,
627  // Hd requires a different instancer and rprims for different combinations
628  // of inherited attributes (material binding, draw mode, etc).
629  // This means we cannot use the Usd prototype prim as the instancer, because
630  // we can't represent this in the case where multiple Usd instances share
631  // the same prototype but have different bindings.
632  //
633  // Instead, we use the first instance of a prototype with a given set of
634  // inherited attributes as our instancer. For example, if /A and /B are
635  // both instances of /__Prototype_1 but /A and /B have different material
636  // bindings authored on them, both /A and /B will be instancers,
637  // with their own set of rprims and instance indices.
638  //
639  // The below is a multimap from prototype path to the cache path of the
640  // hydra instancer. The data for the instancer is located in the
641  // _InstancerDataMap.
643  _PrototypeToInstancerMap;
644  _PrototypeToInstancerMap _prototypeToInstancerMap;
645 
646  // Map from instance cache path to their instancer path.
647  // Note: this is for reducing proto prim lookup in _GetProtoPrim method.
648  typedef std::unordered_map<SdfPath, SdfPath, SdfPath::Hash>
649  _ProtoPrimToInstancerMap;
650  _ProtoPrimToInstancerMap _protoPrimToInstancerMap;
651 };
652 
653 
655 
656 #endif // PXR_USD_IMAGING_USD_IMAGING_INSTANCE_ADAPTER_H
bool GetVisible(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
PXL_API void reload()
Reload the configuration.
HdCullStyle
Definition: enums.h:122
virtual void ProcessPrimRemoval(SdfPath const &cachePath, UsdImagingIndexProxy *index) override
size_t SampleTransform(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, size_t maxNumSamples, float *sampleTimes, GfMatrix4d *sampleValues) override
Samples the transform for the given prim.
HdExtComputationPrimvarDescriptorVector GetExtComputationPrimvars(UsdPrim const &prim, SdfPath const &cachePath, HdInterpolation interpolation, const UsdImagingInstancerContext *instancerContext) const override
GT_API const UT_StringHolder time
uint32_t HdDirtyBits
Definition: types.h:158
virtual void MarkVisibilityDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
virtual void ProcessPrimResync(SdfPath const &cachePath, UsdImagingIndexProxy *index) override
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
std::vector< HdExtComputationInputDescriptor > HdExtComputationInputDescriptorVector
std::vector< VtArray< TfToken > > GetInstanceCategories(UsdPrim const &prim) override
Return an array of the categories used by each instance.
virtual void MarkRenderTagDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
VaryingRef< T > Varying(T *x)
Definition: varyingref.h:193
std::vector< HdExtComputationOutputDescriptor > HdExtComputationOutputDescriptorVector
**But if you need a result
Definition: thread.h:613
virtual SdfPath GetDataSharingId(SdfPath const &cachePath) const override
virtual void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
virtual HdDirtyBits ProcessPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &propertyName) override
VtValue GetLightParamValue(const UsdPrim &prim, const SdfPath &cachePath, const TfToken &paramName, UsdTimeCode time) const override
VtValue GetTopology(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
virtual SdfPathVector GetScenePrimPaths(SdfPath const &cachePath, std::vector< int > const &instanceIndices, std::vector< HdInstancerContext > *instancerCtxs) const override
SdfPathVector GetInstancerPrototypes(UsdPrim const &usdPrim, SdfPath const &cachePath) const override
Return the list of known prototypes of this prim.
std::vector< std::pair< SdfPath, int > > HdInstancerContext
Instancer context: a pair of instancer paths and instance indices.
Definition: sceneDelegate.h:61
virtual SdfPath Populate(UsdPrim const &prim, UsdImagingIndexProxy *index, UsdImagingInstancerContext const *instancerContext=nullptr) override
virtual bool IsInstancerAdapter() const override
size_t SamplePrimvar(UsdPrim const &usdPrim, SdfPath const &cachePath, TfToken const &key, UsdTimeCode time, size_t maxNumSamples, float *sampleTimes, VtValue *sampleValues, VtIntArray *sampleIndices) override
SdfPath GetMaterialId(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
The root transform provided by the delegate.
Definition: token.h:87
PxOsdSubdivTags GetSubdivTags(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
Get the subdiv tags for this prim.
std::string GetExtComputationKernel(UsdPrim const &prim, SdfPath const &cachePath, const UsdImagingInstancerContext *instancerContext) const override
virtual void MarkTransformDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
Definition: prim.h:133
VtValue GetInstanceIndices(UsdPrim const &instancerPrim, SdfPath const &instancerCachePath, SdfPath const &prototypeCachePath, UsdTimeCode time) const override
virtual void MarkReprDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
GfMatrix4d GetInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time) const override
GfRange3d GetExtent(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const override
GLuint const GLchar * name
Definition: glcorearb.h:786
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
Definition: selection.h:56
Definition: path.h:290
std::vector< HdVolumeFieldDescriptor > HdVolumeFieldDescriptorVector
virtual void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=NULL) const override
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
Definition: path.h:211
virtual void MarkDirty(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits dirty, UsdImagingIndexProxy *index) override
std::set< class SdfPath > SdfPathSet
A set of SdfPaths.
Definition: path.h:209
virtual void MarkRefineLevelDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override
bool operator==(const PrimvarInfo &rhs) const
VtValue Get(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &key, UsdTimeCode time, VtIntArray *outIndices) const override
virtual bool PopulateSelection(HdSelection::HighlightMode const &highlightMode, SdfPath const &cachePath, UsdPrim const &usdPrim, int const hydraInstanceIndex, VtIntArray const &parentInstanceIndices, HdSelectionSharedPtr const &result) const override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
GfMatrix4d GetTransform(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, bool ignoreRootTransform=false) const override
GLuint index
Definition: glcorearb.h:786
HdInterpolation
Definition: enums.h:194
TfToken GetPurpose(UsdPrim const &usdPrim, SdfPath const &cachePath, TfToken const &instanceInheritablePurpose) const override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::shared_ptr< UsdImagingPrimAdapter > UsdImagingPrimAdapterSharedPtr
virtual bool ShouldCullChildren() const override
HdExtComputationOutputDescriptorVector GetExtComputationOutputs(UsdPrim const &prim, SdfPath const &cachePath, const UsdImagingInstancerContext *instancerContext) const override
VtValue GetMaterialResource(const UsdPrim &prim, const SdfPath &cachePath, UsdTimeCode time) const override
The root transform provided by the delegate.
virtual HdVolumeFieldDescriptorVector GetVolumeFieldDescriptors(UsdPrim const &usdPrim, SdfPath const &id, UsdTimeCode time) const override
virtual void _RemovePrim(SdfPath const &cachePath, UsdImagingIndexProxy *index) overridefinal
Provides to paramName->UsdAttribute value mappings.
virtual ~UsdImagingInstanceAdapter()
virtual SdfPath GetScenePrimPath(SdfPath const &cachePath, int instanceIndex, HdInstancerContext *instancerContext) const override
virtual GfMatrix4d GetRelativeInstancerTransform(SdfPath const &parentInstancerPath, SdfPath const &instancerPath, UsdTimeCode time) const override
VtValue GetExtComputationInput(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &name, UsdTimeCode time, const UsdImagingInstancerContext *instancerContext) const override
bool operator<(const PrimvarInfo &rhs) const
SdfPath GetInstancerId(UsdPrim const &usdPrim, SdfPath const &cachePath) const override
Return the instancerId for this prim.
std::shared_ptr< class HdSelection > HdSelectionSharedPtr
Definition: selection.h:40
type
Definition: core.h:1059
Definition: value.h:164
size_t SampleInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time, size_t maxSampleCount, float *sampleTimes, GfMatrix4d *sampleValues) override
bool GetDoubleSided(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Reads double-sided from the given prim. If not authored, returns false.
HdCullStyle GetCullStyle(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const override
Gets the cullstyle of a specific path in the scene graph.
HdExtComputationInputDescriptorVector GetExtComputationInputs(UsdPrim const &prim, SdfPath const &cachePath, const UsdImagingInstancerContext *instancerContext) const override
std::vector< HdExtComputationPrimvarDescriptor > HdExtComputationPrimvarDescriptorVector
virtual void MarkCullStyleDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index) override