prefixPathPruningSceneIndex.h
1 //
2 // Copyright 2025 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 #ifndef PXR_IMAGING_HDSI_PREFIX_PATH_PRUNING_SCENE_INDEX_H
7 #define PXR_IMAGING_HDSI_PREFIX_PATH_PRUNING_SCENE_INDEX_H
8 
9 #include "pxr/pxr.h"
10 
11 #include "pxr/imaging/hd/filteringSceneIndex.h"
12 #include "pxr/imaging/hdsi/api.h"
13 
14 PXR_NAMESPACE_OPEN_SCOPE
15 
16 #define HDSI_PREFIX_PATH_PRUNING_SCENE_INDEX_TOKENS \
17  (excludePathPrefixes)
18 
19 TF_DECLARE_PUBLIC_TOKENS(HdsiPrefixPathPruningSceneIndexTokens, HDSI_API,
20  HDSI_PREFIX_PATH_PRUNING_SCENE_INDEX_TOKENS);
21 
23 
47 {
48 public:
49  HDSI_API
50  static HdsiPrefixPathPruningSceneIndexRefPtr
51  New(HdSceneIndexBaseRefPtr const &inputSceneIndex,
52  HdContainerDataSourceHandle const &inputArgs);
53 
54 public:
55  // HdSceneIndex overrides
56  HDSI_API
57  HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
58  HDSI_API
59  SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
60 
61  // Public API
62  HDSI_API
63  void SetExcludePathPrefixes(SdfPathVector paths);
64 
65 protected:
66  // HdSingleInputFilteringSceneIndexBase overrides
67  HDSI_API
68  void _PrimsAdded(
69  const HdSceneIndexBase &sender,
70  const HdSceneIndexObserver::AddedPrimEntries &entries) override;
71  HDSI_API
72  void _PrimsRemoved(
73  const HdSceneIndexBase &sender,
74  const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
75  HDSI_API
76  void _PrimsDirtied(
77  const HdSceneIndexBase &sender,
78  const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
79 
80 private:
81  HDSI_API
83  HdSceneIndexBaseRefPtr const &inputSceneIndex,
84  HdContainerDataSourceHandle const &inputArgs);
85  HDSI_API
87 
88  bool _IsPruned(const SdfPath &primPath) const;
89 
90  void _RemovePrunedChildren(SdfPathVector *childPaths) const;
91 
92  SdfPathVector _sortedExcludePaths;
93  SdfPathSet _excludePathPrefixes;
94 };
95 
96 PXR_NAMESPACE_CLOSE_SCOPE
97 
98 #endif
An abstract base class for a filtering scene index that observes a single input scene index.
A scene index that prunes prims at or below the list of provided prefix paths.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:72
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:35
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:92
Abstract interface to scene data.
Definition: sceneIndex.h:54
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
HDSI_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.
HDSI_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Returns a pair of (prim type, datasource).