diff --git a/loader/include/Geode/cocos/cocoa/CCGeometry.h b/loader/include/Geode/cocos/cocoa/CCGeometry.h index c3312f22e..21b216e92 100644 --- a/loader/include/Geode/cocos/cocoa/CCGeometry.h +++ b/loader/include/Geode/cocos/cocoa/CCGeometry.h @@ -126,7 +126,7 @@ class CC_DLL CCPoint } inline constexpr bool equals(const CCPoint& target) const { - return (fabs(this->x - target.x) < FLT_EPSILON) && (fabs(this->y - target.y) < FLT_EPSILON); + return this->fuzzyEquals(target, FLT_EPSILON); } /** @returns if points have fuzzy equality which means equal with some degree of variance. @@ -145,7 +145,7 @@ class CC_DLL CCPoint * @since v2.1.4 * @lua NA */ - inline constexpr float getLength() const { + inline float getLength() const { return sqrtf(x*x + y*y); }; @@ -177,14 +177,14 @@ class CC_DLL CCPoint /** @returns the angle in radians between this vector and the x axis @since v2.1.4 */ - inline constexpr float getAngle() const { + inline float getAngle() const { return atan2f(y, x); }; /** @returns the angle in radians between two vector directions @since v2.1.4 */ - inline constexpr float getAngle(const CCPoint& other) const { + inline float getAngle(const CCPoint& other) const { CCPoint a2 = normalize(); CCPoint b2 = other.normalize(); float angle = atan2f(a2.cross(b2), a2.dot(b2)); @@ -375,7 +375,14 @@ class CC_DLL CCSize * @lua NA */ inline constexpr bool equals(const CCSize& target) const { - return (fabs(this->width - target.width) < FLT_EPSILON) && (fabs(this->height - target.height) < FLT_EPSILON); + return this->fuzzyEquals(target, FLT_EPSILON); + } + + inline constexpr bool fuzzyEquals(const CCSize& b, float var) const { + if(width - var <= b.width && b.width <= width + var) + if(height - var <= b.height && b.height <= height + var) + return true; + return false; } /** * Get the aspect ratio of this CCSize