Loading...
Searching...
No Matches
delegate.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_DELEGATE_H
25#define PXR_USD_IMAGING_USD_IMAGING_DELEGATE_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/usdImaging/usdImaging/api.h"
31#include "pxr/usdImaging/usdImaging/version.h"
36
37#include "pxr/imaging/cameraUtil/conformWindow.h"
38
39#include "pxr/imaging/hd/coordSys.h"
40#include "pxr/imaging/hd/sceneDelegate.h"
41#include "pxr/imaging/hd/selection.h"
42#include "pxr/imaging/hd/version.h"
43
45#include "pxr/usd/sdf/path.h"
46#include "pxr/usd/sdf/pathTable.h"
47#include "pxr/usd/usd/attribute.h"
48#include "pxr/usd/usd/notice.h"
49#include "pxr/usd/usd/prim.h"
50#include "pxr/usd/usd/stage.h"
53#include "pxr/usd/usdGeom/xformCache.h"
54#include "pxr/base/vt/value.h"
55
56#include "pxr/base/gf/range3d.h"
59#include "pxr/base/tf/hashmap.h"
60#include "pxr/base/tf/hashset.h"
62
63#include <tbb/spin_rw_mutex.h>
64#include <map>
65#include <string>
66
67PXR_NAMESPACE_OPEN_SCOPE
68
69
71typedef std::vector<UsdPrim> UsdPrimVector;
72
76
77using UsdImagingPrimAdapterSharedPtr = std::shared_ptr<UsdImagingPrimAdapter>;
78
86public:
87
88 typedef TfHashMap<SdfPath, GfMatrix4d, SdfPath::Hash> RigidXformOverridesMap;
89
90 USDIMAGING_API
92 SdfPath const& delegateID);
93
94 USDIMAGING_API
95 virtual ~UsdImagingDelegate();
96
97 USDIMAGING_API
98 virtual void Sync(HdSyncRequestVector* request) override;
99
100 // Helper for clients who don't want to drive the sync behavior (unit
101 // tests). Note this method is not virtual.
102 USDIMAGING_API
103 void SyncAll(bool includeUnvarying);
104
106 USDIMAGING_API
107 void Populate(UsdPrim const& rootPrim);
108
111 USDIMAGING_API
112 void Populate(UsdPrim const& rootPrim,
113 SdfPathVector const& excludedPrimPaths,
114 SdfPathVector const &invisedPrimPaths=SdfPathVector());
115
122 USDIMAGING_API
123 static void SetTimes(const std::vector<UsdImagingDelegate*>& delegates,
124 const std::vector<UsdTimeCode>& times);
125
131 USDIMAGING_API
133
135 UsdTimeCode GetTime() const { return _time; }
136
139 UsdTimeCode GetTimeWithOffset(float offset) const;
140
142 USDIMAGING_API
144
152 int GetRefineLevelFallback() const { return _refineLevelFallback; }
153
160 USDIMAGING_API
161 void SetRefineLevelFallback(int level);
162
165 USDIMAGING_API
166 void ClearRefineLevel(SdfPath const& usdPath);
167
173 USDIMAGING_API
174 void SetRefineLevel(SdfPath const& usdPath, int level);
175
177 HdReprSelector GetReprFallback() const { return _reprFallback; }
178
181 USDIMAGING_API
183
185 HdCullStyle GetCullStyleFallback() const { return _cullStyleFallback; }
186
188 USDIMAGING_API
189 void SetCullStyleFallback(HdCullStyle cullStyle);
190
194 USDIMAGING_API
196
198 const GfMatrix4d &GetRootTransform() const { return _rootXf; }
199
203 USDIMAGING_API
204 void SetRootVisibility(bool isVisible);
205
207 bool GetRootVisibility() const { return _rootIsVisible; }
208
211 USDIMAGING_API
212 void SetRootInstancerId(SdfPath const& instancerId);
213
215 SdfPath GetRootInstancerId() const { return _rootInstancerId; }
216
218 USDIMAGING_API
219 void SetInvisedPrimPaths(SdfPathVector const &invisedPaths);
220
222 USDIMAGING_API
223 void SetRigidXformOverrides(RigidXformOverridesMap const &overrides);
224
226 USDIMAGING_API
227 void SetDisplayRender(const bool displayRender);
228 bool GetDisplayRender() const { return _displayRender; }
229
231 USDIMAGING_API
232 void SetDisplayProxy(const bool displayProxy);
233 bool GetDisplayProxy() const { return _displayProxy; }
234
236 USDIMAGING_API
237 void SetDisplayGuides(const bool displayGuides);
238 bool GetDisplayGuides() const { return _displayGuides; }
239
241 USDIMAGING_API
242 void SetUsdDrawModesEnabled(bool enableUsdDrawModes);
243 bool GetUsdDrawModesEnabled() const { return _enableUsdDrawModes; }
244
246 USDIMAGING_API
247 void SetSceneMaterialsEnabled(bool enable);
248
250 USDIMAGING_API
251 void SetSceneLightsEnabled(bool enable);
252
255 USDIMAGING_API
256 void SetWindowPolicy(CameraUtilConformWindowPolicy policy);
257
266 USDIMAGING_API
267 void SetDisplayUnloadedPrimsWithBounds(bool displayUnloaded);
268 bool GetDisplayUnloadedPrimsWithBounds() const {
269 return _displayUnloadedPrimsWithBounds;
270 }
271
273 USDIMAGING_API
275
278 USDIMAGING_API
280
281 // ---------------------------------------------------------------------- //
282 // See HdSceneDelegate for documentation of the following virtual methods.
283 // ---------------------------------------------------------------------- //
284 USDIMAGING_API
285 virtual TfToken GetRenderTag(SdfPath const& id) override;
286 USDIMAGING_API
287 virtual HdMeshTopology GetMeshTopology(SdfPath const& id) override;
288 USDIMAGING_API
290 override;
292
293 // XXX: animated subdiv tags are not currently supported
294 // XXX: subdiv tags currently fetched on-demand
295 USDIMAGING_API
296 virtual SubdivTags GetSubdivTags(SdfPath const& id) override;
297
298 USDIMAGING_API
299 virtual GfRange3d GetExtent(SdfPath const & id) override;
300 USDIMAGING_API
301 virtual GfMatrix4d GetTransform(SdfPath const & id) override;
302 USDIMAGING_API
303 virtual bool GetVisible(SdfPath const & id) override;
304 USDIMAGING_API
305 virtual bool GetDoubleSided(SdfPath const & id) override;
306 USDIMAGING_API
307 virtual HdCullStyle GetCullStyle(SdfPath const &id) override;
308
312 USDIMAGING_API
313 virtual HdDisplayStyle GetDisplayStyle(SdfPath const& id) override;
314
315 USDIMAGING_API
317
318 USDIMAGING_API
319 virtual VtValue Get(SdfPath const& id, TfToken const& key) override;
320 USDIMAGING_API
322 TfToken const& key,
323 VtIntArray *outIndices) override;
324 USDIMAGING_API
325 HdIdVectorSharedPtr
326 virtual GetCoordSysBindings(SdfPath const& id) override;
327 USDIMAGING_API
328 virtual HdReprSelector GetReprSelector(SdfPath const &id) override;
329 USDIMAGING_API
330 virtual VtArray<TfToken> GetCategories(SdfPath const &id) override;
331 USDIMAGING_API
332 virtual std::vector<VtArray<TfToken>>
333 GetInstanceCategories(SdfPath const &instancerId) override;
334 USDIMAGING_API
335 virtual HdPrimvarDescriptorVector
337 HdInterpolation interpolation) override;
338 USDIMAGING_API
339 virtual VtIntArray GetInstanceIndices(SdfPath const &instancerId,
340 SdfPath const &prototypeId) override;
341 USDIMAGING_API
342 virtual GfMatrix4d GetInstancerTransform(SdfPath const &instancerId)
343 override;
344
345 USDIMAGING_API
346 virtual SdfPath GetInstancerId(SdfPath const &primId) override;
347
348 USDIMAGING_API
349 virtual SdfPathVector GetInstancerPrototypes(SdfPath const &instancerId) override;
350
351 // Motion samples
352 USDIMAGING_API
353 virtual size_t
354 SampleTransform(SdfPath const & id, size_t maxNumSamples,
355 float *times, GfMatrix4d *samples) override;
356 USDIMAGING_API
357 virtual size_t
359 size_t maxSampleCount, float *times,
360 GfMatrix4d *samples) override;
361 USDIMAGING_API
362 virtual size_t
363 SamplePrimvar(SdfPath const& id, TfToken const& key,
364 size_t maxNumSamples, float *times,
365 VtValue *samples) override;
366
367 USDIMAGING_API
368 virtual size_t
369 SampleIndexedPrimvar(SdfPath const& id, TfToken const& key,
370 size_t maxNumSamples, float *times,
371 VtValue *samples, VtIntArray *indices) override;
372
373 // Material Support
374 USDIMAGING_API
375 virtual SdfPath GetMaterialId(SdfPath const &rprimId) override;
376
377 USDIMAGING_API
378 virtual VtValue GetMaterialResource(SdfPath const &materialId) override;
379
380 // Light Support
381 USDIMAGING_API
382 virtual VtValue GetLightParamValue(SdfPath const &id,
383 TfToken const &paramName) override;
384 // Camera Support
385 USDIMAGING_API
387 TfToken const &paramName) override;
388
389 // Volume Support
390 USDIMAGING_API
391 virtual HdVolumeFieldDescriptorVector
392 GetVolumeFieldDescriptors(SdfPath const &volumeId) override;
393
394 // Picking path resolution
395 // Resolves a \p rprimId and \p instanceIndex back to the original USD
396 // gprim and instance index. For point-instanced prims, \p instanceContext
397 // returns extra information about which instance this is of which level of
398 // point-instancer. For example:
399 // /World/PI instances /World/PI/proto/PI
400 // /World/PI/proto/PI instances /World/PI/proto/PI/proto/Gprim
401 // instancerContext = [/World/PI, 0], [/World/PI/proto/PI, 1] means that
402 // this instance represents "protoIndex = 0" of /World/PI, etc.
403
404 USDIMAGING_API
405 virtual SdfPath
406 GetScenePrimPath(SdfPath const& rprimId,
407 int instanceIndex,
408 HdInstancerContext *instancerContext = nullptr) override;
409
410 USDIMAGING_API
411 virtual SdfPathVector
413 std::vector<int> instanceIndices,
414 std::vector<HdInstancerContext> *instancerContexts = nullptr) override;
415
416 // ExtComputation support
417 USDIMAGING_API
419 GetExtComputationSceneInputNames(SdfPath const& computationId) override;
420
421 USDIMAGING_API
422 HdExtComputationInputDescriptorVector
423 GetExtComputationInputDescriptors(SdfPath const& computationId) override;
424
425 USDIMAGING_API
426 HdExtComputationOutputDescriptorVector
427 GetExtComputationOutputDescriptors(SdfPath const& computationId) override;
428
429 USDIMAGING_API
430 HdExtComputationPrimvarDescriptorVector
432 HdInterpolation interpolation) override;
433
434 USDIMAGING_API
436 TfToken const& input) override;
437
438 USDIMAGING_API
439 size_t SampleExtComputationInput(SdfPath const& computationId,
440 TfToken const& input,
441 size_t maxSampleCount,
442 float *sampleTimes,
443 VtValue *sampleValues) override;
444
445 USDIMAGING_API
446 std::string GetExtComputationKernel(SdfPath const& computationId) override;
447
448 USDIMAGING_API
449 void InvokeExtComputation(SdfPath const& computationId,
450 HdExtComputationContext *context) override;
451
452public:
453 // Converts a cache path to a path in the render index.
454 USDIMAGING_API
455 SdfPath ConvertCachePathToIndexPath(SdfPath const& cachePath) {
456 SdfPathMap::const_iterator it = _cache2indexPath.find(cachePath);
457 if (it != _cache2indexPath.end()) {
458 return it->second;
459 }
460
461 // For pure/plain usdImaging, there is no prefix to replace
462 SdfPath const &delegateID = GetDelegateID();
463 if (delegateID == SdfPath::AbsoluteRootPath()) {
464 return cachePath;
465 }
466 if (cachePath.IsEmpty()) {
467 return cachePath;
468 }
469
470 return cachePath.ReplacePrefix(SdfPath::AbsoluteRootPath(), delegateID);
471 }
472
478 USDIMAGING_API
480 SdfPathMap::const_iterator it = _index2cachePath.find(indexPath);
481 if (it != _index2cachePath.end()) {
482 return it->second;
483 }
484
485 // For pure/plain usdImaging, there is no prefix to replace
486 SdfPath const &delegateID = GetDelegateID();
487 if (delegateID == SdfPath::AbsoluteRootPath()) {
488 return indexPath;
489 }
490
491 return indexPath.ReplacePrefix(delegateID, SdfPath::AbsoluteRootPath());
492 }
493
508 static constexpr int ALL_INSTANCES = -1;
509 USDIMAGING_API
510 bool PopulateSelection(HdSelection::HighlightMode const& highlightMode,
511 const SdfPath &usdPath,
512 int instanceIndex,
513 HdSelectionSharedPtr const &result);
514
516 USDIMAGING_API
517 bool IsInInvisedPaths(const SdfPath &usdPath) const;
518
519private:
520 // Internal Get and SamplePrimvar
521 VtValue _Get(SdfPath const& id, TfToken const& key, VtIntArray *outIndices);
522
523 size_t _SamplePrimvar(SdfPath const& id, TfToken const& key,
524 size_t maxNumSamples, float *times, VtValue *samples,
525 VtIntArray *indices);
526
527 // Internal friend class.
528 class _Worker;
529 friend class UsdImagingIndexProxy;
530 friend class UsdImagingPrimAdapter;
531
532 bool _ValidateRefineLevel(int level) {
533 if (!(0 <= level && level <= 8)) {
534 TF_CODING_ERROR("Invalid refinement level(%d), "
535 "expected range is [0,8]",
536 level);
537 return false;
538 }
539 return true;
540 }
541
542 void _AddTask(UsdImagingDelegate::_Worker *worker, SdfPath const& usdPath);
543
544 // ---------------------------------------------------------------------- //
545 // Draw mode support
546 // ---------------------------------------------------------------------- //
547 // Determine whether to assign a draw mode adapter to the given prim.
548 bool _IsDrawModeApplied(UsdPrim const& prim);
549 // Get the inherited model:drawMode attribute of the given prim.
550 TfToken _GetModelDrawMode(UsdPrim const& prim);
551
552 // ---------------------------------------------------------------------- //
553 // Usd Change Processing / Notice Handlers
554 // ---------------------------------------------------------------------- //
555 void _OnUsdObjectsChanged(UsdNotice::ObjectsChanged const&,
556 UsdStageWeakPtr const& sender);
557
558 // Map holding USD subtree path keys mapped to associated hydra prim cache
559 // paths. This may be prepopulated and provided to the Refresh and Resync
560 // methods below to speed up dependency gathering.
561 typedef TfHashMap<SdfPath, SdfPathVector, SdfPath::Hash>
562 _FlattenedDependenciesCacheMap;
563
564 // The lightest-weight update, it does fine-grained invalidation of
565 // individual properties at the given path (prim or property).
566 //
567 // If \p path is a prim path, changedPrimInfoFields will be populated
568 // with the list of scene description fields that caused this prim to
569 // be refreshed.
570 //
571 // Returns whether the prim or the subtree rooted at `usdPath` needed to
572 // be resync'd (i.e., removed and repopulated).
573 //
574 bool _RefreshUsdObject(SdfPath const& usdPath,
575 TfTokenVector const& changedPrimInfoFields,
576 _FlattenedDependenciesCacheMap const &cache,
578 SdfPathSet* allTrackedVariabilityPaths);
579
580 // Heavy-weight invalidation of an entire prim subtree. All cached data is
581 // reconstructed for all prims below \p rootPath.
582 //
583 // By default, _ResyncPrim will remove each affected prim and call
584 // Repopulate() on those prims individually. If repopulateFromRoot is
585 // true, Repopulate() will be called on \p rootPath instead. This is slower,
586 // but handles changes in tree topology.
587 void _ResyncUsdPrim(SdfPath const& usdRootPath,
588 _FlattenedDependenciesCacheMap const &cache,
590 bool repopulateFromRoot = false);
591
592 // ---------------------------------------------------------------------- //
593 // Usd Data-Access Helper Methods
594 // ---------------------------------------------------------------------- //
595 UsdPrim _GetUsdPrim(SdfPath const& usdPath) {
596 UsdPrim const& p =
597 _stage->GetPrimAtPath(usdPath.GetAbsoluteRootOrPrimPath());
598 TF_VERIFY(p, "No prim found for id: %s",
600 return p;
601 }
602
603 void _UpdateSingleValue(SdfPath const& cachePath, int dirtyFlags);
604
605 // ---------------------------------------------------------------------- //
606 // Cache structures and related methods for population.
607 // ---------------------------------------------------------------------- //
608
609 // Returns true if this delegate can be populated, false otherwise.
610 bool _CanPopulate(UsdPrim const& rootPrim) const;
611
612 // Set the delegate's state to reflect that it will be populated from
613 // the given root prim with the given excluded paths.
614 void _SetStateForPopulation(UsdPrim const& rootPrim,
615 SdfPathVector const& excludedPaths,
616 SdfPathVector const& invisedPaths);
617
618 // Populates this delegate's render index from the paths specified
619 // in the given index proxy.
620 void _Populate(class UsdImagingIndexProxy* proxy);
621
622 // Execute all variability update tasks that have been added to the given
623 // worker.
624 static void _ExecuteWorkForVariabilityUpdate(_Worker* worker);
625
629 bool _GetVisible(UsdPrim const& prim);
630
632 TfTokenVector _GetPrimvarNames(SdfPath const& usdPath,
633 TfToken const& interpolation);
634
635 // ---------------------------------------------------------------------- //
636 // Helper methods for updating the delegate on time changes
637 // ---------------------------------------------------------------------- //
638
639 // Execute all time update tasks that have been added to the given worker.
640 static void _ExecuteWorkForTimeUpdate(_Worker* worker);
641
642 // ---------------------------------------------------------------------- //
643 // Core Delegate state
644 // ---------------------------------------------------------------------- //
645
646 // Usd Prim Type to Adapter lookup table.
647 typedef TfHashMap<TfToken, UsdImagingPrimAdapterSharedPtr,
648 TfToken::HashFunctor> _AdapterMap;
649 _AdapterMap _adapterMap;
650
651 // Per-Hydra-Primitive tracking data
652 struct _HdPrimInfo {
653 UsdImagingPrimAdapterSharedPtr adapter; // The adapter to use for the
654 // prim
655 UsdPrim usdPrim; // Reference to the Usd prim
656 HdDirtyBits timeVaryingBits; // Dirty Bits to set when
657 // time changes
658 HdDirtyBits dirtyBits; // Current dirty state of the prim.
660 extraDependencies;// Dependencies that aren't usdPrim.
661 };
662
663 typedef TfHashMap<SdfPath, _HdPrimInfo, SdfPath::Hash> _HdPrimInfoMap;
664
665 // Map from cache path to Hydra prim info
666 _HdPrimInfoMap _hdPrimInfoMap;
667
668 typedef std::multimap<SdfPath, SdfPath> _DependencyMap;
669
670 // Map from USD path to Hydra path, for tracking USD->hydra dependencies.
671 _DependencyMap _dependencyInfo;
672
673 // Appends hydra prim cache paths corresponding to the USD subtree
674 // provided by looking up the dependency map (above).
675 void _GatherDependencies(SdfPath const& subtree,
676 SdfPathVector *affectedCachePaths);
677
678 // Overload that takes an additional cache argument to help speed up the
679 // dependency gathering operation. The onus is on the client to prepopulate
680 // the cache.
681 void
682 _GatherDependencies(SdfPath const &subtree,
683 _FlattenedDependenciesCacheMap const &cache,
684 SdfPathVector *affectedCachePaths);
685
686 // SdfPath::ReplacePrefix() is used frequently to convert between
687 // cache path and Hydra render index path and is a performance bottleneck.
688 // These maps pre-computes these conversion.
689 typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash> SdfPathMap;
690 SdfPathMap _cache2indexPath;
691 SdfPathMap _index2cachePath;
692
693 // Only use this method when we think no existing adapter has been
694 // established. For example, during initial Population.
695 UsdImagingPrimAdapterSharedPtr const& _AdapterLookup(
696 UsdPrim const& prim,
697 bool ignoreInstancing = false);
698 UsdImagingPrimAdapterSharedPtr const& _AdapterLookup(
699 TfToken const& adapterKey);
700
701 // Obtain the prim tracking data for the given cache path.
702 _HdPrimInfo *_GetHdPrimInfo(const SdfPath &cachePath);
703
704 Usd_PrimFlagsConjunction _GetDisplayPredicate() const;
705 Usd_PrimFlagsConjunction _GetDisplayPredicateForPrototypes() const;
706
707 // Mark render tags dirty for all prims.
708 // This is done in response to toggling the purpose-based display settings.
709 void _MarkRenderTagsDirty();
710
711 typedef TfHashSet<SdfPath, SdfPath::Hash> _DirtySet;
712
713 // Set of cache paths that are due a Sync()
714 _DirtySet _dirtyCachePaths;
715
717 typedef TfHashMap<SdfPath, int, SdfPath::Hash> _RefineLevelMap;
719 _RefineLevelMap _refineLevelMap;
720
722 UsdImagingPrimvarDescCache _primvarDescCache;
723
725 UsdStageRefPtr _stage;
726 SdfPath _rootPrimPath;
727 SdfPathVector _excludedPrimPaths;
728 SdfPathVector _invisedPrimPaths;
729
730 RigidXformOverridesMap _rigidXformOverrides;
731
732 // Aspects of the delegate root that apply to all items in the index.
733 SdfPath _compensationPath;
734
735 GfMatrix4d _rootXf;
736 bool _rootIsVisible;
737 SdfPath _rootInstancerId;
738
740 UsdTimeCode _time;
741
743 SdfPath _cameraPathForSampling;
744
745 int _refineLevelFallback;
746 HdReprSelector _reprFallback;
747 HdCullStyle _cullStyleFallback;
748
749 // Cache of which prims are time-varying.
750 SdfPathVector _timeVaryingPrimCache;
751 bool _timeVaryingPrimCacheValid;
752
753 // Change processing
754 TfNotice::Key _objectsChangedNoticeKey;
755 SdfPathVector _usdPathsToResync;
756
757 // Map from path of Usd object to update to list of changed scene
758 // description fields for that object. This list of fields is only
759 // populated for prim paths.
760 typedef std::unordered_map<SdfPath, TfTokenVector, SdfPath::Hash>
761 _PathsToUpdateMap;
762 _PathsToUpdateMap _usdPathsToUpdate;
763
764 UsdImaging_XformCache _xformCache;
765 UsdImaging_MaterialBindingImplData _materialBindingImplData;
766 UsdImaging_MaterialBindingCache _materialBindingCache;
767 UsdImaging_CoordSysBindingCache _coordSysBindingCache;
768 UsdImaging_VisCache _visCache;
769 UsdImaging_PurposeCache _purposeCache;
770 UsdImaging_DrawModeCache _drawModeCache;
771 UsdImaging_CollectionCache _collectionCache;
772 UsdImaging_InheritedPrimvarCache _inheritedPrimvarCache;
773 UsdImaging_PointInstancerIndicesCache _pointInstancerIndicesCache;
774 UsdImaging_NonlinearSampleCountCache _nonlinearSampleCountCache;
775 UsdImaging_BlurScaleCache _blurScaleCache;
776
777 // Purpose-based rendering toggles
778 bool _displayRender;
779 bool _displayProxy;
780 bool _displayGuides;
781 bool _enableUsdDrawModes;
782
783 const bool _hasDrawModeAdapter;
784
786 bool _sceneMaterialsEnabled;
787
789 bool _sceneLightsEnabled;
790
791 CameraUtilConformWindowPolicy _appWindowPolicy;
792
793 // Enable HdCoordSys tracking
794 const bool _coordSysEnabled;
795
796 // Display unloaded prims with Bounds adapter
797 bool _displayUnloadedPrimsWithBounds;
798
799 UsdImagingDelegate() = delete;
800 UsdImagingDelegate(UsdImagingDelegate const &) = delete;
801 UsdImagingDelegate &operator =(UsdImagingDelegate const &) = delete;
802};
803
804PXR_NAMESPACE_CLOSE_SCOPE
805
806#endif //PXR_USD_IMAGING_USD_IMAGING_DELEGATE_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
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:55
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:121
Describes one or more authored display representations for an rprim.
Definition: repr.h:49
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: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:291
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:415
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:56
Handle-object returned by TfNotice::Register().
Definition: notice.h:256
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
Definition: delegate.h:84
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:177
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:508
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:207
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:215
virtual USDIMAGING_API std::vector< VtArray< TfToken > > GetInstanceCategories(SdfPath const &instancerId) override
Returns the categories for all 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:198
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:479
UsdTimeCode GetTime() const
Returns the current time.
Definition: delegate.h:135
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:185
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:152
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:47
Base class for all PrimAdapters.
Definition: primAdapter.h:70
A cache for primvar descriptors.
Notice sent in response to authored changes that affect UsdObjects.
Definition: notice.h:128
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
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:228
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:165
Standard pointer typedefs.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:85
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Definition: diagnostic.h:283
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:81
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:69
Functor to use for hash maps from tokens to other things.
Definition: token.h:166
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457