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 // 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 // Instancer to prims that it instances, that are in a prototype with
130 // skelBinding:hasSkelRoot and that are posed by a skeleton.
131 std::map<SdfPath, SdfPathSet> _instancerPathToPrimPaths;
132};
133
134PXR_NAMESPACE_CLOSE_SCOPE
135
136#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:274
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