HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
drawModeSceneIndex.h
Go to the documentation of this file.
1 //
2 // Copyright 2022 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 #ifndef PXR_USD_IMAGING_USD_IMAGING_DRAW_MODE_SCENE_INDEX_H
7 #define PXR_USD_IMAGING_USD_IMAGING_DRAW_MODE_SCENE_INDEX_H
8 
9 #include "pxr/pxr.h"
12 
14 
16  std::shared_ptr<class UsdImaging_DrawModeStandin>;
17 
19 
20 /// A scene index replacing geometry based on the draw mode.
21 ///
22 /// Inspects a prim's values for drawMode and applyDrawMode (see
23 /// UsdImagingGeomModelSchema).
24 /// If the drawMode is valid and not the default and applyDrawMode is true,
25 /// the prim and all its descendents are replaced by stand-in geometry
26 /// specified by the draw mode.
27 ///
28 /// Note that the material that ensures the correct texture is used on each
29 /// face is using glslfx nodes and thus only works properly in Storm.
30 ///
31 /// Using a UsdPreviewSurface instead (so that it works accross different
32 /// renderers) probably requires breaking up the geometry into several pieces.
33 ///
35 {
36 public:
37  /// inputArgs unused for now. In the future, we might use it to say that
38  /// we want to break up the geometry and use UsdPreviewSurface to work
39  /// across different renderers.
40  ///
42  static UsdImagingDrawModeSceneIndexRefPtr
43  New(const HdSceneIndexBaseRefPtr &inputSceneIndex,
44  const HdContainerDataSourceHandle &inputArgs);
45 
48 
50  HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
52  SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
53 
54 protected:
56  const HdSceneIndexBaseRefPtr &inputSceneIndex,
57  const HdContainerDataSourceHandle &inputArgs);
58 
59  void _PrimsAdded(
60  const HdSceneIndexBase &sender,
61  const HdSceneIndexObserver::AddedPrimEntries &entries) override;
62 
63  void _PrimsRemoved(
64  const HdSceneIndexBase &sender,
65  const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
66 
67  void _PrimsDirtied(
68  const HdSceneIndexBase &sender,
69  const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
70 
71 private:
72  // Delete path and all descendents from _prims.
73  void _DeleteSubtree(const SdfPath &path);
74  // Pull prim at path and recursively its descendants from input
75  // scene index - stopping the recursion when a prim with
76  // non-default drawmode is hit. When a prim has non-trivial drawmode,
77  // the DrawModeStandin object is instantiated instead.
78  void _RecursePrims(
79  const TfToken &drawMode,
80  const SdfPath &path,
81  const HdSceneIndexPrim &prim,
83 
84  // Finds prim or ancestor of prim with non-trivial drawmode in _prims map.
85  // isPathDescendant is set to true if the given path is a descendant of such
86  // a prim (but not the prim itself).
88  _FindStandinForPrimOrAncestor(
89  const SdfPath &path, bool * isPathDescendant = nullptr) const;
90 
91  // For prims with applyDrawMode, store a DrawModeStandin object
92  // that can be queried for the stand-in geometry.
93  // No path in the map is a prefix of any other path in the map.
94  std::map<SdfPath, UsdImaging_DrawModeStandinSharedPtr> _prims;
95 };
96 
98 
99 #endif // PXR_USD_IMAGING_USD_IMAGING_GL_DRAW_MODE_SCENE_INDEX_H
#define USDIMAGING_API
Definition: api.h:23
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static USDIMAGING_API UsdImagingDrawModeSceneIndexRefPtr New(const HdSceneIndexBaseRefPtr &inputSceneIndex, const HdContainerDataSourceHandle &inputArgs)
Definition: token.h:70
std::vector< class SdfPath > SdfPathVector
USDIMAGING_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
Definition: path.h:273
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDIMAGING_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
UsdImagingDrawModeSceneIndex(const HdSceneIndexBaseRefPtr &inputSceneIndex, const HdContainerDataSourceHandle &inputArgs)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
TF_DECLARE_REF_PTRS(UsdImagingDrawModeSceneIndex)
std::shared_ptr< class UsdImaging_DrawModeStandin > UsdImaging_DrawModeStandinSharedPtr
USDIMAGING_API ~UsdImagingDrawModeSceneIndex() override
void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries) override