HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sceneGlobalsSceneIndex.h
Go to the documentation of this file.
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 //
7 #ifndef PXR_IMAGING_HDSI_SCENE_GLOBALS_SCENE_INDEX_H
8 #define PXR_IMAGING_HDSI_SCENE_GLOBALS_SCENE_INDEX_H
9 
10 #include "pxr/imaging/hdsi/api.h"
11 
13 #include "pxr/usd/sdf/path.h"
14 #include <optional>
15 
17 
19 
20 // undefined -> 2 : Make SGSI a filtering scene index.
21 #define HDSI_SGSI_API_VERSION 2
22 
23 /// \class HdsiSceneGlobalsSceneIndex
24 ///
25 /// Scene index that populates the "sceneGlobals" data source as modeled
26 /// by HdSceneGlobalsSchema and provides public API to mutate it.
27 /// This provides a way for applications to control high-level scene behavior.
28 ///
30 {
31 public:
32  HDSI_API
33  static HdsiSceneGlobalsSceneIndexRefPtr
34  New(const HdSceneIndexBaseRefPtr &inputSceneIndex);
35 
36  // ------------------------------------------------------------------------
37  // Public (non-virtual) API
38  // ------------------------------------------------------------------------
39 
40  /// Caches the provided path and notifies any observers when the active
41  /// render pass prim path is modified.
42  ///
43  HDSI_API
45 
46  /// Caches the provided path and notifies any observers when the active
47  /// render settings prim path is modified.
48  ///
49  HDSI_API
51 
52  /// Set the path to use as the primaryCameraPrim in the scene
53  /// globals schema.
54  HDSI_API
55  void SetPrimaryCameraPrimPath(const SdfPath &);
56 
57  /// Set the frame number to use the as the currentFrame in the
58  /// scene globals schema.
59  HDSI_API
60  void SetCurrentFrame(double);
61 
62  /// Set the timeCodesPerSecond to use the as the currentFrame in the
63  /// scene globals schema.
64  HDSI_API
65  void SetTimeCodesPerSecond(double);
66 
67  /// Injects an arbitrary value that identifies the state of the input scene
68  /// at that point in time. This value ends up in the render index scene
69  /// globals once that state is processed by Hydra. This is useful for the
70  /// client to identify when certain scene edits have been processed by
71  /// Hydra.
72  HDSI_API
73  void SetSceneStateId(int);
74 
75  // ------------------------------------------------------------------------
76  // Satisfying HdSceneIndexBase
77  // ------------------------------------------------------------------------
78  HDSI_API
80  GetPrim(const SdfPath &primPath) const override final;
81 
82  HDSI_API
84  GetChildPrimPaths(const SdfPath &primPath) const override final;
85 
86 protected:
87  HDSI_API
88  HdsiSceneGlobalsSceneIndex(const HdSceneIndexBaseRefPtr &inputSceneIndex);
89 
90  // ------------------------------------------------------------------------
91  // Satisfying HdSingleInputFilteringSceneIndexBase
92  // ------------------------------------------------------------------------
93  HDSI_API
94  void _PrimsAdded(
95  const HdSceneIndexBase &sender,
96  const HdSceneIndexObserver::AddedPrimEntries &entries) override;
97 
98  HDSI_API
99  void _PrimsRemoved(
100  const HdSceneIndexBase &sender,
101  const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
102 
103  HDSI_API
104  void _PrimsDirtied(
105  const HdSceneIndexBase &sender,
106  const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
107 
108 private:
110 
111  SdfPath _activeRenderPassPrimPath;
112  std::optional<SdfPath> _activeRenderSettingsPrimPath;
113  std::optional<SdfPath> _primaryCameraPrimPath;
114  double _time = std::numeric_limits<double>::quiet_NaN();
115  double _timeCodesPerSecond = 24.0;
116  int _sceneStateId = 0;
117 };
118 
120 
121 #endif //PXR_IMAGING_HDSI_SCENE_GLOBALS_SCENE_INDEX_H
HDSI_API void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
HDSI_API void SetPrimaryCameraPrimPath(const SdfPath &)
HDSI_API void SetCurrentFrame(double)
std::vector< class SdfPath > SdfPathVector
HDSI_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const overridefinal
Definition: path.h:273
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_AND_REF_PTRS(HdsiSceneGlobalsSceneIndex)
#define HDSI_API
Definition: api.h:23
HDSI_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const overridefinal
HDSI_API HdsiSceneGlobalsSceneIndex(const HdSceneIndexBaseRefPtr &inputSceneIndex)
HDSI_API void SetActiveRenderPassPrimPath(const SdfPath &)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HDSI_API void SetActiveRenderSettingsPrimPath(const SdfPath &)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HDSI_API void SetTimeCodesPerSecond(double)
HDSI_API void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
HDSI_API void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries) override
static HDSI_API HdsiSceneGlobalsSceneIndexRefPtr New(const HdSceneIndexBaseRefPtr &inputSceneIndex)
HDSI_API void SetSceneStateId(int)