mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-22 07:27:59 -05:00
make cocos geometry constexpr
This commit is contained in:
parent
91150911d4
commit
db8a6c8903
2 changed files with 137 additions and 112 deletions
173
loader/include/Geode/cocos/cocoa/CCGeometry.h
vendored
173
loader/include/Geode/cocos/cocoa/CCGeometry.h
vendored
|
@ -55,64 +55,64 @@ public:
|
|||
float y;
|
||||
// alk modifications: all defined
|
||||
|
||||
inline CCPoint() : x(0), y(0) {}
|
||||
inline CCPoint(float x, float y) : x(x), y(y) {}
|
||||
inline constexpr CCPoint() : x(0), y(0) {}
|
||||
inline constexpr CCPoint(float x, float y) : x(x), y(y) {}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCPoint(const CCPoint& other) : x(other.x), y(other.y) {}
|
||||
inline constexpr CCPoint(const CCPoint& other) : x(other.x), y(other.y) {}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCPoint(const CCSize& size);
|
||||
inline constexpr CCPoint(const CCSize& size);
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCPoint& operator= (const CCPoint& other) {
|
||||
inline constexpr CCPoint& operator= (const CCPoint& other) {
|
||||
setPoint(other.x, other.y);
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCPoint& operator= (const CCSize& size);
|
||||
inline constexpr CCPoint& operator= (const CCSize& size);
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCPoint operator+(const CCPoint& right) const {
|
||||
inline constexpr CCPoint operator+(const CCPoint& right) const {
|
||||
return CCPoint(this->x + right.x, this->y + right.y);
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCPoint operator-(const CCPoint& right) const {
|
||||
inline constexpr CCPoint operator-(const CCPoint& right) const {
|
||||
return CCPoint(this->x - right.x, this->y - right.y);
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCPoint operator-() const {
|
||||
inline constexpr CCPoint operator-() const {
|
||||
return CCPoint(-x, -y);
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCPoint operator*(float a) const {
|
||||
inline constexpr CCPoint operator*(float a) const {
|
||||
return CCPoint(this->x * a, this->y * a);
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCPoint operator/(float a) const {
|
||||
inline constexpr CCPoint operator/(float a) const {
|
||||
return CCPoint(this->x / a, this->y / a);
|
||||
}
|
||||
|
||||
|
||||
// camila modification
|
||||
inline CCPoint operator*(const CCPoint& right) const {
|
||||
inline constexpr CCPoint operator*(const CCPoint& right) const {
|
||||
return CCPoint(x * right.x, y * right.y);
|
||||
}
|
||||
inline CCPoint operator/(const CCPoint& right) const {
|
||||
inline constexpr CCPoint operator/(const CCPoint& right) const {
|
||||
return CCPoint(x / right.x, y / right.y);
|
||||
}
|
||||
//314
|
||||
|
@ -120,12 +120,12 @@ public:
|
|||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline void setPoint(float x, float y) {
|
||||
inline constexpr void setPoint(float x, float y) {
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
}
|
||||
|
||||
inline bool equals(const CCPoint& target) const {
|
||||
inline constexpr bool equals(const CCPoint& target) const {
|
||||
return (fabs(this->x - target.x) < FLT_EPSILON) && (fabs(this->y - target.y) < FLT_EPSILON);
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ public:
|
|||
* @since v2.1.4
|
||||
* @lua NA
|
||||
*/
|
||||
inline bool fuzzyEquals(const CCPoint& b, float var) const {
|
||||
inline constexpr bool fuzzyEquals(const CCPoint& b, float var) const {
|
||||
if(x - var <= b.x && b.x <= x + var)
|
||||
if(y - var <= b.y && b.y <= y + var)
|
||||
return true;
|
||||
|
@ -145,7 +145,7 @@ public:
|
|||
* @since v2.1.4
|
||||
* @lua NA
|
||||
*/
|
||||
inline float getLength() const {
|
||||
inline constexpr float getLength() const {
|
||||
return sqrtf(x*x + y*y);
|
||||
};
|
||||
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
* @since v2.1.4
|
||||
* @lua NA
|
||||
*/
|
||||
inline float getLengthSq() const {
|
||||
inline constexpr float getLengthSq() const {
|
||||
return dot(*this); //x*x + y*y;
|
||||
};
|
||||
|
||||
|
@ -162,7 +162,7 @@ public:
|
|||
@return float
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline float getDistanceSq(const CCPoint& other) const {
|
||||
inline constexpr float getDistanceSq(const CCPoint& other) const {
|
||||
return (*this - other).getLengthSq();
|
||||
};
|
||||
|
||||
|
@ -170,21 +170,21 @@ public:
|
|||
@return float
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline float getDistance(const CCPoint& other) const {
|
||||
inline constexpr float getDistance(const CCPoint& other) const {
|
||||
return (*this - other).getLength();
|
||||
};
|
||||
|
||||
/** @returns the angle in radians between this vector and the x axis
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline float getAngle() const {
|
||||
inline constexpr float getAngle() const {
|
||||
return atan2f(y, x);
|
||||
};
|
||||
|
||||
/** @returns the angle in radians between two vector directions
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline float getAngle(const CCPoint& other) const {
|
||||
inline constexpr float getAngle(const CCPoint& other) const {
|
||||
CCPoint a2 = normalize();
|
||||
CCPoint b2 = other.normalize();
|
||||
float angle = atan2f(a2.cross(b2), a2.dot(b2));
|
||||
|
@ -196,7 +196,7 @@ public:
|
|||
@return float
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline float dot(const CCPoint& other) const {
|
||||
inline constexpr float dot(const CCPoint& other) const {
|
||||
return x*other.x + y*other.y;
|
||||
};
|
||||
|
||||
|
@ -204,7 +204,7 @@ public:
|
|||
@return float
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline float cross(const CCPoint& other) const {
|
||||
inline constexpr float cross(const CCPoint& other) const {
|
||||
return x*other.y - y*other.x;
|
||||
};
|
||||
|
||||
|
@ -212,7 +212,7 @@ public:
|
|||
@return CCPoint
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline CCPoint getPerp() const {
|
||||
inline constexpr CCPoint getPerp() const {
|
||||
return CCPoint(-y, x);
|
||||
};
|
||||
|
||||
|
@ -220,7 +220,7 @@ public:
|
|||
@return CCPoint
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline CCPoint getRPerp() const {
|
||||
inline constexpr CCPoint getRPerp() const {
|
||||
return CCPoint(y, -x);
|
||||
};
|
||||
|
||||
|
@ -228,7 +228,7 @@ public:
|
|||
@return CCPoint
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline CCPoint project(const CCPoint& other) const {
|
||||
inline constexpr CCPoint project(const CCPoint& other) const {
|
||||
return other * (dot(other)/other.dot(other));
|
||||
};
|
||||
|
||||
|
@ -237,7 +237,7 @@ public:
|
|||
and a length of this.getLength() * other.getLength().
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline CCPoint rotate(const CCPoint& other) const {
|
||||
inline constexpr CCPoint rotate(const CCPoint& other) const {
|
||||
return CCPoint(x*other.x - y*other.y, x*other.y + y*other.x);
|
||||
};
|
||||
|
||||
|
@ -246,7 +246,7 @@ public:
|
|||
and a length of this.getLength() * other.getLength().
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline CCPoint unrotate(const CCPoint& other) const {
|
||||
inline constexpr CCPoint unrotate(const CCPoint& other) const {
|
||||
return CCPoint(x*other.x + y*other.y, y*other.x - x*other.y);
|
||||
};
|
||||
|
||||
|
@ -255,7 +255,7 @@ public:
|
|||
@return CCPoint
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline CCPoint normalize() const {
|
||||
inline constexpr CCPoint normalize() const {
|
||||
float length = getLength();
|
||||
if(length == 0.) return CCPoint(1.f, 0);
|
||||
return *this / getLength();
|
||||
|
@ -268,7 +268,7 @@ public:
|
|||
otherwise a value between a..b
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline CCPoint lerp(const CCPoint& other, float alpha) const {
|
||||
inline constexpr CCPoint lerp(const CCPoint& other, float alpha) const {
|
||||
return *this * (1.f - alpha) + other * alpha;
|
||||
};
|
||||
|
||||
|
@ -278,20 +278,30 @@ public:
|
|||
@returns the rotated point
|
||||
@since v2.1.4
|
||||
*/
|
||||
inline CCPoint rotateByAngle(const CCPoint& pivot, float angle) const {
|
||||
inline constexpr CCPoint rotateByAngle(const CCPoint& pivot, float angle) const {
|
||||
return pivot + (*this - pivot).rotate(CCPoint::forAngle(angle));
|
||||
}
|
||||
|
||||
static inline CCPoint forAngle(const float a)
|
||||
static inline constexpr CCPoint forAngle(const float a)
|
||||
{
|
||||
return CCPoint(cosf(a), sinf(a));
|
||||
}
|
||||
|
||||
void add(int, float);
|
||||
float at(int);
|
||||
bool isZero() const;
|
||||
void set(int, float);
|
||||
void swap();
|
||||
constexpr void add(int idx, float val) {
|
||||
idx == 0 ? x += val : y += val;
|
||||
}
|
||||
constexpr float at(int idx) {
|
||||
return idx == 0 ? x : y;
|
||||
}
|
||||
constexpr bool isZero() const {
|
||||
return x == 0.f && y == 0.f;
|
||||
}
|
||||
constexpr void set(int idx, float val) {
|
||||
idx == 0 ? x = val : y = val;
|
||||
}
|
||||
constexpr void swap() {
|
||||
std::swap(x, y);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -306,86 +316,97 @@ public:
|
|||
float height;
|
||||
|
||||
public:
|
||||
inline CCSize() : width(0), height(0) {}
|
||||
inline CCSize(float width, float height) : width(width), height(height) {}
|
||||
inline constexpr CCSize() : width(0), height(0) {}
|
||||
inline constexpr CCSize(float width, float height) : width(width), height(height) {}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCSize(const CCSize& other) : width(other.width), height(other.height) {}
|
||||
inline constexpr CCSize(const CCSize& other) : width(other.width), height(other.height) {}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCSize(const CCPoint& point) : width(point.x), height(point.y) {}
|
||||
inline constexpr CCSize(const CCPoint& point) : width(point.x), height(point.y) {}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCSize& operator= (const CCSize& other) {
|
||||
inline constexpr CCSize& operator= (const CCSize& other) {
|
||||
setSize(other.width, other.height);
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCSize& operator= (const CCPoint& point) {
|
||||
inline constexpr CCSize& operator= (const CCPoint& point) {
|
||||
setSize(point.x, point.y);
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCSize operator+(const CCSize& right) const {
|
||||
inline constexpr CCSize operator+(const CCSize& right) const {
|
||||
return CCSize(this->width + right.width, this->height + right.height);
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCSize operator-(const CCSize& right) const {
|
||||
inline constexpr CCSize operator-(const CCSize& right) const {
|
||||
return CCSize(this->width - right.width, this->height - right.height);
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCSize operator*(float a) const {
|
||||
inline constexpr CCSize operator*(float a) const {
|
||||
return CCSize(this->width * a, this->height * a);
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCSize operator/(float a) const {
|
||||
inline constexpr CCSize operator/(float a) const {
|
||||
return CCSize(this->width / a, this->height / a);
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline void setSize(float width, float height) {
|
||||
inline constexpr void setSize(float width, float height) {
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline bool equals(const CCSize& target) const {
|
||||
inline constexpr bool equals(const CCSize& target) const {
|
||||
return (fabs(this->width - target.width) < FLT_EPSILON) && (fabs(this->height - target.height) < FLT_EPSILON);
|
||||
}
|
||||
/**
|
||||
* Get the aspect ratio of this CCSize
|
||||
* @note Geode addition
|
||||
*/
|
||||
inline float aspect() const {
|
||||
inline constexpr float aspect() const {
|
||||
return this->width / this->height;
|
||||
}
|
||||
|
||||
void add(int, float);
|
||||
float at(int);
|
||||
void set(int, float);
|
||||
|
||||
constexpr void add(int idx, float val) {
|
||||
idx == 0 ? width += val : height += val;
|
||||
}
|
||||
constexpr float at(int idx) {
|
||||
return idx == 0 ? width : height;
|
||||
}
|
||||
constexpr bool isZero() const {
|
||||
return width == 0.f && height == 0.f;
|
||||
}
|
||||
constexpr void set(int idx, float val) {
|
||||
idx == 0 ? width = val : height = val;
|
||||
}
|
||||
constexpr void swap() {
|
||||
std::swap(width, height);
|
||||
}
|
||||
};
|
||||
|
||||
// alk cont
|
||||
|
||||
CCPoint::CCPoint(const CCSize& size) : x(size.width), y(size.height) {}
|
||||
constexpr CCPoint::CCPoint(const CCSize& size) : x(size.width), y(size.height) {}
|
||||
|
||||
CCPoint& CCPoint::operator= (const CCSize& size) {
|
||||
constexpr CCPoint& CCPoint::operator= (const CCSize& size) {
|
||||
setPoint(size.width, size.height);
|
||||
return *this;
|
||||
}
|
||||
|
@ -402,29 +423,29 @@ public:
|
|||
CCSize size;
|
||||
|
||||
public:
|
||||
inline CCRect() {
|
||||
inline constexpr CCRect() {
|
||||
setRect(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
inline CCRect(float x, float y, float width, float height) {
|
||||
inline constexpr CCRect(float x, float y, float width, float height) {
|
||||
setRect(x, y, width, height);
|
||||
}
|
||||
inline CCRect(CCPoint const& a, CCPoint const& b) {
|
||||
inline constexpr CCRect(CCPoint const& a, CCPoint const& b) {
|
||||
setRect(a.x, a.y, b.x, b.y);
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCRect(const CCRect& other) {
|
||||
inline constexpr CCRect(const CCRect& other) {
|
||||
setRect(other.origin.x, other.origin.y, other.size.width, other.size.height);
|
||||
}
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
inline CCRect& operator= (const CCRect& other) {
|
||||
inline constexpr CCRect& operator= (const CCRect& other) {
|
||||
setRect(other.origin.x, other.origin.y, other.size.width, other.size.height);
|
||||
return *this;
|
||||
}
|
||||
inline void setRect(float x, float y, float width, float height) {
|
||||
inline constexpr void setRect(float x, float y, float width, float height) {
|
||||
// CGRect can support width<0 or height<0
|
||||
// CCAssert(width >= 0.0f && height >= 0.0f, "width and height of Rect must not less than 0.");
|
||||
|
||||
|
@ -435,28 +456,28 @@ public:
|
|||
size.height = height;
|
||||
}
|
||||
|
||||
inline float getMinX() const {
|
||||
inline constexpr float getMinX() const {
|
||||
return origin.x;
|
||||
} /// return the leftmost x-value of current rect
|
||||
inline float getMidX() const {
|
||||
inline constexpr float getMidX() const {
|
||||
return (float)(origin.x + size.width / 2.0);
|
||||
} /// return the midpoint x-value of current rect
|
||||
inline float getMaxX() const {
|
||||
inline constexpr float getMaxX() const {
|
||||
return (float)(origin.x + size.width);
|
||||
} /// return the rightmost x-value of current rect
|
||||
inline float getMinY() const {
|
||||
inline constexpr float getMinY() const {
|
||||
return origin.y;
|
||||
} /// return the bottommost y-value of current rect
|
||||
inline float getMidY() const {
|
||||
inline constexpr float getMidY() const {
|
||||
return (float)(origin.y + size.height / 2.0);
|
||||
} /// return the midpoint y-value of current rect
|
||||
inline float getMaxY() const {
|
||||
inline constexpr float getMaxY() const {
|
||||
return origin.y + size.height;
|
||||
} /// return the topmost y-value of current rect
|
||||
inline bool equals(const CCRect& rect) const {
|
||||
inline constexpr bool equals(const CCRect& rect) const {
|
||||
return (origin.equals(rect.origin) && size.equals(rect.size));
|
||||
}
|
||||
inline bool containsPoint(const CCPoint& point) const {
|
||||
inline constexpr bool containsPoint(const CCPoint& point) const {
|
||||
bool bRet = false;
|
||||
|
||||
if (point.x >= getMinX() && point.x <= getMaxX()
|
||||
|
@ -468,7 +489,7 @@ public:
|
|||
return bRet;
|
||||
}
|
||||
|
||||
inline bool intersectsRect(const CCRect& rect) const {
|
||||
inline constexpr bool intersectsRect(const CCRect& rect) const {
|
||||
// lmao
|
||||
return !( getMaxX() < rect.getMinX() ||
|
||||
rect.getMaxX() < getMinX() ||
|
||||
|
@ -476,8 +497,12 @@ public:
|
|||
rect.getMaxY() < getMinY());
|
||||
}
|
||||
|
||||
float getMax(int);
|
||||
float getMin(int);
|
||||
constexpr float getMax(int idx) {
|
||||
return idx == 0 ? getMaxX() : getMaxY();
|
||||
}
|
||||
constexpr float getMin(int idx) {
|
||||
return idx == 0 ? getMinX() : getMinY();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -30,28 +30,28 @@ struct matjson::Serialize<cocos2d::ccColor4B> {
|
|||
|
||||
// operators for CC geometry
|
||||
namespace cocos2d {
|
||||
static cocos2d::CCPoint& operator*=(cocos2d::CCPoint& pos, float mul) {
|
||||
static constexpr cocos2d::CCPoint& operator*=(cocos2d::CCPoint& pos, float mul) {
|
||||
pos.x *= mul;
|
||||
pos.y *= mul;
|
||||
return pos;
|
||||
}
|
||||
static cocos2d::CCSize& operator*=(cocos2d::CCSize& size, float mul) {
|
||||
static constexpr cocos2d::CCSize& operator*=(cocos2d::CCSize& size, float mul) {
|
||||
size.width *= mul;
|
||||
size.height *= mul;
|
||||
return size;
|
||||
}
|
||||
static cocos2d::CCSize operator*(cocos2d::CCSize const& size, cocos2d::CCPoint const& point) {
|
||||
static constexpr cocos2d::CCSize operator*(cocos2d::CCSize const& size, cocos2d::CCPoint const& point) {
|
||||
return {
|
||||
size.width * point.x,
|
||||
size.height * point.y,
|
||||
};
|
||||
}
|
||||
static cocos2d::CCRect operator*=(cocos2d::CCRect& rect, float mul) {
|
||||
static constexpr cocos2d::CCRect operator*=(cocos2d::CCRect& rect, float mul) {
|
||||
rect.origin *= mul;
|
||||
rect.size *= mul;
|
||||
return rect;
|
||||
}
|
||||
static cocos2d::CCRect operator*(cocos2d::CCRect const& rect, float mul) {
|
||||
static constexpr cocos2d::CCRect operator*(cocos2d::CCRect const& rect, float mul) {
|
||||
return {
|
||||
rect.origin.x * mul,
|
||||
rect.origin.y * mul,
|
||||
|
@ -59,131 +59,131 @@ namespace cocos2d {
|
|||
rect.size.height * mul,
|
||||
};
|
||||
}
|
||||
static cocos2d::CCPoint operator/=(cocos2d::CCPoint& pos, float div) {
|
||||
static constexpr cocos2d::CCPoint operator/=(cocos2d::CCPoint& pos, float div) {
|
||||
pos.x /= div;
|
||||
pos.y /= div;
|
||||
return pos;
|
||||
}
|
||||
static cocos2d::CCSize operator/=(cocos2d::CCSize& size, float div) {
|
||||
static constexpr cocos2d::CCSize operator/=(cocos2d::CCSize& size, float div) {
|
||||
size.width /= div;
|
||||
size.height /= div;
|
||||
return size;
|
||||
}
|
||||
static cocos2d::CCRect operator/=(cocos2d::CCRect& rect, float div) {
|
||||
static constexpr cocos2d::CCRect operator/=(cocos2d::CCRect& rect, float div) {
|
||||
rect.origin /= div;
|
||||
rect.size /= div;
|
||||
return rect;
|
||||
}
|
||||
static cocos2d::CCPoint operator+=(cocos2d::CCPoint& pos, cocos2d::CCPoint const& add) {
|
||||
static constexpr cocos2d::CCPoint operator+=(cocos2d::CCPoint& pos, cocos2d::CCPoint const& add) {
|
||||
pos.x += add.x;
|
||||
pos.y += add.y;
|
||||
return pos;
|
||||
}
|
||||
static cocos2d::CCSize operator+=(cocos2d::CCSize& size, cocos2d::CCPoint const& add) {
|
||||
static constexpr cocos2d::CCSize operator+=(cocos2d::CCSize& size, cocos2d::CCPoint const& add) {
|
||||
size.width += add.x;
|
||||
size.height += add.y;
|
||||
return size;
|
||||
}
|
||||
static cocos2d::CCSize operator+=(cocos2d::CCSize& size, cocos2d::CCSize const& add) {
|
||||
static constexpr cocos2d::CCSize operator+=(cocos2d::CCSize& size, cocos2d::CCSize const& add) {
|
||||
size.width += add.width;
|
||||
size.height += add.height;
|
||||
return size;
|
||||
}
|
||||
static cocos2d::CCRect operator+=(cocos2d::CCRect& rect, cocos2d::CCPoint const& add) {
|
||||
static constexpr cocos2d::CCRect operator+=(cocos2d::CCRect& rect, cocos2d::CCPoint const& add) {
|
||||
rect.origin += add;
|
||||
return rect;
|
||||
}
|
||||
static cocos2d::CCRect operator+=(cocos2d::CCRect& rect, cocos2d::CCSize const& add) {
|
||||
static constexpr cocos2d::CCRect operator+=(cocos2d::CCRect& rect, cocos2d::CCSize const& add) {
|
||||
rect.size += add;
|
||||
return rect;
|
||||
}
|
||||
static cocos2d::CCRect operator+=(cocos2d::CCRect& rect, cocos2d::CCRect const& add) {
|
||||
static constexpr cocos2d::CCRect operator+=(cocos2d::CCRect& rect, cocos2d::CCRect const& add) {
|
||||
rect.origin += add.origin;
|
||||
rect.size += add.size;
|
||||
return rect;
|
||||
}
|
||||
static cocos2d::CCPoint operator-=(cocos2d::CCPoint& pos, cocos2d::CCPoint const& add) {
|
||||
static constexpr cocos2d::CCPoint operator-=(cocos2d::CCPoint& pos, cocos2d::CCPoint const& add) {
|
||||
pos.x -= add.x;
|
||||
pos.y -= add.y;
|
||||
return pos;
|
||||
}
|
||||
static cocos2d::CCSize operator-=(cocos2d::CCSize& size, cocos2d::CCPoint const& add) {
|
||||
static constexpr cocos2d::CCSize operator-=(cocos2d::CCSize& size, cocos2d::CCPoint const& add) {
|
||||
size.width -= add.x;
|
||||
size.height -= add.y;
|
||||
return size;
|
||||
}
|
||||
static cocos2d::CCSize operator-=(cocos2d::CCSize& size, cocos2d::CCSize const& add) {
|
||||
static constexpr cocos2d::CCSize operator-=(cocos2d::CCSize& size, cocos2d::CCSize const& add) {
|
||||
size.width -= add.width;
|
||||
size.height -= add.height;
|
||||
return size;
|
||||
}
|
||||
static cocos2d::CCRect operator-=(cocos2d::CCRect& rect, cocos2d::CCPoint const& add) {
|
||||
static constexpr cocos2d::CCRect operator-=(cocos2d::CCRect& rect, cocos2d::CCPoint const& add) {
|
||||
rect.origin -= add;
|
||||
return rect;
|
||||
}
|
||||
static cocos2d::CCRect operator-=(cocos2d::CCRect& rect, cocos2d::CCSize const& add) {
|
||||
static constexpr cocos2d::CCRect operator-=(cocos2d::CCRect& rect, cocos2d::CCSize const& add) {
|
||||
rect.size -= add;
|
||||
return rect;
|
||||
}
|
||||
static cocos2d::CCRect operator-=(cocos2d::CCRect& rect, cocos2d::CCRect const& add) {
|
||||
static constexpr cocos2d::CCRect operator-=(cocos2d::CCRect& rect, cocos2d::CCRect const& add) {
|
||||
rect.origin -= add.origin;
|
||||
rect.size -= add.size;
|
||||
return rect;
|
||||
}
|
||||
static cocos2d::CCSize operator-(cocos2d::CCSize const& size, float f) {
|
||||
static constexpr cocos2d::CCSize operator-(cocos2d::CCSize const& size, float f) {
|
||||
return {size.width - f, size.height - f};
|
||||
}
|
||||
static cocos2d::CCSize operator-(cocos2d::CCSize const& size) {
|
||||
static constexpr cocos2d::CCSize operator-(cocos2d::CCSize const& size) {
|
||||
return {-size.width, -size.height};
|
||||
}
|
||||
static bool operator==(cocos2d::CCPoint const& p1, cocos2d::CCPoint const& p2) {
|
||||
static constexpr bool operator==(cocos2d::CCPoint const& p1, cocos2d::CCPoint const& p2) {
|
||||
return p1.x == p2.x && p1.y == p2.y;
|
||||
}
|
||||
static bool operator!=(cocos2d::CCPoint const& p1, cocos2d::CCPoint const& p2) {
|
||||
static constexpr bool operator!=(cocos2d::CCPoint const& p1, cocos2d::CCPoint const& p2) {
|
||||
return p1.x != p2.x || p1.y != p2.y;
|
||||
}
|
||||
static bool operator==(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
static constexpr bool operator==(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
return s1.width == s2.width && s1.height == s2.height;
|
||||
}
|
||||
static bool operator!=(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
static constexpr bool operator!=(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
return s1.width != s2.width || s1.height != s2.height;
|
||||
}
|
||||
static bool operator<(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
static constexpr bool operator<(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
return s1.width < s2.width && s1.height < s2.height;
|
||||
}
|
||||
static bool operator<=(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
static constexpr bool operator<=(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
return s1.width <= s2.width && s1.height <= s2.height;
|
||||
}
|
||||
static bool operator>(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
static constexpr bool operator>(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
return s1.width > s2.width && s1.height > s2.height;
|
||||
}
|
||||
static bool operator>=(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
static constexpr bool operator>=(cocos2d::CCSize const& s1, cocos2d::CCSize const& s2) {
|
||||
return s1.width >= s2.width && s1.height >= s2.height;
|
||||
}
|
||||
static bool operator==(cocos2d::CCRect const& r1, cocos2d::CCRect const& r2) {
|
||||
static constexpr bool operator==(cocos2d::CCRect const& r1, cocos2d::CCRect const& r2) {
|
||||
return r1.origin == r2.origin && r1.size == r2.size;
|
||||
}
|
||||
static bool operator!=(cocos2d::CCRect const& r1, cocos2d::CCRect const& r2) {
|
||||
static constexpr bool operator!=(cocos2d::CCRect const& r1, cocos2d::CCRect const& r2) {
|
||||
return r1.origin != r2.origin || r1.size != r2.size;
|
||||
}
|
||||
static bool operator==(cocos2d::ccColor4B const& c1, cocos2d::ccColor4B const& c2) {
|
||||
static constexpr bool operator==(cocos2d::ccColor4B const& c1, cocos2d::ccColor4B const& c2) {
|
||||
return c1.r == c2.r && c1.g == c2.g && c1.b == c2.b && c1.a == c2.a;
|
||||
}
|
||||
static bool operator!=(cocos2d::ccColor4B const& c1, cocos2d::ccColor4B const& c2) {
|
||||
static constexpr bool operator!=(cocos2d::ccColor4B const& c1, cocos2d::ccColor4B const& c2) {
|
||||
return c1.r != c2.r || c1.g != c2.g || c1.b != c2.b || c1.a != c2.a;
|
||||
}
|
||||
static bool operator==(cocos2d::ccColor3B const& c1, cocos2d::ccColor3B const& c2) {
|
||||
static constexpr bool operator==(cocos2d::ccColor3B const& c1, cocos2d::ccColor3B const& c2) {
|
||||
return c1.r == c2.r && c1.g == c2.g && c1.b == c2.b;
|
||||
}
|
||||
static bool operator!=(cocos2d::ccColor3B const& c1, cocos2d::ccColor3B const& c2) {
|
||||
static constexpr bool operator!=(cocos2d::ccColor3B const& c1, cocos2d::ccColor3B const& c2) {
|
||||
return c1.r != c2.r || c1.g != c2.g || c1.b != c2.b;
|
||||
}
|
||||
static bool operator==(cocos2d::ccHSVValue const& c1, cocos2d::ccHSVValue const& c2) {
|
||||
static constexpr bool operator==(cocos2d::ccHSVValue const& c1, cocos2d::ccHSVValue const& c2) {
|
||||
return c1.h == c2.h && c1.s == c2.s && c1.v == c2.v &&
|
||||
c1.absoluteSaturation == c2.absoluteSaturation &&
|
||||
c1.absoluteBrightness == c2.absoluteBrightness;
|
||||
}
|
||||
static bool operator!=(cocos2d::ccHSVValue const& c1, cocos2d::ccHSVValue const& c2) {
|
||||
static constexpr bool operator!=(cocos2d::ccHSVValue const& c1, cocos2d::ccHSVValue const& c2) {
|
||||
return !(c1 == c2);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue