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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_USD_SKEL_CACHE_H
8 #define PXR_USD_USD_SKEL_CACHE_H
9 
10 /// \file usdSkel/cache.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdSkel/api.h"
14 
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/primFlags.h"
17 
20 
21 #include <memory>
22 
23 
25 
26 
27 class UsdSkelRoot;
28 class UsdSkelAnimation;
29 class UsdSkelSkeleton;
32 
34 
35 
36 /// Thread-safe cache for accessing query objects for evaluating skeletal data.
37 ///
38 /// This provides caching of major structural components, such as skeletal
39 /// topology. In a streaming context, this cache is intended to persist.
41 {
42 public:
44  UsdSkelCache();
45 
47  void Clear();
48 
49  /// Populate the cache for the skeletal data beneath prim \p root,
50  /// as traversed using \p predicate.
51  ///
52  /// Population resolves inherited skel bindings set using the
53  /// UsdSkelBindingAPI, making resolved bindings available through
54  /// GetSkinningQuery(), ComputeSkelBinding() and ComputeSkelBindings().
56  bool Populate(const UsdSkelRoot& root,
57  Usd_PrimFlagsPredicate predicate) const;
58 
59  /// Get a skel query for computing properties of \p skel.
60  ///
61  /// This does not require Populate() to be called on the cache.
64 
65  /// Get an anim query corresponding to \p anim.
66  ///
67  /// This does not require Populate() to be called on the cache.
70 
71  /// \overload
72  /// \deprecated
74  UsdSkelAnimQuery GetAnimQuery(const UsdPrim& prim) const;
75 
76  /// Get a skinning query at \p prim.
77  ///
78  /// Skinning queries are defined at any skinnable prims (I.e., boundable
79  /// prims with fully defined joint influences).
80  ///
81  /// The caller must first Populate() the cache with the skel root containing
82  /// \p prim, with a predicate that will visit \p prim, in order for a
83  /// skinning query to be discoverable.
86 
87  /// Compute the set of skeleton bindings beneath \p skelRoot,
88  /// as discovered through a traversal using \p predicate.
89  ///
90  /// Skinnable prims are only discoverable by this method if Populate()
91  /// has already been called for \p skelRoot, with an equivalent predicate.
93  bool ComputeSkelBindings(const UsdSkelRoot& skelRoot,
94  std::vector<UsdSkelBinding>* bindings,
95  Usd_PrimFlagsPredicate predicate) const;
96 
97  /// Compute the bindings corresponding to a single skeleton, bound beneath
98  /// \p skelRoot, as discovered through a traversal using \p predicate.
99  ///
100  /// Skinnable prims are only discoverable by this method if Populate()
101  /// has already been called for \p skelRoot, with an equivalent predicate.
103  bool ComputeSkelBinding(const UsdSkelRoot& skelRoot,
104  const UsdSkelSkeleton& skel,
105  UsdSkelBinding* binding,
106  Usd_PrimFlagsPredicate predicate) const;
107 
108 private:
109  std::shared_ptr<class UsdSkel_CacheImpl> _impl;
110 
111  friend class UsdSkelAnimQuery;
112  friend class UsdSkelSkeletonQuery;
113 };
114 
116 
117 #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:116
#define USDSKEL_API
Definition: api.h:23
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDSKEL_API UsdSkelCache()