Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ConstExpr.cpp « Expressions « gameengine « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e873e968c8690be05019655555547468a42ce9fb (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// ConstExpr.cpp: implementation of the CConstExpr class.

/*
 * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  Erwin Coumans makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 *
 */

#include "Value.h" // for precompiled header
#include "ConstExpr.h"
#include "VectorValue.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CConstExpr::CConstExpr()
{
}



CConstExpr::CConstExpr(CValue* constval) 
/*
pre:
effect: constructs a CConstExpr cointing the value constval
*/
{
	m_value = constval;
//	m_bModified=true;
}



CConstExpr::~CConstExpr()
/*
pre:
effect: deletes the object
*/
{
	if (m_value)
		m_value->Release();
}



unsigned char CConstExpr::GetExpressionID()
{
	return CCONSTEXPRESSIONID;
}



CValue* CConstExpr::Calculate()
/*
pre:
ret: a new object containing the value of the stored CValue
*/
{
	return m_value->AddRef();
}



void CConstExpr::ClearModified()
{ 
	if (m_value)
	{
		m_value->SetModified(false);
		m_value->SetAffected(false);
	}
}



double CConstExpr::GetNumber()
{
	return -1;
}



bool CConstExpr::NeedsRecalculated()
{
	return m_value->IsAffected(); // IsAffected is m_bModified OR m_bAffected !!!
}



CExpression* CConstExpr::CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks)
{
// parent checks if child is still usefull. 
// When for example it's value it's deleted flag set
// then release Value, and return NULL in case of constexpression
// else return this...

	assertd(m_value);
	if (m_value->IsReleaseRequested())
	{
		AddRef(); //numchanges++;
		return Release();
	}
	else
		return this;
}



void CConstExpr::BroadcastOperators(VALUE_OPERATOR op)
{
	assertd(m_value);
	m_value->SetColorOperator(op);
}



bool CConstExpr::MergeExpression(CExpression *otherexpr)
{
	assertd(false);
	return false;
}