Loading...
Searching...
No Matches
generativeProcedural.h
1//
2// Copyright 2022 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24#ifndef PXR_IMAGING_HD_GP_GENERATIVE_PROCEDURAL_H
25#define PXR_IMAGING_HD_GP_GENERATIVE_PROCEDURAL_H
26
27#include "pxr/imaging/hdGp/api.h"
28#include "pxr/imaging/hd/sceneIndex.h"
30
31PXR_NAMESPACE_OPEN_SCOPE
32
33#define HDGPGENERATIVEPROCEDURAL_TOKENS \
34 ((generativeProcedural, "hydraGenerativeProcedural")) \
35 ((proceduralType, "hdGp:proceduralType")) \
36
37TF_DECLARE_PUBLIC_TOKENS(HdGpGenerativeProceduralTokens,
38 HDGPGENERATIVEPROCEDURAL_TOKENS);
39
50{
51public:
52 HDGP_API
53 HdGpGenerativeProcedural(const SdfPath &proceduralPrimPath);
54
55 HDGP_API
57
58 using DependencyMap =
60
61 using ChildPrimTypeMap =
63
64 // Given access to the input scene (specifically the primvars serving as
65 // arguments on the procedural's own prim), return what other data sources
66 // of what other prims we depend upon and should be given the opportunity
67 // to update in response their changes.
68 //
69 // For a single instance, UpdateDependencies will not be called from
70 // multiple threads -- nor concurrent to Update
71 virtual DependencyMap UpdateDependencies(
72 const HdSceneIndexBaseRefPtr &inputScene) = 0;
73
74 // This is the primary "cook" method called when a procedural is initially
75 // resolved or invalidated. The result is a map of child prim paths and
76 // their hydra scene prim types. Because a cook/recook can add, remove or
77 // dirty child prims, the returned ChildPrimTypeMap must always contain
78 // the full set of child prims. It is interpreted in this way:
79 // 1) Prims which did not exist in the result of
80 // of previous calls to this method will be added.
81 // 2) Prims which existed in the results of previous calls but not in this
82 // result will be removed.
83 // 3) Prims whose type has changed between calls to this method will be
84 // re-added.
85 //
86 // Prims which exist in both (and have not changed type) are not considered
87 // dirty unless added to the outputDirtiedPrims vector. Because each entry
88 // in that vector contains an HdDataSourceLocatorSet, invalidation can be
89 // as broad or specific as possible. In order to reduce the amount of
90 // bookkeeping for the procedural itself, previousResult contains the
91 // result of the previous call to this method.
92 //
93 // dirtiedDependencies contains the prim paths and locator sets of
94 // declared dependencies which have been dirtied since the last cook. For
95 // initial cooks (and in response to things like removal of prims previously
96 // dependeded upon), the full set of declared dependencies is sent here. A
97 // procedural may choose to cache values previously queried from the input
98 // scene and invalidate based on the contents of dirtiedDependencies.
99 //
100 // NOTE: For initial cooks, changes to the procedural's own prim will not
101 // be included within dirtiedDependencies. (TODO: reconsider this.)
102 //
103 // ALSO NOTE: Because this method is responsible only for describing the
104 // presence and type (and potential dirtiness) of its child
105 // prims -- and not the data sources for those prims -- it may
106 // choose to defer some computation of values to happen within
107 // data sources returned by GetChildPrim.
108 //
109 // For a single instance, Update will not be called from
110 // multiple threads -- nor concurrent to UpdateDependencies
111 virtual ChildPrimTypeMap Update(
112 const HdSceneIndexBaseRefPtr &inputScene,
113 const ChildPrimTypeMap &previousResult,
114 const DependencyMap &dirtiedDependencies,
115 HdSceneIndexObserver::DirtiedPrimEntries *outputDirtiedPrims) = 0;
116
117 // Returns the type and prim-level data source for a child prim previously
118 // added or invalidated from the Update method.
119 //
120 // This should expect to be called from multiple threads
121 virtual HdSceneIndexPrim GetChildPrim(
122 const HdSceneIndexBaseRefPtr &inputScene,
123 const SdfPath &childPrimPath) = 0;
124
125protected:
126 HDGP_API
127 const SdfPath &_GetProceduralPrimPath();
128
129private:
130 const SdfPath _proceduralPrimPath;
131};
132
133PXR_NAMESPACE_CLOSE_SCOPE
134
135#endif
HdGpGenerativeProcedural is the base class for procedurals which have full access to an input scene i...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:291
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:112
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:52