Loading...
Searching...
No Matches
sceneIndex.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//
7#ifndef PXR_USD_IMAGING_USD_IMAGING_SCENE_INDEX_H
8#define PXR_USD_IMAGING_USD_IMAGING_SCENE_INDEX_H
9
10#include "pxr/pxr.h"
11
12#include "pxr/usd/usd/timeCode.h"
13
14#include "pxr/usdImaging/usdImaging/api.h"
15
16#include "pxr/imaging/hd/filteringSceneIndex.h"
17#include "pxr/imaging/hd/sceneIndex.h"
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21using UsdImagingSceneIndexAppendCallback =
22 std::function<
23 HdSceneIndexBaseRefPtr(HdSceneIndexBaseRefPtr const &)>;
24
26TF_DECLARE_REF_PTRS(HdNoticeBatchingSceneIndex);
31
38{
39public:
48 static UsdImagingSceneIndexRefPtr New(
49 HdContainerDataSourceHandle const &inputArgs,
50 const UsdImagingSceneIndexAppendCallback &
51 overridesSceneIndexCallback) {
52 return TfCreateRefPtr(
54 inputArgs, overridesSceneIndexCallback));
55 }
56
57 USDIMAGING_API
59
60 // ------------------------------------------------------------------------
61 // (Encapsulating) Scene index API
62
63 USDIMAGING_API
64 HdSceneIndexPrim GetPrim(const SdfPath & primPath) const override;
65
66 USDIMAGING_API
67 SdfPathVector GetChildPrimPaths(const SdfPath & primPath) const override;
68
69 USDIMAGING_API
70 HdSceneIndexBaseRefPtrVector GetEncapsulatedScenes() const override;
71
72 // ------------------------------------------------------------------------
73 // App-facing API
74
75 // Set the USD stage to pull data from. Note that this will delete all
76 // scene index prims and reset stage global data.
77 USDIMAGING_API
78 void SetStage(UsdStageRefPtr stage);
79
80 // Set the time, and call PrimsDirtied for any time-varying attributes.
81 //
82 // PrimsDirtied is only called if the time is different from the last call
83 // or forceDirtyingTimeDeps is true.
84 USDIMAGING_API
85 void SetTime(UsdTimeCode time, bool forceDirtyingTimeDeps = false);
86
87 // Return the current time.
88 USDIMAGING_API
89 UsdTimeCode GetTime() const;
90
91 // Apply queued stage edits to imaging scene.
92 // If the USD stage is edited while the scene index is pulling from it,
93 // those edits get queued and deferred. Calling ApplyPendingUpdates will
94 // turn resync requests into PrimsAdded/PrimsRemoved, and property changes
95 // into PrimsDirtied.
96 USDIMAGING_API
97 void ApplyPendingUpdates();
98
103 USDIMAGING_API
104 void AddSelection(const SdfPath &path);
105
107 USDIMAGING_API
109
111 const HdNoticeBatchingSceneIndexRefPtr &
113 return _postInstancingNoticeBatchingSceneIndex;
114 }
115
116private:
117 class _Observer : public HdSceneIndexObserver
118 {
119 public:
120 _Observer(UsdImagingSceneIndex *owner)
121 : _owner(owner) {}
122
123 void PrimsAdded(
124 const HdSceneIndexBase &sender,
125 const AddedPrimEntries &entries) override
126 {
127 _owner->_SendPrimsAdded(entries);
128 }
129
130 void PrimsRemoved(
131 const HdSceneIndexBase &sender,
132 const RemovedPrimEntries &entries) override
133 {
134 _owner->_SendPrimsRemoved(entries);
135 }
136
137 void PrimsDirtied(
138 const HdSceneIndexBase &sender,
139 const DirtiedPrimEntries &entries) override
140 {
141 _owner->_SendPrimsDirtied(entries);
142 }
143
144 void PrimsRenamed(
145 const HdSceneIndexBase &sender,
146 const RenamedPrimEntries &entries) override
147 {
148 _owner->_SendPrimsRenamed(entries);
149 }
150 private:
151 UsdImagingSceneIndex * const _owner;
152 };
153
154 USDIMAGING_API
156 HdContainerDataSourceHandle const &inputArgs,
157 const UsdImagingSceneIndexAppendCallback &overridesSceneIndexCallback);
158
159 USDIMAGING_API
161 const UsdImagingSceneIndices &sceneIndices);
162
163 UsdImagingStageSceneIndexRefPtr _stageSceneIndex;
164 HdNoticeBatchingSceneIndexRefPtr _postInstancingNoticeBatchingSceneIndex;
165 UsdImagingSelectionSceneIndexRefPtr _selectionSceneIndex;
166 HdSceneIndexBaseRefPtr _finalSceneIndex;
167
168 _Observer _observer;
169};
170
171PXR_NAMESPACE_CLOSE_SCOPE
172
173#endif
A mix-in class for scene indices that implement their behaviour by creating other scene indices (inte...
Abstract interface to scene data.
Definition: sceneIndex.h:55
Observer of scene data.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:281
A scene index encapsulating the chain of scene indices (resolving, e.g., USD native instancing) that ...
Definition: sceneIndex.h:38
USDIMAGING_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.
USDIMAGING_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Returns a pair of (prim type, datasource).
const HdNoticeBatchingSceneIndexRefPtr & GetPostInstancingNoticeBatchingSceneIndex() const
Can be used to batch notices.
Definition: sceneIndex.h:112
USDIMAGING_API void ClearSelection()
Reset the scene index selection state.
static UsdImagingSceneIndexRefPtr New(HdContainerDataSourceHandle const &inputArgs, const UsdImagingSceneIndexAppendCallback &overridesSceneIndexCallback)
Create the chain of scene indices.
Definition: sceneIndex.h:48
USDIMAGING_API void AddSelection(const SdfPath &path)
Given a path (including usd proxy path inside a native instance) of a USD prim, determine the corresp...
A simple scene index adding HdSelectionsSchema to all prims selected with AddSelection.
A scene index consuming a UsdStage.
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Definition: stage.h:135
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:72
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:58
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:36
Some scene indices in the chain of filtering scene indices created by UsdImagingCreateSceneIndices.
Definition: sceneIndices.h:57