Loading...
Searching...
No Matches
purposeFilteringSceneIndex.h
1//
2// Copyright 2026 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_PURPOSE_FILTERING_SCENE_INDEX_H
7#define PXR_IMAGING_HDSI_PURPOSE_FILTERING_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#include "pxr/base/tf/token.h"
15#include "pxr/base/vt/array.h"
16
17#include <optional>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21#define HDSI_PURPOSE_FILTERING_SCENE_INDEX_TOKENS \
22 (purposes)
23
24TF_DECLARE_PUBLIC_TOKENS(HdsiPurposeFilteringSceneIndexTokens, HDSI_API,
25 HDSI_PURPOSE_FILTERING_SCENE_INDEX_TOKENS);
26
28
93{
94public:
102 HDSI_API
103 static HdsiPurposeFilteringSceneIndexRefPtr
104 New(HdSceneIndexBaseRefPtr const &inputSceneIndex,
105 HdContainerDataSourceHandle const &inputArgs);
106
111 HDSI_API
112 void SetPurposes(VtArray<TfToken> const &purposes);
113
114 HDSI_API
115 VtArray<TfToken> const &GetPurposes() const;
116
117public: // HdSceneIndex overrides
118 HDSI_API
119 HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
120 HDSI_API
121 SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
122
123protected: // HdSingleInputFilteringSceneIndexBase overrides
124 HDSI_API
125 void _PrimsAdded(
126 const HdSceneIndexBase &sender,
127 const HdSceneIndexObserver::AddedPrimEntries &entries) override;
128 HDSI_API
129 void _PrimsRemoved(
130 const HdSceneIndexBase &sender,
131 const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
132 HDSI_API
133 void _PrimsDirtied(
134 const HdSceneIndexBase &sender,
135 const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
136
137protected:
138 HDSI_API
140 HdSceneIndexBaseRefPtr const &inputSceneIndex,
141 HdContainerDataSourceHandle const &inputArgs);
142 HDSI_API
144
145private:
146 bool _IsFilteringActive() const;
147
148 // Returns true if the prim represented by dataSource should be pruned
149 // based on the current state (_purposes or _excludedPurposesHint).
150 bool _ShouldPrune(const HdContainerDataSourceHandle &dataSource) const;
151
152 // nullopt = hint mode (purposes not provided at c'tor time and SetPurposes
153 // has not been called).
154 // [] = explicit empty = no filtering.
155 // [...] = explicit accepted-purpose filter.
156 std::optional<VtArray<TfToken>> _purposes;
157
158 // Purposes that should be pruned while in hint mode (nullopt _purposes).
159 VtArray<TfToken> _excludedPurposesHint;
160};
161
162PXR_NAMESPACE_CLOSE_SCOPE
163
164#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 whose resolved (flattened) purpose is not in the configured set of acce...
HDSI_API void SetPurposes(VtArray< TfToken > const &purposes)
Switch to explicit (accept-list) mode and set the accepted purposes.
HDSI_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Returns a pair of (prim type, datasource).
static HDSI_API HdsiPurposeFilteringSceneIndexRefPtr New(HdSceneIndexBaseRefPtr const &inputSceneIndex, HdContainerDataSourceHandle const &inputArgs)
The fields in inputArgs that this scene index consumes are:
HDSI_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.
A path value used to locate objects in layers or scenegraphs.
Definition path.h:281
Represents an arbitrary dimensional rectangular container class.
Definition array.h:213
#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
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...