HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cache.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_CACHE_H
25 #define PXR_USD_USD_SKEL_CACHE_H
26 
27 /// \file usdSkel/cache.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdSkel/api.h"
31 
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/primFlags.h"
34 
37 
38 #include <memory>
39 
40 
42 
43 
44 class UsdSkelRoot;
45 class UsdSkelAnimation;
46 class UsdSkelSkeleton;
49 
51 
52 
53 /// Thread-safe cache for accessing query objects for evaluating skeletal data.
54 ///
55 /// This provides caching of major structural components, such as skeletal
56 /// topology. In a streaming context, this cache is intended to persist.
58 {
59 public:
61  UsdSkelCache();
62 
64  void Clear();
65 
66  /// Populate the cache for the skeletal data beneath prim \p root,
67  /// as traversed using \p predicate.
68  ///
69  /// Population resolves inherited skel bindings set using the
70  /// UsdSkelBindingAPI, making resolved bindings available through
71  /// GetSkinningQuery(), ComputeSkelBdining() and ComputeSkelBindings().
73  bool Populate(const UsdSkelRoot& root,
74  Usd_PrimFlagsPredicate predicate) const;
75 
76  /// Get a skel query for computing properties of \p skel.
77  ///
78  /// This does not require Populate() to be called on the cache.
81 
82  /// Get an anim query corresponding to \p anim.
83  ///
84  /// This does not require Populate() to be called on the cache.
87 
88  /// \overload
89  /// \deprecated
91  UsdSkelAnimQuery GetAnimQuery(const UsdPrim& prim) const;
92 
93  /// Get a skinning query at \p prim.
94  ///
95  /// Skinning queries are defined at any skinnable prims (I.e., boundable
96  /// prims with fully defined joint influences).
97  ///
98  /// The caller must first Populate() the cache with the skel root containing
99  /// \p prim, with a predicate that will visit \p prim, in order for a
100  /// skinning query to be discoverable.
102  UsdSkelSkinningQuery GetSkinningQuery(const UsdPrim& prim) const;
103 
104  /// Compute the set of skeleton bindings beneath \p skelRoot,
105  /// as discovered through a traversal using \p predicate.
106  ///
107  /// Skinnable prims are only discoverable by this method if Populate()
108  /// has already been called for \p skelRoot, with an equivalent predicate.
110  bool ComputeSkelBindings(const UsdSkelRoot& skelRoot,
111  std::vector<UsdSkelBinding>* bindings,
112  Usd_PrimFlagsPredicate predicate) const;
113 
114  /// Compute the bindings corresponding to a single skeleton, bound beneath
115  /// \p skelRoot, as discovered through a traversal using \p predicate.
116  ///
117  /// Skinnable prims are only discoverable by this method if Populate()
118  /// has already been called for \p skelRoot, with an equivalent predicate.
120  bool ComputeSkelBinding(const UsdSkelRoot& skelRoot,
121  const UsdSkelSkeleton& skel,
122  UsdSkelBinding* binding,
123  Usd_PrimFlagsPredicate predicate) const;
124 
125 private:
126  std::shared_ptr<class UsdSkel_CacheImpl> _impl;
127 
128  friend class UsdSkelAnimQuery;
129  friend class UsdSkelSkeletonQuery;
130 };
131 
133 
134 #endif // USDSKEL_EVALCACHE_H
USDSKEL_API UsdSkelSkinningQuery GetSkinningQuery(const UsdPrim &prim) const
USDSKEL_API bool ComputeSkelBindings(const UsdSkelRoot &skelRoot, std::vector< UsdSkelBinding > *bindings, Usd_PrimFlagsPredicate predicate) const
TF_DECLARE_REF_PTRS(UsdSkelBinding)
USDSKEL_API UsdSkelSkeletonQuery GetSkelQuery(const UsdSkelSkeleton &skel) const
USDSKEL_API UsdSkelAnimQuery GetAnimQuery(const UsdSkelAnimation &anim) const
USDSKEL_API void Clear()
USDSKEL_API bool ComputeSkelBinding(const UsdSkelRoot &skelRoot, const UsdSkelSkeleton &skel, UsdSkelBinding *binding, Usd_PrimFlagsPredicate predicate) const
USDSKEL_API bool Populate(const UsdSkelRoot &root, Usd_PrimFlagsPredicate predicate) const
Definition: prim.h:132
#define USDSKEL_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1394
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
USDSKEL_API UsdSkelCache()