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"
32 #include "pxr/usdImaging/usdImaging/collectionCache.h"
33 #include "pxr/usdImaging/usdImaging/valueCache.h"
34 #include "pxr/usdImaging/usdImaging/inheritedCache.h"
35 #include "pxr/usdImaging/usdImaging/instancerContext.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/texture.h"
43 #include "pxr/imaging/hd/version.h"
44 
45 #include "pxr/imaging/pxOsd/subdivTags.h"
46 #include "pxr/usd/sdf/path.h"
47 #include "pxr/usd/sdf/pathTable.h"
48 #include "pxr/usd/usd/attribute.h"
49 #include "pxr/usd/usd/notice.h"
50 #include "pxr/usd/usd/prim.h"
51 #include "pxr/usd/usd/stage.h"
52 #include "pxr/usd/usdGeom/cube.h"
53 #include "pxr/usd/usdGeom/sphere.h"
54 #include "pxr/usd/usdGeom/xformCache.h"
55 #include "pxr/base/vt/value.h"
56 
57 #include "pxr/base/gf/range3d.h"
58 #include "pxr/base/gf/interval.h"
59 #include "pxr/base/tf/declarePtrs.h"
60 #include "pxr/base/tf/hashmap.h"
61 #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 SetDisplayGuides(bool displayGuides);
240  bool GetDisplayGuides() const { return _displayGuides; }
241 
243  USDIMAGING_API
244  void SetUsdDrawModesEnabled(bool enableUsdDrawModes);
245  bool GetUsdDrawModesEnabled() const { return _enableUsdDrawModes; }
246 
248  USDIMAGING_API
249  void SetSceneMaterialsEnabled(bool enable);
250 
253  USDIMAGING_API
254  void SetWindowPolicy(CameraUtilConformWindowPolicy policy);
255 
264  USDIMAGING_API
265  void SetDisplayUnloadedPrimsWithBounds(bool displayUnloaded);
266  bool GetDisplayUnloadedPrimsWithBounds() const {
267  return _displayUnloadedPrimsWithBounds;
268  }
269 
271  USDIMAGING_API
272  void SetCameraForSampling(SdfPath const& id);
273 
276  USDIMAGING_API
278 
279  // ---------------------------------------------------------------------- //
280  // See HdSceneDelegate for documentation of the following virtual methods.
281  // ---------------------------------------------------------------------- //
282  USDIMAGING_API
283  virtual TfToken GetRenderTag(SdfPath const& id) override;
284  USDIMAGING_API
285  virtual HdMeshTopology GetMeshTopology(SdfPath const& id) override;
286  USDIMAGING_API
288  override;
289  typedef PxOsdSubdivTags SubdivTags;
290 
291  // XXX: animated subdiv tags are not currently supported
292  // XXX: subdiv tags currently fetched on-demand
293  USDIMAGING_API
294  virtual SubdivTags GetSubdivTags(SdfPath const& id) override;
295 
296  USDIMAGING_API
297  virtual GfRange3d GetExtent(SdfPath const & id) override;
298  USDIMAGING_API
299  virtual GfMatrix4d GetTransform(SdfPath const & id) override;
300  USDIMAGING_API
301  virtual bool GetVisible(SdfPath const & id) override;
302  USDIMAGING_API
303  virtual bool GetDoubleSided(SdfPath const & id) override;
304  USDIMAGING_API
305  virtual HdCullStyle GetCullStyle(SdfPath const &id) override;
306 
310  USDIMAGING_API
311  virtual HdDisplayStyle GetDisplayStyle(SdfPath const& id) override;
312 
313  USDIMAGING_API
314  virtual VtValue Get(SdfPath const& id, TfToken const& key) override;
315  USDIMAGING_API
316  HdIdVectorSharedPtr
317  virtual GetCoordSysBindings(SdfPath const& id) override;
318  USDIMAGING_API
319  virtual HdReprSelector GetReprSelector(SdfPath const &id) override;
320  USDIMAGING_API
321  virtual VtArray<TfToken> GetCategories(SdfPath const &id) override;
322  USDIMAGING_API
323  virtual std::vector<VtArray<TfToken>>
324  GetInstanceCategories(SdfPath const &instancerId) override;
325  USDIMAGING_API
326  virtual HdPrimvarDescriptorVector
327  GetPrimvarDescriptors(SdfPath const& id,
328  HdInterpolation interpolation) override;
329  USDIMAGING_API
330  virtual VtIntArray GetInstanceIndices(SdfPath const &instancerId,
331  SdfPath const &prototypeId) override;
332  USDIMAGING_API
333  virtual GfMatrix4d GetInstancerTransform(SdfPath const &instancerId)
334  override;
335 
336  // Motion samples
337  USDIMAGING_API
338  virtual size_t
339  SampleTransform(SdfPath const & id, size_t maxNumSamples,
340  float *times, GfMatrix4d *samples) override;
341  USDIMAGING_API
342  virtual size_t
343  SampleInstancerTransform(SdfPath const &instancerId,
344  size_t maxSampleCount, float *times,
345  GfMatrix4d *samples) override;
346  USDIMAGING_API
347  virtual size_t
348  SamplePrimvar(SdfPath const& id, TfToken const& key,
349  size_t maxNumSamples, float *times,
350  VtValue *samples) override;
351 
352  // Material Support
353  USDIMAGING_API
354  virtual SdfPath GetMaterialId(SdfPath const &rprimId) override;
355 
356  USDIMAGING_API
357  virtual VtValue GetMaterialResource(SdfPath const &materialId) override;
358 
359  // Texture Support
360  USDIMAGING_API
361  HdTextureResource::ID GetTextureResourceID(SdfPath const &id) override;
362  USDIMAGING_API
363  virtual HdTextureResourceSharedPtr GetTextureResource(SdfPath const &id) override;
364 
365  // Light Support
366  USDIMAGING_API
367  virtual VtValue GetLightParamValue(SdfPath const &id,
368  TfToken const &paramName) override;
369  // Camera Support
370  USDIMAGING_API
371  virtual VtValue GetCameraParamValue(SdfPath const &id,
372  TfToken const &paramName) override;
373 
374  // Volume Support
375  USDIMAGING_API
376  virtual HdVolumeFieldDescriptorVector
377  GetVolumeFieldDescriptors(SdfPath const &volumeId) override;
378 
379  // Picking path resolution
380  // Resolves a \p rprimId and \p instanceIndex back to the original USD
381  // gprim and instance index.
382  USDIMAGING_API
383  virtual SdfPath
384  GetScenePrimPath(SdfPath const& rprimId,
385  int instanceIndex) override;
386 
387  // ExtComputation support
388  USDIMAGING_API
390  GetExtComputationSceneInputNames(SdfPath const& computationId) override;
391 
392  USDIMAGING_API
393  HdExtComputationInputDescriptorVector
394  GetExtComputationInputDescriptors(SdfPath const& computationId) override;
395 
396  USDIMAGING_API
397  HdExtComputationOutputDescriptorVector
398  GetExtComputationOutputDescriptors(SdfPath const& computationId) override;
399 
400  USDIMAGING_API
401  HdExtComputationPrimvarDescriptorVector
402  GetExtComputationPrimvarDescriptors(SdfPath const& computationId,
403  HdInterpolation interpolation) override;
404 
405  USDIMAGING_API
406  VtValue GetExtComputationInput(SdfPath const& computationId,
407  TfToken const& input) override;
408 
409  USDIMAGING_API
410  std::string GetExtComputationKernel(SdfPath const& computationId) override;
411 
412  USDIMAGING_API
413  void InvokeExtComputation(SdfPath const& computationId,
414  HdExtComputationContext *context) override;
415 
416 public:
417  // Converts a cache path to a path in the render index.
418  USDIMAGING_API
419  SdfPath ConvertCachePathToIndexPath(SdfPath const& cachePath) {
420  SdfPathMap::const_iterator it = _cache2indexPath.find(cachePath);
421  if (it != _cache2indexPath.end()) {
422  return it->second;
423  }
424 
425  // For pure/plain usdImaging, there is no prefix to replace
426  SdfPath const &delegateID = GetDelegateID();
427  if (delegateID == SdfPath::AbsoluteRootPath()) {
428  return cachePath;
429  }
430  if (cachePath.IsEmpty()) {
431  return cachePath;
432  }
433 
434  return cachePath.ReplacePrefix(SdfPath::AbsoluteRootPath(), delegateID);
435  }
436 
442  USDIMAGING_API
444  SdfPathMap::const_iterator it = _index2cachePath.find(indexPath);
445  if (it != _index2cachePath.end()) {
446  return it->second;
447  }
448 
449  // For pure/plain usdImaging, there is no prefix to replace
450  SdfPath const &delegateID = GetDelegateID();
451  if (delegateID == SdfPath::AbsoluteRootPath()) {
452  return indexPath;
453  }
454 
455  return indexPath.ReplacePrefix(delegateID, SdfPath::AbsoluteRootPath());
456  }
457 
461  static constexpr int ALL_INSTANCES = -1;
462  USDIMAGING_API
463  bool PopulateSelection(HdSelection::HighlightMode const& highlightMode,
464  const SdfPath &usdPath,
465  int instanceIndex,
466  HdSelectionSharedPtr const &result);
467 
469  USDIMAGING_API
470  bool IsInInvisedPaths(const SdfPath &usdPath) const;
471 
472 private:
473  // Internal friend class.
474  class _Worker;
475  friend class UsdImagingIndexProxy;
476  friend class UsdImagingPrimAdapter;
477 
478  bool _ValidateRefineLevel(int level) {
479  if (!(0 <= level && level <= 8)) {
480  TF_CODING_ERROR("Invalid refinement level(%d), "
481  "expected range is [0,8]",
482  level);
483  return false;
484  }
485  return true;
486  }
487 
488  void _AddTask(UsdImagingDelegate::_Worker *worker, SdfPath const& usdPath);
489 
490  // ---------------------------------------------------------------------- //
491  // Draw mode support
492  // ---------------------------------------------------------------------- //
493  // Determine whether to assign a draw mode adapter to the given prim.
494  bool _IsDrawModeApplied(UsdPrim const& prim);
495  // Get the inherited model:drawMode attribute of the given prim.
496  TfToken _GetModelDrawMode(UsdPrim const& prim);
497 
498  // ---------------------------------------------------------------------- //
499  // Usd Change Processing / Notice Handlers
500  // ---------------------------------------------------------------------- //
501  void _OnUsdObjectsChanged(UsdNotice::ObjectsChanged const&,
502  UsdStageWeakPtr const& sender);
503 
504  // The lightest-weight update, it does fine-grained invalidation of
505  // individual properties at the given path (prim or property).
506  //
507  // If \p path is a prim path, changedPrimInfoFields will be populated
508  // with the list of scene description fields that caused this prim to
509  // be refreshed.
510  void _RefreshUsdObject(SdfPath const& usdPath,
511  TfTokenVector const& changedPrimInfoFields,
512  UsdImagingIndexProxy* proxy);
513 
514  // Heavy-weight invalidation of an entire prim subtree. All cached data is
515  // reconstructed for all prims below \p rootPath.
516  //
517  // By default, _ResyncPrim will remove each affected prim and call
518  // Repopulate() on those prims individually. If repopulateFromRoot is
519  // true, Repopulate() will be called on \p rootPath instead. This is slower,
520  // but handles changes in tree topology.
521  void _ResyncUsdPrim(SdfPath const& usdRootPath, UsdImagingIndexProxy* proxy,
522  bool repopulateFromRoot = false);
523 
524  // ---------------------------------------------------------------------- //
525  // Usd Data-Access Helper Methods
526  // ---------------------------------------------------------------------- //
527  UsdPrim _GetUsdPrim(SdfPath const& usdPath) {
528  UsdPrim const& p =
529  _stage->GetPrimAtPath(usdPath.GetAbsoluteRootOrPrimPath());
530  TF_VERIFY(p, "No prim found for id: %s",
531  usdPath.GetAbsoluteRootOrPrimPath().GetText());
532  return p;
533  }
534 
535  VtValue _GetUsdPrimAttribute(SdfPath const& cachePath,
536  TfToken const &attrName);
537 
538  void _UpdateSingleValue(SdfPath const& cachePath, int dirtyFlags);
539 
540  // ---------------------------------------------------------------------- //
541  // Cache structures and related methods for population.
542  // ---------------------------------------------------------------------- //
543 
544  // Returns true if this delegate can be populated, false otherwise.
545  bool _CanPopulate(UsdPrim const& rootPrim) const;
546 
547  // Set the delegate's state to reflect that it will be populated from
548  // the given root prim with the given excluded paths.
549  void _SetStateForPopulation(UsdPrim const& rootPrim,
550  SdfPathVector const& excludedPaths,
551  SdfPathVector const& invisedPaths);
552 
553  // Populates this delegate's render index from the paths specified
554  // in the given index proxy.
555  void _Populate(class UsdImagingIndexProxy* proxy);
556 
557  // Execute all variability update tasks that have been added to the given
558  // worker.
559  static void _ExecuteWorkForVariabilityUpdate(_Worker* worker);
560 
564  bool _GetVisible(UsdPrim const& prim);
565 
567  TfTokenVector _GetPrimvarNames(SdfPath const& usdPath,
568  TfToken const& interpolation);
569 
570  // ---------------------------------------------------------------------- //
571  // Helper methods for updating the delegate on time changes
572  // ---------------------------------------------------------------------- //
573 
574  // Execute all time update tasks that have been added to the given worker.
575  static void _ExecuteWorkForTimeUpdate(_Worker* worker);
576 
577  // ---------------------------------------------------------------------- //
578  // Core Delegate state
579  // ---------------------------------------------------------------------- //
580 
581  // Usd Prim Type to Adapter lookup table.
582  typedef TfHashMap<TfToken, UsdImagingPrimAdapterSharedPtr,
583  TfToken::HashFunctor> _AdapterMap;
584  _AdapterMap _adapterMap;
585 
586  // Per-Hydra-Primitive tracking data
587  struct _HdPrimInfo {
588  UsdImagingPrimAdapterSharedPtr adapter; // The adapter to use for the
589  // prim
590  UsdPrim usdPrim; // Reference to the Usd prim
591  HdDirtyBits timeVaryingBits; // Dirty Bits to set when
592  // time changes
593  HdDirtyBits dirtyBits; // Current dirty state of the prim.
594  SdfPathVector extraDependencies;// Dependencies that aren't usdPrim.
595  };
596 
597  typedef TfHashMap<SdfPath, _HdPrimInfo, SdfPath::Hash> _HdPrimInfoMap;
598 
599  // Map from cache path to Hydra prim info
600  _HdPrimInfoMap _hdPrimInfoMap;
601 
602  typedef std::multimap<SdfPath, SdfPath> _DependencyMap;
603 
604  // Map from USD path to Hydra path, for tracking USD->hydra dependencies.
605  _DependencyMap _dependencyInfo;
606 
607  void _GatherDependencies(SdfPath const& subtree,
608  SdfPathVector *affectedCachePaths,
609  SdfPathVector *affectedUsdPaths = nullptr);
610 
611  // SdfPath::ReplacePrefix() is used frequently to convert between
612  // cache path and Hydra render index path and is a performance bottleneck.
613  // These maps pre-computes these conversion.
614  typedef TfHashMap<SdfPath, SdfPath, SdfPath::Hash> SdfPathMap;
615  SdfPathMap _cache2indexPath;
616  SdfPathMap _index2cachePath;
617 
618  // Only use this method when we think no existing adapter has been
619  // established. For example, during initial Population.
620  UsdImagingPrimAdapterSharedPtr const& _AdapterLookup(
621  UsdPrim const& prim,
622  bool ignoreInstancing = false);
623  UsdImagingPrimAdapterSharedPtr const& _AdapterLookup(
624  TfToken const& adapterKey);
625 
626  // Obtain the prim tracking data for the given cache path.
627  _HdPrimInfo *_GetHdPrimInfo(const SdfPath &cachePath);
628 
629  Usd_PrimFlagsConjunction _GetDisplayPredicate() const;
630 
631 
632  typedef TfHashSet<SdfPath, SdfPath::Hash> _InstancerSet;
633 
634  // Set of cache paths representing instancers
635  _InstancerSet _instancerPrimCachePaths;
636 
638  typedef TfHashMap<SdfPath, int, SdfPath::Hash> _RefineLevelMap;
640  _RefineLevelMap _refineLevelMap;
641 
643  UsdImagingValueCache _valueCache;
644 
646  UsdStageRefPtr _stage;
647  SdfPath _rootPrimPath;
648  SdfPathVector _excludedPrimPaths;
649  SdfPathVector _invisedPrimPaths;
650 
651  RigidXformOverridesMap _rigidXformOverrides;
652 
653  // Aspects of the delegate root that apply to all items in the index.
654  SdfPath _compensationPath;
655 
656  GfMatrix4d _rootXf;
657  bool _rootIsVisible;
658 
660  UsdTimeCode _time;
661 
663  SdfPath _cameraPathForSampling;
664 
665  int _refineLevelFallback;
666  HdReprSelector _reprFallback;
667  HdCullStyle _cullStyleFallback;
668 
669  // Change processing
670  TfNotice::Key _objectsChangedNoticeKey;
671  SdfPathVector _usdPathsToResync;
672 
673  // Map from path of Usd object to update to list of changed scene
674  // description fields for that object. This list of fields is only
675  // populated for prim paths.
676  typedef std::unordered_map<SdfPath, TfTokenVector, SdfPath::Hash>
677  _PathsToUpdateMap;
678  _PathsToUpdateMap _usdPathsToUpdate;
679 
680  UsdImaging_XformCache _xformCache;
681  UsdImaging_MaterialBindingImplData _materialBindingImplData;
682  UsdImaging_MaterialBindingCache _materialBindingCache;
683  UsdImaging_CoordSysBindingImplData _coordSysBindingImplData;
684  UsdImaging_CoordSysBindingCache _coordSysBindingCache;
685  UsdImaging_VisCache _visCache;
686  UsdImaging_PurposeCache _purposeCache;
687  UsdImaging_DrawModeCache _drawModeCache;
688  UsdImaging_CollectionCache _collectionCache;
689  UsdImaging_InheritedPrimvarCache _inheritedPrimvarCache;
690 
691  // Pickability
692  PickabilityMap _pickablesMap;
693 
694  // Display guides rendering
695  bool _displayGuides;
696  bool _enableUsdDrawModes;
697 
698  const bool _hasDrawModeAdapter;
699 
701  bool _sceneMaterialsEnabled;
702 
703  CameraUtilConformWindowPolicy _appWindowPolicy;
704 
705  // Enable HdCoordSys tracking
706  const bool _coordSysEnabled;
707 
708  // Display unloaded prims with Bounds adapter
709  bool _displayUnloadedPrimsWithBounds;
710 
711  UsdImagingDelegate() = delete;
712  UsdImagingDelegate(UsdImagingDelegate const &) = delete;
713  UsdImagingDelegate &operator =(UsdImagingDelegate const &) = delete;
714 };
715 
716 PXR_NAMESPACE_CLOSE_SCOPE
717 
718 #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:121
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:443
static constexpr int ALL_INSTANCES
Populate HdxSelection for given path (root) and instanceIndex.
Definition: delegate.h:461
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:78
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 SdfPath GetScenePrimPath(SdfPath const &rprimId, int instanceIndex) override
Returns the scene address of the prim corresponding to the given rprim/instance index.
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:54
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
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:55
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:66
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:431
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.
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:215
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.
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.
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:66
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.
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:87
bool IsEmpty() const noexcept
Returns true if this is the empty path (SdfPath::EmptyPath()).
Definition: path.h:413
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:174
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.
USDIMAGING_API void SetRefineLevel(SdfPath const &usdPath, int level)
Sets an explicit refinement level for the given USD prim.