Loading...
Searching...
No Matches
delegate.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_DELEGATE_H
8#define PXR_USD_IMAGING_USD_IMAGING_DELEGATE_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usdImaging/usdImaging/api.h"
14#include "pxr/usdImaging/usdImaging/version.h"
19
20#include "pxr/imaging/cameraUtil/conformWindow.h"
21
22#include "pxr/imaging/hd/coordSys.h"
23#include "pxr/imaging/hd/sceneDelegate.h"
24#include "pxr/imaging/hd/selection.h"
25#include "pxr/imaging/hd/version.h"
26
28#include "pxr/usd/sdf/path.h"
29#include "pxr/usd/sdf/pathTable.h"
30#include "pxr/usd/usd/attribute.h"
31#include "pxr/usd/usd/notice.h"
32#include "pxr/usd/usd/prim.h"
33#include "pxr/usd/usd/stage.h"
36#include "pxr/usd/usdGeom/xformCache.h"
37#include "pxr/base/vt/value.h"
38
39#include "pxr/base/gf/range3d.h"
42#include "pxr/base/tf/hashmap.h"
43#include "pxr/base/tf/hashset.h"
45
46#include <tbb/spin_rw_mutex.h>
47#include <map>
48#include <string>
49
50PXR_NAMESPACE_OPEN_SCOPE
51
52
54typedef std::vector<UsdPrim> UsdPrimVector;
55
59
60using UsdImagingPrimAdapterSharedPtr = std::shared_ptr<UsdImagingPrimAdapter>;
61
69public:
70
71 typedef TfHashMap<SdfPath, GfMatrix4d, SdfPath::Hash> RigidXformOverridesMap;
72
73 USDIMAGING_API
75 SdfPath const& delegateID);
76
77 USDIMAGING_API
78 virtual ~UsdImagingDelegate();
79
80 USDIMAGING_API
81 virtual void Sync(HdSyncRequestVector* request) override;
82
83 // Helper for clients who don't want to drive the sync behavior (unit
84 // tests). Note this method is not virtual.
85 USDIMAGING_API
86 void SyncAll(bool includeUnvarying);
87
89 USDIMAGING_API
90 void Populate(UsdPrim const& rootPrim);
91
94 USDIMAGING_API
95 void Populate(UsdPrim const& rootPrim,
96 SdfPathVector const& excludedPrimPaths,
97 SdfPathVector const &invisedPrimPaths=SdfPathVector());
98
105 USDIMAGING_API
106 static void SetTimes(const std::vector<UsdImagingDelegate*>& delegates,
107 const std::vector<UsdTimeCode>& times);
108
114 USDIMAGING_API
116
118 UsdTimeCode GetTime() const { return _time; }
119
122 UsdTimeCode GetTimeWithOffset(float offset) const;
123
125 USDIMAGING_API
127
135 int GetRefineLevelFallback() const { return _refineLevelFallback; }
136
143 USDIMAGING_API
144 void SetRefineLevelFallback(int level);
145
148 USDIMAGING_API
149 void ClearRefineLevel(SdfPath const& usdPath);
150
156 USDIMAGING_API
157 void SetRefineLevel(SdfPath const& usdPath, int level);
158
160 HdReprSelector GetReprFallback() const { return _reprFallback; }
161
164 USDIMAGING_API
166
168 HdCullStyle GetCullStyleFallback() const { return _cullStyleFallback; }
169
171 USDIMAGING_API
172 void SetCullStyleFallback(HdCullStyle cullStyle);
173
177 USDIMAGING_API
179
181 const GfMatrix4d &GetRootTransform() const { return _rootXf; }
182
186 USDIMAGING_API
187 void SetRootVisibility(bool isVisible);
188
190 bool GetRootVisibility() const { return _rootIsVisible; }
191
194 USDIMAGING_API
195 void SetRootInstancerId(SdfPath const& instancerId);
196
198 SdfPath GetRootInstancerId() const { return _rootInstancerId; }
199
201 USDIMAGING_API
202 void SetInvisedPrimPaths(SdfPathVector const &invisedPaths);
203
205 USDIMAGING_API
206 void SetRigidXformOverrides(RigidXformOverridesMap const &overrides);
207
209 USDIMAGING_API
210 void SetDisplayRender(const bool displayRender);
211 bool GetDisplayRender() const { return _displayRender; }
212
214 USDIMAGING_API
215 void SetDisplayProxy(const bool displayProxy);
216 bool GetDisplayProxy() const { return _displayProxy; }
217
219 USDIMAGING_API
220 void SetDisplayGuides(const bool displayGuides);
221 bool GetDisplayGuides() const { return _displayGuides; }
222
224 USDIMAGING_API
225 void SetUsdDrawModesEnabled(bool enableUsdDrawModes);
226 bool GetUsdDrawModesEnabled() const { return _enableUsdDrawModes; }
227
229 USDIMAGING_API
230 void SetSceneMaterialsEnabled(bool enable);
231
233 USDIMAGING_API
234 void SetSceneLightsEnabled(bool enable);
235
238 USDIMAGING_API
239 void SetWindowPolicy(CameraUtilConformWindowPolicy policy);
240
249 USDIMAGING_API
250 void SetDisplayUnloadedPrimsWithBounds(bool displayUnloaded);
251 bool GetDisplayUnloadedPrimsWithBounds() const {
252 return _displayUnloadedPrimsWithBounds;
253 }
254
256 USDIMAGING_API
258
261 USDIMAGING_API
263
264 // ---------------------------------------------------------------------- //
265 // See HdSceneDelegate for documentation of the following virtual methods.
266 // ---------------------------------------------------------------------- //
267 USDIMAGING_API
268 virtual TfToken GetRenderTag(SdfPath const& id) override;
269 USDIMAGING_API
270 virtual HdMeshTopology GetMeshTopology(SdfPath const& id) override;
271 USDIMAGING_API
273 override;
275
276 // XXX: animated subdiv tags are not currently supported
277 // XXX: subdiv tags currently fetched on-demand
278 USDIMAGING_API
279 virtual SubdivTags GetSubdivTags(SdfPath const& id) override;
280
281 USDIMAGING_API
282 virtual GfRange3d GetExtent(SdfPath const & id) override;
283 USDIMAGING_API
284 virtual GfMatrix4d GetTransform(SdfPath const & id) override;
285 USDIMAGING_API
286 virtual bool GetVisible(SdfPath const & id) override;
287 USDIMAGING_API
288 virtual bool GetDoubleSided(SdfPath const & id) override;
289 USDIMAGING_API
290 virtual HdCullStyle GetCullStyle(SdfPath const &id) override;
291
295 USDIMAGING_API
296 virtual HdDisplayStyle GetDisplayStyle(SdfPath const& id) override;
297
298 USDIMAGING_API
300
301 USDIMAGING_API
302 virtual VtValue Get(SdfPath const& id, TfToken const& key) override;
303 USDIMAGING_API
305 TfToken const& key,
306 VtIntArray *outIndices) override;
307 USDIMAGING_API
308 HdIdVectorSharedPtr
309 virtual GetCoordSysBindings(SdfPath const& id) override;
310 USDIMAGING_API
311 virtual HdReprSelector GetReprSelector(SdfPath const &id) override;
312 USDIMAGING_API
313 virtual VtArray<TfToken> GetCategories(SdfPath const &id) override;
314 USDIMAGING_API
315 virtual std::vector<VtArray<TfToken>>
316 GetInstanceCategories(SdfPath const &instancerId) override;
317 USDIMAGING_API
318 virtual HdPrimvarDescriptorVector
320 HdInterpolation interpolation) override;
321 USDIMAGING_API
322 virtual VtIntArray GetInstanceIndices(SdfPath const &instancerId,
323 SdfPath const &prototypeId) override;
324 USDIMAGING_API
325 virtual GfMatrix4d GetInstancerTransform(SdfPath const &instancerId)
326 override;
327
328 USDIMAGING_API
329 virtual SdfPath GetInstancerId(SdfPath const &primId) override;
330
331 USDIMAGING_API
332 virtual SdfPathVector GetInstancerPrototypes(SdfPath const &instancerId) override;
333
334 // Motion samples
335 USDIMAGING_API
336 virtual size_t
337 SampleTransform(SdfPath const & id, size_t maxNumSamples,
338 float *times, GfMatrix4d *samples) override;
339 USDIMAGING_API
340 virtual size_t
342 size_t maxSampleCount, float *times,
343 GfMatrix4d *samples) override;
344 USDIMAGING_API
345 virtual size_t
346 SamplePrimvar(SdfPath const& id, TfToken const& key,
347 size_t maxNumSamples, float *times,
348 VtValue *samples) override;
349
350 USDIMAGING_API
351 virtual size_t
352 SampleIndexedPrimvar(SdfPath const& id, TfToken const& key,
353 size_t maxNumSamples, float *times,
354 VtValue *samples, VtIntArray *indices) override;
355
356 // Material Support
357 USDIMAGING_API
358 virtual SdfPath GetMaterialId(SdfPath const &rprimId) override;
359
360 USDIMAGING_API
361 virtual VtValue GetMaterialResource(SdfPath const &materialId) override;
362
363 // Light Support
364 USDIMAGING_API
365 virtual VtValue GetLightParamValue(SdfPath const &id,
366 TfToken const &paramName) override;
367 // Camera Support
368 USDIMAGING_API
370 TfToken const &paramName) override;
371
372 // Volume Support
373 USDIMAGING_API
374 virtual HdVolumeFieldDescriptorVector
375 GetVolumeFieldDescriptors(SdfPath const &volumeId) override;
376
377 USDIMAGING_API
378 virtual VtValue GetVolumeParamValue(SdfPath const &id,
379 TfToken const &paramName) override;
380
381 // Picking path resolution
382 // Resolves a \p rprimId and \p instanceIndex back to the original USD
383 // gprim and instance index. For point-instanced prims, \p instanceContext
384 // returns extra information about which instance this is of which level of
385 // point-instancer. For example:
386 // /World/PI instances /World/PI/proto/PI
387 // /World/PI/proto/PI instances /World/PI/proto/PI/proto/Gprim
388 // instancerContext = [/World/PI, 0], [/World/PI/proto/PI, 1] means that
389 // this instance represents "protoIndex = 0" of /World/PI, etc.
390
391 USDIMAGING_API
392 virtual SdfPath
393 GetScenePrimPath(SdfPath const& rprimId,
394 int instanceIndex,
395 HdInstancerContext *instancerContext = nullptr) override;
396
397 USDIMAGING_API
398 virtual SdfPathVector
400 std::vector<int> instanceIndices,
401 std::vector<HdInstancerContext> *instancerContexts = nullptr) override;
402
403 // ExtComputation support
404 USDIMAGING_API
406 GetExtComputationSceneInputNames(SdfPath const& computationId) override;
407
408 USDIMAGING_API
409 HdExtComputationInputDescriptorVector
410 GetExtComputationInputDescriptors(SdfPath const& computationId) override;
411
412 USDIMAGING_API
413 HdExtComputationOutputDescriptorVector
414 GetExtComputationOutputDescriptors(SdfPath const& computationId) override;
415
416 USDIMAGING_API
417 HdExtComputationPrimvarDescriptorVector
419 HdInterpolation interpolation) override;
420
421 USDIMAGING_API
423 TfToken const& input) override;
424
425 USDIMAGING_API
426 size_t SampleExtComputationInput(SdfPath const& computationId,
427 TfToken const& input,
428 size_t maxSampleCount,
429 float *sampleTimes,
430 VtValue *sampleValues) override;
431
432 USDIMAGING_API
433 std::string GetExtComputationKernel(SdfPath const& computationId) override;
434
435 USDIMAGING_API
436 void InvokeExtComputation(SdfPath const& computationId,
437 HdExtComputationContext *context) override;
438
439public:
440 // Converts a cache path to a path in the render index.
441 USDIMAGING_API
442 SdfPath ConvertCachePathToIndexPath(SdfPath const& cachePath) {
443 SdfPathMap::const_iterator it = _cache2indexPath.find(cachePath);
444 if (it != _cache2indexPath.end()) {
445 return it->second;
446 }
447
448 // For pure/plain usdImaging, there is no prefix to replace
449 SdfPath const &delegateID = GetDelegateID();
450 if (delegateID == SdfPath::AbsoluteRootPath()) {
451 return cachePath;
452 }
453 if (cachePath.IsEmpty()) {
454 return cachePath;
455 }
456
457 return cachePath.ReplacePrefix(SdfPath::AbsoluteRootPath(), delegateID);
458 }
459
465 USDIMAGING_API
467 SdfPathMap::const_iterator it = _index2cachePath.find(indexPath);
468 if (it != _index2cachePath.end()) {
469 return it->second;
470 }
471
472 // For pure/plain usdImaging, there is no prefix to replace
473 SdfPath const &delegateID = GetDelegateID();
474 if (delegateID == SdfPath::AbsoluteRootPath()) {
475 return indexPath;
476 }
477
478 return indexPath.ReplacePrefix(delegateID, SdfPath::AbsoluteRootPath());
479 }
480
495 static constexpr int ALL_INSTANCES = -1;
496 USDIMAGING_API
497 bool PopulateSelection(HdSelection::HighlightMode const& highlightMode,
498 const SdfPath &usdPath,
499 int instanceIndex,
500 HdSelectionSharedPtr const &result);
501
503 USDIMAGING_API
504 bool IsInInvisedPaths(const SdfPath &usdPath) const;
505
506private:
507 // Internal Get and SamplePrimvar
508 VtValue _Get(SdfPath const& id, TfToken const& key, VtIntArray *outIndices);
509
510 size_t _SamplePrimvar(SdfPath const& id, TfToken const& key,
511 size_t maxNumSamples, float *times, VtValue *samples,
512 VtIntArray *indices);
513
514 // Internal friend class.
515 class _Worker;
516 friend class UsdImagingIndexProxy;
517 friend class UsdImagingPrimAdapter;
518
519 bool _ValidateRefineLevel(int level) {
520 if (!(0 <= level && level <= 8)) {
521 TF_CODING_ERROR("Invalid refinement level(%d), "
522 "expected range is [0,8]",
523 level);
524 return false;
525 }
526 return true;
527 }
528
529 void _AddTask(UsdImagingDelegate::_Worker *worker, SdfPath const& usdPath);
530
531 // ---------------------------------------------------------------------- //
532 // Draw mode support
533 // ---------------------------------------------------------------------- //
534 // Determine whether to assign a draw mode adapter to the given prim.
535 bool _IsDrawModeApplied(UsdPrim const& prim);
536 // Get the inherited model:drawMode attribute of the given prim.
537 TfToken _GetModelDrawMode(UsdPrim const& prim);
538
539 // ---------------------------------------------------------------------- //
540 // Usd Change Processing / Notice Handlers
541 // ---------------------------------------------------------------------- //
542 void _OnUsdObjectsChanged(UsdNotice::ObjectsChanged const&,
543 UsdStageWeakPtr const& sender);
544
545 // Map holding USD subtree path keys mapped to associated hydra prim cache
546 // paths. This may be prepopulated and provided to the Refresh and Resync
547 // methods below to speed up dependency gathering.
548 typedef TfHashMap<SdfPath, SdfPathVector, SdfPath::Hash>
549 _FlattenedDependenciesCacheMap;
550
551 // The lightest-weight update, it does fine-grained invalidation of
552 // individual properties at the given path (prim or property).
553 //
554 // If \p path is a prim path, changedPrimInfoFields will be populated
555 // with the list of scene description fields that caused this prim to
556 // be refreshed.
557 //
558 // Returns whether the prim or the subtree rooted at `usdPath` needed to
559 // be resync'd (i.e., removed and repopulated).
560 //
561 bool _RefreshUsdObject(SdfPath const& usdPath,
562 TfTokenVector const& changedPrimInfoFields,
563 _FlattenedDependenciesCacheMap const &cache,
565 SdfPathSet* allTrackedVariabilityPaths);
566
567 // Heavy-weight invalidation of an entire prim subtree. All cached data is
568 // reconstructed for all prims below \p rootPath.
569 //
570 // By default, _ResyncPrim will remove each affected prim and call
571 // Repopulate() on those prims individually. If repopulateFromRoot is
572 // true, Repopulate() will be called on \p rootPath instead. This is slower,
573 // but handles changes in tree topology.
574 void _ResyncUsdPrim(SdfPath const& usdRootPath,
575 _FlattenedDependenciesCacheMap const &cache,
577 bool repopulateFromRoot = false);
578
579 // ---------------------------------------------------------------------- //
580 // Usd Data-Access Helper Methods
581 // ---------------------------------------------------------------------- //
582 UsdPrim _GetUsdPrim(SdfPath const& usdPath) {
583 UsdPrim const& p =
584 _stage->GetPrimAtPath(usdPath.GetAbsoluteRootOrPrimPath());
585 TF_VERIFY(p, "No prim found for id: %s",
587 return p;
588 }
589
590 void _UpdateSingleValue(SdfPath const& cachePath, int dirtyFlags);
591
592 // ---------------------------------------------------------------------- //
593 // Cache structures and related methods for population.
594 // ---------------------------------------------------------------------- //
595
596 // Returns true if this delegate can be populated, false otherwise.
597 bool _CanPopulate(UsdPrim const& rootPrim) const;
598
599 // Set the delegate's state to reflect that it will be populated from
600 // the given root prim with the given excluded paths.
601 void _SetStateForPopulation(UsdPrim const& rootPrim,
602 SdfPathVector const& excludedPaths,
603 SdfPathVector const& invisedPaths);
604
605 // Populates this delegate's render index from the paths specified
606 // in the given index proxy.
607 void _Populate(class UsdImagingIndexProxy* proxy);
608
609 // Execute all variability update tasks that have been added to the given
610 // worker.
611 static void _ExecuteWorkForVariabilityUpdate(_Worker* worker);
612
616 bool _GetVisible(UsdPrim const& prim);
617
619 TfTokenVector _GetPrimvarNames(SdfPath const& usdPath,
620 TfToken const& interpolation);
621
622 // ---------------------------------------------------------------------- //
623 // Helper methods for updating the delegate on time changes
624 // ---------------------------------------------------------------------- //
625
626 // Execute all time update tasks that have been added to the given worker.
627 static void _ExecuteWorkForTimeUpdate(_Worker* worker);
628
629 // ---------------------------------------------------------------------- //
630 // Core Delegate state
631 // ---------------------------------------------------------------------- //
632
633 // Usd Prim Type to Adapter lookup table.
634 typedef TfHashMap<TfToken, UsdImagingPrimAdapterSharedPtr,
635 TfToken::HashFunctor> _AdapterMap;
636 _AdapterMap _adapterMap;
637
638 // Per-Hydra-Primitive tracking data
639 struct _HdPrimInfo {
640 UsdImagingPrimAdapterSharedPtr adapter; // The adapter to use for the
641 // prim
642 UsdPrim usdPrim; // Reference to the Usd prim
643 HdDirtyBits timeVaryingBits; // Dirty Bits to set when
644 // time changes
645 HdDirtyBits dirtyBits; // Current dirty state of the prim.
647 extraDependencies;// Dependencies that aren't usdPrim.
648 };
649
650 typedef TfHashMap<SdfPath, _HdPrimInfo, SdfPath::Hash> _HdPrimInfoMap;
651
652 // Map from cache path to Hydra prim info
653 _HdPrimInfoMap _hdPrimInfoMap;
654
655 typedef std::multimap<SdfPath, SdfPath> _DependencyMap;
656
657 // Map from USD path to Hydra path, for tracking USD->hydra dependencies.
658 _DependencyMap _dependencyInfo;
659
660 // Appends hydra prim cache paths corresponding to the USD subtree
661 // provided by looking up the dependency map (above).
662 void _GatherDependencies(SdfPath const& subtree,
663 SdfPathVector *affectedCachePaths);
664
665 // Overload that takes an additional cache argument to help speed up the
666 // dependency gathering operation. The onus is on the client to prepopulate
667 // the cache.
668 void
669 _GatherDependencies(SdfPath const &subtree,
670 _FlattenedDependenciesCacheMap const &cache,
671 SdfPathVector *affectedCachePaths);
672
673 // SdfPath::ReplacePrefix() is used frequently to convert between
674 // cache path and Hydra render index path and is a performance bottleneck.
675 // These maps pre-computes these conversion.
676 typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash> SdfPathMap;
677 SdfPathMap _cache2indexPath;
678 SdfPathMap _index2cachePath;
679
680 // Only use this method when we think no existing adapter has been
681 // established. For example, during initial Population.
682 UsdImagingPrimAdapterSharedPtr const& _AdapterLookup(
683 UsdPrim const& prim,
684 bool ignoreInstancing = false);
685 UsdImagingPrimAdapterSharedPtr const& _AdapterLookup(
686 TfToken const& adapterKey);
687
688 // Obtain the prim tracking data for the given cache path.
689 _HdPrimInfo *_GetHdPrimInfo(const SdfPath &cachePath);
690
691 Usd_PrimFlagsConjunction _GetDisplayPredicate() const;
692 Usd_PrimFlagsConjunction _GetDisplayPredicateForPrototypes() const;
693
694 // Mark render tags dirty for all prims.
695 // This is done in response to toggling the purpose-based display settings.
696 void _MarkRenderTagsDirty();
697
698 typedef TfHashSet<SdfPath, SdfPath::Hash> _DirtySet;
699
700 // Set of cache paths that are due a Sync()
701 _DirtySet _dirtyCachePaths;
702
704 typedef TfHashMap<SdfPath, int, SdfPath::Hash> _RefineLevelMap;
706 _RefineLevelMap _refineLevelMap;
707
709 UsdImagingPrimvarDescCache _primvarDescCache;
710
712 UsdStageRefPtr _stage;
713 SdfPath _rootPrimPath;
714 SdfPathVector _excludedPrimPaths;
715 SdfPathVector _invisedPrimPaths;
716
717 RigidXformOverridesMap _rigidXformOverrides;
718
719 // Aspects of the delegate root that apply to all items in the index.
720 SdfPath _compensationPath;
721
722 GfMatrix4d _rootXf;
723 bool _rootIsVisible;
724 SdfPath _rootInstancerId;
725
727 UsdTimeCode _time;
728
730 SdfPath _cameraPathForSampling;
731
732 int _refineLevelFallback;
733 HdReprSelector _reprFallback;
734 HdCullStyle _cullStyleFallback;
735
736 // Cache of which prims are time-varying.
737 SdfPathVector _timeVaryingPrimCache;
738 bool _timeVaryingPrimCacheValid;
739
740 // Change processing
741 TfNotice::Key _objectsChangedNoticeKey;
742 SdfPathVector _usdPathsToResync;
743
744 // Map from path of Usd object to update to list of changed scene
745 // description fields for that object. This list of fields is only
746 // populated for prim paths.
747 typedef std::unordered_map<SdfPath, TfTokenVector, SdfPath::Hash>
748 _PathsToUpdateMap;
749 _PathsToUpdateMap _usdPathsToUpdate;
750
751 UsdImaging_XformCache _xformCache;
752 UsdImaging_MaterialBindingImplData _materialBindingImplData;
753 UsdImaging_MaterialBindingCache _materialBindingCache;
754 UsdImaging_CoordSysBindingCache _coordSysBindingCache;
755 UsdImaging_VisCache _visCache;
756 UsdImaging_PurposeCache _purposeCache;
757 UsdImaging_DrawModeCache _drawModeCache;
758 UsdImaging_CollectionCache _collectionCache;
759 UsdImaging_InheritedPrimvarCache _inheritedPrimvarCache;
760 UsdImaging_PointInstancerIndicesCache _pointInstancerIndicesCache;
761 UsdImaging_NonlinearSampleCountCache _nonlinearSampleCountCache;
762 UsdImaging_BlurScaleCache _blurScaleCache;
763
764 // Purpose-based rendering toggles
765 bool _displayRender;
766 bool _displayProxy;
767 bool _displayGuides;
768 bool _enableUsdDrawModes;
769
770 const bool _hasDrawModeAdapter;
771
773 bool _sceneMaterialsEnabled;
774
776 bool _sceneLightsEnabled;
777
778 CameraUtilConformWindowPolicy _appWindowPolicy;
779
780 // Enable HdCoordSys tracking
781 const bool _coordSysEnabled;
782
783 // Display unloaded prims with Bounds adapter
784 bool _displayUnloadedPrimsWithBounds;
785
786 UsdImagingDelegate() = delete;
787 UsdImagingDelegate(UsdImagingDelegate const &) = delete;
788 UsdImagingDelegate &operator =(UsdImagingDelegate const &) = delete;
789};
790
791PXR_NAMESPACE_CLOSE_SCOPE
792
793#endif //PXR_USD_IMAGING_USD_IMAGING_DELEGATE_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
Topology data for basisCurves.
Interface class that defines the execution environment for the client to run a computation.
Topology data for meshes.
The render index is part of the Hydra 1.0 API and is only used for emulation purposes so that HdScene...
Describes one or more authored display representations for an rprim.
Definition repr.h:32
Adapter class providing data exchange with the client scene graph.
SdfPath const & GetDelegateID() const
Returns the ID of this delegate, which is used as a prefix for all objects it creates in the RenderIn...
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:281
static SDF_API const SdfPath & AbsoluteRootPath()
The absolute path representing the top of the namespace hierarchy.
SDF_API const char * GetText() const
Returns the string representation of this path as a c string.
bool IsEmpty() const noexcept
Returns true if this is the empty path (SdfPath::EmptyPath()).
Definition path.h:405
SDF_API SdfPath GetAbsoluteRootOrPrimPath() const
Creates a path by stripping all properties and relational attributes from this path,...
SDF_API SdfPath ReplacePrefix(const SdfPath &oldPrefix, const SdfPath &newPrefix, bool fixTargetPaths=true) const
Returns a path with all occurrences of the prefix path oldPrefix replaced with the prefix path newPre...
This is a space efficient container that mimics the TfHashSet API that uses a vector for storage when...
Handle-object returned by TfNotice::Register().
Definition notice.h:243
Token for efficient comparison, assignment, and hashing of known strings.
Definition token.h:71
Enable a concrete base class for use with TfWeakPtr.
Definition weakBase.h:124
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
Definition delegate.h:67
USDIMAGING_API void ClearRefineLevel(SdfPath const &usdPath)
Removes any explicit refine level set for the given USD prim.
USDIMAGING_API void Populate(UsdPrim const &rootPrim, SdfPathVector const &excludedPrimPaths, SdfPathVector const &invisedPrimPaths=SdfPathVector())
Populates the rootPrim in the HdRenderIndex, excluding all paths in the excludedPrimPaths,...
USDIMAGING_API void SetRootVisibility(bool isVisible)
Sets the root visibility for the entire delegate, which is applied to all render prims generated.
HdReprSelector GetReprFallback() const
Returns the fallback repr name.
Definition delegate.h:160
USDIMAGING_API void SetRootInstancerId(SdfPath const &instancerId)
Sets the root instancer id for the entire delegate, which is used as a fallback value for GetInstance...
static constexpr int ALL_INSTANCES
Populate HdxSelection for given path (root) and instanceIndex.
Definition delegate.h:495
UsdTimeCode GetTimeWithOffset(float offset) const
Apply a relative offset to the current time.
USDIMAGING_API void SetRefineLevelFallback(int level)
Sets the fallback refinement level to level, triggers dirty refine level bit to be set on all Rprims ...
virtual USDIMAGING_API bool GetDoubleSided(SdfPath const &id) override
Returns the doubleSided state for the given prim.
USDIMAGING_API void SetSceneMaterialsEnabled(bool enable)
Enables custom shading on prims.
USDIMAGING_API void SetSceneLightsEnabled(bool enable)
Enables lights found in the usdscene.
virtual USDIMAGING_API size_t SampleIndexedPrimvar(SdfPath const &id, TfToken const &key, size_t maxNumSamples, float *times, VtValue *samples, VtIntArray *indices) override
SamplePrimvar() for getting an unflattened primvar and its indices.
USDIMAGING_API void SetUsdDrawModesEnabled(bool enableUsdDrawModes)
Returns whether draw modes are enabled.
virtual USDIMAGING_API SdfPath GetScenePrimPath(SdfPath const &rprimId, int instanceIndex, HdInstancerContext *instancerContext=nullptr) override
Returns the scene address of the prim corresponding to the given rprim/instance index.
USDIMAGING_API void SetWindowPolicy(CameraUtilConformWindowPolicy policy)
Set the window policy on all scene cameras.
virtual USDIMAGING_API size_t SampleInstancerTransform(SdfPath const &instancerId, size_t maxSampleCount, float *times, GfMatrix4d *samples) override
Store up to maxSampleCount transform samples in *sampleValues.
virtual USDIMAGING_API size_t SamplePrimvar(SdfPath const &id, TfToken const &key, size_t maxNumSamples, float *times, VtValue *samples) override
Store up to maxSampleCount primvar samples in *samplesValues.
static USDIMAGING_API void SetTimes(const std::vector< UsdImagingDelegate * > &delegates, const std::vector< UsdTimeCode > &times)
For each delegate in delegates, sets the current time from which data wil be read to the correspondin...
bool GetRootVisibility() const
Returns the root visibility for the entire delegate.
Definition delegate.h:190
USDIMAGING_API GfInterval GetCurrentTimeSamplingInterval()
Returns the current interval that will be used when using the sample* API in the scene delegate.
USDIMAGING_API HdModelDrawMode GetModelDrawMode(SdfPath const &id) override
Returns the model draw mode object for the given prim.
SdfPath GetRootInstancerId() const
Returns the root instancer id for the entire delegate.
Definition delegate.h:198
virtual USDIMAGING_API std::vector< VtArray< TfToken > > GetInstanceCategories(SdfPath const &instancerId) override
Returns the categories for each of the instances in the instancer.
virtual USDIMAGING_API HdReprSelector GetReprSelector(SdfPath const &id) override
Returns the authored repr (if any) for the given prim.
virtual USDIMAGING_API SdfPath GetMaterialId(SdfPath const &rprimId) override
Returns the material ID bound to the rprim rprimId.
USDIMAGING_API HdExtComputationInputDescriptorVector GetExtComputationInputDescriptors(SdfPath const &computationId) override
For the given computation id, returns a list of computation input descriptors.
virtual USDIMAGING_API SubdivTags GetSubdivTags(SdfPath const &id) override
Gets the subdivision surface tags (sharpness, holes, etc).
virtual USDIMAGING_API SdfPathVector GetScenePrimPaths(SdfPath const &rprimId, std::vector< int > instanceIndices, std::vector< HdInstancerContext > *instancerContexts=nullptr) override
A vectorized version of GetScenePrimPath that allows the prim adapter to amortize expensive calculati...
USDIMAGING_API void SetDisplayGuides(const bool displayGuides)
Sets display of prims with purpose "guide".
USDIMAGING_API size_t SampleExtComputationInput(SdfPath const &computationId, TfToken const &input, size_t maxSampleCount, float *sampleTimes, VtValue *sampleValues) override
Return up to maxSampleCount samples for a given computation id and input token.
USDIMAGING_API void SetTime(UsdTimeCode time)
Sets the current time from which data will be read by the delegate.
const GfMatrix4d & GetRootTransform() const
Returns the root transform for the entire delegate.
Definition delegate.h:181
virtual USDIMAGING_API HdDisplayStyle GetDisplayStyle(SdfPath const &id) override
Gets the explicit display style for the given prim, if no refine level is explicitly set,...
USDIMAGING_API SdfPath ConvertIndexPathToCachePath(SdfPath const &indexPath)
Convert the given Hydra ID to a UsdImaging cache path, by stripping the scene delegate prefix.
Definition delegate.h:466
UsdTimeCode GetTime() const
Returns the current time.
Definition delegate.h:118
virtual USDIMAGING_API TfToken GetRenderTag(SdfPath const &id) override
Returns the render tag that will be used to bucket prims during render pass bucketing.
USDIMAGING_API HdExtComputationOutputDescriptorVector GetExtComputationOutputDescriptors(SdfPath const &computationId) override
For the given computation id, returns a list of computation output descriptors.
virtual USDIMAGING_API HdCullStyle GetCullStyle(SdfPath const &id) override
Returns the cullstyle for the given prim.
USDIMAGING_API void SetRootTransform(GfMatrix4d const &xf)
Sets the root transform for the entire delegate, which is applied to all render prims generated.
virtual USDIMAGING_API HdBasisCurvesTopology GetBasisCurvesTopology(SdfPath const &id) override
Gets the topological curve data for a given prim.
USDIMAGING_API void SetReprFallback(HdReprSelector const &repr)
Sets the fallback repr name.
virtual USDIMAGING_API VtIntArray GetInstanceIndices(SdfPath const &instancerId, SdfPath const &prototypeId) override
Gets the extracted indices array of the prototype id used in the instancer.
USDIMAGING_API void SetRigidXformOverrides(RigidXformOverridesMap const &overrides)
Set transform value overrides on a set of paths.
virtual USDIMAGING_API void Sync(HdSyncRequestVector *request) override
Synchronizes the delegate state for the given request vector.
USDIMAGING_API std::string GetExtComputationKernel(SdfPath const &computationId) override
Returns the kernel source assigned to the computation at the path id.
USDIMAGING_API bool IsInInvisedPaths(const SdfPath &usdPath) const
Returns true if usdPath is included in invised path list.
virtual USDIMAGING_API SdfPath GetInstancerId(SdfPath const &primId) override
Returns the parent instancer of the given rprim or instancer.
USDIMAGING_API TfTokenVector GetExtComputationSceneInputNames(SdfPath const &computationId) override
For the given computation id, returns a list of inputs which will be requested from the scene delegat...
USDIMAGING_API void InvokeExtComputation(SdfPath const &computationId, HdExtComputationContext *context) override
Requests the scene delegate run the ExtComputation with the given id.
virtual USDIMAGING_API VtArray< TfToken > GetCategories(SdfPath const &id) override
Returns the prim categories.
USDIMAGING_API void SetInvisedPrimPaths(SdfPathVector const &invisedPaths)
Set the list of paths that must be invised.
virtual USDIMAGING_API bool GetVisible(SdfPath const &id) override
Returns the authored visible state of the prim.
virtual USDIMAGING_API GfMatrix4d GetInstancerTransform(SdfPath const &instancerId) override
Returns the instancer transform.
virtual USDIMAGING_API size_t SampleTransform(SdfPath const &id, size_t maxNumSamples, float *times, GfMatrix4d *samples) override
Store up to maxSampleCount transform samples in *sampleValues.
HdCullStyle GetCullStyleFallback() const
Returns the fallback cull style.
Definition delegate.h:168
USDIMAGING_API void SetCullStyleFallback(HdCullStyle cullStyle)
Sets the fallback cull style.
USDIMAGING_API void SetCameraForSampling(SdfPath const &id)
Setup for the shutter open and close to be used for motion sampling.
USDIMAGING_API void SetRefineLevel(SdfPath const &usdPath, int level)
Sets an explicit refinement level for the given USD prim.
virtual USDIMAGING_API VtValue Get(SdfPath const &id, TfToken const &key) override
Returns a named value.
USDIMAGING_API virtual HdIdVectorSharedPtr GetCoordSysBindings(SdfPath const &id) override
Returns the coordinate system bindings, or a nullptr if none are bound.
int GetRefineLevelFallback() const
Returns the refinement level that is used when prims have no explicit level set.
Definition delegate.h:135
virtual USDIMAGING_API GfRange3d GetExtent(SdfPath const &id) override
Gets the axis aligned bounds of a prim.
virtual USDIMAGING_API VtValue GetIndexedPrimvar(SdfPath const &id, TfToken const &key, VtIntArray *outIndices) override
Returns a named primvar value.
virtual USDIMAGING_API SdfPathVector GetInstancerPrototypes(SdfPath const &instancerId) override
Returns a list of prototypes of this instancer.
USDIMAGING_API HdExtComputationPrimvarDescriptorVector GetExtComputationPrimvarDescriptors(SdfPath const &computationId, HdInterpolation interpolation) override
Returns a list of primvar names that should be bound to a generated output from an ExtComputation for...
USDIMAGING_API void ApplyPendingUpdates()
Applies any scene edits which have been queued up by notices from USD.
USDIMAGING_API void Populate(UsdPrim const &rootPrim)
Populates the rootPrim in the HdRenderIndex.
virtual USDIMAGING_API HdPrimvarDescriptorVector GetPrimvarDescriptors(SdfPath const &id, HdInterpolation interpolation) override
Returns descriptors for all primvars of the given interpolation type.
USDIMAGING_API VtValue GetExtComputationInput(SdfPath const &computationId, TfToken const &input) override
Returns a single value for a given computation id and input token.
virtual USDIMAGING_API HdMeshTopology GetMeshTopology(SdfPath const &id) override
Gets the topological mesh data for a given prim.
USDIMAGING_API void SetDisplayProxy(const bool displayProxy)
Sets display of prims with purpose "proxy".
USDIMAGING_API void SetDisplayRender(const bool displayRender)
Sets display of prims with purpose "render".
virtual USDIMAGING_API GfMatrix4d GetTransform(SdfPath const &id) override
Returns the object space transform, including all parent transforms.
USDIMAGING_API void SetDisplayUnloadedPrimsWithBounds(bool displayUnloaded)
Sets display of unloaded prims as bounding boxes.
virtual USDIMAGING_API VtValue GetCameraParamValue(SdfPath const &id, TfToken const &paramName) override
Returns a single value for a given camera and parameter.
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Definition indexProxy.h:30
Base class for all PrimAdapters.
Definition primAdapter.h:54
A cache for primvar descriptors.
Notice sent in response to authored changes that affect UsdObjects.
Definition notice.h:111
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition prim.h:117
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition timeCode.h:72
Represents an arbitrary dimensional rectangular container class.
Definition array.h:213
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition value.h:90
Standard pointer typedefs.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition declarePtrs.h:45
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition diagnostic.h:68
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Definition diagnostic.h:266
Object used by instancer prim adapters to pass along context about the instancer and instance prim to...
Describes how the geometry of a prim should be displayed.
Describes optional alternative imaging behavior for prims.
The SceneDelegate is requested to synchronize prims as the result of executing a specific render pass...
Functor to use for hash maps from tokens to other things.
Definition token.h:149
std::vector< TfToken > TfTokenVector
Convenience types.
Definition token.h:440