AL_USDMaya  0.29.4
USD to Maya Bridge
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DrivenTransforms.h
1 //
2 // Copyright 2017 Animal Logic
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.//
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 #pragma once
17 
18 #include "../../Api.h"
19 
20 #include "pxr/usd/sdf/path.h"
21 #include "pxr/usd/usd/prim.h"
22 
23 #include "maya/MPxData.h"
24 #include "maya/MVector.h"
25 #include "maya/MMatrix.h"
26 
27 #include <vector>
28 #include <string>
29 #include "AL/maya/utils/ForwardDeclares.h"
30 #include "AL/usd/utils/ForwardDeclares.h"
31 
32 PXR_NAMESPACE_USING_DIRECTIVE
33 
34 namespace AL {
35 namespace usdmaya {
36 namespace nodes {
37 namespace proxy {
38 
39 //----------------------------------------------------------------------------------------------------------------------
49 //----------------------------------------------------------------------------------------------------------------------
51 {
52 public:
53 
56  : m_drivenPrimPaths(), m_drivenMatrix(), m_drivenVisibility(), m_dirtyMatrices(), m_dirtyVisibilities() {}
57 
59  inline size_t transformCount() const
60  { return m_drivenPrimPaths.size(); }
61 
64  AL_USDMAYA_PUBLIC
65  void resizeDrivenTransforms(const size_t primPathCount);
66 
69  inline void setDrivenPrimPaths(const SdfPathVector& primPaths)
70  { m_drivenPrimPaths = primPaths; }
71 
76  AL_USDMAYA_PUBLIC
77  bool update(UsdStageRefPtr stage, const MTime& currentTime);
78 
82  inline void dirtyVisibility(const int32_t primIndex, bool newValue)
83  {
84  m_drivenVisibility[primIndex] = newValue;
85  m_dirtyVisibilities.push_back(primIndex);
86  }
87 
91  inline void dirtyMatrix(const int32_t primIndex, const MMatrix& newValue)
92  {
93  m_drivenMatrix[primIndex] = newValue;
94  m_dirtyMatrices.push_back(primIndex);
95  }
96 
99  inline const SdfPathVector& drivenPrimPaths() const
100  { return m_drivenPrimPaths; }
101 
104  inline const std::vector<int32_t>& dirtyMatrices() const
105  { return m_dirtyMatrices; }
106 
109  inline const std::vector<int32_t>& dirtyVisibilities() const
110  { return m_dirtyVisibilities; }
111 
114  inline const std::vector<MMatrix>& drivenMatrices() const
115  { return m_drivenMatrix; }
116 
119  inline const std::vector<bool>& drivenVisibilities() const
120  { return m_drivenVisibility; }
121 
122 private:
123  void updateDrivenVisibility(std::vector<UsdPrim>& drivenPrims, const MTime& currentTime);
124  void updateDrivenTransforms(std::vector<UsdPrim>& drivenPrims, const MTime& currentTime);
125 private:
126  SdfPathVector m_drivenPrimPaths;
127  std::vector<MMatrix> m_drivenMatrix;
128  std::vector<bool> m_drivenVisibility;
129  std::vector<int32_t> m_dirtyMatrices;
130  std::vector<int32_t> m_dirtyVisibilities;
131 };
132 
133 //----------------------------------------------------------------------------------------------------------------------
134 } // proxy
135 } // nodes
136 } // usdmaya
137 } // AL
138 //----------------------------------------------------------------------------------------------------------------------
139 
const std::vector< MMatrix > & drivenMatrices() const
returns the visibilities that have been dirtied
Definition: DrivenTransforms.h:114
AL_USDMAYA_PUBLIC bool update(UsdStageRefPtr stage, const MTime &currentTime)
update the driven transforms
DrivenTransforms()
ctor
Definition: DrivenTransforms.h:55
This class maintains a set of prim paths to transform prims, and a cache of their matrix and visibili...
Definition: DrivenTransforms.h:50
void dirtyMatrix(const int32_t primIndex, const MMatrix &newValue)
dirties the matrix for the specified prim index
Definition: DrivenTransforms.h:91
const std::vector< bool > & drivenVisibilities() const
returns the visibilities that have been dirtied
Definition: DrivenTransforms.h:119
AL_USDMAYA_PUBLIC void resizeDrivenTransforms(const size_t primPathCount)
resizes the driven transform internals to hold the specified number of prims
size_t transformCount() const
returns the number of transforms
Definition: DrivenTransforms.h:59
const SdfPathVector & drivenPrimPaths() const
returns the paths of the driven transforms
Definition: DrivenTransforms.h:99
const std::vector< int32_t > & dirtyMatrices() const
returns the matrices that have been dirtied
Definition: DrivenTransforms.h:104
void setDrivenPrimPaths(const SdfPathVector &primPaths)
set the driven prim paths on the host driven transforms
Definition: DrivenTransforms.h:69
const std::vector< int32_t > & dirtyVisibilities() const
returns the visibilities that have been dirtied
Definition: DrivenTransforms.h:109
void dirtyVisibility(const int32_t primIndex, bool newValue)
dirties the visibility for the specified prim index
Definition: DrivenTransforms.h:82