mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-06 06:10:06 +03:00
Synchronize most shared variant code with Godot 4.4
(cherry picked from commit 075b517d96)
This commit is contained in:
@@ -59,12 +59,12 @@ struct [[nodiscard]] Vector4i {
|
||||
int32_t coord[4] = { 0 };
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ const int32_t &operator[](const int p_axis) const {
|
||||
_FORCE_INLINE_ const int32_t &operator[](int p_axis) const {
|
||||
DEV_ASSERT((unsigned int)p_axis < 4);
|
||||
return coord[p_axis];
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ int32_t &operator[](const int p_axis) {
|
||||
_FORCE_INLINE_ int32_t &operator[](int p_axis) {
|
||||
DEV_ASSERT((unsigned int)p_axis < 4);
|
||||
return coord[p_axis];
|
||||
}
|
||||
@@ -91,17 +91,17 @@ struct [[nodiscard]] Vector4i {
|
||||
_FORCE_INLINE_ int64_t length_squared() const;
|
||||
_FORCE_INLINE_ double length() const;
|
||||
|
||||
_FORCE_INLINE_ int64_t distance_squared_to(const Vector4i &p_to) const;
|
||||
_FORCE_INLINE_ double distance_to(const Vector4i &p_to) const;
|
||||
|
||||
_FORCE_INLINE_ void zero();
|
||||
|
||||
_FORCE_INLINE_ double distance_to(const Vector4i &p_to) const;
|
||||
_FORCE_INLINE_ int64_t distance_squared_to(const Vector4i &p_to) const;
|
||||
|
||||
_FORCE_INLINE_ Vector4i abs() const;
|
||||
_FORCE_INLINE_ Vector4i sign() const;
|
||||
Vector4i snapped(const Vector4i &p_step) const;
|
||||
Vector4i snappedi(int32_t p_step) const;
|
||||
Vector4i clamp(const Vector4i &p_min, const Vector4i &p_max) const;
|
||||
Vector4i clampi(int32_t p_min, int32_t p_max) const;
|
||||
Vector4i snapped(const Vector4i &p_step) const;
|
||||
Vector4i snappedi(int32_t p_step) const;
|
||||
|
||||
/* Operators */
|
||||
|
||||
@@ -116,12 +116,12 @@ struct [[nodiscard]] Vector4i {
|
||||
_FORCE_INLINE_ Vector4i &operator%=(const Vector4i &p_v);
|
||||
_FORCE_INLINE_ Vector4i operator%(const Vector4i &p_v) const;
|
||||
|
||||
_FORCE_INLINE_ Vector4i &operator*=(const int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector4i operator*(const int32_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector4i &operator/=(const int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector4i operator/(const int32_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector4i &operator%=(const int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector4i operator%(const int32_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector4i &operator*=(int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector4i operator*(int32_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector4i &operator/=(int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector4i operator/(int32_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector4i &operator%=(int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector4i operator%(int32_t p_scalar) const;
|
||||
|
||||
_FORCE_INLINE_ Vector4i operator-() const;
|
||||
|
||||
@@ -137,7 +137,7 @@ struct [[nodiscard]] Vector4i {
|
||||
|
||||
_FORCE_INLINE_ Vector4i() {}
|
||||
Vector4i(const Vector4 &p_vec4);
|
||||
_FORCE_INLINE_ Vector4i(const int32_t p_x, const int32_t p_y, const int32_t p_z, const int32_t p_w) {
|
||||
_FORCE_INLINE_ Vector4i(int32_t p_x, int32_t p_y, int32_t p_z, int32_t p_w) {
|
||||
x = p_x;
|
||||
y = p_y;
|
||||
z = p_z;
|
||||
@@ -153,20 +153,20 @@ double Vector4i::length() const {
|
||||
return Math::sqrt((double)length_squared());
|
||||
}
|
||||
|
||||
int64_t Vector4i::distance_squared_to(const Vector4i &p_to) const {
|
||||
return (p_to - *this).length_squared();
|
||||
}
|
||||
|
||||
double Vector4i::distance_to(const Vector4i &p_to) const {
|
||||
return (p_to - *this).length();
|
||||
}
|
||||
|
||||
int64_t Vector4i::distance_squared_to(const Vector4i &p_to) const {
|
||||
return (p_to - *this).length_squared();
|
||||
}
|
||||
|
||||
Vector4i Vector4i::abs() const {
|
||||
return Vector4i(Math::abs(x), Math::abs(y), Math::abs(z), Math::abs(w));
|
||||
}
|
||||
|
||||
Vector4i Vector4i::sign() const {
|
||||
return Vector4i(Math::sign(x), Math::sign(y), Math::sign(z), Math::sign(w));
|
||||
return Vector4i(SIGN(x), SIGN(y), SIGN(z), SIGN(w));
|
||||
}
|
||||
|
||||
/* Operators */
|
||||
@@ -231,7 +231,7 @@ Vector4i Vector4i::operator%(const Vector4i &p_v) const {
|
||||
return Vector4i(x % p_v.x, y % p_v.y, z % p_v.z, w % p_v.w);
|
||||
}
|
||||
|
||||
Vector4i &Vector4i::operator*=(const int32_t p_scalar) {
|
||||
Vector4i &Vector4i::operator*=(int32_t p_scalar) {
|
||||
x *= p_scalar;
|
||||
y *= p_scalar;
|
||||
z *= p_scalar;
|
||||
@@ -239,29 +239,29 @@ Vector4i &Vector4i::operator*=(const int32_t p_scalar) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector4i Vector4i::operator*(const int32_t p_scalar) const {
|
||||
Vector4i Vector4i::operator*(int32_t p_scalar) const {
|
||||
return Vector4i(x * p_scalar, y * p_scalar, z * p_scalar, w * p_scalar);
|
||||
}
|
||||
|
||||
// Multiplication operators required to workaround issues with LLVM using implicit conversion.
|
||||
|
||||
_FORCE_INLINE_ Vector4i operator*(const int32_t p_scalar, const Vector4i &p_vector) {
|
||||
_FORCE_INLINE_ Vector4i operator*(int32_t p_scalar, const Vector4i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector4i operator*(const int64_t p_scalar, const Vector4i &p_vector) {
|
||||
_FORCE_INLINE_ Vector4i operator*(int64_t p_scalar, const Vector4i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector4i operator*(const float p_scalar, const Vector4i &p_vector) {
|
||||
_FORCE_INLINE_ Vector4i operator*(float p_scalar, const Vector4i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector4i operator*(const double p_scalar, const Vector4i &p_vector) {
|
||||
_FORCE_INLINE_ Vector4i operator*(double p_scalar, const Vector4i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
Vector4i &Vector4i::operator/=(const int32_t p_scalar) {
|
||||
Vector4i &Vector4i::operator/=(int32_t p_scalar) {
|
||||
x /= p_scalar;
|
||||
y /= p_scalar;
|
||||
z /= p_scalar;
|
||||
@@ -269,11 +269,11 @@ Vector4i &Vector4i::operator/=(const int32_t p_scalar) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector4i Vector4i::operator/(const int32_t p_scalar) const {
|
||||
Vector4i Vector4i::operator/(int32_t p_scalar) const {
|
||||
return Vector4i(x / p_scalar, y / p_scalar, z / p_scalar, w / p_scalar);
|
||||
}
|
||||
|
||||
Vector4i &Vector4i::operator%=(const int32_t p_scalar) {
|
||||
Vector4i &Vector4i::operator%=(int32_t p_scalar) {
|
||||
x %= p_scalar;
|
||||
y %= p_scalar;
|
||||
z %= p_scalar;
|
||||
@@ -281,7 +281,7 @@ Vector4i &Vector4i::operator%=(const int32_t p_scalar) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector4i Vector4i::operator%(const int32_t p_scalar) const {
|
||||
Vector4i Vector4i::operator%(int32_t p_scalar) const {
|
||||
return Vector4i(x % p_scalar, y % p_scalar, z % p_scalar, w % p_scalar);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user