rerootingSceneIndex.h
1 //
2 // Copyright 2022 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_IMAGING_USD_IMAGING_REROOTING_SCENE_INDEX_H
8 #define PXR_USD_IMAGING_USD_IMAGING_REROOTING_SCENE_INDEX_H
9 
10 #include "pxr/usdImaging/usdImaging/api.h"
11 #include "pxr/imaging/hd/filteringSceneIndex.h"
12 #include "pxr/usd/pcp/mapFunction.h"
13 #include "pxr/usd/sdf/pathTable.h"
14 #include <variant>
15 
16 PXR_NAMESPACE_OPEN_SCOPE
17 
19 
36 {
37 public:
39  static UsdImagingRerootingSceneIndexRefPtr New(
40  HdSceneIndexBaseRefPtr const &inputScene,
41  const SdfPath &srcPrefix,
42  const SdfPath &dstPrefix)
43  {
44  const PcpMapFunction mapFn =
46  {{srcPrefix, dstPrefix}}, SdfLayerOffset());
47  return TfCreateRefPtr(
48  new UsdImagingRerootingSceneIndex(inputScene, mapFn));
49  }
50 
51  static UsdImagingRerootingSceneIndexRefPtr New(
52  HdSceneIndexBaseRefPtr const &inputScene,
53  PcpMapFunction const& mapFn)
54  {
55  return TfCreateRefPtr(
56  new UsdImagingRerootingSceneIndex(inputScene, mapFn));
57  }
58 
59  USDIMAGING_API
60  HdSceneIndexPrim GetPrim(const SdfPath& primPath) const override;
61 
62  USDIMAGING_API
63  SdfPathVector GetChildPrimPaths(const SdfPath& primPath) const override;
64 
65 protected:
66  USDIMAGING_API
68  HdSceneIndexBaseRefPtr const &inputScene,
69  PcpMapFunction const& mapFn);
70 
71  USDIMAGING_API
73 
74  // satisfying HdSingleInputFilteringSceneIndexBase
75  void _PrimsAdded(
76  const HdSceneIndexBase& sender,
77  const HdSceneIndexObserver::AddedPrimEntries& entries) override;
78 
79  void _PrimsRemoved(
80  const HdSceneIndexBase& sender,
81  const HdSceneIndexObserver::RemovedPrimEntries& entries) override;
82 
83  void _PrimsDirtied(
84  const HdSceneIndexBase& sender,
85  const HdSceneIndexObserver::DirtiedPrimEntries& entries) override;
86 
87 private:
88  const PcpMapFunction _mapFn;
89  SdfPathTable<std::monostate> _targetRootPathsTable;
90 };
91 
92 PXR_NAMESPACE_CLOSE_SCOPE
93 
94 #endif
An abstract base class for a filtering scene index that observes a single input scene index.
USDIMAGING_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.
static UsdImagingRerootingSceneIndexRefPtr New(HdSceneIndexBaseRefPtr const &inputScene, const SdfPath &srcPrefix, const SdfPath &dstPrefix)
A convenience method that maps between two provided paths.
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:35
USDIMAGING_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Returns a pair of (prim type, datasource).
Abstract interface to scene data.
Definition: sceneIndex.h:54
A function that maps values from one namespace (and time domain) to another.
Definition: mapFunction.h:64
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:58
Represents a time offset and scale between layers.
Definition: layerOffset.h:43
Applies a bijective namespace mapping, as represented by a PcpMapFunction, to the input namespace.
static PCP_API PcpMapFunction Create(const PathMap &sourceToTargetMap, const SdfLayerOffset &offset)
Constructs a map function with the given arguments.