HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
legacyGeomSubsetSceneIndex.h
Go to the documentation of this file.
1 //
2 // Copyright 2024 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_HD_LEGACY_GEOM_SUBSET_SCENE_INDEX_H
8 #define PXR_IMAGING_HD_LEGACY_GEOM_SUBSET_SCENE_INDEX_H
9 
10 #include "pxr/imaging/hd/api.h"
14 
15 #include "pxr/usd/sdf/path.h"
16 
18 
19 #include "pxr/pxr.h"
20 
21 #include <map>
22 
24 
26 
27 ///
28 /// HdLegacyGeomSubsetSceneIndex
29 ///
30 /// This scene index converts legacy geom subsets (from mesh or basis curves
31 /// topology, including invisible components) into Hydra geomSubset prims. It
32 /// preserves the authored order of named mesh subsets as USD requires.
33 /// It MUST have a notice-batching scene index before it so that it can access
34 /// topology via the scene delegate during insertion.
35 ///
36 /// For the most part, this scene index will pull information from the scene
37 /// delegate on demand. However, it does keep a cache of all the subset paths
38 /// it has added (organized by parent) so it can be more precise about
39 /// invalidation. Having this cache incidentally provides a few other
40 /// shortcuts to avoid expensive operations.
43 {
44 public:
45  HD_API
46  static HdLegacyGeomSubsetSceneIndexRefPtr New(
47  const HdSceneIndexBaseRefPtr& inputSceneIndex);
48 
49  HD_API
51 
52  HD_API
53  HdSceneIndexPrim GetPrim(const SdfPath& primPath) const override;
54 
55  HD_API
56  SdfPathVector GetChildPrimPaths(const SdfPath& primPath) const override;
57 
58 protected:
60  const HdSceneIndexBaseRefPtr& inputSceneIndex);
61 
62  void _PrimsAdded(
63  const HdSceneIndexBase& sender,
64  const HdSceneIndexObserver::AddedPrimEntries& entries) override;
65 
66  void _PrimsRemoved(
67  const HdSceneIndexBase& sender,
68  const HdSceneIndexObserver::RemovedPrimEntries& entries) override;
69 
70  void _PrimsDirtied(
71  const HdSceneIndexBase& sender,
72  const HdSceneIndexObserver::DirtiedPrimEntries& entries) override;
73 
74 private:
75  static SdfPathVector
76  _ListDelegateSubsets(
77  const SdfPath& parentPath,
78  const HdSceneIndexPrim& parentPrim);
79 
80  // Unordered map of parent path -> [subset paths...]
81  // XXX: Do not use SdfPathTable because we do not want it
82  // to implicitly include the extra ancestor paths.
83  std::map<SdfPath, SdfPathVector> _parentPrims;
84 };
85 
87 
88 #endif // PXR_IMAGING_HD_LEGACY_GEOM_SUBSET_SCENE_INDEX_H
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_REF_PTRS(HdLegacyGeomSubsetSceneIndex)
static HD_API HdLegacyGeomSubsetSceneIndexRefPtr New(const HdSceneIndexBaseRefPtr &inputSceneIndex)
HD_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
#define HD_API
Definition: api.h:23
HdLegacyGeomSubsetSceneIndex(const HdSceneIndexBaseRefPtr &inputSceneIndex)
void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
HD_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
std::vector< class SdfPath > SdfPathVector
HD_API ~HdLegacyGeomSubsetSceneIndex() override
Definition: path.h:273
void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74