Loading...
Searching...
No Matches
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
23PXR_NAMESPACE_OPEN_SCOPE
24
27#define HDSI_LIGHT_LINKING_SCENE_INDEX_TOKENS \
28 (lightPrimTypes) \
29 (lightFilterPrimTypes) \
30 (geometryPrimTypes)
31
32TF_DECLARE_PUBLIC_TOKENS(HdsiLightLinkingSceneIndexTokens, HDSI_API,
33 HDSI_LIGHT_LINKING_SCENE_INDEX_TOKENS);
34
35namespace 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{
82public:
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
104 const SdfPathExpression &expr) const;
105
106protected:
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
129private:
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
139private:
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
155PXR_NAMESPACE_CLOSE_SCOPE
156
157#endif
Evaluates SdfPathExpressions with prims from a given HdSceneIndex.
Abstract interface to scene data.
Definition sceneIndex.h:55
An abstract base class for a filtering scene index that observes a single input scene index.
nested point instancers is not yet supported.
HDSI_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Returns a pair of (prim type, datasource).
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,...
A path value used to locate objects in layers or scenegraphs.
Definition path.h:281
Represents a library of predicate functions for use with SdfPredicateExpression.
Token for efficient comparison, assignment, and hashing of known strings.
Definition token.h:81
Represents an arbitrary dimensional rectangular container class.
Definition array.h:213
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition declarePtrs.h:58
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
A notice indicating a prim of a given type was added to the scene.
Small struct representing a 'prim' in the Hydra scene index.
Definition sceneIndex.h:36
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition token.h:489