HDK
 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 
27 /// \file usdImaging/primAdapter.h
28 
29 #include "pxr/pxr.h"
35 
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 
49 
50 class UsdPrim;
51 
52 // Forward declaration for nested class.
53 class UsdImagingDelegate;
57 
59  std::shared_ptr<class UsdImagingPrimAdapter>;
60 
61 /// \class UsdImagingPrimAdapter
62 ///
63 /// Base class for all PrimAdapters.
64 ///
66  : public std::enable_shared_from_this<UsdImagingPrimAdapter>
67 {
68 public:
69 
70  // ---------------------------------------------------------------------- //
71  /// \name Initialization
72  // ---------------------------------------------------------------------- //
73 
75  {}
76 
78  virtual ~UsdImagingPrimAdapter();
79 
80  /// Called to populate the RenderIndex for this UsdPrim. The adapter is
81  /// expected to create one or more prims in the render index using the
82  /// given proxy.
83  virtual SdfPath Populate(UsdPrim const& prim,
86  instancerContext = nullptr) = 0;
87 
88  // Indicates whether population traversal should be pruned based on
89  // prim-specific features (like whether it's imageable).
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).
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.
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.
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.
139  virtual bool CanPopulateUsdInstance() const;
140 
141  // ---------------------------------------------------------------------- //
142  /// \name Parallel Setup and Resolve
143  // ---------------------------------------------------------------------- //
144 
145  /// For the given \p prim, variability is detected and
146  /// stored in \p timeVaryingBits. Initial values are cached into the value
147  /// cache.
148  ///
149  /// This method is expected to be called from multiple threads.
150  virtual void TrackVariability(UsdPrim const& prim,
151  SdfPath const& cachePath,
152  HdDirtyBits* timeVaryingBits,
154  instancerContext = nullptr) const = 0;
155 
156  /// Populates the \p cache for the given \p prim, \p time and \p
157  /// requestedBits.
158  ///
159  /// This method is expected to be called from multiple threads.
160  virtual void UpdateForTime(UsdPrim const& prim,
161  SdfPath const& cachePath,
163  HdDirtyBits requestedBits,
165  instancerContext = nullptr) const = 0;
166 
167  // ---------------------------------------------------------------------- //
168  /// \name Change Processing
169  // ---------------------------------------------------------------------- //
170 
171  /// Returns a bit mask of attributes to be updated, or
172  /// HdChangeTracker::AllDirty if the entire prim must be resynchronized.
173  ///
174  /// \p changedFields contains a list of changed scene description fields
175  /// for this prim. This may be empty in certain cases, like the addition
176  /// of an inert prim spec for the given \p prim.
177  ///
178  /// The default implementation returns HdChangeTracker::AllDirty if any of
179  /// the changed fields are plugin metadata fields, HdChangeTracker::Clean
180  /// otherwise.
182  virtual HdDirtyBits ProcessPrimChange(UsdPrim const& prim,
183  SdfPath const& cachePath,
184  TfTokenVector const& changedFields);
185 
186  /// Returns a bit mask of attributes to be updated, or
187  /// HdChangeTracker::AllDirty if the entire prim must be resynchronized.
188  virtual HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
189  SdfPath const& cachePath,
190  TfToken const& propertyName) = 0;
191 
192  /// When a PrimResync event occurs, the prim may have been deleted entirely,
193  /// adapter plug-ins should override this method to free any per-prim state
194  /// that was accumulated in the adapter.
196  virtual void ProcessPrimResync(SdfPath const& cachePath,
198 
199  /// Removes all associated Rprims and dependencies from the render index
200  /// without scheduling them for repopulation.
202  virtual void ProcessPrimRemoval(SdfPath const& cachePath,
204 
205 
206  virtual void MarkDirty(UsdPrim const& prim,
207  SdfPath const& cachePath,
208  HdDirtyBits dirty,
210 
212  virtual void MarkRefineLevelDirty(UsdPrim const& prim,
213  SdfPath const& cachePath,
215 
217  virtual void MarkReprDirty(UsdPrim const& prim,
218  SdfPath const& cachePath,
220 
222  virtual void MarkCullStyleDirty(UsdPrim const& prim,
223  SdfPath const& cachePath,
225 
227  virtual void MarkRenderTagDirty(UsdPrim const& prim,
228  SdfPath const& cachePath,
230 
232  virtual void MarkTransformDirty(UsdPrim const& prim,
233  SdfPath const& cachePath,
235 
237  virtual void MarkVisibilityDirty(UsdPrim const& prim,
238  SdfPath const& cachePath,
240 
242  virtual void MarkMaterialDirty(UsdPrim const& prim,
243  SdfPath const& cachePath,
245 
247  virtual void MarkLightParamsDirty(UsdPrim const& prim,
248  SdfPath const& cachePath,
250 
252  virtual void MarkWindowPolicyDirty(UsdPrim const& prim,
253  SdfPath const& cachePath,
255 
256  // ---------------------------------------------------------------------- //
257  /// \name Computations
258  // ---------------------------------------------------------------------- //
260  virtual void InvokeComputation(SdfPath const& cachePath,
261  HdExtComputationContext* context);
262 
263  // ---------------------------------------------------------------------- //
264  /// \name Instancing
265  // ---------------------------------------------------------------------- //
266 
267  /// Return an array of the categories used by each instance.
269  virtual std::vector<VtArray<TfToken>>
270  GetInstanceCategories(UsdPrim const& prim);
271 
272  /// Get the instancer transform for the given prim.
273  /// \see HdSceneDelegate::GetInstancerTransform()
276  UsdPrim const& instancerPrim,
277  SdfPath const& instancerPath,
278  UsdTimeCode time) const;
279 
280  /// Sample the instancer transform for the given prim.
281  /// \see HdSceneDelegate::SampleInstancerTransform()
283  virtual size_t SampleInstancerTransform(
284  UsdPrim const& instancerPrim,
285  SdfPath const& instancerPath,
287  size_t maxNumSamples,
288  float *sampleTimes,
289  GfMatrix4d *sampleValues);
290 
291  /// Return the instancerId for this prim.
293  virtual SdfPath GetInstancerId(
294  UsdPrim const& usdPrim,
295  SdfPath const& cachePath) const;
296 
297  /// Return the list of known prototypes of this prim.
300  UsdPrim const& usdPrim,
301  SdfPath const& cachePath) const;
302 
303  /// Sample the primvar for the given prim. If *sampleIndices is not nullptr
304  /// and the primvar has indices, it will sample the unflattened primvar and
305  /// set *sampleIndices to the primvar's sampled indices.
306  /// \see HdSceneDelegate::SamplePrimvar() and
307  /// HdSceneDelegate::SampleIndexedPrimvar()
309  virtual size_t
310  SamplePrimvar(UsdPrim const& usdPrim,
311  SdfPath const& cachePath,
312  TfToken const& key,
314  size_t maxNumSamples,
315  float *sampleTimes,
316  VtValue *sampleValues,
317  VtIntArray *sampleIndices);
318 
319  /// Get the subdiv tags for this prim.
321  virtual PxOsdSubdivTags GetSubdivTags(UsdPrim const& usdPrim,
322  SdfPath const& cachePath,
323  UsdTimeCode time) const;
324 
325  // ---------------------------------------------------------------------- //
326  /// \name Nested instancing support
327  // ---------------------------------------------------------------------- //
328 
329  // NOTE: This method is currently only used by PointInstancer
330  // style instances, and not instanceable-references.
331 
332  /// Returns the transform of \p protoInstancerPath relative to
333  /// \p instancerPath. \p instancerPath must be managed by this
334  /// adapter.
337  SdfPath const &instancerPath,
338  SdfPath const &protoInstancerPath,
339  UsdTimeCode time) const;
340 
341  // ---------------------------------------------------------------------- //
342  /// \name Selection
343  // ---------------------------------------------------------------------- //
344 
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.
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  // ---------------------------------------------------------------------- //
385  /// \name Volume field information
386  // ---------------------------------------------------------------------- //
387 
390  GetVolumeFieldDescriptors(UsdPrim const& usdPrim, SdfPath const &id,
391  UsdTimeCode time) const;
392 
393  // ---------------------------------------------------------------------- //
394  /// \name Utilities
395  // ---------------------------------------------------------------------- //
396 
397  /// The root transform provided by the delegate.
400 
401  /// A thread-local XformCache provided by the delegate.
403  void SetDelegate(UsdImagingDelegate* delegate);
404 
406  bool IsChildPath(SdfPath const& path) const;
407 
408  /// Returns true if the given prim is visible, taking into account inherited
409  /// visibility values. Inherited values are strongest, Usd has no notion of
410  /// "super vis/invis".
412  virtual bool GetVisible(
413  UsdPrim const& prim,
414  SdfPath const& cachePath,
415  UsdTimeCode time) const;
416 
417  /// Returns the purpose token for \p prim. If a non-empty \p
418  /// instanceInheritablePurpose is specified and the prim doesn't have an
419  /// explicitly authored or inherited purpose, it may inherit the
420  /// instancer's purpose if the instance has an explicit purpose.
422  virtual TfToken GetPurpose(
423  UsdPrim const& prim,
424  SdfPath const& cachePath,
425  TfToken const& instanceInheritablePurpose) const;
426 
427  /// Returns the purpose token for \p prim, but only if it is inheritable
428  /// by child prims (i.e. it is an explicitly authored purpose on the prim
429  /// itself or one of the prim's ancestors), otherwise it returns the empty
430  /// token.
432  TfToken GetInheritablePurpose(UsdPrim const& prim) const;
433 
434  /// Fetches the transform for the given prim at the given time from a
435  /// pre-computed cache of prim transforms. Requesting transforms at
436  /// incoherent times is currently inefficient.
438  virtual GfMatrix4d GetTransform(UsdPrim const& prim,
439  SdfPath const& cachePath,
441  bool ignoreRootTransform = false) const;
442 
443  /// Samples the transform for the given prim.
445  virtual size_t SampleTransform(UsdPrim const& prim,
446  SdfPath const& cachePath,
448  size_t maxNumSamples,
449  float *sampleTimes,
450  GfMatrix4d *sampleValues);
451 
452  /// Gets the value of the parameter named key for the given prim (which
453  /// has the given cache path) and given time. If outIndices is not nullptr
454  /// and the value has indices, it will return the unflattened value and set
455  /// outIndices to the value's associated indices.
457  virtual VtValue Get(UsdPrim const& prim,
458  SdfPath const& cachePath,
459  TfToken const& key,
460  UsdTimeCode time,
461  VtIntArray *outIndices) const;
462 
463  /// Gets the cullstyle of a specific path in the scene graph.
465  virtual HdCullStyle GetCullStyle(UsdPrim const& prim,
466  SdfPath const& cachePath,
467  UsdTimeCode time) const;
468 
469  /// Gets the material path for the given prim, walking up namespace if
470  /// necessary.
472  SdfPath GetMaterialUsdPath(UsdPrim const& prim) const;
473 
474  /// Gets the model:drawMode attribute for the given prim, walking up
475  /// the namespace if necessary.
477  TfToken GetModelDrawMode(UsdPrim const& prim);
478 
479  /// Computes the per-prototype instance indices for a UsdGeomPointInstancer.
480  /// XXX: This needs to be defined on the base class, to have access to the
481  /// delegate, but it's a clear violation of abstraction. This call is only
482  /// legal for prims of type UsdGeomPointInstancer; in other cases, the
483  /// returned array will be empty and the computation will issue errors.
486  UsdTimeCode time) const;
487 
488  /// Gets the topology object of a specific Usd prim. If the
489  /// adapter is a mesh it will return an HdMeshTopology,
490  /// if it is of type basis curves, it will return an HdBasisCurvesTopology.
491  /// If the adapter does not have a topology, it returns an empty VtValue.
493  virtual VtValue GetTopology(UsdPrim const& prim,
494  SdfPath const& cachePath,
495  UsdTimeCode time) const;
496 
497  /// Reads the extent from the given prim. If the extent is not authored,
498  /// an empty GfRange3d is returned, the extent will not be computed.
500  virtual GfRange3d GetExtent(UsdPrim const& prim,
501  SdfPath const& cachePath,
502  UsdTimeCode time) const;
503 
504  /// Reads double-sided from the given prim. If not authored, returns false
506  virtual bool GetDoubleSided(UsdPrim const& prim,
507  SdfPath const& cachePath,
508  UsdTimeCode time) const;
509 
511  virtual SdfPath GetMaterialId(UsdPrim const& prim,
512  SdfPath const& cachePath,
513  UsdTimeCode time) const;
514 
516  virtual VtValue GetMaterialResource(UsdPrim const& prim,
517  SdfPath const& cachePath,
518  UsdTimeCode time) const;
519 
520  // ---------------------------------------------------------------------- //
521  /// \name ExtComputations
522  // ---------------------------------------------------------------------- //
525  SdfPath const& cachePath) const;
526 
529  GetExtComputationInputs(UsdPrim const& prim,
530  SdfPath const& cachePath,
531  const UsdImagingInstancerContext* instancerContext)
532  const;
533 
536  GetExtComputationOutputs(UsdPrim const& prim,
537  SdfPath const& cachePath,
538  const UsdImagingInstancerContext* instancerContext)
539  const;
540 
544  UsdPrim const& prim,
545  SdfPath const& cachePath,
546  HdInterpolation interpolation,
547  const UsdImagingInstancerContext* instancerContext) const;
548 
550  virtual VtValue
552  UsdPrim const& prim,
553  SdfPath const& cachePath,
554  TfToken const& name,
556  const UsdImagingInstancerContext* instancerContext) const;
557 
559  virtual size_t
561  UsdPrim const& prim,
562  SdfPath const& cachePath,
563  TfToken const& name,
565  const UsdImagingInstancerContext* instancerContext,
566  size_t maxSampleCount,
567  float *sampleTimes,
568  VtValue *sampleValues);
569 
571  virtual std::string
573  UsdPrim const& prim,
574  SdfPath const& cachePath,
575  const UsdImagingInstancerContext* instancerContext) const;
576 
578  virtual VtValue
579  GetInstanceIndices(UsdPrim const& instancerPrim,
580  SdfPath const& instancerCachePath,
581  SdfPath const& prototypeCachePath,
582  UsdTimeCode time) const;
583 
584  // ---------------------------------------------------------------------- //
585  /// \name Render Index Compatibility
586  // ---------------------------------------------------------------------- //
587 
588  /// Returns true if the adapter can be populated into the target index.
589  virtual bool IsSupported(UsdImagingIndexProxy const* index) const {
590  return true;
591  }
592 
593 protected:
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 
612 
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.
622  _GetPrimAdapter(UsdPrim const& prim, bool ignoreInstancing = false) const;
623 
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.
636  SdfPathVector const& instancerChain) const;
637 
640 
641  // Converts \p cachePath to the path in the render index.
643  SdfPath _ConvertCachePathToIndexPath(SdfPath const& cachePath) const;
644 
645  // Converts \p indexPath to the path in the USD stage
647  SdfPath _ConvertIndexPathToCachePath(SdfPath const& indexPath) const;
648 
649  // Returns the material binding purpose from the renderer delegate.
652 
653  // Returns the material contexts from the renderer delegate.
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.
660  bool _IsPrimvarFilteringNeeded() const;
661 
662  // Returns the shader source type from the render delegate.
665 
666  // Returns \c true if \p usdPath is included in the scene delegate's
667  // invised path list.
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.
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.
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.
701  void _MergePrimvar(
703  TfToken const& name,
705  TfToken const& role = TfToken(),
706  bool indexed = false) const;
707 
708  // Convenience method for removing a primvar descriptor.
710  void _RemovePrimvar(
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.
720  UsdPrim const& prim,
721  UsdGeomPrimvar const& primvar,
723  HdPrimvarDescriptorVector* primvarDescs,
724  HdInterpolation *interpOverride = nullptr) const;
725 
726  // Returns true if the property name has the "primvars:" prefix.
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.
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.
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,
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).
765  void _ResyncDependents(SdfPath const& usdPath,
767 
770 
773  _GetCoordSysBindings(UsdPrim const& prim) const;
774 
777  _GetInheritedPrimvars(UsdPrim const& prim) const;
778 
781 
784 
787 
789  bool _DoesDelegateSupportCoordSys() const;
790 
791  // Conversion functions between usd and hydra enums.
793  static HdInterpolation _UsdToHdInterpolation(TfToken const& usdInterp);
795  static TfToken _UsdToHdRole(TfToken const& usdRole);
796 
797 private:
798  UsdImagingDelegate* _delegate;
799 };
800 
802 public:
803  virtual UsdImagingPrimAdapterSharedPtr New() const = 0;
804 };
805 
806 template <class T>
808 public:
810  {
811  return std::make_shared<T>();
812  }
813 };
814 
815 
817 
818 #endif // PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H
static USDIMAGING_API bool _HasPrimvarsPrefix(TfToken const &propertyName)
Returns true if the adapter can be populated into the target index.
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)
virtual USDIMAGING_API VtValue GetTopology(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
virtual USDIMAGING_API SdfPathVector GetInstancerPrototypes(UsdPrim const &usdPrim, SdfPath const &cachePath) const
Return the list of known prototypes of this prim.
virtual USDIMAGING_API void InvokeComputation(SdfPath const &cachePath, HdExtComputationContext *context)
virtual HdDirtyBits ProcessPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &propertyName)=0
virtual USDIMAGING_API PxOsdSubdivTags GetSubdivTags(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const
Get the subdiv tags for this prim.
HdCullStyle
Definition: enums.h:122
virtual UsdImagingPrimAdapterSharedPtr New() const =0
bool Get(T *value, UsdTimeCode time=UsdTimeCode::Default()) const
Definition: attribute.h:431
#define USDIMAGING_API
Definition: api.h:40
T _Get(UsdPrim const &prim, TfToken const &attrToken, UsdTimeCode time) const
Returns true if the adapter can be populated into the target index.
Definition: primAdapter.h:597
USDIMAGING_API Usd_PrimFlagsConjunction _GetDisplayPredicateForPrototypes() const
Returns true if the adapter can be populated into the target index.
USDIMAGING_API bool IsChildPath(SdfPath const &path) const
The root transform provided by the delegate.
USDIMAGING_API UsdImagingPrimvarDescCache * _GetPrimvarDescCache() const
Returns true if the adapter can be populated into the target index.
USDIMAGING_API void SetDelegate(UsdImagingDelegate *delegate)
A thread-local XformCache provided by the delegate.
USDIMAGING_API VtArray< VtIntArray > GetPerPrototypeIndices(UsdPrim const &prim, UsdTimeCode time) const
GT_API const UT_StringHolder time
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.
uint32_t HdDirtyBits
Definition: types.h:127
USDIMAGING_API UsdImaging_InheritedPrimvarStrategy::value_type _GetInheritedPrimvars(UsdPrim const &prim) const
Returns true if the adapter can be populated into the target index.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
virtual USDIMAGING_API SdfPath GetInstancerId(UsdPrim const &usdPrim, SdfPath const &cachePath) const
Return the instancerId for this prim.
std::vector< HdExtComputationInputDescriptor > HdExtComputationInputDescriptorVector
virtual void UpdateForTime(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, HdDirtyBits requestedBits, UsdImagingInstancerContext const *instancerContext=nullptr) const =0
virtual USDIMAGING_API GfMatrix4d GetTransform(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time, bool ignoreRootTransform=false) const
USDIMAGING_API SdfPath GetMaterialUsdPath(UsdPrim const &prim) const
virtual USDIMAGING_API void MarkRenderTagDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index)
USDIMAGING_API UsdPrim _GetPrim(SdfPath const &usdPath) const
Returns true if the adapter can be populated into the target index.
virtual USDIMAGING_API void MarkVisibilityDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index)
USDIMAGING_API bool _IsTransformVarying(UsdPrim prim, HdDirtyBits dirtyFlag, TfToken const &perfToken, HdDirtyBits *dirtyFlags) const
Returns true if the adapter can be populated into the target index.
USDIMAGING_API HdDirtyBits _ProcessPrefixedPrimvarPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &propertyName, HdDirtyBits valueChangeDirtyBit=HdChangeTracker::DirtyPrimvar, bool inherited=true) const
Returns true if the adapter can be populated into the target index.
virtual USDIMAGING_API HdExtComputationPrimvarDescriptorVector GetExtComputationPrimvars(UsdPrim const &prim, SdfPath const &cachePath, HdInterpolation interpolation, const UsdImagingInstancerContext *instancerContext) const
std::vector< HdExtComputationOutputDescriptor > HdExtComputationOutputDescriptorVector
USDIMAGING_API UsdImaging_CollectionCache & _GetCollectionCache() const
Returns true if the adapter can be populated into the target index.
GLuint const GLchar * name
Definition: glcorearb.h:785
USDIMAGING_API Usd_PrimFlagsConjunction _GetDisplayPredicate() const
Returns true if the adapter can be populated into the target index.
USDIMAGING_API SdfPath _ConvertCachePathToIndexPath(SdfPath const &cachePath) const
Returns true if the adapter can be populated into the target index.
USDIMAGING_API const UsdImagingPrimAdapterSharedPtr & _GetAdapter(TfToken const &adapterKey) const
Returns true if the adapter can be populated into the target index.
virtual USDIMAGING_API size_t SampleExtComputationInput(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &name, UsdTimeCode time, const UsdImagingInstancerContext *instancerContext, size_t maxSampleCount, float *sampleTimes, VtValue *sampleValues)
virtual USDIMAGING_API void MarkLightParamsDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index)
virtual USDIMAGING_API bool ShouldCullChildren() const
virtual USDIMAGING_API void ProcessPrimResync(SdfPath const &cachePath, UsdImagingIndexProxy *index)
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.
USDIMAGING_API bool _IsPrimvarFilteringNeeded() const
Returns true if the adapter can be populated into the target index.
Base class of all factory types.
Definition: type.h:73
std::vector< std::pair< SdfPath, int > > HdInstancerContext
Instancer context: a pair of instancer paths and instance indices.
Definition: sceneDelegate.h:60
virtual void TrackVariability(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits *timeVaryingBits, UsdImagingInstancerContext const *instancerContext=nullptr) const =0
USDIMAGING_API bool _IsInInvisedPaths(SdfPath const &usdPath) const
Returns true if the adapter can be populated into the target index.
virtual USDIMAGING_API std::string GetExtComputationKernel(UsdPrim const &prim, SdfPath const &cachePath, const UsdImagingInstancerContext *instancerContext) const
virtual void _RemovePrim(SdfPath const &cachePath, UsdImagingIndexProxy *index)=0
Returns true if the adapter can be populated into the target index.
USDIMAGING_API void _RemovePrimvar(HdPrimvarDescriptorVector *vec, TfToken const &name) const
Returns true if the adapter can be populated into the target index.
Definition: token.h:87
static USDIMAGING_API HdInterpolation _UsdToHdInterpolation(TfToken const &usdInterp)
Returns true if the adapter can be populated into the target index.
GLuint64EXT * result
Definition: glew.h:14311
static USDIMAGING_API TfToken _UsdToHdRole(TfToken const &usdRole)
Returns true if the adapter can be populated into the target index.
virtual USDIMAGING_API std::vector< VtArray< TfToken > > GetInstanceCategories(UsdPrim const &prim)
Return an array of the categories used by each instance.
virtual USDIMAGING_API bool ShouldIgnoreNativeInstanceSubtrees() const
virtual USDIMAGING_API GfRange3d GetExtent(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
GLuint interp
Definition: glew.h:8307
virtual USDIMAGING_API void MarkWindowPolicyDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index)
virtual USDIMAGING_API VtValue GetMaterialResource(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
The root transform provided by the delegate.
virtual USDIMAGING_API HdExtComputationOutputDescriptorVector GetExtComputationOutputs(UsdPrim const &prim, SdfPath const &cachePath, const UsdImagingInstancerContext *instancerContext) const
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
virtual USDIMAGING_API void MarkReprDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index)
USDIMAGING_API TfToken _GetMaterialBindingPurpose() const
Returns true if the adapter can be populated into the target index.
USDIMAGING_API const UsdImagingPrimAdapterSharedPtr & _GetPrimAdapter(UsdPrim const &prim, bool ignoreInstancing=false) const
Returns true if the adapter can be populated into the target index.
virtual USDIMAGING_API void MarkCullStyleDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index)
USDIMAGING_API bool _IsVarying(UsdPrim prim, TfToken const &attrName, HdDirtyBits dirtyFlag, TfToken const &perfToken, HdDirtyBits *dirtyFlags, bool isInherited, bool *exists=nullptr) const
Returns true if the adapter can be populated into the target index.
Definition: prim.h:132
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
static USDIMAGING_API bool ShouldCullSubtree(UsdPrim const &prim)
Definition: types.h:166
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
Definition: selection.h:55
Definition: path.h:288
virtual USDIMAGING_API VtValue GetInstanceIndices(UsdPrim const &instancerPrim, SdfPath const &instancerCachePath, SdfPath const &prototypeCachePath, UsdTimeCode time) const
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.
std::vector< HdVolumeFieldDescriptor > HdVolumeFieldDescriptorVector
virtual USDIMAGING_API HdExtComputationInputDescriptorVector GetExtComputationInputs(UsdPrim const &prim, SdfPath const &cachePath, const UsdImagingInstancerContext *instancerContext) const
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
Definition: path.h:209
virtual SdfPath Populate(UsdPrim const &prim, UsdImagingIndexProxy *index, UsdImagingInstancerContext const *instancerContext=nullptr)=0
virtual USDIMAGING_API ~UsdImagingPrimAdapter()
USDIMAGING_API UsdTimeCode _GetTimeWithOffset(float offset) const
Returns true if the adapter can be populated into the target index.
USDIMAGING_API TfTokenVector _GetMaterialRenderContexts() const
Returns true if the adapter can be populated into the target index.
virtual USDIMAGING_API bool IsInstancerAdapter() const
USDIMAGING_API SdfPath _ConvertIndexPathToCachePath(SdfPath const &indexPath) const
Returns true if the adapter can be populated into the target index.
USDIMAGING_API TfToken GetModelDrawMode(UsdPrim const &prim)
virtual void MarkDirty(UsdPrim const &prim, SdfPath const &cachePath, HdDirtyBits dirty, UsdImagingIndexProxy *index)=0
virtual USDIMAGING_API GfMatrix4d GetRelativeInstancerTransform(SdfPath const &instancerPath, SdfPath const &protoInstancerPath, UsdTimeCode time) const
virtual USDIMAGING_API TfToken GetPurpose(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &instanceInheritablePurpose) const
OIIO_API bool exists(string_view path) noexcept
virtual USDIMAGING_API bool CanPopulateUsdInstance() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
virtual USDIMAGING_API GfMatrix4d GetInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time) const
USDIMAGING_API TfToken GetInheritablePurpose(UsdPrim const &prim) const
virtual USDIMAGING_API bool GetVisible(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
USDIMAGING_API SdfPath _GetPrimPathFromInstancerChain(SdfPathVector const &instancerChain) const
Returns true if the adapter can be populated into the target index.
virtual USDIMAGING_API const TfTokenVector & GetExtComputationSceneInputNames(SdfPath const &cachePath) const
virtual USDIMAGING_API void MarkMaterialDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index)
virtual USDIMAGING_API void ProcessPrimRemoval(SdfPath const &cachePath, UsdImagingIndexProxy *index)
virtual USDIMAGING_API HdVolumeFieldDescriptorVector GetVolumeFieldDescriptors(UsdPrim const &usdPrim, SdfPath const &id, UsdTimeCode time) const
void _GetPtr(UsdPrim const &prim, TfToken const &key, UsdTimeCode time, T *out) const
Returns true if the adapter can be populated into the target index.
Definition: primAdapter.h:605
GLuint index
Definition: glcorearb.h:785
virtual USDIMAGING_API VtValue GetExtComputationInput(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &name, UsdTimeCode time, const UsdImagingInstancerContext *instancerContext) const
virtual USDIMAGING_API size_t SampleInstancerTransform(UsdPrim const &instancerPrim, SdfPath const &instancerPath, UsdTimeCode time, size_t maxNumSamples, float *sampleTimes, GfMatrix4d *sampleValues)
HdInterpolation
Definition: enums.h:194
USDIMAGING_API GfMatrix4d GetRootTransform() const
The root transform provided by the delegate.
USDIMAGING_API GfInterval _GetCurrentTimeSamplingInterval()
Returns true if the adapter can be populated into the target index.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
USDIMAGING_API UsdImaging_CoordSysBindingStrategy::value_type _GetCoordSysBindings(UsdPrim const &prim) const
Returns true if the adapter can be populated into the target index.
std::shared_ptr< UsdImagingPrimAdapter > UsdImagingPrimAdapterSharedPtr
virtual USDIMAGING_API void MarkRefineLevelDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index)
GLsizei const GLfloat * value
Definition: glcorearb.h:823
virtual bool IsSupported(UsdImagingIndexProxy const *index) const
Returns true if the adapter can be populated into the target index.
Definition: primAdapter.h:589
std::shared_ptr< PrimvarRecord > value_type
GLintptr offset
Definition: glcorearb.h:664
virtual USDIMAGING_API HdDirtyBits ProcessPrimChange(UsdPrim const &prim, SdfPath const &cachePath, TfTokenVector const &changedFields)
virtual USDIMAGING_API void MarkTransformDirty(UsdPrim const &prim, SdfPath const &cachePath, UsdImagingIndexProxy *index)
virtual UsdImagingPrimAdapterSharedPtr New() const
Definition: primAdapter.h:809
std::vector< HdPrimvarDescriptor > HdPrimvarDescriptorVector
virtual USDIMAGING_API SdfPath GetScenePrimPath(SdfPath const &cachePath, int instanceIndex, HdInstancerContext *instancerCtx) const
USDIMAGING_API void _ResyncDependents(SdfPath const &usdPath, UsdImagingIndexProxy *index)
Returns true if the adapter can be populated into the target index.
USDIMAGING_API HdDirtyBits _ProcessNonPrefixedPrimvarPropertyChange(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &propertyName, TfToken const &primvarName, HdInterpolation const &primvarInterp, HdDirtyBits valueChangeDirtyBit=HdChangeTracker::DirtyPrimvar) const
Returns true if the adapter can be populated into the target index.
USDIMAGING_API void _MergePrimvar(HdPrimvarDescriptorVector *vec, TfToken const &name, HdInterpolation interp, TfToken const &role=TfToken(), bool indexed=false) const
Returns true if the adapter can be populated into the target index.
std::shared_ptr< class HdSelection > HdSelectionSharedPtr
Definition: selection.h:40
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
virtual USDIMAGING_API VtValue Get(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &key, UsdTimeCode time, VtIntArray *outIndices) const
USDIMAGING_API TfTokenVector _GetShaderSourceTypes() const
Returns true if the adapter can be populated into the target index.
Definition: value.h:168
virtual USDIMAGING_API SdfPath GetMaterialId(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
The root transform provided by the delegate.
USDIMAGING_API bool _DoesDelegateSupportCoordSys() const
Returns true if the adapter can be populated into the target index.
std::vector< HdExtComputationPrimvarDescriptor > HdExtComputationPrimvarDescriptorVector
virtual USDIMAGING_API bool PopulateSelection(HdSelection::HighlightMode const &highlightMode, SdfPath const &cachePath, UsdPrim const &usdPrim, int const hydraInstanceIndex, VtIntArray const &parentInstanceIndices, HdSelectionSharedPtr const &result) const
USDIMAGING_API void _ComputeAndMergePrimvar(UsdPrim const &prim, UsdGeomPrimvar const &primvar, UsdTimeCode time, HdPrimvarDescriptorVector *primvarDescs, HdInterpolation *interpOverride=nullptr) const
Returns true if the adapter can be populated into the target index.