Loading...
Searching...
No Matches
primTypePruningSceneIndex.h
1//
2// Copyright 2023 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_PRIM_TYPE_PRUNING_SCENE_INDEX_H
7#define PXR_IMAGING_HDSI_PRIM_TYPE_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#include "pxr/usd/sdf/pathTable.h"
14
15PXR_NAMESPACE_OPEN_SCOPE
16
17#define HDSI_PRIM_TYPE_PRUNING_SCENE_INDEX_TOKENS \
18 (primTypes) \
19 (bindingToken) \
20 (doNotPruneNonPrimPaths)
21
22TF_DECLARE_PUBLIC_TOKENS(HdsiPrimTypePruningSceneIndexTokens, HDSI_API,
23 HDSI_PRIM_TYPE_PRUNING_SCENE_INDEX_TOKENS);
24
26
50{
51public:
52 HDSI_API
53 static HdsiPrimTypePruningSceneIndexRefPtr
54 New(HdSceneIndexBaseRefPtr const &inputSceneIndex,
55 HdContainerDataSourceHandle const &inputArgs);
56
58 HDSI_API
59 bool GetEnabled() const;
61 HDSI_API
62 void SetEnabled(bool);
63
64public: // HdSceneIndex overrides
65 HDSI_API
66 HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
67 HDSI_API
68 SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
69
70 const TfToken &GetBindingToken() const { return _bindingToken; }
71
72protected: // HdSingleInputFilteringSceneIndexBase overrides
73 HDSI_API
74 void _PrimsAdded(
75 const HdSceneIndexBase &sender,
76 const HdSceneIndexObserver::AddedPrimEntries &entries) override;
77 HDSI_API
78 void _PrimsRemoved(
79 const HdSceneIndexBase &sender,
80 const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
81 HDSI_API
82 void _PrimsDirtied(
83 const HdSceneIndexBase &sender,
84 const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
85
86protected:
87 HDSI_API
89 HdSceneIndexBaseRefPtr const &inputSceneIndex,
90 HdContainerDataSourceHandle const &inputArgs);
91 HDSI_API
93
94private:
95 // Should prim be pruned based on its type?
96 bool _PruneType(const TfToken &primType) const;
97 // Should prim be pruned based on its path?
98 bool _PrunePath(const SdfPath &path) const;
99
100 const TfTokenVector _primTypes;
101 const TfToken _bindingToken;
102 const bool _doNotPruneNonPrimPaths;
103
104 // Track pruned prims in a SdfPathTable. A value of true
105 // indicates a prim was filtered at that path.
106 using _PruneMap = SdfPathTable<bool>;
107 _PruneMap _pruneMap;
108
109 bool _enabled;
110};
111
112PXR_NAMESPACE_CLOSE_SCOPE
113
114#endif
Abstract interface to scene data.
Definition sceneIndex.h:55
An abstract base class for a filtering scene index that observes a single input scene index.
Scene Index that prunes prims of given type (e.g., material) and (optionally) bindings to that prim t...
HDSI_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Returns a pair of (prim type, datasource).
HDSI_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.
HDSI_API bool GetEnabled() const
Is scene index actually prunning?
HDSI_API void SetEnabled(bool)
Enable scene index to prune.
A path value used to locate objects in layers or scenegraphs.
Definition path.h:281
A mapping from SdfPath to MappedType, somewhat similar to map<SdfPath, MappedType> and TfHashMap<SdfP...
Definition pathTable.h:66
Token for efficient comparison, assignment, and hashing of known strings.
Definition token.h:81
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition declarePtrs.h:72
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Small struct representing a 'prim' in the Hydra scene index.
Definition sceneIndex.h:36
std::vector< TfToken > TfTokenVector
Convenience types.
Definition token.h:489