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 USDIMAGING_DELEGATE_H
25 #define USDIMAGING_DELEGATE_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usdImaging/usdImaging/api.h"
31 #include "pxr/usdImaging/usdImaging/collectionCache.h"
32 #include "pxr/usdImaging/usdImaging/valueCache.h"
33 #include "pxr/usdImaging/usdImaging/inheritedCache.h"
34 #include "pxr/usdImaging/usdImaging/instancerContext.h"
35 
36 #include "pxr/imaging/cameraUtil/conformWindow.h"
37 
38 #include "pxr/imaging/hd/coordSys.h"
39 #include "pxr/imaging/hd/sceneDelegate.h"
40 #include "pxr/imaging/hd/selection.h"
41 #include "pxr/imaging/hd/texture.h"
42 #include "pxr/imaging/hd/version.h"
43 
44 #include "pxr/imaging/pxOsd/subdivTags.h"
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"
58 #include "pxr/base/tf/declarePtrs.h"
59 #include "pxr/base/tf/hashmap.h"
60 #include "pxr/base/tf/hashset.h"
61 
62 #include <boost/container/flat_map.hpp>
63 #include <boost/scoped_ptr.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 typedef boost::shared_ptr<UsdImagingPrimAdapter> UsdImagingPrimAdapterSharedPtr;
80 
87  typedef UsdImagingDelegate This;
88 public:
89 
90  typedef TfHashMap<SdfPath, GfMatrix4d, SdfPath::Hash> RigidXformOverridesMap;
91 
92  USDIMAGING_API
93  UsdImagingDelegate(HdRenderIndex *parentIndex,
94  SdfPath const& delegateID);
95 
96  USDIMAGING_API
97  virtual ~UsdImagingDelegate();
98 
99  USDIMAGING_API
100  virtual void Sync(HdSyncRequestVector* request) override;
101 
102  // Helper for clients who don't want to drive the sync behavior (unit
103  // tests). Note this method is not virtual.
104  USDIMAGING_API
105  void SyncAll(bool includeUnvarying);
106 
109  USDIMAGING_API
110  virtual void PostSyncCleanup() override;
111 
112  // TODO: Populate implies that multiple stages can be loaded at once, though
113  // this is not currently supported.
114 
122  USDIMAGING_API
123  static void Populate(std::vector<UsdImagingDelegate*> const& delegates,
124  UsdPrimVector const& rootPrims,
125  std::vector<SdfPathVector> const& excludedPrimPaths,
126  std::vector<SdfPathVector> const& invisedPrimPaths);
127 
129  USDIMAGING_API
130  void Populate(UsdPrim const& rootPrim);
131 
134  USDIMAGING_API
135  void Populate(UsdPrim const& rootPrim,
136  SdfPathVector const& excludedPrimPaths,
137  SdfPathVector const &invisedPrimPaths=SdfPathVector());
138 
145  USDIMAGING_API
146  static void SetTimes(const std::vector<UsdImagingDelegate*>& delegates,
147  const std::vector<UsdTimeCode>& times);
148 
154  USDIMAGING_API
155  void SetTime(UsdTimeCode time);
156 
158  UsdTimeCode GetTime() const { return _time; }
159 
162  UsdTimeCode GetTimeWithOffset(float offset) const;
163 
165  USDIMAGING_API
166  void ApplyPendingUpdates();
167 
175  int GetRefineLevelFallback() const { return _refineLevelFallback; }
176 
183  USDIMAGING_API
184  void SetRefineLevelFallback(int level);
185 
188  USDIMAGING_API
189  void ClearRefineLevel(SdfPath const& usdPath);
190 
196  USDIMAGING_API
197  void SetRefineLevel(SdfPath const& usdPath, int level);
198 
200  HdReprSelector GetReprFallback() const { return _reprFallback; }
201 
204  USDIMAGING_API
205  void SetReprFallback(HdReprSelector const &repr);
206 
208  HdCullStyle GetCullStyleFallback() const { return _cullStyleFallback; }
209 
211  USDIMAGING_API
212  void SetCullStyleFallback(HdCullStyle cullStyle);
213 
217  USDIMAGING_API
218  void SetRootTransform(GfMatrix4d const& xf);
219 
221  const GfMatrix4d &GetRootTransform() const { return _rootXf; }
222 
226  USDIMAGING_API
227  void SetRootVisibility(bool isVisible);
228 
230  bool GetRootVisibility() const { return _rootIsVisible; }
231 
233  USDIMAGING_API
234  void SetInvisedPrimPaths(SdfPathVector const &invisedPaths);
235 
237  USDIMAGING_API
238  void SetRigidXformOverrides(RigidXformOverridesMap const &overrides);
239 
241  USDIMAGING_API
242  PickabilityMap GetPickabilityMap() const;
243 
245  USDIMAGING_API
246  void SetPickability(SdfPath const& path, bool pickable);
247 
249  USDIMAGING_API
250  void ClearPickabilityMap();
251 
253  USDIMAGING_API
254  void SetDisplayGuides(bool displayGuides);
255  bool GetDisplayGuides() const { return _displayGuides; }
256 
258  USDIMAGING_API
259  void SetUsdDrawModesEnabled(bool enableUsdDrawModes);
260  bool GetUsdDrawModesEnabled() const { return _enableUsdDrawModes; }
261 
263  USDIMAGING_API
264  void SetSceneMaterialsEnabled(bool enable);
265 
268  USDIMAGING_API
269  void SetWindowPolicy(CameraUtilConformWindowPolicy policy);
270 
272  USDIMAGING_API
273  void SetCameraForSampling(SdfPath const& id);
274 
277  USDIMAGING_API
279 
280  // ---------------------------------------------------------------------- //
281  // See HdSceneDelegate for documentation of the following virtual methods.
282  // ---------------------------------------------------------------------- //
283  USDIMAGING_API
284  virtual TfToken GetRenderTag(SdfPath const& id) override;
285  USDIMAGING_API
286  virtual HdMeshTopology GetMeshTopology(SdfPath const& id) override;
287  USDIMAGING_API
289  override;
290  typedef PxOsdSubdivTags SubdivTags;
291 
292  // XXX: animated subdiv tags are not currently supported
293  // XXX: subdiv tags currently fetched on-demand
294  USDIMAGING_API
295  virtual SubdivTags GetSubdivTags(SdfPath const& id) override;
296 
297  USDIMAGING_API
298  virtual GfRange3d GetExtent(SdfPath const & id) override;
299  USDIMAGING_API
300  virtual GfMatrix4d GetTransform(SdfPath const & id) override;
301  USDIMAGING_API
302  virtual bool GetVisible(SdfPath const & id) override;
303  USDIMAGING_API
304  virtual bool GetDoubleSided(SdfPath const & id) override;
305  USDIMAGING_API
306  virtual HdCullStyle GetCullStyle(SdfPath const &id) override;
307 
311  USDIMAGING_API
312  virtual HdDisplayStyle GetDisplayStyle(SdfPath const& id) override;
313 
314  USDIMAGING_API
315  virtual VtValue Get(SdfPath const& id, TfToken const& key) override;
316  USDIMAGING_API
317  HdIdVectorSharedPtr
318  virtual GetCoordSysBindings(SdfPath const& id) override;
319  USDIMAGING_API
320  virtual HdReprSelector GetReprSelector(SdfPath const &id) override;
321  USDIMAGING_API
322  virtual VtArray<TfToken> GetCategories(SdfPath const &id) override;
323  USDIMAGING_API
324  virtual std::vector<VtArray<TfToken>>
325  GetInstanceCategories(SdfPath const &instancerId) override;
326  USDIMAGING_API
327  virtual HdPrimvarDescriptorVector
328  GetPrimvarDescriptors(SdfPath const& id,
329  HdInterpolation interpolation) override;
330  USDIMAGING_API
331  virtual VtIntArray GetInstanceIndices(SdfPath const &instancerId,
332  SdfPath const &prototypeId) override;
333  USDIMAGING_API
334  virtual GfMatrix4d GetInstancerTransform(SdfPath const &instancerId)
335  override;
336 
337  // Motion samples
338  USDIMAGING_API
339  virtual size_t
340  SampleTransform(SdfPath const & id, size_t maxNumSamples,
341  float *times, GfMatrix4d *samples) override;
342  USDIMAGING_API
343  virtual size_t
344  SampleInstancerTransform(SdfPath const &instancerId,
345  size_t maxSampleCount, float *times,
346  GfMatrix4d *samples) override;
347  USDIMAGING_API
348  virtual size_t
349  SamplePrimvar(SdfPath const& id, TfToken const& key,
350  size_t maxNumSamples, float *times,
351  VtValue *samples) override;
352 
353  // Material Support
354  USDIMAGING_API
355  virtual SdfPath GetMaterialId(SdfPath const &rprimId) override;
356  USDIMAGING_API
357  virtual std::string GetSurfaceShaderSource(SdfPath const &id) override;
358  USDIMAGING_API
359  virtual std::string GetDisplacementShaderSource(SdfPath const &id) override;
360  USDIMAGING_API
361  virtual VtValue GetMaterialParamValue(SdfPath const &id,
362  TfToken const &paramName) override;
363  USDIMAGING_API
364  virtual HdMaterialParamVector GetMaterialParams(SdfPath const &id) override;
365 
366  // Texture Support
367  USDIMAGING_API
368  HdTextureResource::ID GetTextureResourceID(SdfPath const &id) override;
369  USDIMAGING_API
370  virtual HdTextureResourceSharedPtr GetTextureResource(SdfPath const &id) override;
371 
372  // Light Support
373  USDIMAGING_API
374  virtual VtValue GetLightParamValue(SdfPath const &id,
375  TfToken const &paramName) override;
376  // Camera Support
377  USDIMAGING_API
378  virtual VtValue GetCameraParamValue(SdfPath const &id,
379  TfToken const &paramName) override;
380 
381  // Volume Support
382  USDIMAGING_API
383  virtual HdVolumeFieldDescriptorVector
384  GetVolumeFieldDescriptors(SdfPath const &volumeId) override;
385 
386  // Material Support
387  USDIMAGING_API
388  virtual VtValue GetMaterialResource(SdfPath const &materialId) override;
389 
390  USDIMAGING_API
391  virtual VtDictionary
392  GetMaterialMetadata(SdfPath const &materialId) override;
393 
394  // Instance path resolution
395 
455  static constexpr int ALL_INSTANCES = -1;
456  USDIMAGING_API
457  virtual SdfPath GetPathForInstanceIndex(const SdfPath &protoRprimId,
458  int protoIndex,
459  int *instancerIndex,
460  SdfPath *masterCachePath=NULL,
461  SdfPathVector *instanceContext=NULL) override;
462 
463  // ExtComputation support
464  USDIMAGING_API
466  GetExtComputationSceneInputNames(SdfPath const& computationId) override;
467 
468  USDIMAGING_API
469  HdExtComputationInputDescriptorVector
470  GetExtComputationInputDescriptors(SdfPath const& computationId) override;
471 
472  USDIMAGING_API
473  HdExtComputationOutputDescriptorVector
474  GetExtComputationOutputDescriptors(SdfPath const& computationId) override;
475 
476  USDIMAGING_API
477  HdExtComputationPrimvarDescriptorVector
478  GetExtComputationPrimvarDescriptors(SdfPath const& computationId,
479  HdInterpolation interpolation) override;
480 
481  USDIMAGING_API
482  VtValue GetExtComputationInput(SdfPath const& computationId,
483  TfToken const& input) override;
484 
485  USDIMAGING_API
486  std::string GetExtComputationKernel(SdfPath const& computationId) override;
487 
488  USDIMAGING_API
489  void InvokeExtComputation(SdfPath const& computationId,
490  HdExtComputationContext *context) override;
491 
492 public:
493  // Converts a cache path to a path in the render index.
494  USDIMAGING_API
495  SdfPath ConvertCachePathToIndexPath(SdfPath const& cachePath) {
496  SdfPathMap::const_iterator it = _cache2indexPath.find(cachePath);
497  if (it != _cache2indexPath.end()) {
498  return it->second;
499  }
500 
501  // For pure/plain usdImaging, there is no prefix to replace
502  SdfPath const &delegateID = GetDelegateID();
503  if (delegateID == SdfPath::AbsoluteRootPath()) {
504  return cachePath;
505  }
506  if (cachePath.IsEmpty()) {
507  return cachePath;
508  }
509 
510  return cachePath.ReplacePrefix(SdfPath::AbsoluteRootPath(), delegateID);
511  }
512 
518  USDIMAGING_API
520  SdfPathMap::const_iterator it = _index2cachePath.find(indexPath);
521  if (it != _index2cachePath.end()) {
522  return it->second;
523  }
524 
525  // For pure/plain usdImaging, there is no prefix to replace
526  SdfPath const &delegateID = GetDelegateID();
527  if (delegateID == SdfPath::AbsoluteRootPath()) {
528  return indexPath;
529  }
530 
531  return indexPath.ReplacePrefix(delegateID, SdfPath::AbsoluteRootPath());
532  }
533 
540  USDIMAGING_API
541  bool PopulateSelection(HdSelection::HighlightMode const& highlightMode,
542  const SdfPath &indexPath,
543  int instanceIndex,
544  HdSelectionSharedPtr const &result);
545 
547  USDIMAGING_API
548  bool IsInInvisedPaths(const SdfPath &usdPath) const;
549 
550 private:
551  // Internal friend class.
552  class _Worker;
553  friend class UsdImagingIndexProxy;
554  friend class UsdImagingPrimAdapter;
555 
556  bool _ValidateRefineLevel(int level) {
557  if (!(0 <= level && level <= 8)) {
558  TF_CODING_ERROR("Invalid refinement level(%d), "
559  "expected range is [0,8]",
560  level);
561  return false;
562  }
563  return true;
564  }
565 
566  void _AddTask(UsdImagingDelegate::_Worker *worker, SdfPath const& usdPath);
567 
568  // ---------------------------------------------------------------------- //
569  // Draw mode support
570  // ---------------------------------------------------------------------- //
571  // Determine whether to assign a draw mode adapter to the given prim.
572  bool _IsDrawModeApplied(UsdPrim const& prim);
573  // Get the inherited model:drawMode attribute of the given prim.
574  TfToken _GetModelDrawMode(UsdPrim const& prim);
575 
576  // ---------------------------------------------------------------------- //
577  // Usd Change Processing / Notice Handlers
578  // ---------------------------------------------------------------------- //
579  void _OnUsdObjectsChanged(UsdNotice::ObjectsChanged const&,
580  UsdStageWeakPtr const& sender);
581 
582  // The lightest-weight update, it does fine-grained invalidation of
583  // individual properties at the given path (prim or property).
584  //
585  // If \p path is a prim path, changedPrimInfoFields will be populated
586  // with the list of scene description fields that caused this prim to
587  // be refreshed.
588  void _RefreshUsdObject(SdfPath const& usdPath,
589  TfTokenVector const& changedPrimInfoFields,
590  UsdImagingIndexProxy* proxy);
591 
592  // Heavy-weight invalidation of an entire prim subtree. All cached data is
593  // reconstructed for all prims below \p rootPath.
594  //
595  // By default, _ResyncPrim will remove each affected prim and call
596  // Repopulate() on those prims individually. If repopulateFromRoot is
597  // true, Repopulate() will be called on \p rootPath instead. This is slower,
598  // but handles changes in tree topology.
599  void _ResyncUsdPrim(SdfPath const& usdRootPath, UsdImagingIndexProxy* proxy,
600  bool repopulateFromRoot = false);
601 
602  // ---------------------------------------------------------------------- //
603  // Usd Data-Access Helper Methods
604  // ---------------------------------------------------------------------- //
605  UsdPrim _GetUsdPrim(SdfPath const& usdPath) {
606  UsdPrim const& p =
607  _stage->GetPrimAtPath(usdPath.GetAbsoluteRootOrPrimPath());
608  TF_VERIFY(p, "No prim found for id: %s",
609  usdPath.GetAbsoluteRootOrPrimPath().GetText());
610  return p;
611  }
612 
613  VtValue _GetUsdPrimAttribute(SdfPath const& cachePath,
614  TfToken const &attrName);
615 
616  void _UpdateSingleValue(SdfPath const& cachePath, int dirtyFlags);
617 
618  // ---------------------------------------------------------------------- //
619  // Cache structures and related methods for population.
620  // ---------------------------------------------------------------------- //
621 
622  // Returns true if this delegate can be populated, false otherwise.
623  bool _CanPopulate(UsdPrim const& rootPrim) const;
624 
625  // Set the delegate's state to reflect that it will be populated from
626  // the given root prim with the given excluded paths.
627  void _SetStateForPopulation(UsdPrim const& rootPrim,
628  SdfPathVector const& excludedPaths,
629  SdfPathVector const& invisedPaths);
630 
631  // Populates this delegate's render index from the paths specified
632  // in the given index proxy.
633  void _Populate(class UsdImagingIndexProxy* proxy);
634 
635  // Execute all variability update tasks that have been added to the given
636  // worker.
637  static void _ExecuteWorkForVariabilityUpdate(_Worker* worker);
638 
642  bool _GetVisible(UsdPrim const& prim);
643 
645  TfTokenVector _GetPrimvarNames(SdfPath const& usdPath,
646  TfToken const& interpolation);
647 
648  // ---------------------------------------------------------------------- //
649  // Helper methods for updating the delegate on time changes
650  // ---------------------------------------------------------------------- //
651 
652  // Execute all time update tasks that have been added to the given worker.
653  static void _ExecuteWorkForTimeUpdate(_Worker* worker);
654 
655  // ---------------------------------------------------------------------- //
656  // Core Delegate state
657  // ---------------------------------------------------------------------- //
658 
659  // Usd Prim Type to Adapter lookup table.
660  typedef boost::shared_ptr<UsdImagingPrimAdapter> _AdapterSharedPtr;
661  typedef TfHashMap<TfToken,
662  _AdapterSharedPtr, TfToken::HashFunctor> _AdapterMap;
663  _AdapterMap _adapterMap;
664 
665  // Per-Hydra-Primitive tracking data
666  struct _HdPrimInfo {
667  _AdapterSharedPtr adapter; // The adapter to use for the prim
668  UsdPrim usdPrim; // Reference to the Usd prim
669  HdDirtyBits timeVaryingBits; // Dirty Bits to set when
670  // time changes
671  HdDirtyBits dirtyBits; // Current dirty state of the prim.
672  SdfPathVector extraDependencies;// Dependencies that aren't usdPrim.
673  };
674 
675  typedef TfHashMap<SdfPath, _HdPrimInfo, SdfPath::Hash> _HdPrimInfoMap;
676 
677  // Map from cache path to Hydra prim info
678  _HdPrimInfoMap _hdPrimInfoMap;
679 
680  typedef std::multimap<SdfPath, SdfPath> _DependencyMap;
681 
682  // Map from USD path to Hydra path, for tracking USD->hydra dependencies.
683  _DependencyMap _dependencyInfo;
684 
685  void _GatherDependencies(SdfPath const& subtree,
686  SdfPathVector *affectedCachePaths,
687  SdfPathVector *affectedUsdPaths = nullptr);
688 
689  // SdfPath::ReplacePrefix() is used frequently to convert between
690  // cache path and Hydra render index path and is a performance bottleneck.
691  // These maps pre-computes these conversion.
692  typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash> SdfPathMap;
693  SdfPathMap _cache2indexPath;
694  SdfPathMap _index2cachePath;
695 
696  // Only use this method when we think no existing adapter has been
697  // established. For example, during initial Population.
698  _AdapterSharedPtr const& _AdapterLookup(UsdPrim const& prim,
699  bool ignoreInstancing = false);
700  _AdapterSharedPtr const& _AdapterLookup(TfToken const& adapterKey);
701 
702  // Obtain the prim tracking data for the given cache path.
703  _HdPrimInfo *_GetHdPrimInfo(const SdfPath &cachePath);
704 
705  typedef TfHashSet<SdfPath, SdfPath::Hash> _InstancerSet;
706 
707  // Set of cache paths representing instancers
708  _InstancerSet _instancerPrimCachePaths;
709 
710  void _MarkSubtreeTransformDirty(SdfPath const &usdSubtreeRoot);
711  void _MarkSubtreeVisibilityDirty(SdfPath const &usdSubtreeRoot);
712 
713  bool _IsChildPath(SdfPath const& path) const {
714  return path.IsPropertyPath();
715  }
716 
718  typedef TfHashMap<SdfPath, int, SdfPath::Hash> _RefineLevelMap;
720  _RefineLevelMap _refineLevelMap;
721 
723  UsdImagingValueCache _valueCache;
724 
726  UsdStageRefPtr _stage;
727  SdfPath _rootPrimPath;
728  SdfPathVector _excludedPrimPaths;
729  SdfPathVector _invisedPrimPaths;
730 
731  RigidXformOverridesMap _rigidXformOverrides;
732 
733  // Aspects of the delegate root that apply to all items in the index.
734  SdfPath _compensationPath;
735 
736  GfMatrix4d _rootXf;
737  bool _rootIsVisible;
738 
740  UsdTimeCode _time;
741 
743  SdfPath _cameraPathForSampling;
744 
745  int _refineLevelFallback;
746  HdReprSelector _reprFallback;
747  HdCullStyle _cullStyleFallback;
748 
749  // Change processing
750  TfNotice::Key _objectsChangedNoticeKey;
751  SdfPathVector _usdPathsToResync;
752 
753  // Map from path of Usd object to update to list of changed scene
754  // description fields for that object. This list of fields is only
755  // populated for prim paths.
756  typedef std::unordered_map<SdfPath, TfTokenVector, SdfPath::Hash>
757  _PathsToUpdateMap;
758  _PathsToUpdateMap _usdPathsToUpdate;
759 
760  UsdImaging_XformCache _xformCache;
761  UsdImaging_MaterialBindingImplData _materialBindingImplData;
762  UsdImaging_MaterialBindingCache _materialBindingCache;
763  UsdImaging_CoordSysBindingImplData _coordSysBindingImplData;
764  UsdImaging_CoordSysBindingCache _coordSysBindingCache;
765  UsdImaging_VisCache _visCache;
766  UsdImaging_PurposeCache _purposeCache;
767  UsdImaging_DrawModeCache _drawModeCache;
768  UsdImaging_CollectionCache _collectionCache;
769  UsdImaging_InheritedPrimvarCache _inheritedPrimvarCache;
770 
771  // Pickability
772  PickabilityMap _pickablesMap;
773 
774  // Display guides rendering
775  bool _displayGuides;
776  bool _enableUsdDrawModes;
777 
778  const bool _hasDrawModeAdapter;
779 
781  bool _sceneMaterialsEnabled;
782 
783  CameraUtilConformWindowPolicy _appWindowPolicy;
784 
785  // Enable HdCoordSys tracking
786  const bool _coordSysEnabled;
787 
788  UsdImagingDelegate() = delete;
789  UsdImagingDelegate(UsdImagingDelegate const &) = delete;
790  UsdImagingDelegate &operator =(UsdImagingDelegate const &) = delete;
791 };
792 
793 PXR_NAMESPACE_CLOSE_SCOPE
794 
795 #endif //USDIMAGING_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
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:119
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:519
static constexpr int ALL_INSTANCES
Resolves a protoRprimId and protoIndex back to original instancer path by backtracking nested instanc...
Definition: delegate.h:455
USDIMAGING_API void SetPickability(SdfPath const &path, bool pickable)
Sets pickability for a specific path.
USDIMAGING_API HdTextureResource::ID GetTextureResourceID(SdfPath const &id) override
Returns the texture resource ID for a given texture ID.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
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 std::string GetSurfaceShaderSource(SdfPath const &id) override
Returns the surface shader source code for the given material ID.
virtual USDIMAGING_API void PostSyncCleanup() override
Opportunity for the delegate to clean itself up after performing parrellel 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:79
USDIMAGING_API void SetUsdDrawModesEnabled(bool enableUsdDrawModes)
Returns whether draw modes are enabled.
virtual USDIMAGING_API HdTextureResourceSharedPtr GetTextureResource(SdfPath const &id) override
Returns the texture resource for a given texture ID.
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.
A map with string keys and VtValue values.
Definition: dictionary.h:61
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:221
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:87
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:208
USD_API UsdPrim GetPrimAtPath(const SdfPath &path) const
Return the UsdPrim at path, or an invalid UsdPrim if none exists.
virtual USDIMAGING_API bool GetVisible(SdfPath const &id) override
Returns the authored visible state of the prim.
static USDIMAGING_API void Populate(std::vector< UsdImagingDelegate * > const &delegates, UsdPrimVector const &rootPrims, std::vector< SdfPathVector > const &excludedPrimPaths, std::vector< SdfPathVector > const &invisedPrimPaths)
Populates the rootPrim in the HdRenderIndex in each delegate, excluding all paths in the excludedPrim...
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
Definition: selection.h:53
virtual USDIMAGING_API VtValue GetMaterialParamValue(SdfPath const &id, TfToken const &paramName) override
Returns a single value for the given material and named parameter.
Functor to use for hash maps from tokens to other things.
Definition: token.h:168
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
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.
A heterogeneous value container without type erasure.
Definition: valueCache.h:56
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:89
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:289
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:67
HdReprSelector GetReprFallback() const
Returns the fallback repr name.
Definition: delegate.h:200
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:131
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:438
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:287
USDIMAGING_API void InvokeExtComputation(SdfPath const &computationId, HdExtComputationContext *context) override
Requests the scene delegate run the ExtComputation with the given id.
USDIMAGING_API void SetDisplayGuides(bool displayGuides)
Sets display guides rendering.
SDF_API bool IsPropertyPath() const
Returns whether the path identifies a property.
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:230
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 GetPathForInstanceIndex(const SdfPath &protoRprimId, int protoIndex, int *instancerIndex, SdfPath *masterCachePath=NULL, SdfPathVector *instanceContext=NULL) override
Resolves a protoRprimId and protoIndex back to original instancer path by backtracking nested instanc...
UsdTimeCode GetTime() const
Returns the current time.
Definition: delegate.h:158
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.
static SDF_API const SdfPath & AbsoluteRootPath()
The absolute path representing the top of the namespace hierarchy.
USDIMAGING_API bool PopulateSelection(HdSelection::HighlightMode const &highlightMode, const SdfPath &indexPath, int instanceIndex, HdSelectionSharedPtr const &result)
Populate HdxSelection for given path (root) and instanceIndex if indexPath is instancer and instanceI...
The SceneDelegate is requested to synchronize prims as the result of executing a specific render pass...
Definition: sceneDelegate.h:67
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.
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 HdMaterialParamVector GetMaterialParams(SdfPath const &id) override
Returns the material params for the given material ID.
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.
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:86
virtual USDIMAGING_API std::string GetDisplacementShaderSource(SdfPath const &id) override
Returns the displacement shader source code for the given material ID.
bool IsEmpty() const noexcept
Returns true if this is the empty path (SdfPath::EmptyPath()).
Definition: path.h:409
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:142
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:182
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:175
virtual USDIMAGING_API HdCullStyle GetCullStyle(SdfPath const &id) override
Returns the cullstyle for the given prim.
USDIMAGING_API void SetRefineLevel(SdfPath const &usdPath, int level)
Sets an explicit refinement level for the given USD prim.