Loading...
Searching...
No Matches
primTypePruningSceneIndex.h
1//
2// Copyright 2023 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#ifndef PXR_IMAGING_HDSI_PRIM_TYPE_PRUNING_SCENE_INDEX_H
24#define PXR_IMAGING_HDSI_PRIM_TYPE_PRUNING_SCENE_INDEX_H
25
26#include "pxr/pxr.h"
27
28#include "pxr/imaging/hd/filteringSceneIndex.h"
29#include "pxr/imaging/hdsi/api.h"
30#include "pxr/usd/sdf/pathTable.h"
31
32PXR_NAMESPACE_OPEN_SCOPE
33
34#define HDSI_PRIM_TYPE_PRUNING_SCENE_INDEX_TOKENS \
35 (primTypes) \
36 (bindingToken) \
37 (doNotPruneNonPrimPaths)
38
39TF_DECLARE_PUBLIC_TOKENS(HdsiPrimTypePruningSceneIndexTokens, HDSI_API,
40 HDSI_PRIM_TYPE_PRUNING_SCENE_INDEX_TOKENS);
41
43
64{
65public:
66 HDSI_API
67 static HdsiPrimTypePruningSceneIndexRefPtr
68 New(HdSceneIndexBaseRefPtr const &inputSceneIndex,
69 HdContainerDataSourceHandle const &inputArgs);
70
72 HDSI_API
73 bool GetEnabled() const;
75 HDSI_API
76 void SetEnabled(bool);
77
78public: // HdSceneIndex overrides
79 HDSI_API
80 HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
81 HDSI_API
82 SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
83
84 const TfToken &GetBindingToken() const { return _bindingToken; }
85
86protected: // HdSingleInputFilteringSceneIndexBase overrides
87 HDSI_API
88 void _PrimsAdded(
89 const HdSceneIndexBase &sender,
90 const HdSceneIndexObserver::AddedPrimEntries &entries) override;
91 HDSI_API
92 void _PrimsRemoved(
93 const HdSceneIndexBase &sender,
94 const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
95 HDSI_API
96 void _PrimsDirtied(
97 const HdSceneIndexBase &sender,
98 const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
99
100protected:
101 HDSI_API
103 HdSceneIndexBaseRefPtr const &inputSceneIndex,
104 HdContainerDataSourceHandle const &inputArgs);
105 HDSI_API
107
108private:
109 // Should prim be pruned based on its type?
110 bool _PruneType(const TfToken &primType) const;
111 // Should prim be pruned based on its path?
112 bool _PrunePath(const SdfPath &path) const;
113
114 const TfTokenVector _primTypes;
115 const TfToken _bindingToken;
116 const bool _doNotPruneNonPrimPaths;
117
118 // Track pruned prims in a SdfPathTable. A value of true
119 // indicates a prim was filtered at that path.
120 using _PruneMap = SdfPathTable<bool>;
121 _PruneMap _pruneMap;
122
123 bool _enabled;
124};
125
126PXR_NAMESPACE_CLOSE_SCOPE
127
128#endif
Abstract interface to scene data.
Definition: sceneIndex.h:65
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) for the object at primPath.
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:290
A mapping from SdfPath to MappedType, somewhat similar to map<SdfPath, MappedType> and TfHashMap<SdfP...
Definition: pathTable.h:83
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:98
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:52
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457