All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
51 #include "pxr/usd/usdGeom/cube.h"
52 #include "pxr/usd/usdGeom/sphere.h"
53 #include "pxr/usd/usdGeom/xformCache.h"
54 #include "pxr/base/vt/value.h"
55 
56 #include "pxr/base/gf/range3d.h"
57 #include "pxr/base/gf/interval.h"
59 #include "pxr/base/tf/hashmap.h"
60 #include "pxr/base/tf/hashset.h"
62 
63 #include <boost/container/flat_map.hpp>
64 #include <tbb/spin_rw_mutex.h>
65 #include <map>
66 #include <string>
67 
68 PXR_NAMESPACE_OPEN_SCOPE
69 
70 
72 typedef std::vector<UsdPrim> UsdPrimVector;
73 
77 
78 typedef boost::container::flat_map<SdfPath, bool> PickabilityMap;
79 
80 using UsdImagingPrimAdapterSharedPtr = std::shared_ptr<UsdImagingPrimAdapter>;
81 
88  typedef UsdImagingDelegate This;
89 public:
90 
91  typedef TfHashMap<SdfPath, GfMatrix4d, SdfPath::Hash> RigidXformOverridesMap;
92 
93  USDIMAGING_API
94  UsdImagingDelegate(HdRenderIndex *parentIndex,
95  SdfPath const& delegateID);
96 
97  USDIMAGING_API
98  virtual ~UsdImagingDelegate();
99 
100  USDIMAGING_API
101  virtual void Sync(HdSyncRequestVector* request) override;
102 
103  // Helper for clients who don't want to drive the sync behavior (unit
104  // tests). Note this method is not virtual.
105  USDIMAGING_API
106  void SyncAll(bool includeUnvarying);
107 
110  USDIMAGING_API
111  virtual void PostSyncCleanup() override;
112 
114  USDIMAGING_API
115  void Populate(UsdPrim const& rootPrim);
116 
119  USDIMAGING_API
120  void Populate(UsdPrim const& rootPrim,
121  SdfPathVector const& excludedPrimPaths,
122  SdfPathVector const &invisedPrimPaths=SdfPathVector());
123 
130  USDIMAGING_API
131  static void SetTimes(const std::vector<UsdImagingDelegate*>& delegates,
132  const std::vector<UsdTimeCode>& times);
133 
139  USDIMAGING_API
140  void SetTime(UsdTimeCode time);
141 
143  UsdTimeCode GetTime() const { return _time; }
144 
147  UsdTimeCode GetTimeWithOffset(float offset) const;
148 
150  USDIMAGING_API
151  void ApplyPendingUpdates();
152 
160  int GetRefineLevelFallback() const { return _refineLevelFallback; }
161 
168  USDIMAGING_API
169  void SetRefineLevelFallback(int level);
170 
173  USDIMAGING_API
174  void ClearRefineLevel(SdfPath const& usdPath);
175 
181  USDIMAGING_API
182  void SetRefineLevel(SdfPath const& usdPath, int level);
183 
185  HdReprSelector GetReprFallback() const { return _reprFallback; }
186 
189  USDIMAGING_API
190  void SetReprFallback(HdReprSelector const &repr);
191 
193  HdCullStyle GetCullStyleFallback() const { return _cullStyleFallback; }
194 
196  USDIMAGING_API
197  void SetCullStyleFallback(HdCullStyle cullStyle);
198 
202  USDIMAGING_API
203  void SetRootTransform(GfMatrix4d const& xf);
204 
206  const GfMatrix4d &GetRootTransform() const { return _rootXf; }
207 
211  USDIMAGING_API
212  void SetRootVisibility(bool isVisible);
213 
215  bool GetRootVisibility() const { return _rootIsVisible; }
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  PickabilityMap GetPickabilityMap() const;
228 
230  USDIMAGING_API
231  void SetPickability(SdfPath const& path, bool pickable);
232 
234  USDIMAGING_API
235  void ClearPickabilityMap();
236 
238  USDIMAGING_API
239  void SetDisplayRender(const bool displayRender);
240  bool GetDisplayRender() const { return _displayRender; }
241 
243  USDIMAGING_API
244  void SetDisplayProxy(const bool displayProxy);
245  bool GetDisplayProxy() const { return _displayProxy; }
246 
248  USDIMAGING_API
249  void SetDisplayGuides(const bool displayGuides);
250  bool GetDisplayGuides() const { return _displayGuides; }
251 
253  USDIMAGING_API
254  void SetUsdDrawModesEnabled(bool enableUsdDrawModes);
255  bool GetUsdDrawModesEnabled() const { return _enableUsdDrawModes; }
256 
258  USDIMAGING_API
259  void SetSceneMaterialsEnabled(bool enable);
260 
262  USDIMAGING_API
263  void SetSceneLightsEnabled(bool enable);
264 
267  USDIMAGING_API
268  void SetWindowPolicy(CameraUtilConformWindowPolicy policy);
269 
278  USDIMAGING_API
279  void SetDisplayUnloadedPrimsWithBounds(bool displayUnloaded);
280  bool GetDisplayUnloadedPrimsWithBounds() const {
281  return _displayUnloadedPrimsWithBounds;
282  }
283 
285  USDIMAGING_API
286  void SetCameraForSampling(SdfPath const& id);
287 
290  USDIMAGING_API
292 
293  // ---------------------------------------------------------------------- //
294  // See HdSceneDelegate for documentation of the following virtual methods.
295  // ---------------------------------------------------------------------- //
296  USDIMAGING_API
297  virtual TfToken GetRenderTag(SdfPath const& id) override;
298  USDIMAGING_API
299  virtual HdMeshTopology GetMeshTopology(SdfPath const& id) override;
300  USDIMAGING_API
302  override;
303  typedef PxOsdSubdivTags SubdivTags;
304 
305  // XXX: animated subdiv tags are not currently supported
306  // XXX: subdiv tags currently fetched on-demand
307  USDIMAGING_API
308  virtual SubdivTags GetSubdivTags(SdfPath const& id) override;
309 
310  USDIMAGING_API
311  virtual GfRange3d GetExtent(SdfPath const & id) override;
312  USDIMAGING_API
313  virtual GfMatrix4d GetTransform(SdfPath const & id) override;
314  USDIMAGING_API
315  virtual bool GetVisible(SdfPath const & id) override;
316  USDIMAGING_API
317  virtual bool GetDoubleSided(SdfPath const & id) override;
318  USDIMAGING_API
319  virtual HdCullStyle GetCullStyle(SdfPath const &id) override;
320 
324  USDIMAGING_API
325  virtual HdDisplayStyle GetDisplayStyle(SdfPath const& id) override;
326 
327  USDIMAGING_API
328  virtual VtValue Get(SdfPath const& id, TfToken const& key) override;
329  USDIMAGING_API
330  virtual VtValue GetIndexedPrimvar(SdfPath const& id,
331  TfToken const& key,
332  VtIntArray *outIndices) override;
333  USDIMAGING_API
334  HdIdVectorSharedPtr
335  virtual GetCoordSysBindings(SdfPath const& id) override;
336  USDIMAGING_API
337  virtual HdReprSelector GetReprSelector(SdfPath const &id) override;
338  USDIMAGING_API
339  virtual VtArray<TfToken> GetCategories(SdfPath const &id) override;
340  USDIMAGING_API
341  virtual std::vector<VtArray<TfToken>>
342  GetInstanceCategories(SdfPath const &instancerId) override;
343  USDIMAGING_API
344  virtual HdPrimvarDescriptorVector
345  GetPrimvarDescriptors(SdfPath const& id,
346  HdInterpolation interpolation) override;
347  USDIMAGING_API
348  virtual VtIntArray GetInstanceIndices(SdfPath const &instancerId,
349  SdfPath const &prototypeId) override;
350  USDIMAGING_API
351  virtual GfMatrix4d GetInstancerTransform(SdfPath const &instancerId)
352  override;
353 
354  USDIMAGING_API
355  virtual SdfPath GetInstancerId(SdfPath const &primId) override;
356 
357  USDIMAGING_API
358  virtual SdfPathVector GetInstancerPrototypes(SdfPath const &instancerId) override;
359 
360  // Motion samples
361  USDIMAGING_API
362  virtual size_t
363  SampleTransform(SdfPath const & id, size_t maxNumSamples,
364  float *times, GfMatrix4d *samples) override;
365  USDIMAGING_API
366  virtual size_t
367  SampleInstancerTransform(SdfPath const &instancerId,
368  size_t maxSampleCount, float *times,
369  GfMatrix4d *samples) override;
370  USDIMAGING_API
371  virtual size_t
372  SamplePrimvar(SdfPath const& id, TfToken const& key,
373  size_t maxNumSamples, float *times,
374  VtValue *samples) override;
375 
376  USDIMAGING_API
377  virtual size_t
378  SampleIndexedPrimvar(SdfPath const& id, TfToken const& key,
379  size_t maxNumSamples, float *times,
380  VtValue *samples, VtIntArray *indices) override;
381 
382  // Material Support
383  USDIMAGING_API
384  virtual SdfPath GetMaterialId(SdfPath const &rprimId) override;
385 
386  USDIMAGING_API
387  virtual VtValue GetMaterialResource(SdfPath const &materialId) override;
388 
389  // Light Support
390  USDIMAGING_API
391  virtual VtValue GetLightParamValue(SdfPath const &id,
392  TfToken const &paramName) override;
393  // Camera Support
394  USDIMAGING_API
395  virtual VtValue GetCameraParamValue(SdfPath const &id,
396  TfToken const &paramName) override;
397 
398  // Volume Support
399  USDIMAGING_API
400  virtual HdVolumeFieldDescriptorVector
401  GetVolumeFieldDescriptors(SdfPath const &volumeId) override;
402 
403  // Picking path resolution
404  // Resolves a \p rprimId and \p instanceIndex back to the original USD
405  // gprim and instance index. For point-instanced prims, \p instanceContext
406  // returns extra information about which instance this is of which level of
407  // point-instancer. For example:
408  // /World/PI instances /World/PI/proto/PI
409  // /World/PI/proto/PI instances /World/PI/proto/PI/proto/Gprim
410  // instancerContext = [/World/PI, 0], [/World/PI/proto/PI, 1] means that
411  // this instance represents "protoIndex = 0" of /World/PI, etc.
412 
413  USDIMAGING_API
414  virtual SdfPath
415  GetScenePrimPath(SdfPath const& rprimId,
416  int instanceIndex,
417  HdInstancerContext *instancerContext = nullptr) override;
418 
419  // ExtComputation support
420  USDIMAGING_API
422  GetExtComputationSceneInputNames(SdfPath const& computationId) override;
423 
424  USDIMAGING_API
425  HdExtComputationInputDescriptorVector
426  GetExtComputationInputDescriptors(SdfPath const& computationId) override;
427 
428  USDIMAGING_API
429  HdExtComputationOutputDescriptorVector
430  GetExtComputationOutputDescriptors(SdfPath const& computationId) override;
431 
432  USDIMAGING_API
433  HdExtComputationPrimvarDescriptorVector
434  GetExtComputationPrimvarDescriptors(SdfPath const& computationId,
435  HdInterpolation interpolation) override;
436 
437  USDIMAGING_API
438  VtValue GetExtComputationInput(SdfPath const& computationId,
439  TfToken const& input) override;
440 
441  USDIMAGING_API
442  size_t SampleExtComputationInput(SdfPath const& computationId,
443  TfToken const& input,
444  size_t maxSampleCount,
445  float *sampleTimes,
446  VtValue *sampleValues) override;
447 
448  USDIMAGING_API
449  std::string GetExtComputationKernel(SdfPath const& computationId) override;
450 
451  USDIMAGING_API
452  void InvokeExtComputation(SdfPath const& computationId,
453  HdExtComputationContext *context) override;
454 
455 public:
456  // Converts a cache path to a path in the render index.
457  USDIMAGING_API
458  SdfPath ConvertCachePathToIndexPath(SdfPath const& cachePath) {
459  SdfPathMap::const_iterator it = _cache2indexPath.find(cachePath);
460  if (it != _cache2indexPath.end()) {
461  return it->second;
462  }
463 
464  // For pure/plain usdImaging, there is no prefix to replace
465  SdfPath const &delegateID = GetDelegateID();
466  if (delegateID == SdfPath::AbsoluteRootPath()) {
467  return cachePath;
468  }
469  if (cachePath.IsEmpty()) {
470  return cachePath;
471  }
472 
473  return cachePath.ReplacePrefix(SdfPath::AbsoluteRootPath(), delegateID);
474  }
475 
481  USDIMAGING_API
483  SdfPathMap::const_iterator it = _index2cachePath.find(indexPath);
484  if (it != _index2cachePath.end()) {
485  return it->second;
486  }
487 
488  // For pure/plain usdImaging, there is no prefix to replace
489  SdfPath const &delegateID = GetDelegateID();
490  if (delegateID == SdfPath::AbsoluteRootPath()) {
491  return indexPath;
492  }
493 
494  return indexPath.ReplacePrefix(delegateID, SdfPath::AbsoluteRootPath());
495  }
496 
511  static constexpr int ALL_INSTANCES = -1;
512  USDIMAGING_API
513  bool PopulateSelection(HdSelection::HighlightMode const& highlightMode,
514  const SdfPath &usdPath,
515  int instanceIndex,
516  HdSelectionSharedPtr const &result);
517 
519  USDIMAGING_API
520  bool IsInInvisedPaths(const SdfPath &usdPath) const;
521 
522 private:
523  // Internal Get and SamplePrimvar
524  VtValue _Get(SdfPath const& id, TfToken const& key, VtIntArray *outIndices);
525 
526  size_t _SamplePrimvar(SdfPath const& id, TfToken const& key,
527  size_t maxNumSamples, float *times, VtValue *samples,
528  VtIntArray *indices);
529 
530  // Internal friend class.
531  class _Worker;
532  friend class UsdImagingIndexProxy;
533  friend class UsdImagingPrimAdapter;
534 
535  bool _ValidateRefineLevel(int level) {
536  if (!(0 <= level && level <= 8)) {
537  TF_CODING_ERROR("Invalid refinement level(%d), "
538  "expected range is [0,8]",
539  level);
540  return false;
541  }
542  return true;
543  }
544 
545  void _AddTask(UsdImagingDelegate::_Worker *worker, SdfPath const& usdPath);
546 
547  // ---------------------------------------------------------------------- //
548  // Draw mode support
549  // ---------------------------------------------------------------------- //
550  // Determine whether to assign a draw mode adapter to the given prim.
551  bool _IsDrawModeApplied(UsdPrim const& prim);
552  // Get the inherited model:drawMode attribute of the given prim.
553  TfToken _GetModelDrawMode(UsdPrim const& prim);
554 
555  // ---------------------------------------------------------------------- //
556  // Usd Change Processing / Notice Handlers
557  // ---------------------------------------------------------------------- //
558  void _OnUsdObjectsChanged(UsdNotice::ObjectsChanged const&,
559  UsdStageWeakPtr const& sender);
560 
561  // The lightest-weight update, it does fine-grained invalidation of
562  // individual properties at the given path (prim or property).
563  //
564  // If \p path is a prim path, changedPrimInfoFields will be populated
565  // with the list of scene description fields that caused this prim to
566  // be refreshed.
567  void _RefreshUsdObject(SdfPath const& usdPath,
568  TfTokenVector const& changedPrimInfoFields,
569  UsdImagingIndexProxy* proxy);
570 
571  // Heavy-weight invalidation of an entire prim subtree. All cached data is
572  // reconstructed for all prims below \p rootPath.
573  //
574  // By default, _ResyncPrim will remove each affected prim and call
575  // Repopulate() on those prims individually. If repopulateFromRoot is
576  // true, Repopulate() will be called on \p rootPath instead. This is slower,
577  // but handles changes in tree topology.
578  void _ResyncUsdPrim(SdfPath const& usdRootPath, UsdImagingIndexProxy* proxy,
579  bool repopulateFromRoot = false);
580 
581  // ---------------------------------------------------------------------- //
582  // Usd Data-Access Helper Methods
583  // ---------------------------------------------------------------------- //
584  UsdPrim _GetUsdPrim(SdfPath const& usdPath) {
585  UsdPrim const& p =
586  _stage->GetPrimAtPath(usdPath.GetAbsoluteRootOrPrimPath());
587  TF_VERIFY(p, "No prim found for id: %s",
588  usdPath.GetAbsoluteRootOrPrimPath().GetText());
589  return p;
590  }
591 
592  VtValue _GetUsdPrimAttribute(SdfPath const& cachePath,
593  TfToken const &attrName);
594 
595  void _UpdateSingleValue(SdfPath const& cachePath, int dirtyFlags);
596 
597  // ---------------------------------------------------------------------- //
598  // Cache structures and related methods for population.
599  // ---------------------------------------------------------------------- //
600 
601  // Returns true if this delegate can be populated, false otherwise.
602  bool _CanPopulate(UsdPrim const& rootPrim) const;
603 
604  // Set the delegate's state to reflect that it will be populated from
605  // the given root prim with the given excluded paths.
606  void _SetStateForPopulation(UsdPrim const& rootPrim,
607  SdfPathVector const& excludedPaths,
608  SdfPathVector const& invisedPaths);
609 
610  // Populates this delegate's render index from the paths specified
611  // in the given index proxy.
612  void _Populate(class UsdImagingIndexProxy* proxy);
613 
614  // Execute all variability update tasks that have been added to the given
615  // worker.
616  static void _ExecuteWorkForVariabilityUpdate(_Worker* worker);
617 
621  bool _GetVisible(UsdPrim const& prim);
622 
624  TfTokenVector _GetPrimvarNames(SdfPath const& usdPath,
625  TfToken const& interpolation);
626 
627  // ---------------------------------------------------------------------- //
628  // Helper methods for updating the delegate on time changes
629  // ---------------------------------------------------------------------- //
630 
631  // Execute all time update tasks that have been added to the given worker.
632  static void _ExecuteWorkForTimeUpdate(_Worker* worker);
633 
634  // ---------------------------------------------------------------------- //
635  // Core Delegate state
636  // ---------------------------------------------------------------------- //
637 
638  // Usd Prim Type to Adapter lookup table.
639  typedef TfHashMap<TfToken, UsdImagingPrimAdapterSharedPtr,
640  TfToken::HashFunctor> _AdapterMap;
641  _AdapterMap _adapterMap;
642 
643  // Per-Hydra-Primitive tracking data
644  struct _HdPrimInfo {
645  UsdImagingPrimAdapterSharedPtr adapter; // The adapter to use for the
646  // prim
647  UsdPrim usdPrim; // Reference to the Usd prim
648  HdDirtyBits timeVaryingBits; // Dirty Bits to set when
649  // time changes
650  HdDirtyBits dirtyBits; // Current dirty state of the prim.
652  extraDependencies;// Dependencies that aren't usdPrim.
653  };
654 
655  typedef TfHashMap<SdfPath, _HdPrimInfo, SdfPath::Hash> _HdPrimInfoMap;
656 
657  // Map from cache path to Hydra prim info
658  _HdPrimInfoMap _hdPrimInfoMap;
659 
660  typedef std::multimap<SdfPath, SdfPath> _DependencyMap;
661 
662  // Map from USD path to Hydra path, for tracking USD->hydra dependencies.
663  _DependencyMap _dependencyInfo;
664 
665  void _GatherDependencies(SdfPath const& subtree,
666  SdfPathVector *affectedCachePaths);
667 
668  // SdfPath::ReplacePrefix() is used frequently to convert between
669  // cache path and Hydra render index path and is a performance bottleneck.
670  // These maps pre-computes these conversion.
671  typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash> SdfPathMap;
672  SdfPathMap _cache2indexPath;
673  SdfPathMap _index2cachePath;
674 
675  // Only use this method when we think no existing adapter has been
676  // established. For example, during initial Population.
677  UsdImagingPrimAdapterSharedPtr const& _AdapterLookup(
678  UsdPrim const& prim,
679  bool ignoreInstancing = false);
680  UsdImagingPrimAdapterSharedPtr const& _AdapterLookup(
681  TfToken const& adapterKey);
682 
683  // Obtain the prim tracking data for the given cache path.
684  _HdPrimInfo *_GetHdPrimInfo(const SdfPath &cachePath);
685 
686  Usd_PrimFlagsConjunction _GetDisplayPredicate() const;
687  Usd_PrimFlagsConjunction _GetDisplayPredicateForPrototypes() const;
688 
689  // Mark render tags dirty for all prims.
690  // This is done in response to toggling the purpose-based display settings.
691  void _MarkRenderTagsDirty();
692 
693 
694  typedef TfHashSet<SdfPath, SdfPath::Hash> _InstancerSet;
695 
696  // Set of cache paths representing instancers
697  _InstancerSet _instancerPrimCachePaths;
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 
722  UsdTimeCode _time;
723 
725  SdfPath _cameraPathForSampling;
726 
727  int _refineLevelFallback;
728  HdReprSelector _reprFallback;
729  HdCullStyle _cullStyleFallback;
730 
731  // Cache of which prims are time-varying.
732  SdfPathVector _timeVaryingPrimCache;
733  bool _timeVaryingPrimCacheValid;
734 
735  // Change processing
736  TfNotice::Key _objectsChangedNoticeKey;
737  SdfPathVector _usdPathsToResync;
738 
739  // Map from path of Usd object to update to list of changed scene
740  // description fields for that object. This list of fields is only
741  // populated for prim paths.
742  typedef std::unordered_map<SdfPath, TfTokenVector, SdfPath::Hash>
743  _PathsToUpdateMap;
744  _PathsToUpdateMap _usdPathsToUpdate;
745 
746  UsdImaging_XformCache _xformCache;
747  UsdImaging_MaterialBindingImplData _materialBindingImplData;
748  UsdImaging_MaterialBindingCache _materialBindingCache;
749  UsdImaging_CoordSysBindingImplData _coordSysBindingImplData;
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 
758  // Pickability
759  PickabilityMap _pickablesMap;
760 
761  // Purpose-based rendering toggles
762  bool _displayRender;
763  bool _displayProxy;
764  bool _displayGuides;
765  bool _enableUsdDrawModes;
766 
767  const bool _hasDrawModeAdapter;
768 
770  bool _sceneMaterialsEnabled;
771 
773  bool _sceneLightsEnabled;
774 
775  CameraUtilConformWindowPolicy _appWindowPolicy;
776 
777  // Enable HdCoordSys tracking
778  const bool _coordSysEnabled;
779 
780  // Display unloaded prims with Bounds adapter
781  bool _displayUnloadedPrimsWithBounds;
782 
783  UsdImagingDelegate() = delete;
784  UsdImagingDelegate(UsdImagingDelegate const &) = delete;
785  UsdImagingDelegate &operator =(UsdImagingDelegate const &) = delete;
786 };
787 
788 PXR_NAMESPACE_CLOSE_SCOPE
789 
790 #endif //PXR_USD_IMAGING_USD_IMAGING_DELEGATE_H
virtual USDIMAGING_API TfToken GetRenderTag(SdfPath const &id) override
Returns the render tag that will be used to bucket prims during render pass bucketing.
Interface class that defines the execution environment for the client to run a computation.
Handle-object returned by TfNotice::Register().
Definition: notice.h:256
Tags for non-hierarchial subdiv surfaces.
Definition: subdivTags.h:41
USDIMAGING_API void SetDisplayUnloadedPrimsWithBounds(bool displayUnloaded)
Sets display of unloaded prims as bounding boxes.
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:116
Basic type: 3-dimensional floating point range.
Definition: range3d.h:64
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:482
static constexpr int ALL_INSTANCES
Populate HdxSelection for given path (root) and instanceIndex.
Definition: delegate.h:511
USDIMAGING_API void SetPickability(SdfPath const &path, bool pickable)
Sets pickability for a specific path.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
Standard pointer typedefs.
USDIMAGING_API void SetRigidXformOverrides(RigidXformOverridesMap const &overrides)
Set transform value overrides on a set of paths.
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.
virtual USDIMAGING_API void PostSyncCleanup() override
Opportunity for the delegate to clean itself up after performing parallel work during sync phase...
USDIMAGING_API void SetRefineLevelFallback(int level)
Sets the fallback refinement level to level, triggers dirty refine level bit to be set on all Rprims ...
Describes how the geometry of a prim should be displayed.
Definition: sceneDelegate.h:80
USDIMAGING_API void SetDisplayRender(const bool displayRender)
Sets display of prims with purpose &quot;render&quot;.
USDIMAGING_API void SetUsdDrawModesEnabled(bool enableUsdDrawModes)
Returns whether draw modes are enabled.
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...
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.
virtual USDIMAGING_API GfRange3d GetExtent(SdfPath const &id) override
Gets the axis aligned bounds of a prim.
const GfMatrix4d & GetRootTransform() const
Returns the root transform for the entire delegate.
Definition: delegate.h:206
virtual USDIMAGING_API std::vector< VtArray< TfToken > > GetInstanceCategories(SdfPath const &instancerId) override
Returns the categories for all instances in the instancer.
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:85
virtual USDIMAGING_API SubdivTags GetSubdivTags(SdfPath const &id) override
Gets the subdivision surface tags (sharpness, holes, etc).
HdCullStyle GetCullStyleFallback() const
Returns the fallback cull style.
Definition: delegate.h:193
virtual USDIMAGING_API bool GetVisible(SdfPath const &id) override
Returns the authored visible state of the prim.
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
Definition: selection.h:55
Functor to use for hash maps from tokens to other things.
Definition: token.h:166
USDIMAGING_API void SetRootTransform(GfMatrix4d const &xf)
Sets the root transform for the entire delegate, which is applied to all render prims generated...
This proxy class exposes a subset of the private Delegate API to PrimAdapters.
Definition: indexProxy.h:47
virtual USDIMAGING_API SdfPath GetInstancerId(SdfPath const &primId) override
Returns the parent instancer of the given rprim or instancer.
USDIMAGING_API void SetDisplayGuides(const bool displayGuides)
Sets display of prims with purpose &quot;guide&quot;.
USDIMAGING_API PickabilityMap GetPickabilityMap() const
Returns the root paths of pickable objects.
SDF_API SdfPath GetAbsoluteRootOrPrimPath() const
Creates a path by stripping all properties and relational attributes from this path, leaving the path to the containing prim.
USDIMAGING_API HdExtComputationInputDescriptorVector GetExtComputationInputDescriptors(SdfPath const &computationId) override
For the given computation id, returns a list of computation input descriptors.
virtual USDIMAGING_API VtArray< TfToken > GetCategories(SdfPath const &id) override
Returns the prim categories.
UsdTimeCode GetTimeWithOffset(float offset) const
Apply a relative offset to the current time.
virtual USDIMAGING_API GfMatrix4d GetInstancerTransform(SdfPath const &instancerId) override
Returns the instancer transform.
USDIMAGING_API void SetInvisedPrimPaths(SdfPathVector const &invisedPaths)
Set the list of paths that must be invised.
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...
USDIMAGING_API void ApplyPendingUpdates()
Applies any scene edits which have been queued up by notices from USD.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
USDIMAGING_API GfInterval GetCurrentTimeSamplingInterval()
Returns the current interval that will be used when using the sample* API in the scene delegate...
USDIMAGING_API void SetReprFallback(HdReprSelector const &repr)
Sets the fallback repr name.
virtual USDIMAGING_API HdMeshTopology GetMeshTopology(SdfPath const &id) override
Gets the topological mesh data for a given prim.
USDIMAGING_API void SetRootVisibility(bool isVisible)
Sets the root visibility for the entire delegate, which is applied to all render prims generated...
USDIMAGING_API std::string GetExtComputationKernel(SdfPath const &computationId) override
Returns the kernel source assigned to the computation at the path id.
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Definition: diagnostic.h:283
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...
virtual USDIMAGING_API VtValue Get(SdfPath const &id, TfToken const &key) override
Returns a named value.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
Adapter class providing data exchange with the client scene graph.
Base class for all PrimAdapters.
Definition: primAdapter.h:65
HdReprSelector GetReprFallback() const
Returns the fallback repr name.
Definition: delegate.h:185
Notice sent in response to authored changes that affect UsdObjects.
Definition: notice.h:107
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.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:132
virtual USDIMAGING_API VtValue GetCameraParamValue(SdfPath const &id, TfToken const &paramName) override
Returns a single value for a given camera and parameter.
virtual USDIMAGING_API void Sync(HdSyncRequestVector *request) override
Synchronizes the delegate state for the given request vector.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A basic mathematical interval class.
Definition: interval.h:50
virtual USDIMAGING_API HdBasisCurvesTopology GetBasisCurvesTopology(SdfPath const &id) override
Gets the topological curve data for a given prim.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
USDIMAGING_API void InvokeExtComputation(SdfPath const &computationId, HdExtComputationContext *context) override
Requests the scene delegate run the ExtComputation with the given id.
A cache for primvar descriptors.
Topology data for basisCurves.
virtual USDIMAGING_API HdReprSelector GetReprSelector(SdfPath const &id) override
Returns the authored repr (if any) for the given prim.
USDIMAGING_API void SetTime(UsdTimeCode time)
Sets the current time from which data will be read by the delegate.
bool GetRootVisibility() const
Returns the root visibility for the entire delegate.
Definition: delegate.h:215
USDIMAGING_API void SetSceneLightsEnabled(bool enable)
Enables lights found in the usdscene.
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...
USDIMAGING_API void SetSceneMaterialsEnabled(bool enable)
Enables custom shading on prims.
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.
UsdTimeCode GetTime() const
Returns the current time.
Definition: delegate.h:143
USDIMAGING_API void SetCameraForSampling(SdfPath const &id)
Setup for the shutter open and close to be used for motion sampling.
virtual USDIMAGING_API GfMatrix4d GetTransform(SdfPath const &id) override
Returns the object space transform, including all parent transforms.
USDIMAGING_API HdExtComputationOutputDescriptorVector GetExtComputationOutputDescriptors(SdfPath const &computationId) override
For the given computation id, returns a list of computation output descriptors.
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 VtValue GetIndexedPrimvar(SdfPath const &id, TfToken const &key, VtIntArray *outIndices) override
Returns a named primvar value.
static SDF_API const SdfPath & AbsoluteRootPath()
The absolute path representing the top of the namespace hierarchy.
The SceneDelegate is requested to synchronize prims as the result of executing a specific render pass...
Definition: sceneDelegate.h:68
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.
Describes one or more authored display representations for an rprim.
Definition: repr.h:48
USDIMAGING_API void ClearPickabilityMap()
Clears any pickability opinions that this delegates might have.
virtual USDIMAGING_API bool GetDoubleSided(SdfPath const &id) override
Returns the doubleSided state for the given prim.
USDIMAGING_API void SetWindowPolicy(CameraUtilConformWindowPolicy policy)
Set the window policy on all scene cameras.
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.
virtual USDIMAGING_API SdfPath GetMaterialId(SdfPath const &rprimId) override
Returns the material ID bound to the rprim rprimId.
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.
USDIMAGING_API void SetCullStyleFallback(HdCullStyle cullStyle)
Sets the fallback cull style.
Object used by instancer prim adapters to pass along context about the instancer and instance prim to...
Topology data for meshes.
Definition: meshTopology.h:55
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 void ClearRefineLevel(SdfPath const &usdPath)
Removes any explicit refine level set for the given USD prim.
USDIMAGING_API void SetDisplayProxy(const bool displayProxy)
Sets display of prims with purpose &quot;proxy&quot;.
SdfPath const & GetDelegateID() const
Returns the ID of this delegate, which is used as a prefix for all objects it creates in the RenderIn...
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
Definition: delegate.h:87
bool IsEmpty() const noexcept
Returns true if this is the empty path (SdfPath::EmptyPath()).
Definition: path.h:417
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141
USDIMAGING_API virtual HdIdVectorSharedPtr GetCoordSysBindings(SdfPath const &id) override
Returns the coordinate system bindings, or a nullptr if none are bound.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
virtual USDIMAGING_API SdfPathVector GetInstancerPrototypes(SdfPath const &instancerId) override
Returns a list of prototypes of this instancer.
SDF_API const char * GetText() const
Returns the string representation of this path as a c string.
USDIMAGING_API bool IsInInvisedPaths(const SdfPath &usdPath) const
Returns true if usdPath is included in invised path list.
int GetRefineLevelFallback() const
Returns the refinement level that is used when prims have no explicit level set.
Definition: delegate.h:160
virtual USDIMAGING_API HdCullStyle GetCullStyle(SdfPath const &id) override
Returns the cullstyle for the given prim.
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 SetRefineLevel(SdfPath const &usdPath, int level)
Sets an explicit refinement level for the given USD prim.