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  // Helper to process dirtied prim entries.
74  bool _ProcessDirtyLocators(
75  const SdfPath &primPath,
76  const TfToken &dirtiedPrimType,
77  const HdDataSourceLocatorSet &dirtyLocators,
79 
80  using _DsHandle =
81  std::shared_ptr<class UsdSkelImagingDataSourceResolvedPointsBasedPrim>;
82 
83  // Query input scene for prim at path. If that prim is potentially
84  // affected by a skeleton, construct the resolving data source,
85  // store it, update the dependencies.
86  bool _AddResolvedPrim(
87  const SdfPath &path,
88  bool * hasExtComputations = nullptr);
89  void _AddDependenciesForResolvedPrim(
90  const SdfPath &primPath,
91  _DsHandle const &resolvedPrim);
92 
93  // Remove from _pathToResolvedPrim and dependencies.
94  bool _RemoveResolvedPrim(
95  const SdfPath &path,
96  bool * hadExtComputations = nullptr);
97  void _RemoveDependenciesForResolvedPrim(
98  const SdfPath &primPath,
99  _DsHandle const &resolvedPrim);
100 
101  // Refetch data source from input scene and refresh resolved data source in
102  // _pathToResolvedPrim. This does not update the dependencies.
103  //
104  // Call this if refetching the data source is necessary, but the paths to
105  // the skeleton and blend shapes have not changed.
106  void _RefreshResolvedPrimDataSource(
107  const SdfPath &primPath,
108  bool * hasExtComputations);
109  // Refetch data source as above - filling the dirty notications.
110  void _RefreshResolvedPrimDataSources(
111  const SdfPathSet &primPaths,
113  SdfPathSet * addedResolvedPrimsWithComputations,
114  SdfPathSet * removedResolvedPrimsWithComputations);
115 
116  // For each mesh, point, basisCurve in the input scene that has a bound
117  // skeleton (even if the prim at the targeted path is not a Skeleton or
118  // empty), store the resolved data source.
119  //
120  // This scene index overlays it with the input data source.
121  //
122  std::map<SdfPath, _DsHandle> _pathToResolvedPrim;
123 
124  // Path of a skeleton to paths of resolved prim's depending on that
125  // skeleton.
126  std::map<SdfPath, SdfPathSet> _skelPathToPrimPaths;
127  // Same for blend shapes.
128  std::map<SdfPath, SdfPathSet> _blendShapePathToPrimPaths;
129 };
130 
132 
133 #endif
void _PrimsAdded(const HdSceneIndexBase &, const HdSceneIndexObserver::AddedPrimEntries &entries) override
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
Definition: path.h:273
std::set< class SdfPath > SdfPathSet
A set of SdfPaths.
Definition: path.h:192
void _PrimsDirtied(const HdSceneIndexBase &, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
#define USDSKELIMAGING_API
Definition: api.h:23
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
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)