HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bakeSkinning.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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_USD_USD_SKEL_BAKE_SKINNING_H
25 #define PXR_USD_USD_SKEL_BAKE_SKINNING_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/usdSkel/api.h"
29 
30 #include "pxr/base/gf/interval.h"
31 #include "pxr/base/vt/array.h"
32 #include "pxr/base/vt/types.h"
33 
34 #include "pxr/usd/sdf/layer.h"
36 
37 #include <vector>
38 
40 
41 class UsdPrimRange;
42 class UsdSkelCache;
43 class UsdSkelRoot;
44 
45 /// Parameters for configuring UsdSkelBakeSkinning.
47 {
48  /// Flags for identifying different deformation paths.
61  /// Flags indicating which components of skinned prims may be
62  /// modified, based on the active deformations.
66  };
67 
68  /// Flags determining which deformation paths are enabled.
70 
71  /// Determines whether or not layers are saved during skinning.
72  /// If disabled, all skinning data is kept in-memory, and it is up
73  /// to the caller to save or export the affected layers.
74  bool saveLayers = true;
75 
76  /// Memory limit for pending stage writes, given in bytes.
77  /// If zero, memory limits are ignored. Otherwise, output stages
78  /// are flushed each time pending writes exceed this amount.
79  /// Note that at least one frame of data for *all* skinned prims
80  /// will be held in memory prior to values being written to disk,
81  /// regardless of this memory limit.
82  /// Since flushing pending changes requires layers to be saved,
83  /// memory limiting is only active when _saveLayers_ is enabled.
84  size_t memoryLimit = 0;
85 
86  /// If true, extents of UsdGeomPointBased-derived prims are updated
87  /// as new skinned values are produced. This is made optional
88  /// in case an alternate procedure is being used to compute
89  /// extents elsewhere.
90  bool updateExtents = true;
91 
92  /// If true, extents hints of models that already stored
93  /// an extentsHint are updated to reflect skinning changes.
94  /// All extent hints are authored to the stage's current edit target.
95  bool updateExtentHints = true;
96 
97  /// The set of bindings to bake.
98  std::vector<UsdSkelBinding> bindings;
99 
100  /// Data layers being written to.
101  /// Layer authoring is not thread-safe, but if multiple layers are
102  /// provided, then each of those layers may be written to on separate
103  /// threads, improving parallelism of writes.
104  /// Note that each layer must already be in the layer stack of the stage on
105  /// which the _bindings_ are defined *before* running baking. This is
106  /// necessary in order for composition of some properties during the
107  /// baking process. If this is not done, then extents of some models
108  /// may be incorrect.
109  std::vector<SdfLayerHandle> layers;
110 
111  /// Array providing an index per elem in _bindings_, indicating
112  /// which layer the skinned result of the binding should be written to.
113  /// The length of this array must be equal to the length of
114  /// the _bindings_ array.
115  VtUIntArray layerIndices;
116 };
117 
118 
119 /// Bake the effect of skinning prims directly into points and transforms,
120 /// over \p interval.
121 /// This is intended to serve as a complete reference implementation,
122 /// providing a ground truth for testing and validation purposes.
123 ///
124 /// Although this process attempts to bake skinning as efficiently as possible,
125 /// beware that this will undo the IO gains that deferred deformations provide.
126 /// A USD file, once skinning has been baked, may easily see an increase of 100x
127 /// in disk usage, if not more. The render-time costs of invoking skinning
128 /// tend to be low relative to the IO gains, so there is little render-time
129 /// benefit in baking the result down. Whatever wins are achieved may in fact
130 /// be undone by the increased IO costs.
131 /// The intent of the UsdSkel encoding is to defer skinning until as late in
132 /// the pipeline as possible (I.e., render time), partially for the sake of
133 /// improving IO in distributed renderings contexts. We encourage users to
134 /// bring similar deferred-deformation capabalities to their renderer, rather
135 /// than relying on baking data down.
137 bool
138 UsdSkelBakeSkinning(const UsdSkelCache& skelCache,
139  const UsdSkelBakeSkinningParms& parms,
140  const GfInterval& interval=GfInterval::GetFullInterval());
141 
142 
143 /// Overload of UsdSkelBakeSkinning, which bakes the effect of skinning prims
144 /// directly into points and transforms, for all skels bound beneath \p root,
145 /// over \p interval.
146 /// Skinning is baked into the current edit target. The edit target is *not*
147 /// saved during skinning: the caller should Save() or Export() the result.
149 bool
150 UsdSkelBakeSkinning(const UsdSkelRoot& root,
151  const GfInterval& interval=GfInterval::GetFullInterval());
152 
153 
154 /// Overload of UsdSkelBakeSkinning, which bakes the effect of skinning prims
155 /// directly into points and transforms, for all SkelRoot prims in \p range,
156 /// over \p interval.
157 /// Skinning is baked into the current edit target. The edit target is *not*
158 /// saved during skinning: the caller should Save() or Export() the result.
160 bool
162  const GfInterval& interval=GfInterval::GetFullInterval());
163 
164 
166 
167 
168 #endif // PXR_USD_USD_SKEL_BAKE_SKINNING_H
int deformationFlags
Flags determining which deformation paths are enabled.
Definition: bakeSkinning.h:69
USDSKEL_API bool UsdSkelBakeSkinning(const UsdSkelCache &skelCache, const UsdSkelBakeSkinningParms &parms, const GfInterval &interval=GfInterval::GetFullInterval())
static GfInterval GetFullInterval()
Returns the full interval (-inf, inf).
Definition: interval.h:346
DeformationFlags
Flags for identifying different deformation paths.
Definition: bakeSkinning.h:49
Parameters for configuring UsdSkelBakeSkinning.
Definition: bakeSkinning.h:46
std::vector< SdfLayerHandle > layers
Definition: bakeSkinning.h:109
#define USDSKEL_API
Definition: api.h:40
std::vector< UsdSkelBinding > bindings
The set of bindings to bake.
Definition: bakeSkinning.h:98
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1394
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
GLenum GLint * range
Definition: glcorearb.h:1925