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 
351  virtual SdfPathVector GetScenePrimPaths(SdfPath const& cachePath,
352  std::vector<int> const& instanceIndices,
353  std::vector<HdInstancerContext> *instancerCtxs) const;
354 
356  virtual SdfPath GetDataSharingId(SdfPath const& cachePath) const;
357 
358  // Add the given usdPrim to the HdSelection object, to mark it for
359  // selection highlighting. cachePath is the path of the object referencing
360  // this adapter.
361  //
362  // If an instance index is provided to Delegate::PopulateSelection, it's
363  // interpreted as a hydra instance index and left unchanged (to make
364  // picking/selection round-tripping work). Otherwise, instance adapters
365  // will build up a composite instance index range at each level.
366  //
367  // Consider:
368  // /World/A (2 instances)
369  // /B (2 instances)
370  // /C (gprim)
371  // ... to select /World/A, instance 0, you want to select cartesian
372  // coordinates (0, *) -> (0, 0) and (0, 1). The flattened representation
373  // of this is:
374  // index = coordinate[0] * instance_count[1] + coordinate[1]
375  // Likewise, for one more nesting level you get:
376  // index = c[0] * count[1] * count[2] + c[1] * count[2] + c[2]
377  // ... since the adapter for /World/A has no idea what count[1+] are,
378  // this needs to be built up. The delegate initially sets
379  // parentInstanceIndices to []. /World/A sets this to [0]. /World/A/B,
380  // since it is selecting *, adds all possible instance indices:
381  // 0 * 2 + 0 = 0, 0 * 2 + 1 = 1. /World/A/B/C is a gprim, and adds
382  // instances [0,1] to its selection.
384  virtual bool PopulateSelection(
385  HdSelection::HighlightMode const& highlightMode,
386  SdfPath const &cachePath,
387  UsdPrim const &usdPrim,
388  int const hydraInstanceIndex,
389  VtIntArray const &parentInstanceIndices,
390  HdSelectionSharedPtr const &result) const;
391 
392  // ---------------------------------------------------------------------- //
393  /// \name Volume field information
394  // ---------------------------------------------------------------------- //
395 
398  GetVolumeFieldDescriptors(UsdPrim const& usdPrim, SdfPath const &id,
399  UsdTimeCode time) const;
400 
401  // ---------------------------------------------------------------------- //
402  /// \name Utilities
403  // ---------------------------------------------------------------------- //
404 
405  /// The root transform provided by the delegate.
408 
409  /// A thread-local XformCache provided by the delegate.
411  void SetDelegate(UsdImagingDelegate* delegate);
412 
414  bool IsChildPath(SdfPath const& path) const;
415 
416  /// Returns true if the given prim is visible, taking into account inherited
417  /// visibility values. Inherited values are strongest, Usd has no notion of
418  /// "super vis/invis".
420  virtual bool GetVisible(
421  UsdPrim const& prim,
422  SdfPath const& cachePath,
423  UsdTimeCode time) const;
424 
425  /// Returns the purpose token for \p prim. If a non-empty \p
426  /// instanceInheritablePurpose is specified and the prim doesn't have an
427  /// explicitly authored or inherited purpose, it may inherit the
428  /// instancer's purpose if the instance has an explicit purpose.
430  virtual TfToken GetPurpose(
431  UsdPrim const& prim,
432  SdfPath const& cachePath,
433  TfToken const& instanceInheritablePurpose) const;
434 
435  /// Returns the purpose token for \p prim, but only if it is inheritable
436  /// by child prims (i.e. it is an explicitly authored purpose on the prim
437  /// itself or one of the prim's ancestors), otherwise it returns the empty
438  /// token.
440  TfToken GetInheritablePurpose(UsdPrim const& prim) const;
441 
442  /// Fetches the transform for the given prim at the given time from a
443  /// pre-computed cache of prim transforms. Requesting transforms at
444  /// incoherent times is currently inefficient.
446  virtual GfMatrix4d GetTransform(UsdPrim const& prim,
447  SdfPath const& cachePath,
449  bool ignoreRootTransform = false) const;
450 
451  /// Samples the transform for the given prim.
453  virtual size_t SampleTransform(UsdPrim const& prim,
454  SdfPath const& cachePath,
456  size_t maxNumSamples,
457  float *sampleTimes,
458  GfMatrix4d *sampleValues);
459 
460  /// Gets the value of the parameter named key for the given prim (which
461  /// has the given cache path) and given time. If outIndices is not nullptr
462  /// and the value has indices, it will return the unflattened value and set
463  /// outIndices to the value's associated indices.
465  virtual VtValue Get(UsdPrim const& prim,
466  SdfPath const& cachePath,
467  TfToken const& key,
468  UsdTimeCode time,
469  VtIntArray *outIndices) const;
470 
471  /// Gets the cullstyle of a specific path in the scene graph.
473  virtual HdCullStyle GetCullStyle(UsdPrim const& prim,
474  SdfPath const& cachePath,
475  UsdTimeCode time) const;
476 
477  /// Gets the material path for the given prim, walking up namespace if
478  /// necessary.
480  SdfPath GetMaterialUsdPath(UsdPrim const& prim) const;
481 
482  /// Gets the model:drawMode attribute for the given prim, walking up
483  /// the namespace if necessary.
485  TfToken GetModelDrawMode(UsdPrim const& prim);
486 
487  /// Computes the per-prototype instance indices for a UsdGeomPointInstancer.
488  /// XXX: This needs to be defined on the base class, to have access to the
489  /// delegate, but it's a clear violation of abstraction. This call is only
490  /// legal for prims of type UsdGeomPointInstancer; in other cases, the
491  /// returned array will be empty and the computation will issue errors.
494  UsdTimeCode time) const;
495 
496  /// Gets the topology object of a specific Usd prim. If the
497  /// adapter is a mesh it will return an HdMeshTopology,
498  /// if it is of type basis curves, it will return an HdBasisCurvesTopology.
499  /// If the adapter does not have a topology, it returns an empty VtValue.
501  virtual VtValue GetTopology(UsdPrim const& prim,
502  SdfPath const& cachePath,
503  UsdTimeCode time) const;
504 
505  /// Reads the extent from the given prim. If the extent is not authored,
506  /// an empty GfRange3d is returned, the extent will not be computed.
508  virtual GfRange3d GetExtent(UsdPrim const& prim,
509  SdfPath const& cachePath,
510  UsdTimeCode time) const;
511 
512  /// Reads double-sided from the given prim. If not authored, returns false
514  virtual bool GetDoubleSided(UsdPrim const& prim,
515  SdfPath const& cachePath,
516  UsdTimeCode time) const;
517 
519  virtual SdfPath GetMaterialId(UsdPrim const& prim,
520  SdfPath const& cachePath,
521  UsdTimeCode time) const;
522 
524  virtual VtValue GetMaterialResource(UsdPrim const& prim,
525  SdfPath const& cachePath,
526  UsdTimeCode time) const;
527 
528  // ---------------------------------------------------------------------- //
529  /// \name ExtComputations
530  // ---------------------------------------------------------------------- //
533  SdfPath const& cachePath) const;
534 
537  GetExtComputationInputs(UsdPrim const& prim,
538  SdfPath const& cachePath,
539  const UsdImagingInstancerContext* instancerContext)
540  const;
541 
544  GetExtComputationOutputs(UsdPrim const& prim,
545  SdfPath const& cachePath,
546  const UsdImagingInstancerContext* instancerContext)
547  const;
548 
552  UsdPrim const& prim,
553  SdfPath const& cachePath,
554  HdInterpolation interpolation,
555  const UsdImagingInstancerContext* instancerContext) const;
556 
558  virtual VtValue
560  UsdPrim const& prim,
561  SdfPath const& cachePath,
562  TfToken const& name,
564  const UsdImagingInstancerContext* instancerContext) const;
565 
567  virtual size_t
569  UsdPrim const& prim,
570  SdfPath const& cachePath,
571  TfToken const& name,
573  const UsdImagingInstancerContext* instancerContext,
574  size_t maxSampleCount,
575  float *sampleTimes,
576  VtValue *sampleValues);
577 
579  virtual std::string
581  UsdPrim const& prim,
582  SdfPath const& cachePath,
583  const UsdImagingInstancerContext* instancerContext) const;
584 
586  virtual VtValue
587  GetInstanceIndices(UsdPrim const& instancerPrim,
588  SdfPath const& instancerCachePath,
589  SdfPath const& prototypeCachePath,
590  UsdTimeCode time) const;
591 
592  // ---------------------------------------------------------------------- //
593  /// \name Render Index Compatibility
594  // ---------------------------------------------------------------------- //
595 
596  /// Returns true if the adapter can be populated into the target index.
597  virtual bool IsSupported(UsdImagingIndexProxy const* index) const {
598  return true;
599  }
600 
601 protected:
603 
604  template <typename T>
605  T _Get(UsdPrim const& prim, TfToken const& attrToken,
606  UsdTimeCode time) const {
607  T value;
608  prim.GetAttribute(attrToken).Get<T>(&value, time);
609  return value;
610  }
611 
612  template <typename T>
613  void _GetPtr(UsdPrim const& prim, TfToken const& key, UsdTimeCode time,
614  T* out) const {
615  prim.GetAttribute(key).Get<T>(out, time);
616  }
617 
620 
622  UsdPrim _GetPrim(SdfPath const& usdPath) const;
623 
624  // Returns the prim adapter for the given \p prim, or an invalid pointer if
625  // no adapter exists. If \p prim is an instance and \p ignoreInstancing
626  // is \c true, the instancing adapter will be ignored and an adapter will
627  // be looked up based on \p prim's type.
630  _GetPrimAdapter(UsdPrim const& prim, bool ignoreInstancing = false) const;
631 
634  _GetAdapter(TfToken const& adapterKey) const;
635 
636  // XXX: Transitional API
637  // Returns the instance proxy prim path for a USD-instanced prim, given the
638  // instance chain leading to that prim. The paths are sorted from more to
639  // less local; the first path is the prim path (possibly in prototype), then
640  // instance paths (possibly in prototype); the last path is the prim or
641  // instance path in the scene.
644  SdfPathVector const& instancerChain) const;
645 
648 
649  // Converts \p cachePath to the path in the render index.
651  SdfPath _ConvertCachePathToIndexPath(SdfPath const& cachePath) const;
652 
653  // Converts \p indexPath to the path in the USD stage
655  SdfPath _ConvertIndexPathToCachePath(SdfPath const& indexPath) const;
656 
657  // Returns the material binding purpose from the renderer delegate.
660 
661  // Returns the material contexts from the renderer delegate.
664 
665  // Returns true if render delegate wants primvars to be filtered based.
666  // This will filter the primvars based on the bound material primvar needs.
668  bool _IsPrimvarFilteringNeeded() const;
669 
670  // Returns the shader source type from the render delegate.
673 
674  // Returns \c true if \p usdPath is included in the scene delegate's
675  // invised path list.
677  bool _IsInInvisedPaths(SdfPath const& usdPath) const;
678 
679  // Determines if an attribute is varying and if so, sets the given
680  // \p dirtyFlag in the \p dirtyFlags and increments a perf counter. Returns
681  // true if the attribute is varying.
682  //
683  // If \p exists is non-null, _IsVarying will store whether the attribute
684  // was found. If the attribute is not found, it counts as non-varying.
685  //
686  // This only sets the dirty bit, never un-sets. The caller is responsible
687  // for setting the initial state correctly.
689  bool _IsVarying(UsdPrim prim, TfToken const& attrName,
690  HdDirtyBits dirtyFlag, TfToken const& perfToken,
691  HdDirtyBits* dirtyFlags, bool isInherited,
692  bool* exists = nullptr) const;
693 
694  // Determines if the prim's transform (CTM) is varying and if so, sets the
695  // given \p dirtyFlag in the \p dirtyFlags and increments a perf counter.
696  // Returns true if the prim's transform is varying.
697  //
698  // This only sets the dirty bit, never un-sets. The caller is responsible
699  // for setting the initial state correctly.
701  bool _IsTransformVarying(UsdPrim prim,
702  HdDirtyBits dirtyFlag,
703  TfToken const& perfToken,
704  HdDirtyBits* dirtyFlags) const;
705 
706  // Convenience method for adding or updating a primvar descriptor.
707  // Role defaults to empty token (none). Indexed defaults to false.
709  void _MergePrimvar(
711  TfToken const& name,
713  TfToken const& role = TfToken(),
714  bool indexed = false) const;
715 
716  // Convenience method for removing a primvar descriptor.
718  void _RemovePrimvar(
720  TfToken const& name) const;
721 
722  // Convenience method for computing a primvar. The primvar will only be
723  // added to the list of prim desc if there is no primvar of the same
724  // name already present. Thus, "local" primvars should be merged before
725  // inherited primvars.
728  UsdPrim const& prim,
729  UsdGeomPrimvar const& primvar,
731  HdPrimvarDescriptorVector* primvarDescs,
732  HdInterpolation *interpOverride = nullptr) const;
733 
734  // Returns true if the property name has the "primvars:" prefix.
736  static bool _HasPrimvarsPrefix(TfToken const& propertyName);
737 
738  // Convenience methods to figure out what changed about the primvar and
739  // return the appropriate dirty bit.
740  // Caller can optionally pass in a dirty bit to set for primvar value
741  // changes. This is useful for attributes that have a special dirty bit
742  // such as normals and widths.
743  //
744  // Handle USD attributes that are treated as primvars by Hydra. This
745  // requires the interpolation to be passed in, as well as the primvar
746  // name passed to Hydra.
749  UsdPrim const& prim,
750  SdfPath const& cachePath,
751  TfToken const& propertyName,
752  TfToken const& primvarName,
753  HdInterpolation const& primvarInterp,
754  HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar) const;
755 
756  // Handle UsdGeomPrimvars that use the "primvars:" prefix, while also
757  // accommodating inheritance.
760  UsdPrim const& prim,
761  SdfPath const& cachePath,
762  TfToken const& propertyName,
763  HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar,
764  bool inherited = true) const;
765 
766  virtual void _RemovePrim(SdfPath const& cachePath,
768 
769  // Utility to resync bound dependencies of a particular usd path.
770  // This is necessary for the resync processing of certain prim types
771  // (e.g. materials).
773  void _ResyncDependents(SdfPath const& usdPath,
775 
778 
781  _GetCoordSysBindings(UsdPrim const& prim) const;
782 
785  _GetInheritedPrimvars(UsdPrim const& prim) const;
786 
789 
792 
795 
797  bool _DoesDelegateSupportCoordSys() const;
798 
799  // Conversion functions between usd and hydra enums.
801  static HdInterpolation _UsdToHdInterpolation(TfToken const& usdInterp);
803  static TfToken _UsdToHdRole(TfToken const& usdRole);
804 
805 private:
806  UsdImagingDelegate* _delegate;
807 };
808 
810 public:
811  virtual UsdImagingPrimAdapterSharedPtr New() const = 0;
812 };
813 
814 template <class T>
816 public:
818  {
819  return std::make_shared<T>();
820  }
821 };
822 
823 
825 
826 #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:605
virtual USDIMAGING_API SdfPathVector GetScenePrimPaths(SdfPath const &cachePath, std::vector< int > const &instanceIndices, std::vector< HdInstancerContext > *instancerCtxs) const
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 SdfPath GetDataSharingId(SdfPath const &cachePath) const
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:613
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:597
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:817
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.