Fix issue in Rocket.lua script.
[Cafu-Engine.git] / Libs / MaterialSystem / Common / DepRelMatrix.cpp
blob1a4572df820d89b146908e669f2f5256457931ec
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
7 /****************************************/
8 /*** Dependency Relationship Matrices ***/
9 /****************************************/
11 #include "DepRelMatrix.hpp"
14 unsigned long DepRelMatrixT::GlobalIDCount=0;
17 DepRelMatrixT::DepRelMatrixT()
18 : Age(0),
19 ID(GlobalIDCount++)
24 DepRelMatrixT::DepRelMatrixT(const DepRelMatrixT& Other)
25 : Matrix(Other.Matrix),
26 Age(0),
27 ID(GlobalIDCount++)
34 InverseMatrixT::InverseMatrixT(DepRelMatrixT* Source)
35 : m_Source(Source)
40 void InverseMatrixT::SetSourceMatrix(DepRelMatrixT* Source)
42 m_Source=Source;
46 void InverseMatrixT::Update()
48 // First make recursively sure that the source matrix is up-to-date.
49 m_Source->Update();
51 // Now see if updating the source actually aged (changed) it.
52 if (m_Source->Age > Age)
54 Matrix=m_Source->Matrix.GetInverse();
55 Age =m_Source->Age;
62 ProductMatrixT::ProductMatrixT(DepRelMatrixT& A, DepRelMatrixT& B)
63 : m_A(A), m_B(B)
68 void ProductMatrixT::Update()
70 // First make recursively sure that the sources are up-to-date.
71 m_A.Update();
72 m_B.Update();
74 // Now see if updating them actually aged (changed) them.
75 if (m_A.Age+m_B.Age > Age)
77 Matrix=m_A.Matrix*m_B.Matrix;
78 Age =m_A.Age+m_B.Age;