1 #include "State.h" 2 3 4 namespace StructureSynth { 5 namespace Model { 6 State()7 State::State() : 8 matrix(SyntopiaCore::Math::Matrix4f::Identity()), 9 hsv(SyntopiaCore::Math::Vector3f(0,1.0f,1.0f)), 10 alpha(1.0f), previous(0), seed(0) { 11 12 } 13 operator =(const State & rhs)14 State& State::operator=(const State& rhs){ 15 this->matrix = rhs.matrix; 16 this->hsv = rhs.hsv; 17 this->alpha = rhs.alpha; 18 this->maxDepths = rhs.maxDepths; 19 this->seed = rhs.seed; 20 if (rhs.previous) { 21 delete(this->previous); 22 this->previous = new PreviousState(); 23 *(this->previous) = *rhs.previous; 24 } else { 25 delete(this->previous); 26 this->previous = 0; 27 } 28 return *this; 29 } 30 setPreviousState(SyntopiaCore::Math::Matrix4f matrix,SyntopiaCore::Math::Vector3f hsv,float alpha)31 void State::setPreviousState(SyntopiaCore::Math::Matrix4f matrix,SyntopiaCore::Math::Vector3f hsv, float alpha) { 32 if (previous) {delete (previous); } 33 34 this->previous = new PreviousState(); 35 this->previous->matrix = matrix; 36 this->previous->hsv = hsv; 37 this->previous->alpha = alpha; 38 } 39 40 State(const State & rhs)41 State::State(const State& rhs) : matrix(rhs.matrix), 42 hsv(rhs.hsv), 43 alpha(rhs.alpha), maxDepths(rhs.maxDepths), previous(0), seed(rhs.seed) { 44 45 if (rhs.previous) { 46 delete(this->previous); 47 this->previous = new PreviousState(); 48 *(this->previous) = *rhs.previous; 49 } else { 50 delete(this->previous); 51 this->previous = 0; 52 } 53 } 54 55 56 ~State()57 State::~State() { 58 delete(previous); 59 } 60 } 61 } 62 63