HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
USD_XformCache.h
Go to the documentation of this file.
1 //
2 // Copyright 2017 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 _GUSD_USD_XFORMCACHE_H_
25 #define _GUSD_USD_XFORMCACHE_H_
26 
27 #include "gusd/api.h"
28 
29 #include "gusd/defaultArray.h"
30 #include "gusd/UT_CappedCache.h"
31 #include "gusd/USD_DataCache.h"
32 #include "gusd/USD_Utils.h"
33 
34 #include "pxr/pxr.h"
36 
38 
39 /** Concurrent memory-capped cache for primitive transforms.*/
41 {
42 public:
43 
44  GUSD_API
46 
49 
50  virtual ~GusdUSD_XformCache() {}
51 
52  bool GetLocalTransformation(const UsdPrim& prim,
54  UT_Matrix4D& xform);
55 
56  bool GetLocalToWorldTransform(const UsdPrim& prim,
58  UT_Matrix4D& xform);
59 
60  /** Compute multiple local transforms in parallel. */
62  const UT_Array<UsdPrim>& prims,
63  const GusdDefaultArray<UsdTimeCode>& times,
64  UT_Matrix4D* xfroms);
65 
66  /** Compute multiple world transforms in parallel.*/
68  const UT_Array<UsdPrim>& prims,
69  const GusdDefaultArray<UsdTimeCode>& times,
70  UT_Matrix4D* xforms);
71 
72  /* Compute constraint transforms given a common constraint name
73  for all prims. Constraint transforms not cached.*/
75  const TfToken& constraint,
76  const UT_Array<UsdPrim>& prims,
77  const GusdDefaultArray<UsdTimeCode>& times,
78  UT_Matrix4D* xforms);
79 
80  /* Given tokens representing *full* names of attributes
81  (I.e., including the namespace), compute constraint transforms.
82  Constraint transforms not cached.*/
84  const UT_Array<TfToken>& constraints,
85  const UT_Array<UsdPrim>& prims,
86  const GusdDefaultArray<UsdTimeCode>& times,
87  UT_Matrix4D* xforms);
88 
89  struct XformInfo : public UT_CappedItem
90  {
91  enum Flags
92  {
96  };
97 
99  : UT_CappedItem(), query(xf), _flags(0) {}
100 
101  virtual ~XformInfo() {}
102 
103  virtual int64 getMemoryUsage() const { return sizeof(*this); }
104 
105  void ComputeFlags(const UsdPrim& prim,
106  GusdUSD_XformCache& cache);
107 
109  { return _flags&FLAGS_LOCAL_MAYBE_TIMEVARYING; }
110 
112  { return _flags&FLAGS_WORLD_MAYBE_TIMEVARYING; }
113 
115  { return _flags&FLAGS_HAS_PARENT_XFORM; }
116 
118  private:
119  int _flags;
120  };
122 
123 
124  GUSD_API
125  XformInfoHandle GetXformInfo(const UsdPrim& prim);
126 
127  GUSD_API
128  virtual void Clear() override;
129 
130  GUSD_API
131  virtual int64 Clear(const UT_StringSet& paths) override;
132 
133 private:
134  bool _GetLocalTransformation(const UsdPrim& prim,
136  UT_Matrix4D& xform,
137  const XformInfoHandle& info);
138 
139 
140 
141 private:
142  GusdUT_CappedCache _xforms, _worldXforms, _xformInfos;
143 };
144 
146 
147 #endif /*_GUSD_USD_XFORMCACHE_H_*/
SYS_FORCE_INLINE bool WorldXformIsMaybeTimeVarying() const
GT_API const UT_StringHolder time
UT_IntrusivePtr< const XformInfo > XformInfoHandle
GLenum query
Definition: glew.h:5704
bool GetConstraintTransforms(const TfToken &constraint, const UT_Array< UsdPrim > &prims, const GusdDefaultArray< UsdTimeCode > &times, UT_Matrix4D *xforms)
SYS_FORCE_INLINE bool HasParentXform() const
long long int64
Definition: SYS_Types.h:111
Definition: token.h:89
bool GetLocalToWorldTransforms(const UT_Array< UsdPrim > &prims, const GusdDefaultArray< UsdTimeCode > &times, UT_Matrix4D *xforms)
bool GetLocalTransformations(const UT_Array< UsdPrim > &prims, const GusdDefaultArray< UsdTimeCode > &times, UT_Matrix4D *xfroms)
static GUSD_API GusdUSD_XformCache & GetInstance()
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
Wrapper around hboost::intrusive_ptr.
Definition: prim.h:131
virtual ~GusdUSD_XformCache()
XformInfo(const UsdGeomXformable &xf)
bool GetLocalTransformation(const UsdPrim &prim, UsdTimeCode time, UT_Matrix4D &xform)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1245
void ComputeFlags(const UsdPrim &prim, GusdUSD_XformCache &cache)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:83
SYS_FORCE_INLINE bool LocalXformIsMaybeTimeVarying() const
const UsdGeomXformable::XformQuery query
#define GUSD_API
Definition: api.h:40
virtual GUSD_API void Clear() override
Clear all caches.
virtual int64 getMemoryUsage() const
Base class for items in the UT_CappedCache.
bool GetLocalToWorldTransform(const UsdPrim &prim, UsdTimeCode time, UT_Matrix4D &xform)
GLenum const void * paths
Definition: glew.h:13589
GUSD_API XformInfoHandle GetXformInfo(const UsdPrim &prim)