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