Loading...
Searching...
No Matches
backPlateSceneIndex.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_IMAGING_HDSI_BACK_PLATE_SCENE_INDEX_H
8#define PXR_IMAGING_HDSI_BACK_PLATE_SCENE_INDEX_H
9
10#include "pxr/imaging/hdsi/api.h"
11#include "pxr/imaging/hd/sceneIndex.h"
14#include "pxr/imaging/hd/filteringSceneIndex.h"
15
16#include <unordered_set>
17
18PXR_NAMESPACE_OPEN_SCOPE
19
21
30{
31public:
32 HDSI_API
33 HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override final;
34
35 HDSI_API
36 SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override final;
37
38protected:
39 HDSI_API
40 virtual HdContainerDataSourceHandle
41 _BuildMeshPrimDataSource(
42 const SdfPath &platePath,
43 const TfToken &instanceName,
44 const HdContainerDataSourceHandle &primDataSource) const = 0;
45
46 HDSI_API
47 virtual HdContainerDataSourceHandle
48 _BuildMaterialDataSource(
49 const TfToken &instanceName,
50 const HdContainerDataSourceHandle &primDataSource) const = 0;
51
52 HDSI_API
54 _GetAdditionalDirtyLocators() const;
55
56 HDSI_API
57 void _PrimsAdded(
58 const HdSceneIndexBase &sender,
59 const HdSceneIndexObserver::AddedPrimEntries &entries) override final;
60
61 HDSI_API
62 void _PrimsRemoved(
63 const HdSceneIndexBase &sender,
64 const HdSceneIndexObserver::RemovedPrimEntries &entries) override final;
65
66 HDSI_API
67 void _PrimsDirtied(
68 const HdSceneIndexBase &sender,
69 const HdSceneIndexObserver::DirtiedPrimEntries &entries) override final;
70
71 static HdBackPlateSchema
72 _GetBackPlateSchema(TfToken const &instanceName,
73 HdContainerDataSourceHandle const &primDataSource)
74 {
75 HdCameraSchema cam = HdCameraSchema::GetFromParent(primDataSource);
76 HdBackPlateSchema backplate = cam.GetBackPlate().Get(instanceName);
77 return backplate;
78 }
79
80 template <typename DataSourceHandle, typename T>
81 static bool
82 _GetDefaultTypedValue(const DataSourceHandle &dataSource,
83 HdSampledDataSource::Time const shutterOffset,
84 T* result)
85 {
86 if (!dataSource || !result) {
87 return false;
88 }
89 *result = dataSource->GetTypedValue(shutterOffset);
90 return true;
91 }
92
93 HDSI_API
94 static GfVec2f
95 _ComputeEffectiveDimensions(
96 TfToken const &instanceName,
97 HdContainerDataSourceHandle const &primDataSource,
98 HdSampledDataSource::Time const shutterOffset) ;
99
100 HDSI_API
101 static GfMatrix4d
102 _ComputeLocalXform(HdContainerDataSourceHandle const &primDataSource,
103 TfToken const &instanceName,
104 HdSampledDataSource::Time const shutterOffset);
105
106 HDSI_API
108 const HdSceneIndexBaseRefPtr &inputSceneIndex);
109
110private:
111 void
112 _RemoveBackPlateChildren(
113 const SdfPath &primPath,
114 SdfPathSet * const removedBackPlatePrims);
115 void
116 _AddBackPlateChildren(
117 const SdfPath &primPath,
118 SdfPathSet * const addedBackPlatePrims);
119 void
120 _DirtyBackPlateChildren(
121 const SdfPath &primPath,
123 dirtiedBackPlatePrims);
124
126 _GetMeshOrMaterialSiPrim(
127 const SdfPath &plateInstancePath,
128 const TfToken &plateChildType) const;
129
130 bool
131 _IsBackPlateInMap(
132 const SdfPath &platePath) const;
133
134 bool
135 _HasTrackedBackPlates() const;
136
137 using _BackPlates = std::unordered_set<TfToken,TfToken::HashFunctor>;
138 using _CameraToBackPlatesMap = std::map<SdfPath, _BackPlates>;
139
140 // Maps the camera prim path to all the names of the back plate instances
141 // associated with it.
142 _CameraToBackPlatesMap _cameraToBackPlates;
143};
144
145PXR_NAMESPACE_CLOSE_SCOPE
146
147#endif //PXR_IMAGING_HDSI_BACK_PLATE_SCENE_INDEX_H
Stores a 4x4 matrix of double elements.
Definition matrix4d.h:71
Basic type for a vector of 2 float components.
Definition vec2f.h:46
The HdBackPlateSchema specifies a container that will hold "back plate" data.
Represents a set of data source locators closed under descendancy.
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.
The back plate scene index converts back plate prims into mesh and material prims that align with the...
HDSI_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override final
Returns a pair of (prim type, datasource).
HDSI_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override final
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
Token for efficient comparison, assignment, and hashing of known strings.
Definition token.h:81
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition declarePtrs.h:72
Small struct representing a 'prim' in the Hydra scene index.
Definition sceneIndex.h:36