lightLinkingSceneIndex.h
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_HDSI_LIGHT_LINKING_SCENE_INDEX_H
8 #define PXR_IMAGING_HDSI_LIGHT_LINKING_SCENE_INDEX_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdsi/api.h"
12 
13 #include "pxr/imaging/hd/collectionExpressionEvaluator.h"
14 #include "pxr/imaging/hd/collectionPredicateLibrary.h"
15 #include "pxr/imaging/hd/filteringSceneIndex.h"
16 #include "pxr/usd/sdf/path.h"
18 #include "pxr/base/tf/token.h"
19 #include "pxr/base/vt/array.h"
20 
21 #include <memory>
22 
23 PXR_NAMESPACE_OPEN_SCOPE
24 
27 #define HDSI_LIGHT_LINKING_SCENE_INDEX_TOKENS \
28  (lightPrimTypes) \
29  (lightFilterPrimTypes) \
30  (geometryPrimTypes)
31 
32 TF_DECLARE_PUBLIC_TOKENS(HdsiLightLinkingSceneIndexTokens, HDSI_API,
33  HDSI_LIGHT_LINKING_SCENE_INDEX_TOKENS);
34 
35 namespace HdsiLightLinkingSceneIndex_Impl
36 {
37  struct _Cache;
38  using _CacheSharedPtr = std::shared_ptr<_Cache>;
39 }
40 
42 
72 // Linking to instance proxy prims, nested instances and
81 {
82 public:
83  HDSI_API
84  static HdSceneIndexBaseRefPtr
85  New(const HdSceneIndexBaseRefPtr &inputSceneIndex,
86  const HdContainerDataSourceHandle &inputArgs,
87  const HdCollectionPredicateLibrary &predicateLibrary);
88 
89  // Old signature that doesn't provide a predicate library. An empty
90  // library will be used in this case.
91  HDSI_API
92  static HdSceneIndexBaseRefPtr
93  New(const HdSceneIndexBaseRefPtr &inputSceneIndex,
94  const HdContainerDataSourceHandle &inputArgs);
95 
96  HDSI_API
97  HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
98 
99  HDSI_API
100  SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
101 
102  HDSI_API
103  HdCollectionExpressionEvaluator MakeEvaluator(
104  const SdfPathExpression &expr) const;
105 
106 protected:
107 
108  HDSI_API
110  const HdSceneIndexBaseRefPtr &inputSceneIndex,
111  const HdContainerDataSourceHandle &inputArgs,
112  const HdCollectionPredicateLibrary &predicateLibrary);
113 
114  HDSI_API
115  void _PrimsAdded(
116  const HdSceneIndexBase &sender,
117  const HdSceneIndexObserver::AddedPrimEntries &entries) override;
118 
119  HDSI_API
120  void _PrimsRemoved(
121  const HdSceneIndexBase &sender,
122  const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
123 
124  HDSI_API
125  void _PrimsDirtied(
126  const HdSceneIndexBase &sender,
127  const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
128 
129 private:
130  void _ProcessAddedLightOrFilter(
132  const TfTokenVector &collectionNames,
134 
135  bool _IsLight(const TfToken &primType) const;
136  bool _IsLightFilter(const TfToken &primType) const;
137  bool _IsGeometry(const TfToken &primType) const;
138 
139 private:
140  HdsiLightLinkingSceneIndex_Impl::_CacheSharedPtr const _cache;
141 
142  // Track prims with light linking collections.
143  SdfPathSet _lightAndFilterPrimPaths;
144 
145  const VtArray<TfToken> _lightPrimTypes;
146  const VtArray<TfToken> _lightFilterPrimTypes;
147  const VtArray<TfToken> _geometryPrimTypes;
148 
149  const HdCollectionPredicateLibrary _predicateLibrary;
150 
151  // Flag tracking first population.
152  bool _wasPopulated;
153 };
154 
155 PXR_NAMESPACE_CLOSE_SCOPE
156 
157 #endif
An abstract base class for a filtering scene index that observes a single input scene index.
Represents a library of predicate functions for use with SdfPredicateExpression.
HDSI_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.
Objects of this class represent a logical expression syntax tree consisting of SdfPathPattern s,...
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:35
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:80
A notice indicating a prim of a given type was added to the scene.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:92
Abstract interface to scene data.
Definition: sceneIndex.h:54
nested point instancers is not yet supported.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:489
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
HDSI_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Returns a pair of (prim type, datasource).
This file defines some macros that are useful for declaring and using static TfTokens.
Evaluates SdfPathExpressions with prims from a given HdSceneIndex.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:58
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...