return const refs + vec constantize

This commit is contained in:
vaxerski 2022-04-23 14:40:51 +02:00
parent 77002eeea0
commit 306d163613
2 changed files with 12 additions and 12 deletions

View file

@ -22,37 +22,37 @@ public:
~CAnimatedVariable(); ~CAnimatedVariable();
// gets the current vector value (real time) // gets the current vector value (real time)
Vector2D vec() { const Vector2D& vec() const {
ASSERT(m_eVarType == AVARTYPE_VECTOR); ASSERT(m_eVarType == AVARTYPE_VECTOR);
return m_vValue; return m_vValue;
} }
// gets the current float value (real time) // gets the current float value (real time)
float fl() { const float& fl() const {
ASSERT(m_eVarType == AVARTYPE_FLOAT); ASSERT(m_eVarType == AVARTYPE_FLOAT);
return m_fValue; return m_fValue;
} }
// gets the current color value (real time) // gets the current color value (real time)
CColor col() { const CColor& col() const {
ASSERT(m_eVarType == AVARTYPE_COLOR); ASSERT(m_eVarType == AVARTYPE_COLOR);
return m_cValue; return m_cValue;
} }
// gets the goal vector value // gets the goal vector value
Vector2D goalv() { const Vector2D& goalv() const {
ASSERT(m_eVarType == AVARTYPE_VECTOR); ASSERT(m_eVarType == AVARTYPE_VECTOR);
return m_vGoal; return m_vGoal;
} }
// gets the goal float value // gets the goal float value
float goalf() { const float& goalf() const {
ASSERT(m_eVarType == AVARTYPE_FLOAT); ASSERT(m_eVarType == AVARTYPE_FLOAT);
return m_fGoal; return m_fGoal;
} }
// gets the goal color value // gets the goal color value
CColor goalc() { const CColor& goalc() const {
ASSERT(m_eVarType == AVARTYPE_COLOR); ASSERT(m_eVarType == AVARTYPE_COLOR);
return m_cGoal; return m_cGoal;
} }

View file

@ -14,24 +14,24 @@ class Vector2D {
// returns the scale // returns the scale
double normalize(); double normalize();
Vector2D operator+(const Vector2D a) { Vector2D operator+(const Vector2D a) const {
return Vector2D(this->x + a.x, this->y + a.y); return Vector2D(this->x + a.x, this->y + a.y);
} }
Vector2D operator-(const Vector2D a) { Vector2D operator-(const Vector2D a) const {
return Vector2D(this->x - a.x, this->y - a.y); return Vector2D(this->x - a.x, this->y - a.y);
} }
Vector2D operator*(const float a) { Vector2D operator*(const float a) const {
return Vector2D(this->x * a, this->y * a); return Vector2D(this->x * a, this->y * a);
} }
Vector2D operator/(const float a) { Vector2D operator/(const float a) const {
return Vector2D(this->x / a, this->y / a); return Vector2D(this->x / a, this->y / a);
} }
bool operator==(const Vector2D& a) { bool operator==(const Vector2D& a) const {
return a.x == x && a.y == y; return a.x == x && a.y == y;
} }
bool operator!=(const Vector2D& a) { bool operator!=(const Vector2D& a) const {
return a.x != x || a.y != y; return a.x != x || a.y != y;
} }