HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pointsResolvingSceneIndex.h
Go to the documentation of this file.
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 //
7 #ifndef PXR_USD_IMAGING_USD_SKEL_IMAGING_POINTS_RESOLVING_SCENE_INDEX_H
8 #define PXR_USD_IMAGING_USD_SKEL_IMAGING_POINTS_RESOLVING_SCENE_INDEX_H
9 
11 
13 
14 #include <optional>
15 
17 
19 
20 /// \class UsdSkelImagingPointsResolvingSceneIndex
21 ///
22 /// Adds ext computations to skin to points of a mesh, point, basisCurves prims.
23 /// It uses the prim from the input scene, the targeted skelBlendShape's as well
24 /// as the resolved skeleton schema from the targeted skeleton.
25 ///
26 /// Thus, this scene index has to run after the
27 /// UsdSkelImagingSkeletonResolvingSceneIndex.
28 ///
31 {
32 public:
34  static
35  UsdSkelImagingPointsResolvingSceneIndexRefPtr
36  New(HdSceneIndexBaseRefPtr const &inputSceneIndex);
37 
39  HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
40 
42  SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
43 
44 protected:
45  void _PrimsAdded(
46  const HdSceneIndexBase&,
47  const HdSceneIndexObserver::AddedPrimEntries &entries) override;
48  void _PrimsDirtied(
49  const HdSceneIndexBase&,
50  const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
51  void _PrimsRemoved(
52  const HdSceneIndexBase&,
53  const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
54 
55 private:
57  HdSceneIndexBaseRefPtr const &inputSceneIndex);
58 
59  // Helper to reconstruct the data source stored for a particular prim
60  // in _pathToResolvedPrim, update dependencies in _skelPathToPrimPaths
61  // and _blendShapePathToPrimPaths and fill in dirty notifications.
62  //
63  // The input are prim paths with an annotation (stored in a map). If the
64  // annotation is true, we do not fill the dirty notifcation for the prim
65  // itself.
66  //
67  void _ProcessPrimsNeedingRefreshAndSendNotices(
68  const std::map<SdfPath, bool> &primsNeedingRefreshToHasAddedEntry,
72 
73  const TfTokenVector &_GetResolvedPrimComputations(
74  const SdfPath &primPath) const;
75 
76  // Helper to process dirtied prim entries.
77  bool _ProcessDirtyLocators(
78  const SdfPath &primPath,
79  const TfToken &dirtiedPrimType,
80  const HdDataSourceLocatorSet &dirtyLocators,
82 
83  using _DsHandle =
84  std::shared_ptr<class UsdSkelImagingDataSourceResolvedPointsBasedPrim>;
85 
86  // Query input scene for prim at path. If that prim is potentially
87  // affected by a skeleton, construct the resolving data source,
88  // store it, update the dependencies.
89  bool _AddResolvedPrim(
90  const SdfPath &path);
91  void _AddDependenciesForResolvedPrim(
92  const SdfPath &primPath,
93  _DsHandle const &resolvedPrim);
94 
95  // Remove from _pathToResolvedPrim and dependencies.
96  bool _RemoveResolvedPrim(
97  const SdfPath &path);
98  void _RemoveDependenciesForResolvedPrim(
99  const SdfPath &primPath,
100  _DsHandle const &resolvedPrim);
101 
102  // Refetch data source from input scene and refresh resolved data source in
103  // _pathToResolvedPrim. This does not update the dependencies.
104  //
105  // Call this if refetching the data source is necessary, but the paths to
106  // the skeleton and blend shapes have not changed.
107  void _RefreshResolvedPrimDataSource(
108  const SdfPath &primPath,
109  bool * hasExtComputations);
110  // Refetch data source as above - filling the dirty notications.
111  void _RefreshResolvedPrimDataSources(
112  const SdfPathSet &primPaths,
114  SdfPathSet * addedResolvedPrimsWithComputations,
115  SdfPathSet * removedResolvedPrimsWithComputations);
116 
117  // For each mesh, point, basisCurve in the input scene that has a bound
118  // skeleton (even if the prim at the targeted path is not a Skeleton or
119  // empty), store the resolved data source.
120  //
121  // This scene index overlays it with the input data source.
122  //
123  std::map<SdfPath, _DsHandle> _pathToResolvedPrim;
124 
125  // Path of a skeleton to paths of resolved prim's depending on that
126  // skeleton.
127  std::map<SdfPath, SdfPathSet> _skelPathToPrimPaths;
128  // Same for blend shapes.
129  std::map<SdfPath, SdfPathSet> _blendShapePathToPrimPaths;
130  // Instancer to prims that it instances, that are in a prototype with
131  // skelBinding:hasSkelRoot and that are posed by a skeleton.
132  std::map<SdfPath, SdfPathSet> _instancerPathToPrimPaths;
133 };
134 
136 
137 #endif
void _PrimsAdded(const HdSceneIndexBase &, const HdSceneIndexObserver::AddedPrimEntries &entries) override
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
void _PrimsRemoved(const HdSceneIndexBase &, const HdSceneIndexObserver::RemovedPrimEntries &entries) override
static USDSKELIMAGING_API UsdSkelImagingPointsResolvingSceneIndexRefPtr New(HdSceneIndexBaseRefPtr const &inputSceneIndex)
Definition: token.h:70
std::vector< class SdfPath > SdfPathVector
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:280
std::set< class SdfPath > SdfPathSet
A set of SdfPaths.
Definition: path.h:199
void _PrimsDirtied(const HdSceneIndexBase &, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
#define USDSKELIMAGING_API
Definition: api.h:23
USDSKELIMAGING_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
USDSKELIMAGING_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_REF_PTRS(UsdSkelImagingPointsResolvingSceneIndex)