All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
primAdapter.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_PRIM_ADAPTER_H
25 #define PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usdImaging/usdImaging/api.h"
31 #include "pxr/usdImaging/usdImaging/version.h"
35 
36 #include "pxr/imaging/hd/changeTracker.h"
37 #include "pxr/imaging/hd/selection.h"
38 #include "pxr/usd/usd/attribute.h"
39 #include "pxr/usd/usd/prim.h"
40 #include "pxr/usd/usd/timeCode.h"
41 
43 
44 #include "pxr/base/tf/type.h"
45 
46 #include <memory>
47 
48 PXR_NAMESPACE_OPEN_SCOPE
49 
50 class UsdPrim;
51 
52 // Forward declaration for nested class.
53 class UsdImagingDelegate;
57 
58 using UsdImagingPrimAdapterSharedPtr =
59  std::shared_ptr<class UsdImagingPrimAdapter>;
60 
66  : public std::enable_shared_from_this<UsdImagingPrimAdapter>
67 {
68 public:
69 
70  // ---------------------------------------------------------------------- //
72  // ---------------------------------------------------------------------- //
73 
75  {}
76 
77  USDIMAGING_API
78  virtual ~UsdImagingPrimAdapter();
79 
83  virtual SdfPath Populate(UsdPrim const& prim,
84  UsdImagingIndexProxy* index,
86  instancerContext = nullptr) = 0;
87 
88  // Indicates whether population traversal should be pruned based on
89  // prim-specific features (like whether it's imageable).
90  USDIMAGING_API
91  static bool ShouldCullSubtree(UsdPrim const& prim);
92 
93  // Indicates whether population traversal should be pruned based on
94  // adapter-specific features (like whether the adapter is an instance
95  // adapter, and wants to do its own population).
96  USDIMAGING_API
97  virtual bool ShouldCullChildren() const;
98 
99  // Indicates whether or not native USD prim instancing should be ignored
100  // for prims using this delegate, along with their descendants.
101  USDIMAGING_API
102  virtual bool ShouldIgnoreNativeInstanceSubtrees() const;
103 
104  // Indicates the adapter is a multiplexing adapter (e.g. PointInstancer),
105  // potentially managing its children. This flag is used in nested
106  // instancer cases to determine which adapter is assigned to which prim.
107  USDIMAGING_API
108  virtual bool IsInstancerAdapter() const;
109 
110  // Indicates whether this adapter can directly populate USD instance prims.
111  //
112  // Normally, with USD instances, we make a firewall between the instance
113  // prim and the USD prototype tree. The instance adapter creates one
114  // hydra prototype per prim in the USD prototype tree, shared by all USD
115  // instances; this lets us recognize the benefits of instancing,
116  // by hopefully having a high instance count per prototype. The instance
117  // adapter additionally configures a hydra instancer for the prototype tree;
118  // and a small set of specially-handled data is allowed through: things like
119  // inherited constant primvars, transforms, visibility, and other things
120  // we know how to vary per-instance.
121  //
122  // We enforce the above policy by refusing to populate gprims which are
123  // USD instances, since we'd need one prototype per instance and would lose
124  // any instancing benefit.
125  //
126  // There are a handful of times when it really is useful to directly
127  // populate instance prims: for example, instances with cards applied,
128  // or instances of type UsdSkelRoot. In those cases, the adapters can
129  // opt into this scheme with "CanPopulateUsdInstance".
130  //
131  // Note that any adapters taking advantage of this feature will need
132  // extensive code support in instanceAdapter: the instance adapter will
133  // need to potentially create and track multiple hydra prototypes per
134  // USD prototype, and the adapter will need special handling to pass down
135  // any relevant instance-varying data.
136  //
137  // In summary: use with caution.
138  USDIMAGING_API
139  virtual bool CanPopulateUsdInstance() const;
140 
141  // ---------------------------------------------------------------------- //
143  // ---------------------------------------------------------------------- //
144 
150  virtual void TrackVariability(UsdPrim const& prim,
151  SdfPath const& cachePath,
152  HdDirtyBits* timeVaryingBits,
154  instancerContext = nullptr) const = 0;
155 
160  virtual void UpdateForTime(UsdPrim const& prim,
161  SdfPath const& cachePath,
162  UsdTimeCode time,
163  HdDirtyBits requestedBits,
165  instancerContext = nullptr) const = 0;
166 
167  // ---------------------------------------------------------------------- //
169  // ---------------------------------------------------------------------- //
170 
181  USDIMAGING_API
182  virtual HdDirtyBits ProcessPrimChange(UsdPrim const& prim,
183  SdfPath const& cachePath,
184  TfTokenVector const& changedFields);
185 
188  virtual HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
189  SdfPath const& cachePath,
190  TfToken const& propertyName) = 0;
191 
195  USDIMAGING_API
196  virtual void ProcessPrimResync(SdfPath const& cachePath,
197  UsdImagingIndexProxy* index);
198 
201  USDIMAGING_API
202  virtual void ProcessPrimRemoval(SdfPath const& cachePath,
203  UsdImagingIndexProxy* index);
204 
205 
206  virtual void MarkDirty(UsdPrim const& prim,
207  SdfPath const& cachePath,
208  HdDirtyBits dirty,
209  UsdImagingIndexProxy* index) = 0;
210 
211  USDIMAGING_API
212  virtual void MarkRefineLevelDirty(UsdPrim const& prim,
213  SdfPath const& cachePath,
214  UsdImagingIndexProxy* index);
215 
216  USDIMAGING_API
217  virtual void MarkReprDirty(UsdPrim const& prim,
218  SdfPath const& cachePath,
219  UsdImagingIndexProxy* index);
220 
221  USDIMAGING_API
222  virtual void MarkCullStyleDirty(UsdPrim const& prim,
223  SdfPath const& cachePath,
224  UsdImagingIndexProxy* index);
225 
226  USDIMAGING_API
227  virtual void MarkRenderTagDirty(UsdPrim const& prim,
228  SdfPath const& cachePath,
229  UsdImagingIndexProxy* index);
230 
231  USDIMAGING_API
232  virtual void MarkTransformDirty(UsdPrim const& prim,
233  SdfPath const& cachePath,
234  UsdImagingIndexProxy* index);
235 
236  USDIMAGING_API
237  virtual void MarkVisibilityDirty(UsdPrim const& prim,
238  SdfPath const& cachePath,
239  UsdImagingIndexProxy* index);
240 
241  USDIMAGING_API
242  virtual void MarkMaterialDirty(UsdPrim const& prim,
243  SdfPath const& cachePath,
244  UsdImagingIndexProxy* index);
245 
246  USDIMAGING_API
247  virtual void MarkLightParamsDirty(UsdPrim const& prim,
248  SdfPath const& cachePath,
249  UsdImagingIndexProxy* index);
250 
251  USDIMAGING_API
252  virtual void MarkWindowPolicyDirty(UsdPrim const& prim,
253  SdfPath const& cachePath,
254  UsdImagingIndexProxy* index);
255 
256  // ---------------------------------------------------------------------- //
258  // ---------------------------------------------------------------------- //
259  USDIMAGING_API
260  virtual void InvokeComputation(SdfPath const& cachePath,
261  HdExtComputationContext* context);
262 
263  // ---------------------------------------------------------------------- //
265  // ---------------------------------------------------------------------- //
266 
268  USDIMAGING_API
269  virtual std::vector<VtArray<TfToken>>
270  GetInstanceCategories(UsdPrim const& prim);
271 
274  USDIMAGING_API
276  UsdPrim const& instancerPrim,
277  SdfPath const& instancerPath,
278  UsdTimeCode time) const;
279 
282  USDIMAGING_API
283  virtual size_t SampleInstancerTransform(
284  UsdPrim const& instancerPrim,
285  SdfPath const& instancerPath,
286  UsdTimeCode time,
287  size_t maxNumSamples,
288  float *sampleTimes,
289  GfMatrix4d *sampleValues);
290 
292  USDIMAGING_API
293  virtual SdfPath GetInstancerId(
294  UsdPrim const& usdPrim,
295  SdfPath const& cachePath) const;
296 
298  USDIMAGING_API
299  virtual SdfPathVector GetInstancerPrototypes(
300  UsdPrim const& usdPrim,
301  SdfPath const& cachePath) const;
302 
308  USDIMAGING_API
309  virtual size_t
310  SamplePrimvar(UsdPrim const& usdPrim,
311  SdfPath const& cachePath,
312  TfToken const& key,
313  UsdTimeCode time,
314  size_t maxNumSamples,
315  float *sampleTimes,
316  VtValue *sampleValues,
317  VtIntArray *sampleIndices);
318 
320  USDIMAGING_API
321  virtual PxOsdSubdivTags GetSubdivTags(UsdPrim const& usdPrim,
322  SdfPath const& cachePath,
323  UsdTimeCode time) const;
324 
325  // ---------------------------------------------------------------------- //
327  // ---------------------------------------------------------------------- //
328 
329  // NOTE: This method is currently only used by PointInstancer
330  // style instances, and not instanceable-references.
331 
335  USDIMAGING_API
337  SdfPath const &instancerPath,
338  SdfPath const &protoInstancerPath,
339  UsdTimeCode time) const;
340 
341  // ---------------------------------------------------------------------- //
343  // ---------------------------------------------------------------------- //
344 
345  USDIMAGING_API
346  virtual SdfPath GetScenePrimPath(SdfPath const& cachePath,
347  int instanceIndex,
348  HdInstancerContext *instancerCtx) const;
349 
350  // Add the given usdPrim to the HdSelection object, to mark it for
351  // selection highlighting. cachePath is the path of the object referencing
352  // this adapter.
353  //
354  // If an instance index is provided to Delegate::PopulateSelection, it's
355  // interpreted as a hydra instance index and left unchanged (to make
356  // picking/selection round-tripping work). Otherwise, instance adapters
357  // will build up a composite instance index range at each level.
358  //
359  // Consider:
360  // /World/A (2 instances)
361  // /B (2 instances)
362  // /C (gprim)
363  // ... to select /World/A, instance 0, you want to select cartesian
364  // coordinates (0, *) -> (0, 0) and (0, 1). The flattened representation
365  // of this is:
366  // index = coordinate[0] * instance_count[1] + coordinate[1]
367  // Likewise, for one more nesting level you get:
368  // index = c[0] * count[1] * count[2] + c[1] * count[2] + c[2]
369  // ... since the adapter for /World/A has no idea what count[1+] are,
370  // this needs to be built up. The delegate initially sets
371  // parentInstanceIndices to []. /World/A sets this to [0]. /World/A/B,
372  // since it is selecting *, adds all possible instance indices:
373  // 0 * 2 + 0 = 0, 0 * 2 + 1 = 1. /World/A/B/C is a gprim, and adds
374  // instances [0,1] to its selection.
375  USDIMAGING_API
376  virtual bool PopulateSelection(
377  HdSelection::HighlightMode const& highlightMode,
378  SdfPath const &cachePath,
379  UsdPrim const &usdPrim,
380  int const hydraInstanceIndex,
381  VtIntArray const &parentInstanceIndices,
382  HdSelectionSharedPtr const &result) const;
383 
384  // ---------------------------------------------------------------------- //
386  // ---------------------------------------------------------------------- //
387 
388  USDIMAGING_API
389  virtual HdVolumeFieldDescriptorVector
390  GetVolumeFieldDescriptors(UsdPrim const& usdPrim, SdfPath const &id,
391  UsdTimeCode time) const;
392 
393  // ---------------------------------------------------------------------- //
395  // ---------------------------------------------------------------------- //
396 
398  USDIMAGING_API
400 
402  USDIMAGING_API
403  void SetDelegate(UsdImagingDelegate* delegate);
404 
405  USDIMAGING_API
406  bool IsChildPath(SdfPath const& path) const;
407 
411  USDIMAGING_API
412  virtual bool GetVisible(
413  UsdPrim const& prim,
414  SdfPath const& cachePath,
415  UsdTimeCode time) const;
416 
421  USDIMAGING_API
422  virtual TfToken GetPurpose(
423  UsdPrim const& prim,
424  SdfPath const& cachePath,
425  TfToken const& instanceInheritablePurpose) const;
426 
431  USDIMAGING_API
432  TfToken GetInheritablePurpose(UsdPrim const& prim) const;
433 
437  USDIMAGING_API
438  virtual GfMatrix4d GetTransform(UsdPrim const& prim,
439  SdfPath const& cachePath,
440  UsdTimeCode time,
441  bool ignoreRootTransform = false) const;
442 
444  USDIMAGING_API
445  virtual size_t SampleTransform(UsdPrim const& prim,
446  SdfPath const& cachePath,
447  UsdTimeCode time,
448  size_t maxNumSamples,
449  float *sampleTimes,
450  GfMatrix4d *sampleValues);
451 
456  USDIMAGING_API
457  virtual VtValue Get(UsdPrim const& prim,
458  SdfPath const& cachePath,
459  TfToken const& key,
460  UsdTimeCode time,
461  VtIntArray *outIndices) const;
462 
464  USDIMAGING_API
465  virtual HdCullStyle GetCullStyle(UsdPrim const& prim,
466  SdfPath const& cachePath,
467  UsdTimeCode time) const;
468 
471  USDIMAGING_API
472  SdfPath GetMaterialUsdPath(UsdPrim const& prim) const;
473 
476  USDIMAGING_API
477  TfToken GetModelDrawMode(UsdPrim const& prim);
478 
484  USDIMAGING_API
486  UsdTimeCode time) const;
487 
492  USDIMAGING_API
493  virtual VtValue GetTopology(UsdPrim const& prim,
494  SdfPath const& cachePath,
495  UsdTimeCode time) const;
496 
499  USDIMAGING_API
500  virtual GfRange3d GetExtent(UsdPrim const& prim,
501  SdfPath const& cachePath,
502  UsdTimeCode time) const;
503 
505  USDIMAGING_API
506  virtual bool GetDoubleSided(UsdPrim const& prim,
507  SdfPath const& cachePath,
508  UsdTimeCode time) const;
509 
510  USDIMAGING_API
511  virtual SdfPath GetMaterialId(UsdPrim const& prim,
512  SdfPath const& cachePath,
513  UsdTimeCode time) const;
514 
515  USDIMAGING_API
516  virtual VtValue GetMaterialResource(UsdPrim const& prim,
517  SdfPath const& cachePath,
518  UsdTimeCode time) const;
519 
520  // ---------------------------------------------------------------------- //
522  // ---------------------------------------------------------------------- //
523  USDIMAGING_API
524  virtual const TfTokenVector &GetExtComputationSceneInputNames(
525  SdfPath const& cachePath) const;
526 
527  USDIMAGING_API
528  virtual HdExtComputationInputDescriptorVector
529  GetExtComputationInputs(UsdPrim const& prim,
530  SdfPath const& cachePath,
531  const UsdImagingInstancerContext* instancerContext)
532  const;
533 
534  USDIMAGING_API
535  virtual HdExtComputationOutputDescriptorVector
536  GetExtComputationOutputs(UsdPrim const& prim,
537  SdfPath const& cachePath,
538  const UsdImagingInstancerContext* instancerContext)
539  const;
540 
541  USDIMAGING_API
542  virtual HdExtComputationPrimvarDescriptorVector
543  GetExtComputationPrimvars(
544  UsdPrim const& prim,
545  SdfPath const& cachePath,
546  HdInterpolation interpolation,
547  const UsdImagingInstancerContext* instancerContext) const;
548 
549  USDIMAGING_API
550  virtual VtValue
551  GetExtComputationInput(
552  UsdPrim const& prim,
553  SdfPath const& cachePath,
554  TfToken const& name,
555  UsdTimeCode time,
556  const UsdImagingInstancerContext* instancerContext) const;
557 
558  USDIMAGING_API
559  virtual size_t
560  SampleExtComputationInput(
561  UsdPrim const& prim,
562  SdfPath const& cachePath,
563  TfToken const& name,
564  UsdTimeCode time,
565  const UsdImagingInstancerContext* instancerContext,
566  size_t maxSampleCount,
567  float *sampleTimes,
568  VtValue *sampleValues);
569 
570  USDIMAGING_API
571  virtual std::string
572  GetExtComputationKernel(
573  UsdPrim const& prim,
574  SdfPath const& cachePath,
575  const UsdImagingInstancerContext* instancerContext) const;
576 
577  USDIMAGING_API
578  virtual VtValue
579  GetInstanceIndices(UsdPrim const& instancerPrim,
580  SdfPath const& instancerCachePath,
581  SdfPath const& prototypeCachePath,
582  UsdTimeCode time) const;
583 
584  // ---------------------------------------------------------------------- //
586  // ---------------------------------------------------------------------- //
587 
589  virtual bool IsSupported(UsdImagingIndexProxy const* index) const {
590  return true;
591  }
592 
593 protected:
594  using Keys = UsdImagingPrimvarDescCache::Key;
595 
596  template <typename T>
597  T _Get(UsdPrim const& prim, TfToken const& attrToken,
598  UsdTimeCode time) const {
599  T value;
600  prim.GetAttribute(attrToken).Get<T>(&value, time);
601  return value;
602  }
603 
604  template <typename T>
605  void _GetPtr(UsdPrim const& prim, TfToken const& key, UsdTimeCode time,
606  T* out) const {
607  prim.GetAttribute(key).Get<T>(out, time);
608  }
609 
610  USDIMAGING_API
611  UsdImagingPrimvarDescCache* _GetPrimvarDescCache() const;
612 
613  USDIMAGING_API
614  UsdPrim _GetPrim(SdfPath const& usdPath) const;
615 
616  // Returns the prim adapter for the given \p prim, or an invalid pointer if
617  // no adapter exists. If \p prim is an instance and \p ignoreInstancing
618  // is \c true, the instancing adapter will be ignored and an adapter will
619  // be looked up based on \p prim's type.
620  USDIMAGING_API
621  const UsdImagingPrimAdapterSharedPtr&
622  _GetPrimAdapter(UsdPrim const& prim, bool ignoreInstancing = false) const;
623 
624  USDIMAGING_API
625  const UsdImagingPrimAdapterSharedPtr&
626  _GetAdapter(TfToken const& adapterKey) const;
627 
628  // XXX: Transitional API
629  // Returns the instance proxy prim path for a USD-instanced prim, given the
630  // instance chain leading to that prim. The paths are sorted from more to
631  // less local; the first path is the prim path (possibly in prototype), then
632  // instance paths (possibly in prototype); the last path is the prim or
633  // instance path in the scene.
634  USDIMAGING_API
635  SdfPath _GetPrimPathFromInstancerChain(
636  SdfPathVector const& instancerChain) const;
637 
638  USDIMAGING_API
639  UsdTimeCode _GetTimeWithOffset(float offset) const;
640 
641  // Converts \p cachePath to the path in the render index.
642  USDIMAGING_API
643  SdfPath _ConvertCachePathToIndexPath(SdfPath const& cachePath) const;
644 
645  // Converts \p indexPath to the path in the USD stage
646  USDIMAGING_API
647  SdfPath _ConvertIndexPathToCachePath(SdfPath const& indexPath) const;
648 
649  // Returns the material binding purpose from the renderer delegate.
650  USDIMAGING_API
651  TfToken _GetMaterialBindingPurpose() const;
652 
653  // Returns the material contexts from the renderer delegate.
654  USDIMAGING_API
655  TfTokenVector _GetMaterialRenderContexts() const;
656 
657  // Returns true if render delegate wants primvars to be filtered based.
658  // This will filter the primvars based on the bound material primvar needs.
659  USDIMAGING_API
660  bool _IsPrimvarFilteringNeeded() const;
661 
662  // Returns the shader source type from the render delegate.
663  USDIMAGING_API
664  TfTokenVector _GetShaderSourceTypes() const;
665 
666  // Returns \c true if \p usdPath is included in the scene delegate's
667  // invised path list.
668  USDIMAGING_API
669  bool _IsInInvisedPaths(SdfPath const& usdPath) const;
670 
671  // Determines if an attribute is varying and if so, sets the given
672  // \p dirtyFlag in the \p dirtyFlags and increments a perf counter. Returns
673  // true if the attribute is varying.
674  //
675  // If \p exists is non-null, _IsVarying will store whether the attribute
676  // was found. If the attribute is not found, it counts as non-varying.
677  //
678  // This only sets the dirty bit, never un-sets. The caller is responsible
679  // for setting the initial state correctly.
680  USDIMAGING_API
681  bool _IsVarying(UsdPrim prim, TfToken const& attrName,
682  HdDirtyBits dirtyFlag, TfToken const& perfToken,
683  HdDirtyBits* dirtyFlags, bool isInherited,
684  bool* exists = nullptr) const;
685 
686  // Determines if the prim's transform (CTM) is varying and if so, sets the
687  // given \p dirtyFlag in the \p dirtyFlags and increments a perf counter.
688  // Returns true if the prim's transform is varying.
689  //
690  // This only sets the dirty bit, never un-sets. The caller is responsible
691  // for setting the initial state correctly.
692  USDIMAGING_API
693  bool _IsTransformVarying(UsdPrim prim,
694  HdDirtyBits dirtyFlag,
695  TfToken const& perfToken,
696  HdDirtyBits* dirtyFlags) const;
697 
698  // Convenience method for adding or updating a primvar descriptor.
699  // Role defaults to empty token (none). Indexed defaults to false.
700  USDIMAGING_API
701  void _MergePrimvar(
702  HdPrimvarDescriptorVector* vec,
703  TfToken const& name,
704  HdInterpolation interp,
705  TfToken const& role = TfToken(),
706  bool indexed = false) const;
707 
708  // Convenience method for removing a primvar descriptor.
709  USDIMAGING_API
710  void _RemovePrimvar(
711  HdPrimvarDescriptorVector* vec,
712  TfToken const& name) const;
713 
714  // Convenience method for computing a primvar. The primvar will only be
715  // added to the list of prim desc if there is no primvar of the same
716  // name already present. Thus, "local" primvars should be merged before
717  // inherited primvars.
718  USDIMAGING_API
719  void _ComputeAndMergePrimvar(
720  UsdPrim const& prim,
721  UsdGeomPrimvar const& primvar,
722  UsdTimeCode time,
723  HdPrimvarDescriptorVector* primvarDescs,
724  HdInterpolation *interpOverride = nullptr) const;
725 
726  // Returns true if the property name has the "primvars:" prefix.
727  USDIMAGING_API
728  static bool _HasPrimvarsPrefix(TfToken const& propertyName);
729 
730  // Convenience methods to figure out what changed about the primvar and
731  // return the appropriate dirty bit.
732  // Caller can optionally pass in a dirty bit to set for primvar value
733  // changes. This is useful for attributes that have a special dirty bit
734  // such as normals and widths.
735  //
736  // Handle USD attributes that are treated as primvars by Hydra. This
737  // requires the interpolation to be passed in, as well as the primvar
738  // name passed to Hydra.
739  USDIMAGING_API
740  HdDirtyBits _ProcessNonPrefixedPrimvarPropertyChange(
741  UsdPrim const& prim,
742  SdfPath const& cachePath,
743  TfToken const& propertyName,
744  TfToken const& primvarName,
745  HdInterpolation const& primvarInterp,
746  HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar) const;
747 
748  // Handle UsdGeomPrimvars that use the "primvars:" prefix, while also
749  // accommodating inheritance.
750  USDIMAGING_API
751  HdDirtyBits _ProcessPrefixedPrimvarPropertyChange(
752  UsdPrim const& prim,
753  SdfPath const& cachePath,
754  TfToken const& propertyName,
755  HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar,
756  bool inherited = true) const;
757 
758  virtual void _RemovePrim(SdfPath const& cachePath,
759  UsdImagingIndexProxy* index) = 0;
760 
761  // Utility to resync bound dependencies of a particular usd path.
762  // This is necessary for the resync processing of certain prim types
763  // (e.g. materials).
764  USDIMAGING_API
765  void _ResyncDependents(SdfPath const& usdPath,
766  UsdImagingIndexProxy *index);
767 
768  USDIMAGING_API
769  UsdImaging_CollectionCache& _GetCollectionCache() const;
770 
771  USDIMAGING_API
772  UsdImaging_CoordSysBindingStrategy::value_type
773  _GetCoordSysBindings(UsdPrim const& prim) const;
774 
775  USDIMAGING_API
776  UsdImaging_InheritedPrimvarStrategy::value_type
777  _GetInheritedPrimvars(UsdPrim const& prim) const;
778 
779  USDIMAGING_API
780  GfInterval _GetCurrentTimeSamplingInterval();
781 
782  USDIMAGING_API
783  Usd_PrimFlagsConjunction _GetDisplayPredicate() const;
784 
785  USDIMAGING_API
786  Usd_PrimFlagsConjunction _GetDisplayPredicateForPrototypes() const;
787 
788  USDIMAGING_API
789  bool _DoesDelegateSupportCoordSys() const;
790 
791  // Conversion functions between usd and hydra enums.
792  USDIMAGING_API
793  static HdInterpolation _UsdToHdInterpolation(TfToken const& usdInterp);
794  USDIMAGING_API
795  static TfToken _UsdToHdRole(TfToken const& usdRole);
796 
797 private:
798  UsdImagingDelegate* _delegate;
799 };
800 
801 class UsdImagingPrimAdapterFactoryBase : public TfType::FactoryBase {
802 public:
803  virtual UsdImagingPrimAdapterSharedPtr New() const = 0;
804 };
805 
806 template <class T>
807 class UsdImagingPrimAdapterFactory : public UsdImagingPrimAdapterFactoryBase {
808 public:
809  virtual UsdImagingPrimAdapterSharedPtr New() const
810  {
811  return std::make_shared<T>();
812  }
813 };
814 
815 
816 PXR_NAMESPACE_CLOSE_SCOPE
817 
818 #endif // PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H
Interface class that defines the execution environment for the client to run a computation.
Tags for non-hierarchial subdiv surfaces.
Definition: subdivTags.h:41
Basic type: 3-dimensional floating point range.
Definition: range3d.h:64
virtual USDIMAGING_API HdDirtyBits ProcessPrimChange(UsdPrim const &prim, SdfPath const &cachePath, TfTokenVector const &changedFields)
Returns a bit mask of attributes to be updated, or HdChangeTracker::AllDirty if the entire prim must ...
virtual USDIMAGING_API PxOsdSubdivTags GetSubdivTags(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const
Get the subdiv tags for this prim.
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
Definition: selection.h:55
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Definition: indexProxy.h:47
USDIMAGING_API TfToken GetInheritablePurpose(UsdPrim const &prim) const
Returns the purpose token for prim, but only if it is inheritable by child prims (i.e.
USDIMAGING_API void SetDelegate(UsdImagingDelegate *delegate)
A thread-local XformCache provided by the delegate.
virtual void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=nullptr) const =0
Populates the cache for the given prim, time and requestedBits.
virtual USDIMAGING_API void ProcessPrimRemoval(SdfPath const &cachePath, UsdImagingIndexProxy *index)
Removes all associated Rprims and dependencies from the render index without scheduling them for repo...
Base class of all factory types.
Definition: type.h:73
virtual USDIMAGING_API size_t SamplePrimvar(UsdPrim const &usdPrim, SdfPath const &cachePath, TfToken const &key, UsdTimeCode time, size_t maxNumSamples, float *sampleTimes, VtValue *sampleValues, VtIntArray *sampleIndices)
Sample the primvar for the given prim.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
virtual USDIMAGING_API bool GetDoubleSided(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Reads double-sided from the given prim. If not authored, returns false.
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
virtual bool IsSupported(UsdImagingIndexProxy const *index) const
Returns true if the adapter can be populated into the target index.
Definition: primAdapter.h:589
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
Base class for all PrimAdapters.
Definition: primAdapter.h:65
USDIMAGING_API TfToken GetModelDrawMode(UsdPrim const &prim)
Gets the model:drawMode attribute for the given prim, walking up the namespace if necessary...
virtual USDIMAGING_API GfMatrix4d GetInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time) const
Get the instancer transform for the given prim.
virtual void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=nullptr) const =0
For the given prim, variability is detected and stored in timeVaryingBits.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:132
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A basic mathematical interval class.
Definition: interval.h:50
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:229
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
A cache for primvar descriptors.
bool Get(T *value, UsdTimeCode time=UsdTimeCode::Default()) const
Perform value resolution to fetch the value of this attribute at the requested UsdTimeCode time...
Definition: attribute.h:431
virtual USDIMAGING_API GfRange3d GetExtent(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Reads the extent from the given prim.
virtual USDIMAGING_API SdfPath GetInstancerId(UsdPrim const &usdPrim, SdfPath const &cachePath) const
Return the instancerId for this prim.
virtual USDIMAGING_API size_t SampleTransform(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, size_t maxNumSamples, float *sampleTimes, GfMatrix4d *sampleValues)
Samples the transform for the given prim.
USDIMAGING_API GfMatrix4d GetRootTransform() const
The root transform provided by the delegate.
virtual USDIMAGING_API bool GetVisible(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Returns true if the given prim is visible, taking into account inherited visibility values...
virtual USDIMAGING_API size_t SampleInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time, size_t maxNumSamples, float *sampleTimes, GfMatrix4d *sampleValues)
Sample the instancer transform for the given prim.
USDIMAGING_API SdfPath GetMaterialUsdPath(UsdPrim const &prim) const
Gets the material path for the given prim, walking up namespace if necessary.
virtual USDIMAGING_API HdCullStyle GetCullStyle(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Gets the cullstyle of a specific path in the scene graph.
virtual USDIMAGING_API VtValue Get(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &key, UsdTimeCode time, VtIntArray *outIndices) const
Gets the value of the parameter named key for the given prim (which has the given cache path) and giv...
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
Return a UsdAttribute with the name attrName.
Object used by instancer prim adapters to pass along context about the instancer and instance prim to...
Schema wrapper for UsdAttribute for authoring and introspecting attributes that are primvars...
Definition: primvar.h:260
virtual HdDirtyBits ProcessPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &propertyName)=0
Returns a bit mask of attributes to be updated, or HdChangeTracker::AllDirty if the entire prim must ...
virtual SdfPath Populate(UsdPrim const &prim, UsdImagingIndexProxy *index, UsdImagingInstancerContext const *instancerContext=nullptr)=0
Called to populate the RenderIndex for this UsdPrim.
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
Definition: delegate.h:87
virtual USDIMAGING_API SdfPathVector GetInstancerPrototypes(UsdPrim const &usdPrim, SdfPath const &cachePath) const
Return the list of known prototypes of this prim.
virtual USDIMAGING_API GfMatrix4d GetRelativeInstancerTransform(SdfPath const &instancerPath, SdfPath const &protoInstancerPath, UsdTimeCode time) const
Returns the transform of protoInstancerPath relative to instancerPath.
virtual USDIMAGING_API void ProcessPrimResync(SdfPath const &cachePath, UsdImagingIndexProxy *index)
When a PrimResync event occurs, the prim may have been deleted entirely, adapter plug-ins should over...
virtual USDIMAGING_API GfMatrix4d GetTransform(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, bool ignoreRootTransform=false) const
Fetches the transform for the given prim at the given time from a pre-computed cache of prim transfor...
USDIMAGING_API VtArray< VtIntArray > GetPerPrototypeIndices(UsdPrim const &prim, UsdTimeCode time) const
Computes the per-prototype instance indices for a UsdGeomPointInstancer.
virtual USDIMAGING_API TfToken GetPurpose(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &instanceInheritablePurpose) const
Returns the purpose token for prim.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
virtual USDIMAGING_API std::vector< VtArray< TfToken > > GetInstanceCategories(UsdPrim const &prim)
Return an array of the categories used by each instance.
virtual USDIMAGING_API VtValue GetTopology(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Gets the topology object of a specific Usd prim.