Loading...
Searching...
No Matches
unboundMaterialPruningSceneIndex.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_UNBOUND_MATERIAL_PRUNING_SCENE_INDEX_H
7#define PXR_IMAGING_HDSI_UNBOUND_MATERIAL_PRUNING_SCENE_INDEX_H
8
9#include "pxr/pxr.h"
10
11#include "pxr/imaging/hdsi/api.h"
12#include "pxr/imaging/hd/filteringSceneIndex.h"
13
15#include "pxr/usd/sdf/path.h"
16#include "pxr/base/vt/array.h"
17
18#include <unordered_set>
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22#define HDSI_UNBOUND_MATERIAL_PRUNING_SCENE_INDEX_TOKENS \
23 (materialBindingPurposes)
24
25TF_DECLARE_PUBLIC_TOKENS(HdsiUnboundMaterialPruningSceneIndexTokens, HDSI_API,
26 HDSI_UNBOUND_MATERIAL_PRUNING_SCENE_INDEX_TOKENS);
27
29
43{
44public:
45 HDSI_API
46 static HdsiUnboundMaterialPruningSceneIndexRefPtr
47 New(HdSceneIndexBaseRefPtr const &inputSceneIndex,
48 HdContainerDataSourceHandle const &inputArgs);
49
50public: // HdSceneIndex overrides
51 HDSI_API
52 HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
53 HDSI_API
54 SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
55
56protected: // HdSingleInputFilteringSceneIndexBase overrides
57 HDSI_API
58 void _PrimsAdded(
59 const HdSceneIndexBase &sender,
60 const HdSceneIndexObserver::AddedPrimEntries &entries) override;
61 HDSI_API
62 void _PrimsRemoved(
63 const HdSceneIndexBase &sender,
64 const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
65 HDSI_API
66 void _PrimsDirtied(
67 const HdSceneIndexBase &sender,
68 const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
69
70private:
71 HDSI_API
73 HdSceneIndexBaseRefPtr const &inputSceneIndex,
74 HdContainerDataSourceHandle const &inputArgs);
75 HDSI_API
77
78 // Traverse input scene to update internal tracking and
79 // discover and invalidate unbound materials.
80 void _PopulateFromInputSceneIndex();
81
82 bool _IsBoundMaterial(const SdfPath &materialPath) const;
83 bool _WasAdded(const SdfPath &materialPath) const;
84
85 const VtArray<TfToken> _bindingPurposes;
86 const HdDataSourceLocatorSet _bindingLocators;
87 std::unordered_set<SdfPath, SdfPath::Hash> _boundMaterialPaths;
88 std::unordered_set<SdfPath, SdfPath::Hash> _addedMaterialPaths;
89};
90
91PXR_NAMESPACE_CLOSE_SCOPE
92
93#endif
Represents a set of data source locators closed under descendancy.
Abstract interface to scene data.
Definition: sceneIndex.h:54
An abstract base class for a filtering scene index that observes a single input scene index.
A scene index that prunes material prims that are not bound.
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.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:213
Standard pointer typedefs.
#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.
Definition: staticTokens.h:92
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:35