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 // Picking path resolution
378 // Resolves a \p rprimId and \p instanceIndex back to the original USD
379 // gprim and instance index. For point-instanced prims, \p instanceContext
380 // returns extra information about which instance this is of which level of
381 // point-instancer. For example:
382 // /World/PI instances /World/PI/proto/PI
383 // /World/PI/proto/PI instances /World/PI/proto/PI/proto/Gprim
384 // instancerContext = [/World/PI, 0], [/World/PI/proto/PI, 1] means that
385 // this instance represents "protoIndex = 0" of /World/PI, etc.
386
387 USDIMAGING_API
388 virtual SdfPath
389 GetScenePrimPath(SdfPath const& rprimId,
390 int instanceIndex,
391 HdInstancerContext *instancerContext = nullptr) override;
392
393 USDIMAGING_API
394 virtual SdfPathVector
396 std::vector<int> instanceIndices,
397 std::vector<HdInstancerContext> *instancerContexts = nullptr) override;
398
399 // ExtComputation support
400 USDIMAGING_API
402 GetExtComputationSceneInputNames(SdfPath const& computationId) override;
403
404 USDIMAGING_API
405 HdExtComputationInputDescriptorVector
406 GetExtComputationInputDescriptors(SdfPath const& computationId) override;
407
408 USDIMAGING_API
409 HdExtComputationOutputDescriptorVector
410 GetExtComputationOutputDescriptors(SdfPath const& computationId) override;
411
412 USDIMAGING_API
413 HdExtComputationPrimvarDescriptorVector
415 HdInterpolation interpolation) override;
416
417 USDIMAGING_API
419 TfToken const& input) override;
420
421 USDIMAGING_API
422 size_t SampleExtComputationInput(SdfPath const& computationId,
423 TfToken const& input,
424 size_t maxSampleCount,
425 float *sampleTimes,
426 VtValue *sampleValues) override;
427
428 USDIMAGING_API
429 std::string GetExtComputationKernel(SdfPath const& computationId) override;
430
431 USDIMAGING_API
432 void InvokeExtComputation(SdfPath const& computationId,
433 HdExtComputationContext *context) override;
434
435public:
436 // Converts a cache path to a path in the render index.
437 USDIMAGING_API
438 SdfPath ConvertCachePathToIndexPath(SdfPath const& cachePath) {
439 SdfPathMap::const_iterator it = _cache2indexPath.find(cachePath);
440 if (it != _cache2indexPath.end()) {
441 return it->second;
442 }
443
444 // For pure/plain usdImaging, there is no prefix to replace
445 SdfPath const &delegateID = GetDelegateID();
446 if (delegateID == SdfPath::AbsoluteRootPath()) {
447 return cachePath;
448 }
449 if (cachePath.IsEmpty()) {
450 return cachePath;
451 }
452
453 return cachePath.ReplacePrefix(SdfPath::AbsoluteRootPath(), delegateID);
454 }
455
461 USDIMAGING_API
463 SdfPathMap::const_iterator it = _index2cachePath.find(indexPath);
464 if (it != _index2cachePath.end()) {
465 return it->second;
466 }
467
468 // For pure/plain usdImaging, there is no prefix to replace
469 SdfPath const &delegateID = GetDelegateID();
470 if (delegateID == SdfPath::AbsoluteRootPath()) {
471 return indexPath;
472 }
473
474 return indexPath.ReplacePrefix(delegateID, SdfPath::AbsoluteRootPath());
475 }
476
491 static constexpr int ALL_INSTANCES = -1;
492 USDIMAGING_API
493 bool PopulateSelection(HdSelection::HighlightMode const& highlightMode,
494 const SdfPath &usdPath,
495 int instanceIndex,
496 HdSelectionSharedPtr const &result);
497
499 USDIMAGING_API
500 bool IsInInvisedPaths(const SdfPath &usdPath) const;
501
502private:
503 // Internal Get and SamplePrimvar
504 VtValue _Get(SdfPath const& id, TfToken const& key, VtIntArray *outIndices);
505
506 size_t _SamplePrimvar(SdfPath const& id, TfToken const& key,
507 size_t maxNumSamples, float *times, VtValue *samples,
508 VtIntArray *indices);
509
510 // Internal friend class.
511 class _Worker;
512 friend class UsdImagingIndexProxy;
513 friend class UsdImagingPrimAdapter;
514
515 bool _ValidateRefineLevel(int level) {
516 if (!(0 <= level && level <= 8)) {
517 TF_CODING_ERROR("Invalid refinement level(%d), "
518 "expected range is [0,8]",
519 level);
520 return false;
521 }
522 return true;
523 }
524
525 void _AddTask(UsdImagingDelegate::_Worker *worker, SdfPath const& usdPath);
526
527 // ---------------------------------------------------------------------- //
528 // Draw mode support
529 // ---------------------------------------------------------------------- //
530 // Determine whether to assign a draw mode adapter to the given prim.
531 bool _IsDrawModeApplied(UsdPrim const& prim);
532 // Get the inherited model:drawMode attribute of the given prim.
533 TfToken _GetModelDrawMode(UsdPrim const& prim);
534
535 // ---------------------------------------------------------------------- //
536 // Usd Change Processing / Notice Handlers
537 // ---------------------------------------------------------------------- //
538 void _OnUsdObjectsChanged(UsdNotice::ObjectsChanged const&,
539 UsdStageWeakPtr const& sender);
540
541 // Map holding USD subtree path keys mapped to associated hydra prim cache
542 // paths. This may be prepopulated and provided to the Refresh and Resync
543 // methods below to speed up dependency gathering.
544 typedef TfHashMap<SdfPath, SdfPathVector, SdfPath::Hash>
545 _FlattenedDependenciesCacheMap;
546
547 // The lightest-weight update, it does fine-grained invalidation of
548 // individual properties at the given path (prim or property).
549 //
550 // If \p path is a prim path, changedPrimInfoFields will be populated
551 // with the list of scene description fields that caused this prim to
552 // be refreshed.
553 //
554 // Returns whether the prim or the subtree rooted at `usdPath` needed to
555 // be resync'd (i.e., removed and repopulated).
556 //
557 bool _RefreshUsdObject(SdfPath const& usdPath,
558 TfTokenVector const& changedPrimInfoFields,
559 _FlattenedDependenciesCacheMap const &cache,
561 SdfPathSet* allTrackedVariabilityPaths);
562
563 // Heavy-weight invalidation of an entire prim subtree. All cached data is
564 // reconstructed for all prims below \p rootPath.
565 //
566 // By default, _ResyncPrim will remove each affected prim and call
567 // Repopulate() on those prims individually. If repopulateFromRoot is
568 // true, Repopulate() will be called on \p rootPath instead. This is slower,
569 // but handles changes in tree topology.
570 void _ResyncUsdPrim(SdfPath const& usdRootPath,
571 _FlattenedDependenciesCacheMap const &cache,
573 bool repopulateFromRoot = false);
574
575 // ---------------------------------------------------------------------- //
576 // Usd Data-Access Helper Methods
577 // ---------------------------------------------------------------------- //
578 UsdPrim _GetUsdPrim(SdfPath const& usdPath) {
579 UsdPrim const& p =
580 _stage->GetPrimAtPath(usdPath.GetAbsoluteRootOrPrimPath());
581 TF_VERIFY(p, "No prim found for id: %s",
583 return p;
584 }
585
586 void _UpdateSingleValue(SdfPath const& cachePath, int dirtyFlags);
587
588 // ---------------------------------------------------------------------- //
589 // Cache structures and related methods for population.
590 // ---------------------------------------------------------------------- //
591
592 // Returns true if this delegate can be populated, false otherwise.
593 bool _CanPopulate(UsdPrim const& rootPrim) const;
594
595 // Set the delegate's state to reflect that it will be populated from
596 // the given root prim with the given excluded paths.
597 void _SetStateForPopulation(UsdPrim const& rootPrim,
598 SdfPathVector const& excludedPaths,
599 SdfPathVector const& invisedPaths);
600
601 // Populates this delegate's render index from the paths specified
602 // in the given index proxy.
603 void _Populate(class UsdImagingIndexProxy* proxy);
604
605 // Execute all variability update tasks that have been added to the given
606 // worker.
607 static void _ExecuteWorkForVariabilityUpdate(_Worker* worker);
608
612 bool _GetVisible(UsdPrim const& prim);
613
615 TfTokenVector _GetPrimvarNames(SdfPath const& usdPath,
616 TfToken const& interpolation);
617
618 // ---------------------------------------------------------------------- //
619 // Helper methods for updating the delegate on time changes
620 // ---------------------------------------------------------------------- //
621
622 // Execute all time update tasks that have been added to the given worker.
623 static void _ExecuteWorkForTimeUpdate(_Worker* worker);
624
625 // ---------------------------------------------------------------------- //
626 // Core Delegate state
627 // ---------------------------------------------------------------------- //
628
629 // Usd Prim Type to Adapter lookup table.
630 typedef TfHashMap<TfToken, UsdImagingPrimAdapterSharedPtr,
631 TfToken::HashFunctor> _AdapterMap;
632 _AdapterMap _adapterMap;
633
634 // Per-Hydra-Primitive tracking data
635 struct _HdPrimInfo {
636 UsdImagingPrimAdapterSharedPtr adapter; // The adapter to use for the
637 // prim
638 UsdPrim usdPrim; // Reference to the Usd prim
639 HdDirtyBits timeVaryingBits; // Dirty Bits to set when
640 // time changes
641 HdDirtyBits dirtyBits; // Current dirty state of the prim.
643 extraDependencies;// Dependencies that aren't usdPrim.
644 };
645
646 typedef TfHashMap<SdfPath, _HdPrimInfo, SdfPath::Hash> _HdPrimInfoMap;
647
648 // Map from cache path to Hydra prim info
649 _HdPrimInfoMap _hdPrimInfoMap;
650
651 typedef std::multimap<SdfPath, SdfPath> _DependencyMap;
652
653 // Map from USD path to Hydra path, for tracking USD->hydra dependencies.
654 _DependencyMap _dependencyInfo;
655
656 // Appends hydra prim cache paths corresponding to the USD subtree
657 // provided by looking up the dependency map (above).
658 void _GatherDependencies(SdfPath const& subtree,
659 SdfPathVector *affectedCachePaths);
660
661 // Overload that takes an additional cache argument to help speed up the
662 // dependency gathering operation. The onus is on the client to prepopulate
663 // the cache.
664 void
665 _GatherDependencies(SdfPath const &subtree,
666 _FlattenedDependenciesCacheMap const &cache,
667 SdfPathVector *affectedCachePaths);
668
669 // SdfPath::ReplacePrefix() is used frequently to convert between
670 // cache path and Hydra render index path and is a performance bottleneck.
671 // These maps pre-computes these conversion.
672 typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash> SdfPathMap;
673 SdfPathMap _cache2indexPath;
674 SdfPathMap _index2cachePath;
675
676 // Only use this method when we think no existing adapter has been
677 // established. For example, during initial Population.
678 UsdImagingPrimAdapterSharedPtr const& _AdapterLookup(
679 UsdPrim const& prim,
680 bool ignoreInstancing = false);
681 UsdImagingPrimAdapterSharedPtr const& _AdapterLookup(
682 TfToken const& adapterKey);
683
684 // Obtain the prim tracking data for the given cache path.
685 _HdPrimInfo *_GetHdPrimInfo(const SdfPath &cachePath);
686
687 Usd_PrimFlagsConjunction _GetDisplayPredicate() const;
688 Usd_PrimFlagsConjunction _GetDisplayPredicateForPrototypes() const;
689
690 // Mark render tags dirty for all prims.
691 // This is done in response to toggling the purpose-based display settings.
692 void _MarkRenderTagsDirty();
693
694 typedef TfHashSet<SdfPath, SdfPath::Hash> _DirtySet;
695
696 // Set of cache paths that are due a Sync()
697 _DirtySet _dirtyCachePaths;
698
700 typedef TfHashMap<SdfPath, int, SdfPath::Hash> _RefineLevelMap;
702 _RefineLevelMap _refineLevelMap;
703
705 UsdImagingPrimvarDescCache _primvarDescCache;
706
708 UsdStageRefPtr _stage;
709 SdfPath _rootPrimPath;
710 SdfPathVector _excludedPrimPaths;
711 SdfPathVector _invisedPrimPaths;
712
713 RigidXformOverridesMap _rigidXformOverrides;
714
715 // Aspects of the delegate root that apply to all items in the index.
716 SdfPath _compensationPath;
717
718 GfMatrix4d _rootXf;
719 bool _rootIsVisible;
720 SdfPath _rootInstancerId;
721
723 UsdTimeCode _time;
724
726 SdfPath _cameraPathForSampling;
727
728 int _refineLevelFallback;
729 HdReprSelector _reprFallback;
730 HdCullStyle _cullStyleFallback;
731
732 // Cache of which prims are time-varying.
733 SdfPathVector _timeVaryingPrimCache;
734 bool _timeVaryingPrimCacheValid;
735
736 // Change processing
737 TfNotice::Key _objectsChangedNoticeKey;
738 SdfPathVector _usdPathsToResync;
739
740 // Map from path of Usd object to update to list of changed scene
741 // description fields for that object. This list of fields is only
742 // populated for prim paths.
743 typedef std::unordered_map<SdfPath, TfTokenVector, SdfPath::Hash>
744 _PathsToUpdateMap;
745 _PathsToUpdateMap _usdPathsToUpdate;
746
747 UsdImaging_XformCache _xformCache;
748 UsdImaging_MaterialBindingImplData _materialBindingImplData;
749 UsdImaging_MaterialBindingCache _materialBindingCache;
750 UsdImaging_CoordSysBindingCache _coordSysBindingCache;
751 UsdImaging_VisCache _visCache;
752 UsdImaging_PurposeCache _purposeCache;
753 UsdImaging_DrawModeCache _drawModeCache;
754 UsdImaging_CollectionCache _collectionCache;
755 UsdImaging_InheritedPrimvarCache _inheritedPrimvarCache;
756 UsdImaging_PointInstancerIndicesCache _pointInstancerIndicesCache;
757 UsdImaging_NonlinearSampleCountCache _nonlinearSampleCountCache;
758 UsdImaging_BlurScaleCache _blurScaleCache;
759
760 // Purpose-based rendering toggles
761 bool _displayRender;
762 bool _displayProxy;
763 bool _displayGuides;
764 bool _enableUsdDrawModes;
765
766 const bool _hasDrawModeAdapter;
767
769 bool _sceneMaterialsEnabled;
770
772 bool _sceneLightsEnabled;
773
774 CameraUtilConformWindowPolicy _appWindowPolicy;
775
776 // Enable HdCoordSys tracking
777 const bool _coordSysEnabled;
778
779 // Display unloaded prims with Bounds adapter
780 bool _displayUnloadedPrimsWithBounds;
781
782 UsdImagingDelegate() = delete;
783 UsdImagingDelegate(UsdImagingDelegate const &) = delete;
784 UsdImagingDelegate &operator =(UsdImagingDelegate const &) = delete;
785};
786
787PXR_NAMESPACE_CLOSE_SCOPE
788
789#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.
Definition: meshTopology.h:38
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:105
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:274
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:398
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...
Definition: denseHashSet.h:39
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:491
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:462
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.
Definition: sceneDelegate.h:64
Describes optional alternative imaging behavior for prims.
The SceneDelegate is requested to synchronize prims as the result of executing a specific render pass...
Definition: sceneDelegate.h:52
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