Loading...
Searching...
No Matches
pointsResolvingSceneIndex.h
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
10#include "pxr/usdImaging/usdSkelImaging/api.h"
11
12#include "pxr/imaging/hd/filteringSceneIndex.h"
13
14#include <optional>
15
16PXR_NAMESPACE_OPEN_SCOPE
17
19
31{
32public:
33 USDSKELIMAGING_API
34 static
35 UsdSkelImagingPointsResolvingSceneIndexRefPtr
36 New(HdSceneIndexBaseRefPtr const &inputSceneIndex);
37
38 USDSKELIMAGING_API
39 HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
40
41 USDSKELIMAGING_API
42 SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
43
44protected:
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
55private:
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
135PXR_NAMESPACE_CLOSE_SCOPE
136
137#endif
Represents a set of data source locators closed under descendancy.
Abstract interface to scene data.
Definition: sceneIndex.h:54
An abstract base class for a filtering scene index that observes a single input scene index.
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:71
Adds ext computations to skin to points of a mesh, point, basisCurves prims.
USDSKELIMAGING_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.
USDSKELIMAGING_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Returns a pair of (prim type, datasource).
#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:35
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440