Skip to content

Commit

Permalink
Merge pull request #1197 from AThousandShips/vec_elem
Browse files Browse the repository at this point in the history
Add remaining component-wise `min/max` functions to `Vector*`
  • Loading branch information
dsnopek authored Aug 16, 2023
2 parents 112e41b + 52eb77e commit 7ed7a84
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/godot_cpp/variant/vector3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ struct _NO_DISCARD_ Vector3 {
return x < y ? (y < z ? Vector3::AXIS_Z : Vector3::AXIS_Y) : (x < z ? Vector3::AXIS_Z : Vector3::AXIS_X);
}

Vector3 min(const Vector3 &p_vector3) const {
return Vector3(MIN(x, p_vector3.x), MIN(y, p_vector3.y), MIN(z, p_vector3.z));
}

Vector3 max(const Vector3 &p_vector3) const {
return Vector3(MAX(x, p_vector3.x), MAX(y, p_vector3.y), MAX(z, p_vector3.z));
}

_FORCE_INLINE_ real_t length() const;
_FORCE_INLINE_ real_t length_squared() const;

Expand Down
8 changes: 8 additions & 0 deletions include/godot_cpp/variant/vector3i.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ struct _NO_DISCARD_ Vector3i {
Vector3i::Axis min_axis_index() const;
Vector3i::Axis max_axis_index() const;

Vector3i min(const Vector3i &p_vector3i) const {
return Vector3i(MIN(x, p_vector3i.x), MIN(y, p_vector3i.y), MIN(z, p_vector3i.z));
}

Vector3i max(const Vector3i &p_vector3i) const {
return Vector3i(MAX(x, p_vector3i.x), MAX(y, p_vector3i.y), MAX(z, p_vector3i.z));
}

_FORCE_INLINE_ int64_t length_squared() const;
_FORCE_INLINE_ double length() const;

Expand Down
8 changes: 8 additions & 0 deletions include/godot_cpp/variant/vector4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ struct _NO_DISCARD_ Vector4 {
Vector4::Axis min_axis_index() const;
Vector4::Axis max_axis_index() const;

Vector4 min(const Vector4 &p_vector4) const {
return Vector4(MIN(x, p_vector4.x), MIN(y, p_vector4.y), MIN(z, p_vector4.z), MIN(w, p_vector4.w));
}

Vector4 max(const Vector4 &p_vector4) const {
return Vector4(MAX(x, p_vector4.x), MAX(y, p_vector4.y), MAX(z, p_vector4.z), MAX(w, p_vector4.w));
}

_FORCE_INLINE_ real_t length_squared() const;
bool is_equal_approx(const Vector4 &p_vec4) const;
bool is_zero_approx() const;
Expand Down
8 changes: 8 additions & 0 deletions include/godot_cpp/variant/vector4i.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ struct _NO_DISCARD_ Vector4i {
Vector4i::Axis min_axis_index() const;
Vector4i::Axis max_axis_index() const;

Vector4i min(const Vector4i &p_vector4i) const {
return Vector4i(MIN(x, p_vector4i.x), MIN(y, p_vector4i.y), MIN(z, p_vector4i.z), MIN(w, p_vector4i.w));
}

Vector4i max(const Vector4i &p_vector4i) const {
return Vector4i(MAX(x, p_vector4i.x), MAX(y, p_vector4i.y), MAX(z, p_vector4i.z), MAX(w, p_vector4i.w));
}

_FORCE_INLINE_ int64_t length_squared() const;
_FORCE_INLINE_ double length() const;

Expand Down

0 comments on commit 7ed7a84

Please sign in to comment.