File: State.cpp

package info (click to toggle)
structure-synth 1.0.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,072 kB
  • ctags: 1,176
  • sloc: cpp: 7,070; python: 167; makefile: 66; lisp: 25
file content (60 lines) | stat: -rw-r--r-- 1,405 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "State.h"


namespace StructureSynth {
	namespace Model {	

		State::State() : 
			matrix(SyntopiaCore::Math::Matrix4f::Identity()), 
			hsv(SyntopiaCore::Math::Vector3f(0,1.0f,1.0f)), 
			alpha(1.0f), prevMatrix(0), seed(0)  { 
			
		}

		State& State::operator=(const State& rhs){
			this->matrix = rhs.matrix;
			this->hsv = rhs.hsv;
			this->alpha = rhs.alpha;
			this->maxDepths = rhs.maxDepths;
			this->seed = rhs.seed;
			if (rhs.prevMatrix) {
				delete(this->prevMatrix);
				this->prevMatrix = new SyntopiaCore::Math::Matrix4f();
				*(this->prevMatrix) = *rhs.prevMatrix;
			} else {
				delete(this->prevMatrix);
				this->prevMatrix = 0;
			}
			return *this;
		}

		void State::setPrevMatrix(SyntopiaCore::Math::Matrix4f matrix) {
			if (prevMatrix) {delete (prevMatrix); }

			this->prevMatrix = new SyntopiaCore::Math::Matrix4f();
			*(this->prevMatrix) = matrix;
		}

		
		State::State(const State& rhs) : matrix(rhs.matrix), 
			hsv(rhs.hsv), 
			alpha(rhs.alpha), maxDepths(rhs.maxDepths), prevMatrix(0), seed(rhs.seed) {

			if (rhs.prevMatrix) {
				delete(this->prevMatrix);
				this->prevMatrix = new SyntopiaCore::Math::Matrix4f();
				*(this->prevMatrix) = *rhs.prevMatrix;
			} else {
				delete(this->prevMatrix);
				this->prevMatrix = 0;
			}
		}
		


		State::~State() { 
			delete(prevMatrix);
		}
	}
}