All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
primAdapter.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H
8#define PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usdImaging/usdImaging/api.h"
14#include "pxr/usdImaging/usdImaging/version.h"
18#include "pxr/usdImaging/usdImaging/types.h"
19
20#include "pxr/imaging/hd/changeTracker.h"
21#include "pxr/imaging/hd/selection.h"
22#include "pxr/usd/sdf/path.h"
23#include "pxr/usd/usd/attribute.h"
24#include "pxr/usd/usd/prim.h"
25#include "pxr/usd/usd/timeCode.h"
26
28
29#include "pxr/base/tf/type.h"
30
31#include <memory>
32
33PXR_NAMESPACE_OPEN_SCOPE
34
35class UsdPrim;
36
37// Forward declaration for nested class.
42
44
45using UsdImagingPrimAdapterSharedPtr =
46 std::shared_ptr<class UsdImagingPrimAdapter>;
47
53 : public std::enable_shared_from_this<UsdImagingPrimAdapter>
54{
55public:
56 USDIMAGING_API
57 virtual ~UsdImagingPrimAdapter() = default;
58
59 // ---------------------------------------------------------------------- //
61 // ---------------------------------------------------------------------- //
62
63 USDIMAGING_API
64 virtual TfTokenVector GetImagingSubprims(UsdPrim const& prim);
65
66 USDIMAGING_API
67 virtual TfToken GetImagingSubprimType(
68 UsdPrim const& prim, TfToken const& subprim);
69
70 USDIMAGING_API
71 virtual HdContainerDataSourceHandle GetImagingSubprimData(
72 UsdPrim const& prim,
73 TfToken const& subprim,
74 const UsdImagingDataSourceStageGlobals &stageGlobals);
75
76 USDIMAGING_API
77 virtual HdDataSourceLocatorSet InvalidateImagingSubprim(
78 UsdPrim const& prim,
79 TfToken const& subprim,
80 TfTokenVector const& properties,
81 UsdImagingPropertyInvalidationType invalidationType);
82
89 {
93
99
108 };
109
112 USDIMAGING_API
114
119 USDIMAGING_API
121 UsdPrim const& prim,
122 UsdPrim const& descendentPrim,
123 TfToken const& subprim,
124 TfTokenVector const& properties,
125 UsdImagingPropertyInvalidationType invalidationType);
126
127 // ---------------------------------------------------------------------- //
129 // ---------------------------------------------------------------------- //
130
134 virtual SdfPath Populate(UsdPrim const& prim,
137 instancerContext = nullptr) = 0;
138
139 // Indicates whether population traversal should be pruned based on
140 // prim-specific features (like whether it's imageable).
141 USDIMAGING_API
142 static bool ShouldCullSubtree(UsdPrim const& prim);
143
144 // Indicates whether population traversal should be pruned based on
145 // adapter-specific features (like whether the adapter is an instance
146 // adapter, and wants to do its own population).
147 USDIMAGING_API
148 virtual bool ShouldCullChildren() const;
149
150 // Indicates whether or not native USD prim instancing should be ignored
151 // for prims using this delegate, along with their descendants.
152 USDIMAGING_API
153 virtual bool ShouldIgnoreNativeInstanceSubtrees() const;
154
155 // Indicates the adapter is a multiplexing adapter (e.g. PointInstancer),
156 // potentially managing its children. This flag is used in nested
157 // instancer cases to determine which adapter is assigned to which prim.
158 USDIMAGING_API
159 virtual bool IsInstancerAdapter() const;
160
161 // Indicates whether this adapter can directly populate USD instance prims.
162 //
163 // Normally, with USD instances, we make a firewall between the instance
164 // prim and the USD prototype tree. The instance adapter creates one
165 // hydra prototype per prim in the USD prototype tree, shared by all USD
166 // instances; this lets us recognize the benefits of instancing,
167 // by hopefully having a high instance count per prototype. The instance
168 // adapter additionally configures a hydra instancer for the prototype tree;
169 // and a small set of specially-handled data is allowed through: things like
170 // inherited constant primvars, transforms, visibility, and other things
171 // we know how to vary per-instance.
172 //
173 // We enforce the above policy by refusing to populate gprims which are
174 // USD instances, since we'd need one prototype per instance and would lose
175 // any instancing benefit.
176 //
177 // There are a handful of times when it really is useful to directly
178 // populate instance prims: for example, instances with cards applied,
179 // or instances of type UsdSkelRoot. In those cases, the adapters can
180 // opt into this scheme with "CanPopulateUsdInstance".
181 //
182 // Note that any adapters taking advantage of this feature will need
183 // extensive code support in instanceAdapter: the instance adapter will
184 // need to potentially create and track multiple hydra prototypes per
185 // USD prototype, and the adapter will need special handling to pass down
186 // any relevant instance-varying data.
187 //
188 // In summary: use with caution.
189 USDIMAGING_API
190 virtual bool CanPopulateUsdInstance() const;
191
192 // ---------------------------------------------------------------------- //
194 // ---------------------------------------------------------------------- //
195
201 virtual void TrackVariability(UsdPrim const& prim,
202 SdfPath const& cachePath,
203 HdDirtyBits* timeVaryingBits,
205 instancerContext = nullptr) const = 0;
206
211 virtual void UpdateForTime(UsdPrim const& prim,
212 SdfPath const& cachePath,
213 UsdTimeCode time,
214 HdDirtyBits requestedBits,
216 instancerContext = nullptr) const = 0;
217
218 // ---------------------------------------------------------------------- //
220 // ---------------------------------------------------------------------- //
221
232 USDIMAGING_API
233 virtual HdDirtyBits ProcessPrimChange(UsdPrim const& prim,
234 SdfPath const& cachePath,
235 TfTokenVector const& changedFields);
236
239 virtual HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
240 SdfPath const& cachePath,
241 TfToken const& propertyName) = 0;
242
246 USDIMAGING_API
247 virtual void ProcessPrimResync(SdfPath const& cachePath,
248 UsdImagingIndexProxy* index);
249
252 USDIMAGING_API
253 virtual void ProcessPrimRemoval(SdfPath const& cachePath,
254 UsdImagingIndexProxy* index);
255
256
257 virtual void MarkDirty(UsdPrim const& prim,
258 SdfPath const& cachePath,
259 HdDirtyBits dirty,
260 UsdImagingIndexProxy* index) = 0;
261
262 USDIMAGING_API
263 virtual void MarkRefineLevelDirty(UsdPrim const& prim,
264 SdfPath const& cachePath,
265 UsdImagingIndexProxy* index);
266
267 USDIMAGING_API
268 virtual void MarkReprDirty(UsdPrim const& prim,
269 SdfPath const& cachePath,
270 UsdImagingIndexProxy* index);
271
272 USDIMAGING_API
273 virtual void MarkCullStyleDirty(UsdPrim const& prim,
274 SdfPath const& cachePath,
275 UsdImagingIndexProxy* index);
276
277 USDIMAGING_API
278 virtual void MarkRenderTagDirty(UsdPrim const& prim,
279 SdfPath const& cachePath,
280 UsdImagingIndexProxy* index);
281
282 USDIMAGING_API
283 virtual void MarkTransformDirty(UsdPrim const& prim,
284 SdfPath const& cachePath,
285 UsdImagingIndexProxy* index);
286
287 USDIMAGING_API
288 virtual void MarkVisibilityDirty(UsdPrim const& prim,
289 SdfPath const& cachePath,
290 UsdImagingIndexProxy* index);
291
292 USDIMAGING_API
293 virtual void MarkMaterialDirty(UsdPrim const& prim,
294 SdfPath const& cachePath,
295 UsdImagingIndexProxy* index);
296
297 USDIMAGING_API
298 virtual void MarkLightParamsDirty(UsdPrim const& prim,
299 SdfPath const& cachePath,
300 UsdImagingIndexProxy* index);
301
302 USDIMAGING_API
303 virtual void MarkWindowPolicyDirty(UsdPrim const& prim,
304 SdfPath const& cachePath,
305 UsdImagingIndexProxy* index);
306
307 USDIMAGING_API
308 virtual void MarkCollectionsDirty(UsdPrim const& prim,
309 SdfPath const& cachePath,
310 UsdImagingIndexProxy* index);
311
312 // ---------------------------------------------------------------------- //
314 // ---------------------------------------------------------------------- //
315 USDIMAGING_API
316 virtual void InvokeComputation(SdfPath const& cachePath,
317 HdExtComputationContext* context);
318
319 // ---------------------------------------------------------------------- //
321 // ---------------------------------------------------------------------- //
322
324 USDIMAGING_API
325 virtual std::vector<VtArray<TfToken>>
327
330 USDIMAGING_API
332 UsdPrim const& instancerPrim,
333 SdfPath const& instancerPath,
334 UsdTimeCode time) const;
335
338 USDIMAGING_API
340 UsdPrim const& instancerPrim,
341 SdfPath const& instancerPath,
342 UsdTimeCode time,
343 size_t maxNumSamples,
344 float *sampleTimes,
345 GfMatrix4d *sampleValues);
346
348 USDIMAGING_API
350 UsdPrim const& usdPrim,
351 SdfPath const& cachePath) const;
352
354 USDIMAGING_API
355 virtual SdfPathVector GetInstancerPrototypes(
356 UsdPrim const& usdPrim,
357 SdfPath const& cachePath) const;
358
364 USDIMAGING_API
365 virtual size_t
366 SamplePrimvar(UsdPrim const& usdPrim,
367 SdfPath const& cachePath,
368 TfToken const& key,
369 UsdTimeCode time,
370 size_t maxNumSamples,
371 float *sampleTimes,
372 VtValue *sampleValues,
373 VtIntArray *sampleIndices);
374
376 USDIMAGING_API
377 virtual PxOsdSubdivTags GetSubdivTags(UsdPrim const& usdPrim,
378 SdfPath const& cachePath,
379 UsdTimeCode time) const;
380
381 // ---------------------------------------------------------------------- //
383 // ---------------------------------------------------------------------- //
384
385 // NOTE: This method is currently only used by PointInstancer
386 // style instances, and not instanceable-references.
387
391 USDIMAGING_API
393 SdfPath const &instancerPath,
394 SdfPath const &protoInstancerPath,
395 UsdTimeCode time) const;
396
397 // ---------------------------------------------------------------------- //
399 // ---------------------------------------------------------------------- //
400
402 USDIMAGING_API
403 virtual SdfPath GetScenePrimPath(SdfPath const& cachePath,
404 int instanceIndex,
405 HdInstancerContext *instancerCtx) const;
406
407 USDIMAGING_API
408 virtual SdfPathVector GetScenePrimPaths(SdfPath const& cachePath,
409 std::vector<int> const& instanceIndices,
410 std::vector<HdInstancerContext> *instancerCtxs) const;
411
412 // Add the given usdPrim to the HdSelection object, to mark it for
413 // selection highlighting. cachePath is the path of the object referencing
414 // this adapter.
415 //
416 // If an instance index is provided to Delegate::PopulateSelection, it's
417 // interpreted as a hydra instance index and left unchanged (to make
418 // picking/selection round-tripping work). Otherwise, instance adapters
419 // will build up a composite instance index range at each level.
420 //
421 // Consider:
422 // /World/A (2 instances)
423 // /B (2 instances)
424 // /C (gprim)
425 // ... to select /World/A, instance 0, you want to select cartesian
426 // coordinates (0, *) -> (0, 0) and (0, 1). The flattened representation
427 // of this is:
428 // index = coordinate[0] * instance_count[1] + coordinate[1]
429 // Likewise, for one more nesting level you get:
430 // index = c[0] * count[1] * count[2] + c[1] * count[2] + c[2]
431 // ... since the adapter for /World/A has no idea what count[1+] are,
432 // this needs to be built up. The delegate initially sets
433 // parentInstanceIndices to []. /World/A sets this to [0]. /World/A/B,
434 // since it is selecting *, adds all possible instance indices:
435 // 0 * 2 + 0 = 0, 0 * 2 + 1 = 1. /World/A/B/C is a gprim, and adds
436 // instances [0,1] to its selection.
437 USDIMAGING_API
438 virtual bool PopulateSelection(
439 HdSelection::HighlightMode const& highlightMode,
440 SdfPath const &cachePath,
441 UsdPrim const &usdPrim,
442 int const hydraInstanceIndex,
443 VtIntArray const &parentInstanceIndices,
444 HdSelectionSharedPtr const &result) const;
445
446 // ---------------------------------------------------------------------- //
448 // ---------------------------------------------------------------------- //
449
450 USDIMAGING_API
451 virtual HdVolumeFieldDescriptorVector
452 GetVolumeFieldDescriptors(UsdPrim const& usdPrim, SdfPath const &id,
453 UsdTimeCode time) const;
454
455 // ---------------------------------------------------------------------- //
457 // ---------------------------------------------------------------------- //
458
459 USDIMAGING_API
460 virtual VtValue
461 GetLightParamValue(
462 const UsdPrim& prim,
463 const SdfPath& cachePath,
464 const TfToken& paramName,
465 UsdTimeCode time) const;
466
467 // ---------------------------------------------------------------------- //
469 // ---------------------------------------------------------------------- //
470
472 USDIMAGING_API
474
476 USDIMAGING_API
478
479 USDIMAGING_API
480 virtual bool IsChildPath(const SdfPath& path) const;
481
485 USDIMAGING_API
486 virtual bool GetVisible(
487 UsdPrim const& prim,
488 SdfPath const& cachePath,
489 UsdTimeCode time) const;
490
495 USDIMAGING_API
497 UsdPrim const& prim,
498 SdfPath const& cachePath,
499 TfToken const& instanceInheritablePurpose) const;
500
505 USDIMAGING_API
507
511 USDIMAGING_API
512 virtual GfMatrix4d GetTransform(UsdPrim const& prim,
513 SdfPath const& cachePath,
514 UsdTimeCode time,
515 bool ignoreRootTransform = false) const;
516
518 USDIMAGING_API
519 virtual size_t SampleTransform(UsdPrim const& prim,
520 SdfPath const& cachePath,
521 UsdTimeCode time,
522 size_t maxNumSamples,
523 float *sampleTimes,
524 GfMatrix4d *sampleValues);
525
530 USDIMAGING_API
531 virtual VtValue Get(UsdPrim const& prim,
532 SdfPath const& cachePath,
533 TfToken const& key,
534 UsdTimeCode time,
535 VtIntArray *outIndices) const;
536
538 USDIMAGING_API
539 virtual HdCullStyle GetCullStyle(UsdPrim const& prim,
540 SdfPath const& cachePath,
541 UsdTimeCode time) const;
542
545 USDIMAGING_API
547
550 USDIMAGING_API
552
555 USDIMAGING_API
557
563 USDIMAGING_API
565 UsdTimeCode time) const;
566
571 USDIMAGING_API
572 virtual VtValue GetTopology(UsdPrim const& prim,
573 SdfPath const& cachePath,
574 UsdTimeCode time) const;
575
578 USDIMAGING_API
579 virtual GfRange3d GetExtent(UsdPrim const& prim,
580 SdfPath const& cachePath,
581 UsdTimeCode time) const;
582
584 USDIMAGING_API
585 virtual bool GetDoubleSided(UsdPrim const& prim,
586 SdfPath const& cachePath,
587 UsdTimeCode time) const;
588
589 USDIMAGING_API
590 virtual SdfPath GetMaterialId(UsdPrim const& prim,
591 SdfPath const& cachePath,
592 UsdTimeCode time) const;
593
594 USDIMAGING_API
595 virtual VtValue GetMaterialResource(UsdPrim const& prim,
596 SdfPath const& cachePath,
597 UsdTimeCode time) const;
598
599 // ---------------------------------------------------------------------- //
601 // ---------------------------------------------------------------------- //
602 USDIMAGING_API
603 virtual const TfTokenVector &GetExtComputationSceneInputNames(
604 SdfPath const& cachePath) const;
605
606 USDIMAGING_API
607 virtual HdExtComputationInputDescriptorVector
608 GetExtComputationInputs(UsdPrim const& prim,
609 SdfPath const& cachePath,
610 const UsdImagingInstancerContext* instancerContext)
611 const;
612
613 USDIMAGING_API
614 virtual HdExtComputationOutputDescriptorVector
615 GetExtComputationOutputs(UsdPrim const& prim,
616 SdfPath const& cachePath,
617 const UsdImagingInstancerContext* instancerContext)
618 const;
619
620 USDIMAGING_API
621 virtual HdExtComputationPrimvarDescriptorVector
622 GetExtComputationPrimvars(
623 UsdPrim const& prim,
624 SdfPath const& cachePath,
625 HdInterpolation interpolation,
626 const UsdImagingInstancerContext* instancerContext) const;
627
628 USDIMAGING_API
629 virtual VtValue
630 GetExtComputationInput(
631 UsdPrim const& prim,
632 SdfPath const& cachePath,
633 TfToken const& name,
634 UsdTimeCode time,
635 const UsdImagingInstancerContext* instancerContext) const;
636
637 USDIMAGING_API
638 virtual size_t
639 SampleExtComputationInput(
640 UsdPrim const& prim,
641 SdfPath const& cachePath,
642 TfToken const& name,
643 UsdTimeCode time,
644 const UsdImagingInstancerContext* instancerContext,
645 size_t maxSampleCount,
646 float *sampleTimes,
647 VtValue *sampleValues);
648
649 USDIMAGING_API
650 virtual std::string
651 GetExtComputationKernel(
652 UsdPrim const& prim,
653 SdfPath const& cachePath,
654 const UsdImagingInstancerContext* instancerContext) const;
655
656 USDIMAGING_API
657 virtual VtValue
658 GetInstanceIndices(UsdPrim const& instancerPrim,
659 SdfPath const& instancerCachePath,
660 SdfPath const& prototypeCachePath,
661 UsdTimeCode time) const;
662
663 // ---------------------------------------------------------------------- //
665 // ---------------------------------------------------------------------- //
666
668 virtual bool IsSupported(UsdImagingIndexProxy const* index) const
669 {
670 return true;
671 }
672
673 // ---------------------------------------------------------------------- //
675 // ---------------------------------------------------------------------- //
676
678 USDIMAGING_API
680 UsdPrim const& prim,
681 TfToken const& paramName);
682
683protected:
684 friend class UsdImagingInstanceAdapter;
686 // ---------------------------------------------------------------------- //
688 // ---------------------------------------------------------------------- //
689
690 // Given the USD path for a prim of this adapter's type, returns
691 // the prim's Hydra cache path.
692 USDIMAGING_API
693 virtual SdfPath
694 ResolveCachePath(
695 const SdfPath& usdPath,
696 const UsdImagingInstancerContext* instancerContext = nullptr) const;
697
698 using Keys = UsdImagingPrimvarDescCache::Key;
699
700 template <typename T>
701 T _Get(UsdPrim const& prim, TfToken const& attrToken,
702 UsdTimeCode time) const {
703 T value;
704 prim.GetAttribute(attrToken).Get<T>(&value, time);
705 return value;
706 }
707
708 template <typename T>
709 void _GetPtr(UsdPrim const& prim, TfToken const& key, UsdTimeCode time,
710 T* out) const {
711 prim.GetAttribute(key).Get<T>(out, time);
712 }
713
714 USDIMAGING_API
715 UsdImagingPrimvarDescCache* _GetPrimvarDescCache() const;
716
717 USDIMAGING_API
718 UsdImaging_NonlinearSampleCountCache*
719 _GetNonlinearSampleCountCache() const;
720
721 USDIMAGING_API
722 UsdImaging_BlurScaleCache*
723 _GetBlurScaleCache() const;
724
725 USDIMAGING_API
726 UsdPrim _GetPrim(SdfPath const& usdPath) const;
727
728 // Returns the prim adapter for the given \p prim, or an invalid pointer if
729 // no adapter exists. If \p prim is an instance and \p ignoreInstancing
730 // is \c true, the instancing adapter will be ignored and an adapter will
731 // be looked up based on \p prim's type.
732 USDIMAGING_API
733 const UsdImagingPrimAdapterSharedPtr&
734 _GetPrimAdapter(UsdPrim const& prim, bool ignoreInstancing = false) const;
735
736 USDIMAGING_API
737 const UsdImagingPrimAdapterSharedPtr&
738 _GetAdapter(TfToken const& adapterKey) const;
739
740 // XXX: Transitional API
741 // Returns the instance proxy prim path for a USD-instanced prim, given the
742 // instance chain leading to that prim. The paths are sorted from more to
743 // less local; the first path is the prim path (possibly in prototype), then
744 // instance paths (possibly in prototype); the last path is the prim or
745 // instance path in the scene.
746 USDIMAGING_API
747 SdfPath _GetPrimPathFromInstancerChain(
748 SdfPathVector const& instancerChain) const;
749
750 USDIMAGING_API
751 UsdTimeCode _GetTimeWithOffset(float offset) const;
752
753 // Converts \p cachePath to the path in the render index.
754 USDIMAGING_API
755 SdfPath _ConvertCachePathToIndexPath(SdfPath const& cachePath) const;
756
757 // Converts \p indexPath to the path in the USD stage
758 USDIMAGING_API
759 SdfPath _ConvertIndexPathToCachePath(SdfPath const& indexPath) const;
760
761 // Returns the material binding purpose from the renderer delegate.
762 USDIMAGING_API
763 TfToken _GetMaterialBindingPurpose() const;
764
765 // Returns the material contexts from the renderer delegate.
766 USDIMAGING_API
767 TfTokenVector _GetMaterialRenderContexts() const;
768
769 // Returns the namespace prefixes for render settings attributes relevant
770 // to a renderer delegate.
771 USDIMAGING_API
772 TfTokenVector _GetRenderSettingsNamespaces() const;
773
775 USDIMAGING_API
777
779 USDIMAGING_API
781
782 // Returns true if render delegate wants primvars to be filtered based.
783 // This will filter the primvars based on the bound material primvar needs.
784 USDIMAGING_API
785 bool _IsPrimvarFilteringNeeded() const;
786
787 // Returns the shader source type from the render delegate.
788 USDIMAGING_API
789 TfTokenVector _GetShaderSourceTypes() const;
790
791 // Returns \c true if \p usdPath is included in the scene delegate's
792 // invised path list.
793 USDIMAGING_API
794 bool _IsInInvisedPaths(SdfPath const& usdPath) const;
795
796 // Determines if an attribute is varying and if so, sets the given
797 // \p dirtyFlag in the \p dirtyFlags and increments a perf counter. Returns
798 // true if the attribute is varying.
799 //
800 // If \p exists is non-null, _IsVarying will store whether the attribute
801 // was found. If the attribute is not found, it counts as non-varying.
802 //
803 // This only sets the dirty bit, never un-sets. The caller is responsible
804 // for setting the initial state correctly.
805 USDIMAGING_API
806 bool _IsVarying(UsdPrim prim, TfToken const& attrName,
807 HdDirtyBits dirtyFlag, TfToken const& perfToken,
808 HdDirtyBits* dirtyFlags, bool isInherited,
809 bool* exists = nullptr) const;
810
811 // Determines if the prim's transform (CTM) is varying and if so, sets the
812 // given \p dirtyFlag in the \p dirtyFlags and increments a perf counter.
813 // Returns true if the prim's transform is varying.
814 //
815 // This only sets the dirty bit, never un-sets. The caller is responsible
816 // for setting the initial state correctly.
817 USDIMAGING_API
818 bool _IsTransformVarying(UsdPrim prim,
819 HdDirtyBits dirtyFlag,
820 TfToken const& perfToken,
821 HdDirtyBits* dirtyFlags) const;
822
823 // Convenience method for adding or updating a primvar descriptor.
824 // Role defaults to empty token (none). Indexed defaults to false.
825 USDIMAGING_API
826 void _MergePrimvar(
827 HdPrimvarDescriptorVector* vec,
828 TfToken const& name,
829 HdInterpolation interp,
830 TfToken const& role = TfToken(),
831 bool indexed = false) const;
832
833 // Convenience method for removing a primvar descriptor.
834 USDIMAGING_API
835 void _RemovePrimvar(
836 HdPrimvarDescriptorVector* vec,
837 TfToken const& name) const;
838
839 // Convenience method for computing a primvar. The primvar will only be
840 // added to the list of prim desc if there is no primvar of the same
841 // name already present. Thus, "local" primvars should be merged before
842 // inherited primvars.
843 USDIMAGING_API
844 void _ComputeAndMergePrimvar(
845 UsdPrim const& prim,
846 UsdGeomPrimvar const& primvar,
847 UsdTimeCode time,
848 HdPrimvarDescriptorVector* primvarDescs,
849 HdInterpolation *interpOverride = nullptr) const;
850
851 // Returns true if the property name has the "primvars:" prefix.
852 USDIMAGING_API
853 static bool _HasPrimvarsPrefix(TfToken const& propertyName);
854
855 // Convenience methods to figure out what changed about the primvar and
856 // return the appropriate dirty bit.
857 // Caller can optionally pass in a dirty bit to set for primvar value
858 // changes. This is useful for attributes that have a special dirty bit
859 // such as normals and widths.
860 //
861 // Handle USD attributes that are treated as primvars by Hydra. This
862 // requires the interpolation to be passed in, as well as the primvar
863 // name passed to Hydra.
864 USDIMAGING_API
865 HdDirtyBits _ProcessNonPrefixedPrimvarPropertyChange(
866 UsdPrim const& prim,
867 SdfPath const& cachePath,
868 TfToken const& propertyName,
869 TfToken const& primvarName,
870 HdInterpolation const& primvarInterp,
871 HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar) const;
872
873 // Handle UsdGeomPrimvars that use the "primvars:" prefix, while also
874 // accommodating inheritance.
875 USDIMAGING_API
876 HdDirtyBits _ProcessPrefixedPrimvarPropertyChange(
877 UsdPrim const& prim,
878 SdfPath const& cachePath,
879 TfToken const& propertyName,
880 HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar,
881 bool inherited = true) const;
882
883 virtual void _RemovePrim(SdfPath const& cachePath,
884 UsdImagingIndexProxy* index) = 0;
885
886 // Utility to resync bound dependencies of a particular usd path.
887 // This is necessary for the resync processing of certain prim types
888 // (e.g. materials).
889 USDIMAGING_API
890 void _ResyncDependents(SdfPath const& usdPath,
891 UsdImagingIndexProxy *index);
892
893 USDIMAGING_API
894 UsdImaging_CollectionCache& _GetCollectionCache() const;
895
896 USDIMAGING_API
897 UsdStageRefPtr _GetStage() const;
898
899 USDIMAGING_API
900 UsdImaging_CoordSysBindingStrategy::value_type
901 _GetCoordSysBindings(UsdPrim const& prim) const;
902
903 USDIMAGING_API
904 UsdImaging_InheritedPrimvarStrategy::value_type
905 _GetInheritedPrimvars(UsdPrim const& prim) const;
906
907 // Utility for derived classes to try to find an inherited primvar.
908 USDIMAGING_API
909 UsdGeomPrimvar _GetInheritedPrimvar(UsdPrim const& prim,
910 TfToken const& primvarName) const;
911
912 USDIMAGING_API
913 GfInterval _GetCurrentTimeSamplingInterval();
914
915 USDIMAGING_API
916 Usd_PrimFlagsConjunction _GetDisplayPredicate() const;
917
918 USDIMAGING_API
919 Usd_PrimFlagsConjunction _GetDisplayPredicateForPrototypes() const;
920
921 USDIMAGING_API
922 bool _DoesDelegateSupportCoordSys() const;
923
924private:
925 UsdImagingDelegate* _delegate;
926};
927
928class UsdImagingPrimAdapterFactoryBase : public TfType::FactoryBase {
929public:
930 virtual UsdImagingPrimAdapterSharedPtr New() const = 0;
931};
932
933template <class T>
934class UsdImagingPrimAdapterFactory : public UsdImagingPrimAdapterFactoryBase {
935public:
936 virtual UsdImagingPrimAdapterSharedPtr New() const
937 {
938 return std::make_shared<T>();
939 }
940};
941
942PXR_NAMESPACE_CLOSE_SCOPE
943
944#endif // PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H
A basic mathematical interval class.
Definition: interval.h:33
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
Basic type: 3-dimensional floating point range.
Definition: range3d.h:47
Represents a set of data source locators closed under descendancy.
Interface class that defines the execution environment for the client to run a computation.
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
Definition: selection.h:39
Tags for non-hierarchial subdiv surfaces.
Definition: subdivTags.h:26
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Base class of all factory types.
Definition: type.h:56
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:160
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:420
Schema wrapper for UsdAttribute for authoring and introspecting attributes that are primvars.
Definition: primvar.h:245
This class is used as a context object with global stage information, that gets passed down to dataso...
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
Definition: delegate.h:67
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Definition: indexProxy.h:30
Delegate support for instanced prims.
Delegate support for UsdGeomPointInstancer.
Base class for all PrimAdapters.
Definition: primAdapter.h:54
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...
USDIMAGING_API SdfPath GetMaterialUsdPath(UsdPrim const &prim) const
Gets the material path for the given prim, walking up namespace if necessary.
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...
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 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...
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 VtArray< VtIntArray > GetPerPrototypeIndices(UsdPrim const &prim, UsdTimeCode time) const
Computes the per-prototype instance indices for a UsdGeomPointInstancer.
USDIMAGING_API HdModelDrawMode GetFullModelDrawMode(UsdPrim const &prim)
Gets the model draw mode object for the given prim, walking up the namespace if necessary.
USDIMAGING_API void SetDelegate(UsdImagingDelegate *delegate)
A thread-local XformCache provided by the delegate.
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 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.
virtual USDIMAGING_API PopulationMode GetPopulationMode()
Returns the prim's behavior with regard to population and invalidation.
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.
virtual SdfPath Populate(UsdPrim const &prim, UsdImagingIndexProxy *index, UsdImagingInstancerContext const *instancerContext=nullptr)=0
Called to populate the RenderIndex for this UsdPrim.
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 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.
USDIMAGING_API TfToken GetInheritablePurpose(UsdPrim const &prim) const
Returns the purpose token for prim, but only if it is inheritable by child prims (i....
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...
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 std::vector< VtArray< TfToken > > GetInstanceCategories(UsdPrim const &prim)
Return an array of the categories used by each instance.
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 VtValue GetTopology(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Gets the topology object of a specific Usd prim.
USDIMAGING_API GfMatrix4d GetRootTransform() const
The root transform provided by the delegate.
virtual USDIMAGING_API TfToken GetPurpose(UsdPrim const &prim, SdfPath const &cachePath, TfToken const &instanceInheritablePurpose) const
Returns the purpose token for prim.
static USDIMAGING_API UsdAttribute LookupLightParamAttribute(UsdPrim const &prim, TfToken const &paramName)
Provides to paramName->UsdAttribute value mappings.
virtual bool IsSupported(UsdImagingIndexProxy const *index) const
Returns true if the adapter can be populated into the target index.
Definition: primAdapter.h:668
virtual USDIMAGING_API GfRange3d GetExtent(UsdPrim const &prim, SdfPath const &cachePath, UsdTimeCode time) const
Reads the extent from the given prim.
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 PxOsdSubdivTags GetSubdivTags(UsdPrim const &usdPrim, SdfPath const &cachePath, UsdTimeCode time) const
Get the subdiv tags for this prim.
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 bool _GetSceneLightsEnabled() const
Returns whether lights found in the usdscene are enabled.
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 HdDataSourceLocatorSet InvalidateImagingSubprimFromDescendent(UsdPrim const &prim, UsdPrim const &descendentPrim, TfToken const &subprim, TfTokenVector const &properties, UsdImagingPropertyInvalidationType invalidationType)
This is called (for each result of GetImagingSubprims) when this adapter's GetScope() result is Repre...
virtual USDIMAGING_API SdfPath GetInstancerId(UsdPrim const &usdPrim, SdfPath const &cachePath) const
Return the instancerId for this prim.
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.
USDIMAGING_API bool _GetSceneMaterialsEnabled() const
Returns whether custom shading of prims is enabled.
@ RepresentsSelfAndDescendents
The adapter is responsible for USD prims of its registered type as well as any descendents of those p...
Definition: primAdapter.h:98
@ RepresentedByAncestor
Changes to prims of this adapter's registered type are sent to the first ancestor prim whose adapter'...
Definition: primAdapter.h:107
@ RepresentsSelf
The adapter is responsible only for USD prims of its registered type.
Definition: primAdapter.h:92
virtual USDIMAGING_API SdfPath GetScenePrimPath(SdfPath const &cachePath, int instanceIndex, HdInstancerContext *instancerCtx) const
A cache for primvar descriptors.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
Return a UsdAttribute with the name attrName.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:67
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:211
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
Object used by instancer prim adapters to pass along context about the instancer and instance prim to...
Describes optional alternative imaging behavior for prims.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440