Changeset 460 for cafu/trunk
- Timestamp:
- 01/11/12 12:10:00 (4 months ago)
- Location:
- cafu/trunk/Libs/Models
- Files:
-
- 2 modified
-
AnimExpr.cpp (modified) (8 diffs)
-
AnimExpr.hpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/Libs/Models/AnimExpr.cpp
r459 r460 26 26 AnimExpressionT::AnimExpressionT(const CafuModelT& Model) 27 27 : m_Model(Model), 28 m_RefCount(0), 29 m_ChangeNum(0) 30 { 31 UpdateChangeNum(); 32 } 33 34 35 void AnimExpressionT::UpdateChangeNum() 36 { 37 static unsigned int s_ChangeCount=0; 38 39 m_ChangeNum = ++s_ChangeCount; 28 m_RefCount(0) 29 { 40 30 } 41 31 … … 174 164 m_SequNr=SequNr; 175 165 NormalizeInput(); 176 177 UpdateChangeNum();178 166 } 179 167 … … 185 173 m_FrameNr=FrameNr; 186 174 NormalizeInput(); 187 188 UpdateChangeNum();189 175 } 190 176 … … 231 217 m_SubExpr =SubExpr; 232 218 m_ChannelNr=ChannelNr; 233 234 UpdateChangeNum();235 }236 237 238 unsigned int AnimExprFilterT::GetChangeNum() const239 {240 return std::max(AnimExpressionT::GetChangeNum(), m_SubExpr->GetChangeNum());241 219 } 242 220 … … 286 264 m_A=A; 287 265 m_B=B; 288 289 UpdateChangeNum();290 }291 292 293 unsigned int AnimExprCombineT::GetChangeNum() const294 {295 return std::max(AnimExpressionT::GetChangeNum(),296 std::max(m_A->GetChangeNum(), m_B->GetChangeNum()));297 266 } 298 267 … … 362 331 m_Duration=Duration; 363 332 m_Frac=0.0f; 364 365 UpdateChangeNum();366 }367 368 369 unsigned int AnimExprBlendT::GetChangeNum() const370 {371 if (m_Frac >= 1.0f)372 {373 return std::max(AnimExpressionT::GetChangeNum(), m_B->GetChangeNum());374 }375 376 return std::max(AnimExpressionT::GetChangeNum(),377 std::max(m_A->GetChangeNum(), m_B->GetChangeNum()));378 333 } 379 334 … … 437 392 438 393 m_B->AdvanceTime(Time, ForceLoop); 439 440 441 UpdateChangeNum();442 394 } 443 395 … … 457 409 458 410 if (!Other) return false; 459 return m_Frac==Other->m_Frac && m_Duration==Other->m_Duration && m_A->IsEqual(Other->m_A) && m_B->IsEqual(Other->m_B); 411 return m_Frac==Other->m_Frac && m_Duration==Other->m_Duration && 412 m_B->IsEqual(Other->m_B) && 413 (m_A==NULL ? Other->m_A==NULL : m_A->IsEqual(Other->m_A)); 460 414 } 461 415 -
cafu/trunk/Libs/Models/AnimExpr.hpp
r459 r460 65 65 unsigned int GetRefCount() const { return m_RefCount; } 66 66 67 /// Returns a number that changes whenever this expression changes,68 /// or more precisely, that changes whenever the data returned by GetData() changes.69 /// This is the case for example after every call to AdvanceTime() with a nonzero Time,70 /// or when a sub-expression has been modified (e.g. got a new sequence number assigned).71 /// The caller can use this number in order to control updates of its mesh caches.72 virtual unsigned int GetChangeNum() const { return m_ChangeNum; }73 74 67 /// For the joint with the given JointNr, this function returns 75 68 /// - the joint weight, … … 90 83 91 84 92 protected:93 94 void UpdateChangeNum();95 96 97 85 private: 98 86 … … 104 92 const CafuModelT& m_Model; ///< The related model that this is an anim expression for. 105 93 unsigned int m_RefCount; ///< How many IntrusivePtrT<>'s currently refer to this anim expression? 106 unsigned int m_ChangeNum; ///< Changes whenever the data returned by GetData() changes.107 94 }; 108 95 … … 156 143 157 144 // Implementations and overrides for base class methods. 158 virtual unsigned int GetChangeNum() const;159 145 virtual void GetData(unsigned int JointNr, float& Weight, Vector3fT& Pos, cf::math::QuaternionfT& Quat, Vector3fT& Scale) const; 160 146 virtual void AdvanceTime(float Time, bool ForceLoop=false) { m_SubExpr->AdvanceTime(Time, ForceLoop); } … … 180 166 181 167 // Implementations and overrides for base class methods. 182 virtual unsigned int GetChangeNum() const;183 168 virtual void GetData(unsigned int JointNr, float& Weight, Vector3fT& Pos, cf::math::QuaternionfT& Quat, Vector3fT& Scale) const; 184 169 virtual void AdvanceTime(float Time, bool ForceLoop=false); … … 215 200 216 201 // Implementations and overrides for base class methods. 217 virtual unsigned int GetChangeNum() const;218 202 virtual void GetData(unsigned int JointNr, float& Weight, Vector3fT& Pos, cf::math::QuaternionfT& Quat, Vector3fT& Scale) const; 219 203 virtual void AdvanceTime(float Time, bool ForceLoop=false);
