Loading...
Searching...
No Matches
primAdapter.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24#ifndef PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H
25#define PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/usdImaging/usdImaging/api.h"
31#include "pxr/usdImaging/usdImaging/version.h"
35#include "pxr/usdImaging/usdImaging/types.h"
36
37#include "pxr/imaging/hd/changeTracker.h"
38#include "pxr/imaging/hd/selection.h"
39#include "pxr/usd/usd/attribute.h"
40#include "pxr/usd/usd/prim.h"
41#include "pxr/usd/usd/timeCode.h"
42
44
45#include "pxr/base/tf/type.h"
46
47#include <memory>
48
49PXR_NAMESPACE_OPEN_SCOPE
50
51class UsdPrim;
52
53// Forward declaration for nested class.
58
60
61using UsdImagingPrimAdapterSharedPtr =
62 std::shared_ptr<class UsdImagingPrimAdapter>;
63
69 : public std::enable_shared_from_this<UsdImagingPrimAdapter>
70{
71public:
72
74 {}
75
76 USDIMAGING_API
77 virtual ~UsdImagingPrimAdapter();
78
79 // ---------------------------------------------------------------------- //
81 // ---------------------------------------------------------------------- //
82
83 USDIMAGING_API
84 virtual TfTokenVector GetImagingSubprims(UsdPrim const& prim);
85
86 USDIMAGING_API
87 virtual TfToken GetImagingSubprimType(
88 UsdPrim const& prim, TfToken const& subprim);
89
90 USDIMAGING_API
91 virtual HdContainerDataSourceHandle GetImagingSubprimData(
92 UsdPrim const& prim,
93 TfToken const& subprim,
94 const UsdImagingDataSourceStageGlobals &stageGlobals);
95
96 USDIMAGING_API
97 virtual HdDataSourceLocatorSet InvalidateImagingSubprim(
98 UsdPrim const& prim,
99 TfToken const& subprim,
100 TfTokenVector const& properties,
101 UsdImagingPropertyInvalidationType invalidationType);
102
109 {
113
119
128 };
129
132 USDIMAGING_API
134
139 USDIMAGING_API
141 UsdPrim const& prim,
142 UsdPrim const& descendentPrim,
143 TfToken const& subprim,
144 TfTokenVector const& properties,
145 UsdImagingPropertyInvalidationType invalidationType);
146
147 // ---------------------------------------------------------------------- //
149 // ---------------------------------------------------------------------- //
150
154 virtual SdfPath Populate(UsdPrim const& prim,
157 instancerContext = nullptr) = 0;
158
159 // Indicates whether population traversal should be pruned based on
160 // prim-specific features (like whether it's imageable).
161 USDIMAGING_API
162 static bool ShouldCullSubtree(UsdPrim const& prim);
163
164 // Indicates whether population traversal should be pruned based on
165 // adapter-specific features (like whether the adapter is an instance
166 // adapter, and wants to do its own population).
167 USDIMAGING_API
168 virtual bool ShouldCullChildren() const;
169
170 // Indicates whether or not native USD prim instancing should be ignored
171 // for prims using this delegate, along with their descendants.
172 USDIMAGING_API
173 virtual bool ShouldIgnoreNativeInstanceSubtrees() const;
174
175 // Indicates the adapter is a multiplexing adapter (e.g. PointInstancer),
176 // potentially managing its children. This flag is used in nested
177 // instancer cases to determine which adapter is assigned to which prim.
178 USDIMAGING_API
179 virtual bool IsInstancerAdapter() const;
180
181 // Indicates whether this adapter can directly populate USD instance prims.
182 //
183 // Normally, with USD instances, we make a firewall between the instance
184 // prim and the USD prototype tree. The instance adapter creates one
185 // hydra prototype per prim in the USD prototype tree, shared by all USD
186 // instances; this lets us recognize the benefits of instancing,
187 // by hopefully having a high instance count per prototype. The instance
188 // adapter additionally configures a hydra instancer for the prototype tree;
189 // and a small set of specially-handled data is allowed through: things like
190 // inherited constant primvars, transforms, visibility, and other things
191 // we know how to vary per-instance.
192 //
193 // We enforce the above policy by refusing to populate gprims which are
194 // USD instances, since we'd need one prototype per instance and would lose
195 // any instancing benefit.
196 //
197 // There are a handful of times when it really is useful to directly
198 // populate instance prims: for example, instances with cards applied,
199 // or instances of type UsdSkelRoot. In those cases, the adapters can
200 // opt into this scheme with "CanPopulateUsdInstance".
201 //
202 // Note that any adapters taking advantage of this feature will need
203 // extensive code support in instanceAdapter: the instance adapter will
204 // need to potentially create and track multiple hydra prototypes per
205 // USD prototype, and the adapter will need special handling to pass down
206 // any relevant instance-varying data.
207 //
208 // In summary: use with caution.
209 USDIMAGING_API
210 virtual bool CanPopulateUsdInstance() const;
211
212 // ---------------------------------------------------------------------- //
214 // ---------------------------------------------------------------------- //
215
221 virtual void TrackVariability(UsdPrim const& prim,
222 SdfPath const& cachePath,
223 HdDirtyBits* timeVaryingBits,
225 instancerContext = nullptr) const = 0;
226
231 virtual void UpdateForTime(UsdPrim const& prim,
232 SdfPath const& cachePath,
233 UsdTimeCode time,
234 HdDirtyBits requestedBits,
236 instancerContext = nullptr) const = 0;
237
238 // ---------------------------------------------------------------------- //
240 // ---------------------------------------------------------------------- //
241
252 USDIMAGING_API
253 virtual HdDirtyBits ProcessPrimChange(UsdPrim const& prim,
254 SdfPath const& cachePath,
255 TfTokenVector const& changedFields);
256
259 virtual HdDirtyBits ProcessPropertyChange(UsdPrim const& prim,
260 SdfPath const& cachePath,
261 TfToken const& propertyName) = 0;
262
266 USDIMAGING_API
267 virtual void ProcessPrimResync(SdfPath const& cachePath,
268 UsdImagingIndexProxy* index);
269
272 USDIMAGING_API
273 virtual void ProcessPrimRemoval(SdfPath const& cachePath,
274 UsdImagingIndexProxy* index);
275
276
277 virtual void MarkDirty(UsdPrim const& prim,
278 SdfPath const& cachePath,
279 HdDirtyBits dirty,
280 UsdImagingIndexProxy* index) = 0;
281
282 USDIMAGING_API
283 virtual void MarkRefineLevelDirty(UsdPrim const& prim,
284 SdfPath const& cachePath,
285 UsdImagingIndexProxy* index);
286
287 USDIMAGING_API
288 virtual void MarkReprDirty(UsdPrim const& prim,
289 SdfPath const& cachePath,
290 UsdImagingIndexProxy* index);
291
292 USDIMAGING_API
293 virtual void MarkCullStyleDirty(UsdPrim const& prim,
294 SdfPath const& cachePath,
295 UsdImagingIndexProxy* index);
296
297 USDIMAGING_API
298 virtual void MarkRenderTagDirty(UsdPrim const& prim,
299 SdfPath const& cachePath,
300 UsdImagingIndexProxy* index);
301
302 USDIMAGING_API
303 virtual void MarkTransformDirty(UsdPrim const& prim,
304 SdfPath const& cachePath,
305 UsdImagingIndexProxy* index);
306
307 USDIMAGING_API
308 virtual void MarkVisibilityDirty(UsdPrim const& prim,
309 SdfPath const& cachePath,
310 UsdImagingIndexProxy* index);
311
312 USDIMAGING_API
313 virtual void MarkMaterialDirty(UsdPrim const& prim,
314 SdfPath const& cachePath,
315 UsdImagingIndexProxy* index);
316
317 USDIMAGING_API
318 virtual void MarkLightParamsDirty(UsdPrim const& prim,
319 SdfPath const& cachePath,
320 UsdImagingIndexProxy* index);
321
322 USDIMAGING_API
323 virtual void MarkWindowPolicyDirty(UsdPrim const& prim,
324 SdfPath const& cachePath,
325 UsdImagingIndexProxy* index);
326
327 USDIMAGING_API
328 virtual void MarkCollectionsDirty(UsdPrim const& prim,
329 SdfPath const& cachePath,
330 UsdImagingIndexProxy* index);
331
332 // ---------------------------------------------------------------------- //
334 // ---------------------------------------------------------------------- //
335 USDIMAGING_API
336 virtual void InvokeComputation(SdfPath const& cachePath,
337 HdExtComputationContext* context);
338
339 // ---------------------------------------------------------------------- //
341 // ---------------------------------------------------------------------- //
342
344 USDIMAGING_API
345 virtual std::vector<VtArray<TfToken>>
347
350 USDIMAGING_API
352 UsdPrim const& instancerPrim,
353 SdfPath const& instancerPath,
354 UsdTimeCode time) const;
355
358 USDIMAGING_API
360 UsdPrim const& instancerPrim,
361 SdfPath const& instancerPath,
362 UsdTimeCode time,
363 size_t maxNumSamples,
364 float *sampleTimes,
365 GfMatrix4d *sampleValues);
366
368 USDIMAGING_API
370 UsdPrim const& usdPrim,
371 SdfPath const& cachePath) const;
372
374 USDIMAGING_API
375 virtual SdfPathVector GetInstancerPrototypes(
376 UsdPrim const& usdPrim,
377 SdfPath const& cachePath) const;
378
384 USDIMAGING_API
385 virtual size_t
386 SamplePrimvar(UsdPrim const& usdPrim,
387 SdfPath const& cachePath,
388 TfToken const& key,
389 UsdTimeCode time,
390 size_t maxNumSamples,
391 float *sampleTimes,
392 VtValue *sampleValues,
393 VtIntArray *sampleIndices);
394
396 USDIMAGING_API
397 virtual PxOsdSubdivTags GetSubdivTags(UsdPrim const& usdPrim,
398 SdfPath const& cachePath,
399 UsdTimeCode time) const;
400
401 // ---------------------------------------------------------------------- //
403 // ---------------------------------------------------------------------- //
404
405 // NOTE: This method is currently only used by PointInstancer
406 // style instances, and not instanceable-references.
407
411 USDIMAGING_API
413 SdfPath const &instancerPath,
414 SdfPath const &protoInstancerPath,
415 UsdTimeCode time) const;
416
417 // ---------------------------------------------------------------------- //
419 // ---------------------------------------------------------------------- //
420
422 USDIMAGING_API
423 virtual SdfPath GetScenePrimPath(SdfPath const& cachePath,
424 int instanceIndex,
425 HdInstancerContext *instancerCtx) const;
426
427 USDIMAGING_API
428 virtual SdfPathVector GetScenePrimPaths(SdfPath const& cachePath,
429 std::vector<int> const& instanceIndices,
430 std::vector<HdInstancerContext> *instancerCtxs) const;
431
432 // Add the given usdPrim to the HdSelection object, to mark it for
433 // selection highlighting. cachePath is the path of the object referencing
434 // this adapter.
435 //
436 // If an instance index is provided to Delegate::PopulateSelection, it's
437 // interpreted as a hydra instance index and left unchanged (to make
438 // picking/selection round-tripping work). Otherwise, instance adapters
439 // will build up a composite instance index range at each level.
440 //
441 // Consider:
442 // /World/A (2 instances)
443 // /B (2 instances)
444 // /C (gprim)
445 // ... to select /World/A, instance 0, you want to select cartesian
446 // coordinates (0, *) -> (0, 0) and (0, 1). The flattened representation
447 // of this is:
448 // index = coordinate[0] * instance_count[1] + coordinate[1]
449 // Likewise, for one more nesting level you get:
450 // index = c[0] * count[1] * count[2] + c[1] * count[2] + c[2]
451 // ... since the adapter for /World/A has no idea what count[1+] are,
452 // this needs to be built up. The delegate initially sets
453 // parentInstanceIndices to []. /World/A sets this to [0]. /World/A/B,
454 // since it is selecting *, adds all possible instance indices:
455 // 0 * 2 + 0 = 0, 0 * 2 + 1 = 1. /World/A/B/C is a gprim, and adds
456 // instances [0,1] to its selection.
457 USDIMAGING_API
458 virtual bool PopulateSelection(
459 HdSelection::HighlightMode const& highlightMode,
460 SdfPath const &cachePath,
461 UsdPrim const &usdPrim,
462 int const hydraInstanceIndex,
463 VtIntArray const &parentInstanceIndices,
464 HdSelectionSharedPtr const &result) const;
465
466 // ---------------------------------------------------------------------- //
468 // ---------------------------------------------------------------------- //
469
470 USDIMAGING_API
471 virtual HdVolumeFieldDescriptorVector
472 GetVolumeFieldDescriptors(UsdPrim const& usdPrim, SdfPath const &id,
473 UsdTimeCode time) const;
474
475 // ---------------------------------------------------------------------- //
477 // ---------------------------------------------------------------------- //
478
479 USDIMAGING_API
480 virtual VtValue
481 GetLightParamValue(
482 const UsdPrim& prim,
483 const SdfPath& cachePath,
484 const TfToken& paramName,
485 UsdTimeCode time) const;
486
487 // ---------------------------------------------------------------------- //
489 // ---------------------------------------------------------------------- //
490
492 USDIMAGING_API
494
496 USDIMAGING_API
498
499 USDIMAGING_API
500 bool IsChildPath(SdfPath const& path) const;
501
505 USDIMAGING_API
506 virtual bool GetVisible(
507 UsdPrim const& prim,
508 SdfPath const& cachePath,
509 UsdTimeCode time) const;
510
515 USDIMAGING_API
517 UsdPrim const& prim,
518 SdfPath const& cachePath,
519 TfToken const& instanceInheritablePurpose) const;
520
525 USDIMAGING_API
527
531 USDIMAGING_API
532 virtual GfMatrix4d GetTransform(UsdPrim const& prim,
533 SdfPath const& cachePath,
534 UsdTimeCode time,
535 bool ignoreRootTransform = false) const;
536
538 USDIMAGING_API
539 virtual size_t SampleTransform(UsdPrim const& prim,
540 SdfPath const& cachePath,
541 UsdTimeCode time,
542 size_t maxNumSamples,
543 float *sampleTimes,
544 GfMatrix4d *sampleValues);
545
550 USDIMAGING_API
551 virtual VtValue Get(UsdPrim const& prim,
552 SdfPath const& cachePath,
553 TfToken const& key,
554 UsdTimeCode time,
555 VtIntArray *outIndices) const;
556
558 USDIMAGING_API
559 virtual HdCullStyle GetCullStyle(UsdPrim const& prim,
560 SdfPath const& cachePath,
561 UsdTimeCode time) const;
562
565 USDIMAGING_API
567
570 USDIMAGING_API
572
575 USDIMAGING_API
577
583 USDIMAGING_API
585 UsdTimeCode time) const;
586
591 USDIMAGING_API
592 virtual VtValue GetTopology(UsdPrim const& prim,
593 SdfPath const& cachePath,
594 UsdTimeCode time) const;
595
598 USDIMAGING_API
599 virtual GfRange3d GetExtent(UsdPrim const& prim,
600 SdfPath const& cachePath,
601 UsdTimeCode time) const;
602
604 USDIMAGING_API
605 virtual bool GetDoubleSided(UsdPrim const& prim,
606 SdfPath const& cachePath,
607 UsdTimeCode time) const;
608
609 USDIMAGING_API
610 virtual SdfPath GetMaterialId(UsdPrim const& prim,
611 SdfPath const& cachePath,
612 UsdTimeCode time) const;
613
614 USDIMAGING_API
615 virtual VtValue GetMaterialResource(UsdPrim const& prim,
616 SdfPath const& cachePath,
617 UsdTimeCode time) const;
618
619 // ---------------------------------------------------------------------- //
621 // ---------------------------------------------------------------------- //
622 USDIMAGING_API
623 virtual const TfTokenVector &GetExtComputationSceneInputNames(
624 SdfPath const& cachePath) const;
625
626 USDIMAGING_API
627 virtual HdExtComputationInputDescriptorVector
628 GetExtComputationInputs(UsdPrim const& prim,
629 SdfPath const& cachePath,
630 const UsdImagingInstancerContext* instancerContext)
631 const;
632
633 USDIMAGING_API
634 virtual HdExtComputationOutputDescriptorVector
635 GetExtComputationOutputs(UsdPrim const& prim,
636 SdfPath const& cachePath,
637 const UsdImagingInstancerContext* instancerContext)
638 const;
639
640 USDIMAGING_API
641 virtual HdExtComputationPrimvarDescriptorVector
642 GetExtComputationPrimvars(
643 UsdPrim const& prim,
644 SdfPath const& cachePath,
645 HdInterpolation interpolation,
646 const UsdImagingInstancerContext* instancerContext) const;
647
648 USDIMAGING_API
649 virtual VtValue
650 GetExtComputationInput(
651 UsdPrim const& prim,
652 SdfPath const& cachePath,
653 TfToken const& name,
654 UsdTimeCode time,
655 const UsdImagingInstancerContext* instancerContext) const;
656
657 USDIMAGING_API
658 virtual size_t
659 SampleExtComputationInput(
660 UsdPrim const& prim,
661 SdfPath const& cachePath,
662 TfToken const& name,
663 UsdTimeCode time,
664 const UsdImagingInstancerContext* instancerContext,
665 size_t maxSampleCount,
666 float *sampleTimes,
667 VtValue *sampleValues);
668
669 USDIMAGING_API
670 virtual std::string
671 GetExtComputationKernel(
672 UsdPrim const& prim,
673 SdfPath const& cachePath,
674 const UsdImagingInstancerContext* instancerContext) const;
675
676 USDIMAGING_API
677 virtual VtValue
678 GetInstanceIndices(UsdPrim const& instancerPrim,
679 SdfPath const& instancerCachePath,
680 SdfPath const& prototypeCachePath,
681 UsdTimeCode time) const;
682
683 // ---------------------------------------------------------------------- //
685 // ---------------------------------------------------------------------- //
686
688 virtual bool IsSupported(UsdImagingIndexProxy const* index) const {
689 return true;
690 }
691
692
693 // ---------------------------------------------------------------------- //
695 // ---------------------------------------------------------------------- //
696
698 USDIMAGING_API
700 UsdPrim const& prim,
701 TfToken const& paramName);
702
703protected:
704 using Keys = UsdImagingPrimvarDescCache::Key;
705
706 template <typename T>
707 T _Get(UsdPrim const& prim, TfToken const& attrToken,
708 UsdTimeCode time) const {
709 T value;
710 prim.GetAttribute(attrToken).Get<T>(&value, time);
711 return value;
712 }
713
714 template <typename T>
715 void _GetPtr(UsdPrim const& prim, TfToken const& key, UsdTimeCode time,
716 T* out) const {
717 prim.GetAttribute(key).Get<T>(out, time);
718 }
719
720 USDIMAGING_API
721 UsdImagingPrimvarDescCache* _GetPrimvarDescCache() const;
722
723 UsdImaging_NonlinearSampleCountCache*
724 _GetNonlinearSampleCountCache() const;
725
726 UsdImaging_BlurScaleCache*
727 _GetBlurScaleCache() const;
728
729 USDIMAGING_API
730 UsdPrim _GetPrim(SdfPath const& usdPath) const;
731
732 // Returns the prim adapter for the given \p prim, or an invalid pointer if
733 // no adapter exists. If \p prim is an instance and \p ignoreInstancing
734 // is \c true, the instancing adapter will be ignored and an adapter will
735 // be looked up based on \p prim's type.
736 USDIMAGING_API
737 const UsdImagingPrimAdapterSharedPtr&
738 _GetPrimAdapter(UsdPrim const& prim, bool ignoreInstancing = false) const;
739
740 USDIMAGING_API
741 const UsdImagingPrimAdapterSharedPtr&
742 _GetAdapter(TfToken const& adapterKey) const;
743
744 // XXX: Transitional API
745 // Returns the instance proxy prim path for a USD-instanced prim, given the
746 // instance chain leading to that prim. The paths are sorted from more to
747 // less local; the first path is the prim path (possibly in prototype), then
748 // instance paths (possibly in prototype); the last path is the prim or
749 // instance path in the scene.
750 USDIMAGING_API
751 SdfPath _GetPrimPathFromInstancerChain(
752 SdfPathVector const& instancerChain) const;
753
754 USDIMAGING_API
755 UsdTimeCode _GetTimeWithOffset(float offset) const;
756
757 // Converts \p cachePath to the path in the render index.
758 USDIMAGING_API
759 SdfPath _ConvertCachePathToIndexPath(SdfPath const& cachePath) const;
760
761 // Converts \p indexPath to the path in the USD stage
762 USDIMAGING_API
763 SdfPath _ConvertIndexPathToCachePath(SdfPath const& indexPath) const;
764
765 // Returns the material binding purpose from the renderer delegate.
766 USDIMAGING_API
767 TfToken _GetMaterialBindingPurpose() const;
768
769 // Returns the material contexts from the renderer delegate.
770 USDIMAGING_API
771 TfTokenVector _GetMaterialRenderContexts() const;
772
773 // Returns the namespace prefixes for render settings attributes relevant
774 // to a renderer delegate.
775 USDIMAGING_API
776 TfTokenVector _GetRenderSettingsNamespaces() const;
777
779 USDIMAGING_API
781
783 USDIMAGING_API
785
786 // Returns true if render delegate wants primvars to be filtered based.
787 // This will filter the primvars based on the bound material primvar needs.
788 USDIMAGING_API
789 bool _IsPrimvarFilteringNeeded() const;
790
791 // Returns the shader source type from the render delegate.
792 USDIMAGING_API
793 TfTokenVector _GetShaderSourceTypes() const;
794
795 // Returns \c true if \p usdPath is included in the scene delegate's
796 // invised path list.
797 USDIMAGING_API
798 bool _IsInInvisedPaths(SdfPath const& usdPath) const;
799
800 // Determines if an attribute is varying and if so, sets the given
801 // \p dirtyFlag in the \p dirtyFlags and increments a perf counter. Returns
802 // true if the attribute is varying.
803 //
804 // If \p exists is non-null, _IsVarying will store whether the attribute
805 // was found. If the attribute is not found, it counts as non-varying.
806 //
807 // This only sets the dirty bit, never un-sets. The caller is responsible
808 // for setting the initial state correctly.
809 USDIMAGING_API
810 bool _IsVarying(UsdPrim prim, TfToken const& attrName,
811 HdDirtyBits dirtyFlag, TfToken const& perfToken,
812 HdDirtyBits* dirtyFlags, bool isInherited,
813 bool* exists = nullptr) const;
814
815 // Determines if the prim's transform (CTM) is varying and if so, sets the
816 // given \p dirtyFlag in the \p dirtyFlags and increments a perf counter.
817 // Returns true if the prim's transform is varying.
818 //
819 // This only sets the dirty bit, never un-sets. The caller is responsible
820 // for setting the initial state correctly.
821 USDIMAGING_API
822 bool _IsTransformVarying(UsdPrim prim,
823 HdDirtyBits dirtyFlag,
824 TfToken const& perfToken,
825 HdDirtyBits* dirtyFlags) const;
826
827 // Convenience method for adding or updating a primvar descriptor.
828 // Role defaults to empty token (none). Indexed defaults to false.
829 USDIMAGING_API
830 void _MergePrimvar(
831 HdPrimvarDescriptorVector* vec,
832 TfToken const& name,
833 HdInterpolation interp,
834 TfToken const& role = TfToken(),
835 bool indexed = false) const;
836
837 // Convenience method for removing a primvar descriptor.
838 USDIMAGING_API
839 void _RemovePrimvar(
840 HdPrimvarDescriptorVector* vec,
841 TfToken const& name) const;
842
843 // Convenience method for computing a primvar. The primvar will only be
844 // added to the list of prim desc if there is no primvar of the same
845 // name already present. Thus, "local" primvars should be merged before
846 // inherited primvars.
847 USDIMAGING_API
848 void _ComputeAndMergePrimvar(
849 UsdPrim const& prim,
850 UsdGeomPrimvar const& primvar,
851 UsdTimeCode time,
852 HdPrimvarDescriptorVector* primvarDescs,
853 HdInterpolation *interpOverride = nullptr) const;
854
855 // Returns true if the property name has the "primvars:" prefix.
856 USDIMAGING_API
857 static bool _HasPrimvarsPrefix(TfToken const& propertyName);
858
859 // Convenience methods to figure out what changed about the primvar and
860 // return the appropriate dirty bit.
861 // Caller can optionally pass in a dirty bit to set for primvar value
862 // changes. This is useful for attributes that have a special dirty bit
863 // such as normals and widths.
864 //
865 // Handle USD attributes that are treated as primvars by Hydra. This
866 // requires the interpolation to be passed in, as well as the primvar
867 // name passed to Hydra.
868 USDIMAGING_API
869 HdDirtyBits _ProcessNonPrefixedPrimvarPropertyChange(
870 UsdPrim const& prim,
871 SdfPath const& cachePath,
872 TfToken const& propertyName,
873 TfToken const& primvarName,
874 HdInterpolation const& primvarInterp,
875 HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar) const;
876
877 // Handle UsdGeomPrimvars that use the "primvars:" prefix, while also
878 // accommodating inheritance.
879 USDIMAGING_API
880 HdDirtyBits _ProcessPrefixedPrimvarPropertyChange(
881 UsdPrim const& prim,
882 SdfPath const& cachePath,
883 TfToken const& propertyName,
884 HdDirtyBits valueChangeDirtyBit = HdChangeTracker::DirtyPrimvar,
885 bool inherited = true) const;
886
887 virtual void _RemovePrim(SdfPath const& cachePath,
888 UsdImagingIndexProxy* index) = 0;
889
890 // Utility to resync bound dependencies of a particular usd path.
891 // This is necessary for the resync processing of certain prim types
892 // (e.g. materials).
893 USDIMAGING_API
894 void _ResyncDependents(SdfPath const& usdPath,
895 UsdImagingIndexProxy *index);
896
897 USDIMAGING_API
898 UsdImaging_CollectionCache& _GetCollectionCache() const;
899
900 USDIMAGING_API
901 UsdStageRefPtr _GetStage() const;
902
903 USDIMAGING_API
904 UsdImaging_CoordSysBindingStrategy::value_type
905 _GetCoordSysBindings(UsdPrim const& prim) const;
906
907 USDIMAGING_API
908 UsdImaging_InheritedPrimvarStrategy::value_type
909 _GetInheritedPrimvars(UsdPrim const& prim) const;
910
911 // Utility for derived classes to try to find an inherited primvar.
912 USDIMAGING_API
913 UsdGeomPrimvar _GetInheritedPrimvar(UsdPrim const& prim,
914 TfToken const& primvarName) const;
915
916 USDIMAGING_API
917 GfInterval _GetCurrentTimeSamplingInterval();
918
919 USDIMAGING_API
920 Usd_PrimFlagsConjunction _GetDisplayPredicate() const;
921
922 USDIMAGING_API
923 Usd_PrimFlagsConjunction _GetDisplayPredicateForPrototypes() const;
924
925 USDIMAGING_API
926 bool _DoesDelegateSupportCoordSys() const;
927
928private:
929 UsdImagingDelegate* _delegate;
930};
931
932class UsdImagingPrimAdapterFactoryBase : public TfType::FactoryBase {
933public:
934 virtual UsdImagingPrimAdapterSharedPtr New() const = 0;
935};
936
937template <class T>
938class UsdImagingPrimAdapterFactory : public UsdImagingPrimAdapterFactoryBase {
939public:
940 virtual UsdImagingPrimAdapterSharedPtr New() const
941 {
942 return std::make_shared<T>();
943 }
944};
945
946
947PXR_NAMESPACE_CLOSE_SCOPE
948
949#endif // PXR_USD_IMAGING_USD_IMAGING_PRIM_ADAPTER_H
A basic mathematical interval class.
Definition: interval.h:50
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
Basic type: 3-dimensional floating point range.
Definition: range3d.h:64
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:56
Tags for non-hierarchial subdiv surfaces.
Definition: subdivTags.h:43
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:292
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
Base class of all factory types.
Definition: type.h:73
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
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:436
Schema wrapper for UsdAttribute for authoring and introspecting attributes that are primvars.
Definition: primvar.h:262
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:87
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Definition: indexProxy.h:47
Base class for all PrimAdapters.
Definition: primAdapter.h:70
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:688
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:118
@ RepresentedByAncestor
Changes to prims of this adapter's registered type are sent to the first ancestor prim whose adapter'...
Definition: primAdapter.h:127
@ RepresentsSelf
The adapter is responsible only for USD prims of its registered type.
Definition: primAdapter.h:112
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:136
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:84
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:229
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
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:442