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/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 
357  USDIMAGING_API
358  virtual VtValue GetMaterialResource(SdfPath const &materialId) override;
359 
360  // Texture Support
361  USDIMAGING_API
362  HdTextureResource::ID GetTextureResourceID(SdfPath const &id) override;
363  USDIMAGING_API
364  virtual HdTextureResourceSharedPtr GetTextureResource(SdfPath const &id) override;
365 
366  // Light Support
367  USDIMAGING_API
368  virtual VtValue GetLightParamValue(SdfPath const &id,
369  TfToken const &paramName) override;
370  // Camera Support
371  USDIMAGING_API
372  virtual VtValue GetCameraParamValue(SdfPath const &id,
373  TfToken const &paramName) override;
374 
375  // Volume Support
376  USDIMAGING_API
377  virtual HdVolumeFieldDescriptorVector
378  GetVolumeFieldDescriptors(SdfPath const &volumeId) override;
379 
380  // Instance path resolution
381 
441  static constexpr int ALL_INSTANCES = -1;
442  USDIMAGING_API
443  virtual SdfPath GetPathForInstanceIndex(const SdfPath &protoRprimId,
444  int protoIndex,
445  int *instancerIndex,
446  SdfPath *masterCachePath=NULL,
447  SdfPathVector *instanceContext=NULL) override;
448 
449  // ExtComputation support
450  USDIMAGING_API
452  GetExtComputationSceneInputNames(SdfPath const& computationId) override;
453 
454  USDIMAGING_API
455  HdExtComputationInputDescriptorVector
456  GetExtComputationInputDescriptors(SdfPath const& computationId) override;
457 
458  USDIMAGING_API
459  HdExtComputationOutputDescriptorVector
460  GetExtComputationOutputDescriptors(SdfPath const& computationId) override;
461 
462  USDIMAGING_API
463  HdExtComputationPrimvarDescriptorVector
464  GetExtComputationPrimvarDescriptors(SdfPath const& computationId,
465  HdInterpolation interpolation) override;
466 
467  USDIMAGING_API
468  VtValue GetExtComputationInput(SdfPath const& computationId,
469  TfToken const& input) override;
470 
471  USDIMAGING_API
472  std::string GetExtComputationKernel(SdfPath const& computationId) override;
473 
474  USDIMAGING_API
475  void InvokeExtComputation(SdfPath const& computationId,
476  HdExtComputationContext *context) override;
477 
478 public:
479  // Converts a cache path to a path in the render index.
480  USDIMAGING_API
481  SdfPath ConvertCachePathToIndexPath(SdfPath const& cachePath) {
482  SdfPathMap::const_iterator it = _cache2indexPath.find(cachePath);
483  if (it != _cache2indexPath.end()) {
484  return it->second;
485  }
486 
487  // For pure/plain usdImaging, there is no prefix to replace
488  SdfPath const &delegateID = GetDelegateID();
489  if (delegateID == SdfPath::AbsoluteRootPath()) {
490  return cachePath;
491  }
492  if (cachePath.IsEmpty()) {
493  return cachePath;
494  }
495 
496  return cachePath.ReplacePrefix(SdfPath::AbsoluteRootPath(), delegateID);
497  }
498 
504  USDIMAGING_API
506  SdfPathMap::const_iterator it = _index2cachePath.find(indexPath);
507  if (it != _index2cachePath.end()) {
508  return it->second;
509  }
510 
511  // For pure/plain usdImaging, there is no prefix to replace
512  SdfPath const &delegateID = GetDelegateID();
513  if (delegateID == SdfPath::AbsoluteRootPath()) {
514  return indexPath;
515  }
516 
517  return indexPath.ReplacePrefix(delegateID, SdfPath::AbsoluteRootPath());
518  }
519 
526  USDIMAGING_API
527  bool PopulateSelection(HdSelection::HighlightMode const& highlightMode,
528  const SdfPath &indexPath,
529  int instanceIndex,
530  HdSelectionSharedPtr const &result);
531 
533  USDIMAGING_API
534  bool IsInInvisedPaths(const SdfPath &usdPath) const;
535 
536 private:
537  // Internal friend class.
538  class _Worker;
539  friend class UsdImagingIndexProxy;
540  friend class UsdImagingPrimAdapter;
541 
542  bool _ValidateRefineLevel(int level) {
543  if (!(0 <= level && level <= 8)) {
544  TF_CODING_ERROR("Invalid refinement level(%d), "
545  "expected range is [0,8]",
546  level);
547  return false;
548  }
549  return true;
550  }
551 
552  void _AddTask(UsdImagingDelegate::_Worker *worker, SdfPath const& usdPath);
553 
554  // ---------------------------------------------------------------------- //
555  // Draw mode support
556  // ---------------------------------------------------------------------- //
557  // Determine whether to assign a draw mode adapter to the given prim.
558  bool _IsDrawModeApplied(UsdPrim const& prim);
559  // Get the inherited model:drawMode attribute of the given prim.
560  TfToken _GetModelDrawMode(UsdPrim const& prim);
561 
562  // ---------------------------------------------------------------------- //
563  // Usd Change Processing / Notice Handlers
564  // ---------------------------------------------------------------------- //
565  void _OnUsdObjectsChanged(UsdNotice::ObjectsChanged const&,
566  UsdStageWeakPtr const& sender);
567 
568  // The lightest-weight update, it does fine-grained invalidation of
569  // individual properties at the given path (prim or property).
570  //
571  // If \p path is a prim path, changedPrimInfoFields will be populated
572  // with the list of scene description fields that caused this prim to
573  // be refreshed.
574  void _RefreshUsdObject(SdfPath const& usdPath,
575  TfTokenVector const& changedPrimInfoFields,
576  UsdImagingIndexProxy* proxy);
577 
578  // Heavy-weight invalidation of an entire prim subtree. All cached data is
579  // reconstructed for all prims below \p rootPath.
580  //
581  // By default, _ResyncPrim will remove each affected prim and call
582  // Repopulate() on those prims individually. If repopulateFromRoot is
583  // true, Repopulate() will be called on \p rootPath instead. This is slower,
584  // but handles changes in tree topology.
585  void _ResyncUsdPrim(SdfPath const& usdRootPath, UsdImagingIndexProxy* proxy,
586  bool repopulateFromRoot = false);
587 
588  // ---------------------------------------------------------------------- //
589  // Usd Data-Access Helper Methods
590  // ---------------------------------------------------------------------- //
591  UsdPrim _GetUsdPrim(SdfPath const& usdPath) {
592  UsdPrim const& p =
593  _stage->GetPrimAtPath(usdPath.GetAbsoluteRootOrPrimPath());
594  TF_VERIFY(p, "No prim found for id: %s",
595  usdPath.GetAbsoluteRootOrPrimPath().GetText());
596  return p;
597  }
598 
599  VtValue _GetUsdPrimAttribute(SdfPath const& cachePath,
600  TfToken const &attrName);
601 
602  void _UpdateSingleValue(SdfPath const& cachePath, int dirtyFlags);
603 
604  // ---------------------------------------------------------------------- //
605  // Cache structures and related methods for population.
606  // ---------------------------------------------------------------------- //
607 
608  // Returns true if this delegate can be populated, false otherwise.
609  bool _CanPopulate(UsdPrim const& rootPrim) const;
610 
611  // Set the delegate's state to reflect that it will be populated from
612  // the given root prim with the given excluded paths.
613  void _SetStateForPopulation(UsdPrim const& rootPrim,
614  SdfPathVector const& excludedPaths,
615  SdfPathVector const& invisedPaths);
616 
617  // Populates this delegate's render index from the paths specified
618  // in the given index proxy.
619  void _Populate(class UsdImagingIndexProxy* proxy);
620 
621  // Execute all variability update tasks that have been added to the given
622  // worker.
623  static void _ExecuteWorkForVariabilityUpdate(_Worker* worker);
624 
628  bool _GetVisible(UsdPrim const& prim);
629 
631  TfTokenVector _GetPrimvarNames(SdfPath const& usdPath,
632  TfToken const& interpolation);
633 
634  // ---------------------------------------------------------------------- //
635  // Helper methods for updating the delegate on time changes
636  // ---------------------------------------------------------------------- //
637 
638  // Execute all time update tasks that have been added to the given worker.
639  static void _ExecuteWorkForTimeUpdate(_Worker* worker);
640 
641  // ---------------------------------------------------------------------- //
642  // Core Delegate state
643  // ---------------------------------------------------------------------- //
644 
645  // Usd Prim Type to Adapter lookup table.
646  typedef boost::shared_ptr<UsdImagingPrimAdapter> _AdapterSharedPtr;
647  typedef TfHashMap<TfToken,
648  _AdapterSharedPtr, TfToken::HashFunctor> _AdapterMap;
649  _AdapterMap _adapterMap;
650 
651  // Per-Hydra-Primitive tracking data
652  struct _HdPrimInfo {
653  _AdapterSharedPtr adapter; // The adapter to use for the prim
654  UsdPrim usdPrim; // Reference to the Usd prim
655  HdDirtyBits timeVaryingBits; // Dirty Bits to set when
656  // time changes
657  HdDirtyBits dirtyBits; // Current dirty state of the prim.
658  SdfPathVector extraDependencies;// Dependencies that aren't usdPrim.
659  };
660 
661  typedef TfHashMap<SdfPath, _HdPrimInfo, SdfPath::Hash> _HdPrimInfoMap;
662 
663  // Map from cache path to Hydra prim info
664  _HdPrimInfoMap _hdPrimInfoMap;
665 
666  typedef std::multimap<SdfPath, SdfPath> _DependencyMap;
667 
668  // Map from USD path to Hydra path, for tracking USD->hydra dependencies.
669  _DependencyMap _dependencyInfo;
670 
671  void _GatherDependencies(SdfPath const& subtree,
672  SdfPathVector *affectedCachePaths,
673  SdfPathVector *affectedUsdPaths = nullptr);
674 
675  // SdfPath::ReplacePrefix() is used frequently to convert between
676  // cache path and Hydra render index path and is a performance bottleneck.
677  // These maps pre-computes these conversion.
678  typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash> SdfPathMap;
679  SdfPathMap _cache2indexPath;
680  SdfPathMap _index2cachePath;
681 
682  // Only use this method when we think no existing adapter has been
683  // established. For example, during initial Population.
684  _AdapterSharedPtr const& _AdapterLookup(UsdPrim const& prim,
685  bool ignoreInstancing = false);
686  _AdapterSharedPtr const& _AdapterLookup(TfToken const& adapterKey);
687 
688  // Obtain the prim tracking data for the given cache path.
689  _HdPrimInfo *_GetHdPrimInfo(const SdfPath &cachePath);
690 
691  typedef TfHashSet<SdfPath, SdfPath::Hash> _InstancerSet;
692 
693  // Set of cache paths representing instancers
694  _InstancerSet _instancerPrimCachePaths;
695 
697  typedef TfHashMap<SdfPath, int, SdfPath::Hash> _RefineLevelMap;
699  _RefineLevelMap _refineLevelMap;
700 
702  UsdImagingValueCache _valueCache;
703 
705  UsdStageRefPtr _stage;
706  SdfPath _rootPrimPath;
707  SdfPathVector _excludedPrimPaths;
708  SdfPathVector _invisedPrimPaths;
709 
710  RigidXformOverridesMap _rigidXformOverrides;
711 
712  // Aspects of the delegate root that apply to all items in the index.
713  SdfPath _compensationPath;
714 
715  GfMatrix4d _rootXf;
716  bool _rootIsVisible;
717 
719  UsdTimeCode _time;
720 
722  SdfPath _cameraPathForSampling;
723 
724  int _refineLevelFallback;
725  HdReprSelector _reprFallback;
726  HdCullStyle _cullStyleFallback;
727 
728  // Change processing
729  TfNotice::Key _objectsChangedNoticeKey;
730  SdfPathVector _usdPathsToResync;
731 
732  // Map from path of Usd object to update to list of changed scene
733  // description fields for that object. This list of fields is only
734  // populated for prim paths.
735  typedef std::unordered_map<SdfPath, TfTokenVector, SdfPath::Hash>
736  _PathsToUpdateMap;
737  _PathsToUpdateMap _usdPathsToUpdate;
738 
739  UsdImaging_XformCache _xformCache;
740  UsdImaging_MaterialBindingImplData _materialBindingImplData;
741  UsdImaging_MaterialBindingCache _materialBindingCache;
742  UsdImaging_CoordSysBindingImplData _coordSysBindingImplData;
743  UsdImaging_CoordSysBindingCache _coordSysBindingCache;
744  UsdImaging_VisCache _visCache;
745  UsdImaging_PurposeCache _purposeCache;
746  UsdImaging_DrawModeCache _drawModeCache;
747  UsdImaging_CollectionCache _collectionCache;
748  UsdImaging_InheritedPrimvarCache _inheritedPrimvarCache;
749 
750  // Pickability
751  PickabilityMap _pickablesMap;
752 
753  // Display guides rendering
754  bool _displayGuides;
755  bool _enableUsdDrawModes;
756 
757  const bool _hasDrawModeAdapter;
758 
760  bool _sceneMaterialsEnabled;
761 
762  CameraUtilConformWindowPolicy _appWindowPolicy;
763 
764  // Enable HdCoordSys tracking
765  const bool _coordSysEnabled;
766 
767  UsdImagingDelegate() = delete;
768  UsdImagingDelegate(UsdImagingDelegate const &) = delete;
769  UsdImagingDelegate &operator =(UsdImagingDelegate const &) = delete;
770 };
771 
772 PXR_NAMESPACE_CLOSE_SCOPE
773 
774 #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
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:117
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:505
static constexpr int ALL_INSTANCES
Resolves a protoRprimId and protoIndex back to original instancer path by backtracking nested instanc...
Definition: delegate.h:441
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 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.
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
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:433
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.
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 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
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.