mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-03 18:09:13 +03:00
Synchronize most shared variant code with Godot 4.4
This commit is contained in:
@@ -72,16 +72,21 @@ struct [[nodiscard]] AABB {
|
||||
AABB merge(const AABB &p_with) const;
|
||||
void merge_with(const AABB &p_aabb); ///merge with another AABB
|
||||
AABB intersection(const AABB &p_aabb) const; ///get box where two intersect, empty if no intersection occurs
|
||||
bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip = nullptr, Vector3 *r_normal = nullptr) const;
|
||||
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = nullptr, Vector3 *r_normal = nullptr) const;
|
||||
_FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const;
|
||||
_FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t p_t0, real_t p_t1) const;
|
||||
|
||||
bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_intersection_point = nullptr, Vector3 *r_normal = nullptr) const;
|
||||
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir) const {
|
||||
bool inside;
|
||||
return find_intersects_ray(p_from, p_dir, inside);
|
||||
}
|
||||
bool find_intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, bool &r_inside, Vector3 *r_intersection_point = nullptr, Vector3 *r_normal = nullptr) const;
|
||||
|
||||
_FORCE_INLINE_ bool intersects_convex_shape(const Plane *p_planes, int p_plane_count, const Vector3 *p_points, int p_point_count) const;
|
||||
_FORCE_INLINE_ bool inside_convex_shape(const Plane *p_planes, int p_plane_count) const;
|
||||
bool intersects_plane(const Plane &p_plane) const;
|
||||
|
||||
_FORCE_INLINE_ bool has_point(const Vector3 &p_point) const;
|
||||
_FORCE_INLINE_ Vector3 get_support(const Vector3 &p_normal) const;
|
||||
_FORCE_INLINE_ Vector3 get_support(const Vector3 &p_direction) const;
|
||||
|
||||
Vector3 get_longest_axis() const;
|
||||
int get_longest_axis_index() const;
|
||||
@@ -208,15 +213,18 @@ inline bool AABB::encloses(const AABB &p_aabb) const {
|
||||
(src_max.z >= dst_max.z));
|
||||
}
|
||||
|
||||
Vector3 AABB::get_support(const Vector3 &p_normal) const {
|
||||
Vector3 half_extents = size * 0.5f;
|
||||
Vector3 ofs = position + half_extents;
|
||||
|
||||
return Vector3(
|
||||
(p_normal.x > 0) ? half_extents.x : -half_extents.x,
|
||||
(p_normal.y > 0) ? half_extents.y : -half_extents.y,
|
||||
(p_normal.z > 0) ? half_extents.z : -half_extents.z) +
|
||||
ofs;
|
||||
Vector3 AABB::get_support(const Vector3 &p_direction) const {
|
||||
Vector3 support = position;
|
||||
if (p_direction.x > 0.0f) {
|
||||
support.x += size.x;
|
||||
}
|
||||
if (p_direction.y > 0.0f) {
|
||||
support.y += size.y;
|
||||
}
|
||||
if (p_direction.z > 0.0f) {
|
||||
support.z += size.z;
|
||||
}
|
||||
return support;
|
||||
}
|
||||
|
||||
Vector3 AABB::get_endpoint(int p_point) const {
|
||||
@@ -402,7 +410,7 @@ inline real_t AABB::get_shortest_axis_size() const {
|
||||
return max_size;
|
||||
}
|
||||
|
||||
bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const {
|
||||
bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t p_t0, real_t p_t1) const {
|
||||
#ifdef MATH_CHECKS
|
||||
if (unlikely(size.x < 0 || size.y < 0 || size.z < 0)) {
|
||||
ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size.");
|
||||
@@ -453,7 +461,7 @@ bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real
|
||||
if (tzmax < tmax) {
|
||||
tmax = tzmax;
|
||||
}
|
||||
return ((tmin < t1) && (tmax > t0));
|
||||
return ((tmin < p_t1) && (tmax > p_t0));
|
||||
}
|
||||
|
||||
void AABB::grow_by(real_t p_amount) {
|
||||
|
||||
@@ -43,11 +43,11 @@ struct [[nodiscard]] Basis {
|
||||
Vector3(0, 0, 1)
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ const Vector3 &operator[](int axis) const {
|
||||
return rows[axis];
|
||||
_FORCE_INLINE_ const Vector3 &operator[](int p_row) const {
|
||||
return rows[p_row];
|
||||
}
|
||||
_FORCE_INLINE_ Vector3 &operator[](int axis) {
|
||||
return rows[axis];
|
||||
_FORCE_INLINE_ Vector3 &operator[](int p_row) {
|
||||
return rows[p_row];
|
||||
}
|
||||
|
||||
void invert();
|
||||
@@ -58,21 +58,19 @@ struct [[nodiscard]] Basis {
|
||||
|
||||
_FORCE_INLINE_ real_t determinant() const;
|
||||
|
||||
void from_z(const Vector3 &p_z);
|
||||
|
||||
void rotate(const Vector3 &p_axis, real_t p_angle);
|
||||
Basis rotated(const Vector3 &p_axis, real_t p_angle) const;
|
||||
|
||||
void rotate_local(const Vector3 &p_axis, real_t p_angle);
|
||||
Basis rotated_local(const Vector3 &p_axis, real_t p_angle) const;
|
||||
|
||||
void rotate(const Vector3 &p_euler, EulerOrder p_order = EULER_ORDER_YXZ);
|
||||
Basis rotated(const Vector3 &p_euler, EulerOrder p_order = EULER_ORDER_YXZ) const;
|
||||
void rotate(const Vector3 &p_euler, EulerOrder p_order = EulerOrder::EULER_ORDER_YXZ);
|
||||
Basis rotated(const Vector3 &p_euler, EulerOrder p_order = EulerOrder::EULER_ORDER_YXZ) const;
|
||||
|
||||
void rotate(const Quaternion &p_quaternion);
|
||||
Basis rotated(const Quaternion &p_quaternion) const;
|
||||
|
||||
Vector3 get_euler_normalized(EulerOrder p_order = EULER_ORDER_YXZ) const;
|
||||
Vector3 get_euler_normalized(EulerOrder p_order = EulerOrder::EULER_ORDER_YXZ) const;
|
||||
void get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const;
|
||||
void get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) const;
|
||||
Quaternion get_rotation_quaternion() const;
|
||||
@@ -81,9 +79,9 @@ struct [[nodiscard]] Basis {
|
||||
|
||||
Vector3 rotref_posscale_decomposition(Basis &rotref) const;
|
||||
|
||||
Vector3 get_euler(EulerOrder p_order = EULER_ORDER_YXZ) const;
|
||||
void set_euler(const Vector3 &p_euler, EulerOrder p_order = EULER_ORDER_YXZ);
|
||||
static Basis from_euler(const Vector3 &p_euler, EulerOrder p_order = EULER_ORDER_YXZ) {
|
||||
Vector3 get_euler(EulerOrder p_order = EulerOrder::EULER_ORDER_YXZ) const;
|
||||
void set_euler(const Vector3 &p_euler, EulerOrder p_order = EulerOrder::EULER_ORDER_YXZ);
|
||||
static Basis from_euler(const Vector3 &p_euler, EulerOrder p_order = EulerOrder::EULER_ORDER_YXZ) {
|
||||
Basis b;
|
||||
b.set_euler(p_euler, p_order);
|
||||
return b;
|
||||
@@ -103,27 +101,25 @@ struct [[nodiscard]] Basis {
|
||||
|
||||
void scale_orthogonal(const Vector3 &p_scale);
|
||||
Basis scaled_orthogonal(const Vector3 &p_scale) const;
|
||||
|
||||
void make_scale_uniform();
|
||||
float get_uniform_scale() const;
|
||||
real_t get_uniform_scale() const;
|
||||
|
||||
Vector3 get_scale() const;
|
||||
Vector3 get_scale_abs() const;
|
||||
Vector3 get_scale_local() const;
|
||||
Vector3 get_scale_global() const;
|
||||
|
||||
void set_axis_angle_scale(const Vector3 &p_axis, real_t p_angle, const Vector3 &p_scale);
|
||||
void set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale, EulerOrder p_order = EULER_ORDER_YXZ);
|
||||
void set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale, EulerOrder p_order = EulerOrder::EULER_ORDER_YXZ);
|
||||
void set_quaternion_scale(const Quaternion &p_quaternion, const Vector3 &p_scale);
|
||||
|
||||
// transposed dot products
|
||||
_FORCE_INLINE_ real_t tdotx(const Vector3 &v) const {
|
||||
return rows[0][0] * v[0] + rows[1][0] * v[1] + rows[2][0] * v[2];
|
||||
_FORCE_INLINE_ real_t tdotx(const Vector3 &p_v) const {
|
||||
return rows[0][0] * p_v[0] + rows[1][0] * p_v[1] + rows[2][0] * p_v[2];
|
||||
}
|
||||
_FORCE_INLINE_ real_t tdoty(const Vector3 &v) const {
|
||||
return rows[0][1] * v[0] + rows[1][1] * v[1] + rows[2][1] * v[2];
|
||||
_FORCE_INLINE_ real_t tdoty(const Vector3 &p_v) const {
|
||||
return rows[0][1] * p_v[0] + rows[1][1] * p_v[1] + rows[2][1] * p_v[2];
|
||||
}
|
||||
_FORCE_INLINE_ real_t tdotz(const Vector3 &v) const {
|
||||
return rows[0][2] * v[0] + rows[1][2] * v[1] + rows[2][2] * v[2];
|
||||
_FORCE_INLINE_ real_t tdotz(const Vector3 &p_v) const {
|
||||
return rows[0][2] * p_v[0] + rows[1][2] * p_v[1] + rows[2][2] * p_v[2];
|
||||
}
|
||||
|
||||
bool is_equal_approx(const Basis &p_basis) const;
|
||||
@@ -140,31 +136,35 @@ struct [[nodiscard]] Basis {
|
||||
_FORCE_INLINE_ Basis operator+(const Basis &p_matrix) const;
|
||||
_FORCE_INLINE_ void operator-=(const Basis &p_matrix);
|
||||
_FORCE_INLINE_ Basis operator-(const Basis &p_matrix) const;
|
||||
_FORCE_INLINE_ void operator*=(const real_t p_val);
|
||||
_FORCE_INLINE_ Basis operator*(const real_t p_val) const;
|
||||
_FORCE_INLINE_ void operator*=(real_t p_val);
|
||||
_FORCE_INLINE_ Basis operator*(real_t p_val) const;
|
||||
_FORCE_INLINE_ void operator/=(real_t p_val);
|
||||
_FORCE_INLINE_ Basis operator/(real_t p_val) const;
|
||||
|
||||
bool is_orthogonal() const;
|
||||
bool is_orthonormal() const;
|
||||
bool is_conformal() const;
|
||||
bool is_diagonal() const;
|
||||
bool is_rotation() const;
|
||||
|
||||
Basis lerp(const Basis &p_to, const real_t &p_weight) const;
|
||||
Basis slerp(const Basis &p_to, const real_t &p_weight) const;
|
||||
Basis lerp(const Basis &p_to, real_t p_weight) const;
|
||||
Basis slerp(const Basis &p_to, real_t p_weight) const;
|
||||
void rotate_sh(real_t *p_values);
|
||||
|
||||
operator String() const;
|
||||
|
||||
/* create / set */
|
||||
|
||||
_FORCE_INLINE_ void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) {
|
||||
rows[0][0] = xx;
|
||||
rows[0][1] = xy;
|
||||
rows[0][2] = xz;
|
||||
rows[1][0] = yx;
|
||||
rows[1][1] = yy;
|
||||
rows[1][2] = yz;
|
||||
rows[2][0] = zx;
|
||||
rows[2][1] = zy;
|
||||
rows[2][2] = zz;
|
||||
_FORCE_INLINE_ void set(real_t p_xx, real_t p_xy, real_t p_xz, real_t p_yx, real_t p_yy, real_t p_yz, real_t p_zx, real_t p_zy, real_t p_zz) {
|
||||
rows[0][0] = p_xx;
|
||||
rows[0][1] = p_xy;
|
||||
rows[0][2] = p_xz;
|
||||
rows[1][0] = p_yx;
|
||||
rows[1][1] = p_yy;
|
||||
rows[1][2] = p_yz;
|
||||
rows[2][0] = p_zx;
|
||||
rows[2][1] = p_zy;
|
||||
rows[2][2] = p_zz;
|
||||
}
|
||||
_FORCE_INLINE_ void set_columns(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z) {
|
||||
set_column(0, p_x);
|
||||
@@ -194,20 +194,20 @@ struct [[nodiscard]] Basis {
|
||||
rows[2].zero();
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Basis transpose_xform(const Basis &m) const {
|
||||
_FORCE_INLINE_ Basis transpose_xform(const Basis &p_m) const {
|
||||
return Basis(
|
||||
rows[0].x * m[0].x + rows[1].x * m[1].x + rows[2].x * m[2].x,
|
||||
rows[0].x * m[0].y + rows[1].x * m[1].y + rows[2].x * m[2].y,
|
||||
rows[0].x * m[0].z + rows[1].x * m[1].z + rows[2].x * m[2].z,
|
||||
rows[0].y * m[0].x + rows[1].y * m[1].x + rows[2].y * m[2].x,
|
||||
rows[0].y * m[0].y + rows[1].y * m[1].y + rows[2].y * m[2].y,
|
||||
rows[0].y * m[0].z + rows[1].y * m[1].z + rows[2].y * m[2].z,
|
||||
rows[0].z * m[0].x + rows[1].z * m[1].x + rows[2].z * m[2].x,
|
||||
rows[0].z * m[0].y + rows[1].z * m[1].y + rows[2].z * m[2].y,
|
||||
rows[0].z * m[0].z + rows[1].z * m[1].z + rows[2].z * m[2].z);
|
||||
rows[0].x * p_m[0].x + rows[1].x * p_m[1].x + rows[2].x * p_m[2].x,
|
||||
rows[0].x * p_m[0].y + rows[1].x * p_m[1].y + rows[2].x * p_m[2].y,
|
||||
rows[0].x * p_m[0].z + rows[1].x * p_m[1].z + rows[2].x * p_m[2].z,
|
||||
rows[0].y * p_m[0].x + rows[1].y * p_m[1].x + rows[2].y * p_m[2].x,
|
||||
rows[0].y * p_m[0].y + rows[1].y * p_m[1].y + rows[2].y * p_m[2].y,
|
||||
rows[0].y * p_m[0].z + rows[1].y * p_m[1].z + rows[2].y * p_m[2].z,
|
||||
rows[0].z * p_m[0].x + rows[1].z * p_m[1].x + rows[2].z * p_m[2].x,
|
||||
rows[0].z * p_m[0].y + rows[1].z * p_m[1].y + rows[2].z * p_m[2].y,
|
||||
rows[0].z * p_m[0].z + rows[1].z * p_m[1].z + rows[2].z * p_m[2].z);
|
||||
}
|
||||
Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) {
|
||||
set(xx, xy, xz, yx, yy, yz, zx, zy, zz);
|
||||
Basis(real_t p_xx, real_t p_xy, real_t p_xz, real_t p_yx, real_t p_yy, real_t p_yz, real_t p_zx, real_t p_zy, real_t p_zz) {
|
||||
set(p_xx, p_xy, p_xz, p_yx, p_yy, p_yz, p_zx, p_zy, p_zz);
|
||||
}
|
||||
|
||||
void orthonormalize();
|
||||
@@ -281,18 +281,30 @@ _FORCE_INLINE_ Basis Basis::operator-(const Basis &p_matrix) const {
|
||||
return ret;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void Basis::operator*=(const real_t p_val) {
|
||||
_FORCE_INLINE_ void Basis::operator*=(real_t p_val) {
|
||||
rows[0] *= p_val;
|
||||
rows[1] *= p_val;
|
||||
rows[2] *= p_val;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Basis Basis::operator*(const real_t p_val) const {
|
||||
_FORCE_INLINE_ Basis Basis::operator*(real_t p_val) const {
|
||||
Basis ret(*this);
|
||||
ret *= p_val;
|
||||
return ret;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void Basis::operator/=(real_t p_val) {
|
||||
rows[0] /= p_val;
|
||||
rows[1] /= p_val;
|
||||
rows[2] /= p_val;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Basis Basis::operator/(real_t p_val) const {
|
||||
Basis ret(*this);
|
||||
ret /= p_val;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Vector3 Basis::xform(const Vector3 &p_vector) const {
|
||||
return Vector3(
|
||||
rows[0].dot(p_vector),
|
||||
|
||||
3631
include/godot_cpp/variant/char_range.inc.hpp
Normal file
3631
include/godot_cpp/variant/char_range.inc.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -30,58 +30,105 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
static _FORCE_INLINE_ bool is_ascii_upper_case(char32_t c) {
|
||||
return (c >= 'A' && c <= 'Z');
|
||||
#include "char_range.inc.hpp"
|
||||
|
||||
namespace godot {
|
||||
|
||||
#define BSEARCH_CHAR_RANGE(m_array) \
|
||||
int low = 0; \
|
||||
int high = sizeof(m_array) / sizeof(m_array[0]) - 1; \
|
||||
int middle = (low + high) / 2; \
|
||||
\
|
||||
while (low <= high) { \
|
||||
if (p_char < m_array[middle].start) { \
|
||||
high = middle - 1; \
|
||||
} else if (p_char > m_array[middle].end) { \
|
||||
low = middle + 1; \
|
||||
} else { \
|
||||
return true; \
|
||||
} \
|
||||
\
|
||||
middle = (low + high) / 2; \
|
||||
} \
|
||||
\
|
||||
return false
|
||||
|
||||
constexpr bool is_unicode_identifier_start(char32_t p_char) {
|
||||
BSEARCH_CHAR_RANGE(xid_start);
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_ascii_lower_case(char32_t c) {
|
||||
return (c >= 'a' && c <= 'z');
|
||||
constexpr bool is_unicode_identifier_continue(char32_t p_char) {
|
||||
BSEARCH_CHAR_RANGE(xid_continue);
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_digit(char32_t c) {
|
||||
return (c >= '0' && c <= '9');
|
||||
constexpr bool is_unicode_upper_case(char32_t p_char) {
|
||||
BSEARCH_CHAR_RANGE(uppercase_letter);
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_hex_digit(char32_t c) {
|
||||
return (is_digit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'));
|
||||
constexpr bool is_unicode_lower_case(char32_t p_char) {
|
||||
BSEARCH_CHAR_RANGE(lowercase_letter);
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_binary_digit(char32_t c) {
|
||||
return (c == '0' || c == '1');
|
||||
constexpr bool is_unicode_letter(char32_t p_char) {
|
||||
BSEARCH_CHAR_RANGE(unicode_letter);
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_ascii_char(char32_t c) {
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
#undef BSEARCH_CHAR_RANGE
|
||||
|
||||
constexpr bool is_ascii_upper_case(char32_t p_char) {
|
||||
return (p_char >= 'A' && p_char <= 'Z');
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_ascii_alphanumeric_char(char32_t c) {
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9');
|
||||
constexpr bool is_ascii_lower_case(char32_t p_char) {
|
||||
return (p_char >= 'a' && p_char <= 'z');
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_ascii_identifier_char(char32_t c) {
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
|
||||
constexpr bool is_digit(char32_t p_char) {
|
||||
return (p_char >= '0' && p_char <= '9');
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_symbol(char32_t c) {
|
||||
return c != '_' && ((c >= '!' && c <= '/') || (c >= ':' && c <= '@') || (c >= '[' && c <= '`') || (c >= '{' && c <= '~') || c == '\t' || c == ' ');
|
||||
constexpr bool is_hex_digit(char32_t p_char) {
|
||||
return (is_digit(p_char) || (p_char >= 'a' && p_char <= 'f') || (p_char >= 'A' && p_char <= 'F'));
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_control(char32_t p_char) {
|
||||
constexpr bool is_binary_digit(char32_t p_char) {
|
||||
return (p_char == '0' || p_char == '1');
|
||||
}
|
||||
|
||||
constexpr bool is_ascii_alphabet_char(char32_t p_char) {
|
||||
return (p_char >= 'a' && p_char <= 'z') || (p_char >= 'A' && p_char <= 'Z');
|
||||
}
|
||||
|
||||
constexpr bool is_ascii_alphanumeric_char(char32_t p_char) {
|
||||
return (p_char >= 'a' && p_char <= 'z') || (p_char >= 'A' && p_char <= 'Z') || (p_char >= '0' && p_char <= '9');
|
||||
}
|
||||
|
||||
constexpr bool is_ascii_identifier_char(char32_t p_char) {
|
||||
return (p_char >= 'a' && p_char <= 'z') || (p_char >= 'A' && p_char <= 'Z') || (p_char >= '0' && p_char <= '9') || p_char == '_';
|
||||
}
|
||||
|
||||
constexpr bool is_symbol(char32_t p_char) {
|
||||
return p_char != '_' && ((p_char >= '!' && p_char <= '/') || (p_char >= ':' && p_char <= '@') || (p_char >= '[' && p_char <= '`') || (p_char >= '{' && p_char <= '~') || p_char == '\t' || p_char == ' ');
|
||||
}
|
||||
|
||||
constexpr bool is_control(char32_t p_char) {
|
||||
return (p_char <= 0x001f) || (p_char >= 0x007f && p_char <= 0x009f);
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_whitespace(char32_t p_char) {
|
||||
return (p_char == ' ') || (p_char == 0x00a0) || (p_char == 0x1680) || (p_char >= 0x2000 && p_char <= 0x200a) || (p_char == 0x202f) || (p_char == 0x205f) || (p_char == 0x3000) || (p_char == 0x2028) || (p_char == 0x2029) || (p_char >= 0x0009 && p_char <= 0x000d) || (p_char == 0x0085);
|
||||
constexpr bool is_whitespace(char32_t p_char) {
|
||||
return (p_char == ' ') || (p_char == 0x00a0) || (p_char == 0x1680) || (p_char >= 0x2000 && p_char <= 0x200b) || (p_char == 0x202f) || (p_char == 0x205f) || (p_char == 0x3000) || (p_char == 0x2028) || (p_char == 0x2029) || (p_char >= 0x0009 && p_char <= 0x000d) || (p_char == 0x0085);
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_linebreak(char32_t p_char) {
|
||||
constexpr bool is_linebreak(char32_t p_char) {
|
||||
return (p_char >= 0x000a && p_char <= 0x000d) || (p_char == 0x0085) || (p_char == 0x2028) || (p_char == 0x2029);
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_punct(char32_t p_char) {
|
||||
constexpr bool is_punct(char32_t p_char) {
|
||||
return (p_char >= ' ' && p_char <= '/') || (p_char >= ':' && p_char <= '@') || (p_char >= '[' && p_char <= '^') || (p_char == '`') || (p_char >= '{' && p_char <= '~') || (p_char >= 0x2000 && p_char <= 0x206f) || (p_char >= 0x3000 && p_char <= 0x303f);
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool is_underscore(char32_t p_char) {
|
||||
constexpr bool is_underscore(char32_t p_char) {
|
||||
return (p_char == '_');
|
||||
}
|
||||
|
||||
} // namespace godot
|
||||
|
||||
@@ -102,12 +102,10 @@ struct [[nodiscard]] Color {
|
||||
|
||||
_FORCE_INLINE_ Color lerp(const Color &p_to, float p_weight) const {
|
||||
Color res = *this;
|
||||
|
||||
res.r += (p_weight * (p_to.r - r));
|
||||
res.g += (p_weight * (p_to.g - g));
|
||||
res.b += (p_weight * (p_to.b - b));
|
||||
res.a += (p_weight * (p_to.a - a));
|
||||
|
||||
res.r = Math::lerp(res.r, p_to.r, p_weight);
|
||||
res.g = Math::lerp(res.g, p_to.g, p_weight);
|
||||
res.b = Math::lerp(res.b, p_to.b, p_weight);
|
||||
res.a = Math::lerp(res.a, p_to.a, p_weight);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -128,33 +126,46 @@ struct [[nodiscard]] Color {
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ uint32_t to_rgbe9995() const {
|
||||
const float pow2to9 = 512.0f;
|
||||
const float B = 15.0f;
|
||||
const float N = 9.0f;
|
||||
// https://github.com/microsoft/DirectX-Graphics-Samples/blob/v10.0.19041.0/MiniEngine/Core/Color.cpp
|
||||
static const float kMaxVal = float(0x1FF << 7);
|
||||
static const float kMinVal = float(1.f / (1 << 16));
|
||||
|
||||
float sharedexp = 65408.000f; // Result of: ((pow2to9 - 1.0f) / pow2to9) * powf(2.0f, 31.0f - 15.0f)
|
||||
// Clamp RGB to [0, 1.FF*2^16]
|
||||
const float _r = CLAMP(r, 0.0f, kMaxVal);
|
||||
const float _g = CLAMP(g, 0.0f, kMaxVal);
|
||||
const float _b = CLAMP(b, 0.0f, kMaxVal);
|
||||
|
||||
float cRed = MAX(0.0f, MIN(sharedexp, r));
|
||||
float cGreen = MAX(0.0f, MIN(sharedexp, g));
|
||||
float cBlue = MAX(0.0f, MIN(sharedexp, b));
|
||||
// Compute the maximum channel, no less than 1.0*2^-15
|
||||
const float MaxChannel = MAX(MAX(_r, _g), MAX(_b, kMinVal));
|
||||
|
||||
float cMax = MAX(cRed, MAX(cGreen, cBlue));
|
||||
// Take the exponent of the maximum channel (rounding up the 9th bit) and
|
||||
// add 15 to it. When added to the channels, it causes the implicit '1.0'
|
||||
// bit and the first 8 mantissa bits to be shifted down to the low 9 bits
|
||||
// of the mantissa, rounding the truncated bits.
|
||||
union {
|
||||
float f;
|
||||
uint32_t i;
|
||||
} R, G, B, E;
|
||||
|
||||
float expp = MAX(-B - 1.0f, floor(Math::log(cMax) / (real_t)Math_LN2)) + 1.0f + B;
|
||||
E.f = MaxChannel;
|
||||
E.i += 0x07804000; // Add 15 to the exponent and 0x4000 to the mantissa
|
||||
E.i &= 0x7F800000; // Zero the mantissa
|
||||
|
||||
float sMax = (float)floor((cMax / Math::pow(2.0f, expp - B - N)) + 0.5f);
|
||||
// This shifts the 9-bit values we need into the lowest bits, rounding as
|
||||
// needed. Note that if the channel has a smaller exponent than the max
|
||||
// channel, it will shift even more. This is intentional.
|
||||
R.f = _r + E.f;
|
||||
G.f = _g + E.f;
|
||||
B.f = _b + E.f;
|
||||
|
||||
float exps = expp + 1.0f;
|
||||
// Convert the Bias to the correct exponent in the upper 5 bits.
|
||||
E.i <<= 4;
|
||||
E.i += 0x10000000;
|
||||
|
||||
if (0.0f <= sMax && sMax < pow2to9) {
|
||||
exps = expp;
|
||||
}
|
||||
|
||||
float sRed = Math::floor((cRed / pow(2.0f, exps - B - N)) + 0.5f);
|
||||
float sGreen = Math::floor((cGreen / pow(2.0f, exps - B - N)) + 0.5f);
|
||||
float sBlue = Math::floor((cBlue / pow(2.0f, exps - B - N)) + 0.5f);
|
||||
|
||||
return (uint32_t(Math::fast_ftoi(sRed)) & 0x1FF) | ((uint32_t(Math::fast_ftoi(sGreen)) & 0x1FF) << 9) | ((uint32_t(Math::fast_ftoi(sBlue)) & 0x1FF) << 18) | ((uint32_t(Math::fast_ftoi(exps)) & 0x1F) << 27);
|
||||
// Combine the fields. RGB floats have unwanted data in the upper 9
|
||||
// bits. Only red needs to mask them off because green and blue shift
|
||||
// it out to the left.
|
||||
return E.i | (B.i << 18U) | (G.i << 9U) | (R.i & 511U);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Color blend(const Color &p_over) const {
|
||||
@@ -173,16 +184,16 @@ struct [[nodiscard]] Color {
|
||||
|
||||
_FORCE_INLINE_ Color srgb_to_linear() const {
|
||||
return Color(
|
||||
r < 0.04045f ? r * (1.0f / 12.92f) : Math::pow((r + 0.055f) * (float)(1.0 / (1.0 + 0.055)), 2.4f),
|
||||
g < 0.04045f ? g * (1.0f / 12.92f) : Math::pow((g + 0.055f) * (float)(1.0 / (1.0 + 0.055)), 2.4f),
|
||||
b < 0.04045f ? b * (1.0f / 12.92f) : Math::pow((b + 0.055f) * (float)(1.0 / (1.0 + 0.055)), 2.4f),
|
||||
r < 0.04045f ? r * (1.0f / 12.92f) : Math::pow(float((r + 0.055) * (1.0 / (1.0 + 0.055))), 2.4f),
|
||||
g < 0.04045f ? g * (1.0f / 12.92f) : Math::pow(float((g + 0.055) * (1.0 / (1.0 + 0.055))), 2.4f),
|
||||
b < 0.04045f ? b * (1.0f / 12.92f) : Math::pow(float((b + 0.055) * (1.0 / (1.0 + 0.055))), 2.4f),
|
||||
a);
|
||||
}
|
||||
_FORCE_INLINE_ Color linear_to_srgb() const {
|
||||
return Color(
|
||||
r < 0.0031308f ? 12.92f * r : (1.0f + 0.055f) * Math::pow(r, 1.0f / 2.4f) - 0.055f,
|
||||
g < 0.0031308f ? 12.92f * g : (1.0f + 0.055f) * Math::pow(g, 1.0f / 2.4f) - 0.055f,
|
||||
b < 0.0031308f ? 12.92f * b : (1.0f + 0.055f) * Math::pow(b, 1.0f / 2.4f) - 0.055f, a);
|
||||
r < 0.0031308f ? 12.92f * r : (1.0 + 0.055) * Math::pow(r, 1.0f / 2.4f) - 0.055,
|
||||
g < 0.0031308f ? 12.92f * g : (1.0 + 0.055) * Math::pow(g, 1.0f / 2.4f) - 0.055,
|
||||
b < 0.0031308f ? 12.92f * b : (1.0 + 0.055) * Math::pow(b, 1.0f / 2.4f) - 0.055, a);
|
||||
}
|
||||
|
||||
static Color hex(uint32_t p_hex);
|
||||
@@ -198,6 +209,7 @@ struct [[nodiscard]] Color {
|
||||
static Color from_string(const String &p_string, const Color &p_default);
|
||||
static Color from_hsv(float p_h, float p_s, float p_v, float p_alpha = 1.0f);
|
||||
static Color from_rgbe9995(uint32_t p_rgbe);
|
||||
static Color from_rgba8(int64_t p_r8, int64_t p_g8, int64_t p_b8, int64_t p_a8 = 255);
|
||||
|
||||
_FORCE_INLINE_ bool operator<(const Color &p_color) const; // Used in set keys.
|
||||
operator String() const;
|
||||
|
||||
@@ -187,7 +187,6 @@ static NamedColor named_colors[] = {
|
||||
{ "WHITE_SMOKE", Color::hex(0xF5F5F5FF) },
|
||||
{ "YELLOW", Color::hex(0xFFFF00FF) },
|
||||
{ "YELLOW_GREEN", Color::hex(0x9ACD32FF) },
|
||||
{ nullptr, Color() },
|
||||
};
|
||||
|
||||
} // namespace godot
|
||||
|
||||
@@ -49,7 +49,7 @@ struct [[nodiscard]] Plane {
|
||||
|
||||
/* Plane-Point operations */
|
||||
|
||||
_FORCE_INLINE_ Vector3 center() const { return normal * d; }
|
||||
_FORCE_INLINE_ Vector3 get_center() const { return normal * d; }
|
||||
Vector3 get_any_perpendicular_normal() const;
|
||||
|
||||
_FORCE_INLINE_ bool is_point_over(const Vector3 &p_point) const; ///< Point is over plane
|
||||
@@ -102,7 +102,7 @@ real_t Plane::distance_to(const Vector3 &p_point) const {
|
||||
|
||||
bool Plane::has_point(const Vector3 &p_point, real_t p_tolerance) const {
|
||||
real_t dist = normal.dot(p_point) - d;
|
||||
dist = Math::abs(dist);
|
||||
dist = ABS(dist);
|
||||
return (dist <= p_tolerance);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <godot_cpp/core/math.hpp>
|
||||
#include <godot_cpp/templates/vector.hpp>
|
||||
#include <godot_cpp/variant/vector3.hpp>
|
||||
#include <godot_cpp/variant/vector4.hpp>
|
||||
|
||||
@@ -55,21 +56,21 @@ struct [[nodiscard]] Projection {
|
||||
|
||||
Vector4 columns[4];
|
||||
|
||||
_FORCE_INLINE_ const Vector4 &operator[](const int p_axis) const {
|
||||
_FORCE_INLINE_ const Vector4 &operator[](int p_axis) const {
|
||||
DEV_ASSERT((unsigned int)p_axis < 4);
|
||||
return columns[p_axis];
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector4 &operator[](const int p_axis) {
|
||||
_FORCE_INLINE_ Vector4 &operator[](int p_axis) {
|
||||
DEV_ASSERT((unsigned int)p_axis < 4);
|
||||
return columns[p_axis];
|
||||
}
|
||||
|
||||
float determinant() const;
|
||||
real_t determinant() const;
|
||||
void set_identity();
|
||||
void set_zero();
|
||||
void set_light_bias();
|
||||
void set_depth_correction(bool p_flip_y = true);
|
||||
void set_depth_correction(bool p_flip_y = true, bool p_reverse_z = true, bool p_remap_z = true);
|
||||
|
||||
void set_light_atlas_rect(const Rect2 &p_rect);
|
||||
void set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov = false);
|
||||
@@ -106,7 +107,7 @@ struct [[nodiscard]] Projection {
|
||||
real_t get_fov() const;
|
||||
bool is_orthogonal() const;
|
||||
|
||||
Array get_projection_planes(const Transform3D &p_transform) const;
|
||||
Vector<Plane> get_projection_planes(const Transform3D &p_transform) const;
|
||||
|
||||
bool get_endpoints(const Transform3D &p_transform, Vector3 *p_8points) const;
|
||||
Vector2 get_viewport_half_extents() const;
|
||||
@@ -148,7 +149,7 @@ struct [[nodiscard]] Projection {
|
||||
return !(*this == p_cam);
|
||||
}
|
||||
|
||||
float get_lod_multiplier() const;
|
||||
real_t get_lod_multiplier() const;
|
||||
|
||||
Projection();
|
||||
Projection(const Vector4 &p_x, const Vector4 &p_y, const Vector4 &p_z, const Vector4 &p_w);
|
||||
|
||||
@@ -142,15 +142,24 @@ struct [[nodiscard]] Quaternion {
|
||||
}
|
||||
|
||||
Quaternion(const Vector3 &p_v0, const Vector3 &p_v1) { // Shortest arc.
|
||||
Vector3 c = p_v0.cross(p_v1);
|
||||
real_t d = p_v0.dot(p_v1);
|
||||
|
||||
if (d < -1.0f + (real_t)CMP_EPSILON) {
|
||||
x = 0;
|
||||
y = 1;
|
||||
z = 0;
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_MSG(p_v0.is_zero_approx() || p_v1.is_zero_approx(), "The vectors must not be zero.");
|
||||
#endif
|
||||
constexpr real_t ALMOST_ONE = 1.0f - (real_t)CMP_EPSILON;
|
||||
Vector3 n0 = p_v0.normalized();
|
||||
Vector3 n1 = p_v1.normalized();
|
||||
real_t d = n0.dot(n1);
|
||||
if (abs(d) > ALMOST_ONE) {
|
||||
if (d >= 0) {
|
||||
return; // Vectors are same.
|
||||
}
|
||||
Vector3 axis = n0.get_any_perpendicular();
|
||||
x = axis.x;
|
||||
y = axis.y;
|
||||
z = axis.z;
|
||||
w = 0;
|
||||
} else {
|
||||
Vector3 c = n0.cross(n1);
|
||||
real_t s = Math::sqrt((1.0f + d) * 2.0f);
|
||||
real_t rs = 1.0f / s;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ struct [[nodiscard]] Rect2 {
|
||||
|
||||
_FORCE_INLINE_ Vector2 get_center() const { return position + (size * 0.5f); }
|
||||
|
||||
inline bool intersects(const Rect2 &p_rect, const bool p_include_borders = false) const {
|
||||
inline bool intersects(const Rect2 &p_rect, bool p_include_borders = false) const {
|
||||
#ifdef MATH_CHECKS
|
||||
if (unlikely(size.x < 0 || size.y < 0 || p_rect.size.x < 0 || p_rect.size.y < 0)) {
|
||||
ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size.");
|
||||
@@ -105,17 +105,17 @@ struct [[nodiscard]] Rect2 {
|
||||
}
|
||||
if (p_point.y < position.y) {
|
||||
real_t d = position.y - p_point.y;
|
||||
dist = inside ? d : Math::min(dist, d);
|
||||
dist = inside ? d : MIN(dist, d);
|
||||
inside = false;
|
||||
}
|
||||
if (p_point.x >= (position.x + size.x)) {
|
||||
real_t d = p_point.x - (position.x + size.x);
|
||||
dist = inside ? d : Math::min(dist, d);
|
||||
dist = inside ? d : MIN(dist, d);
|
||||
inside = false;
|
||||
}
|
||||
if (p_point.y >= (position.y + size.y)) {
|
||||
real_t d = p_point.y - (position.y + size.y);
|
||||
dist = inside ? d : Math::min(dist, d);
|
||||
dist = inside ? d : MIN(dist, d);
|
||||
inside = false;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ struct [[nodiscard]] Rect2 {
|
||||
return size.x > 0.0f && size.y > 0.0f;
|
||||
}
|
||||
|
||||
// Returns the intersection between two Rect2s or an empty Rect2 if there is no intersection
|
||||
// Returns the intersection between two Rect2s or an empty Rect2 if there is no intersection.
|
||||
inline Rect2 intersection(const Rect2 &p_rect) const {
|
||||
Rect2 new_rect = p_rect;
|
||||
|
||||
@@ -282,13 +282,19 @@ struct [[nodiscard]] Rect2 {
|
||||
return Rect2(position + size.minf(0), size.abs());
|
||||
}
|
||||
|
||||
Vector2 get_support(const Vector2 &p_normal) const {
|
||||
Vector2 half_extents = size * 0.5f;
|
||||
Vector2 ofs = position + half_extents;
|
||||
return Vector2(
|
||||
(p_normal.x > 0) ? -half_extents.x : half_extents.x,
|
||||
(p_normal.y > 0) ? -half_extents.y : half_extents.y) +
|
||||
ofs;
|
||||
_FORCE_INLINE_ Rect2 round() const {
|
||||
return Rect2(position.round(), size.round());
|
||||
}
|
||||
|
||||
Vector2 get_support(const Vector2 &p_direction) const {
|
||||
Vector2 support = position;
|
||||
if (p_direction.x > 0.0f) {
|
||||
support.x += size.x;
|
||||
}
|
||||
if (p_direction.y > 0.0f) {
|
||||
support.y += size.y;
|
||||
}
|
||||
return support;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ bool intersects_filled_polygon(const Vector2 *p_points, int p_point_count) const {
|
||||
@@ -304,14 +310,14 @@ struct [[nodiscard]] Rect2 {
|
||||
i_f = i;
|
||||
|
||||
Vector2 r = (b - a);
|
||||
float l = r.length();
|
||||
const real_t l = r.length();
|
||||
if (l == 0.0f) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check inside.
|
||||
Vector2 tg = r.orthogonal();
|
||||
float s = tg.dot(center) - tg.dot(a);
|
||||
const real_t s = tg.dot(center) - tg.dot(a);
|
||||
if (s < 0.0f) {
|
||||
side_plus++;
|
||||
} else {
|
||||
@@ -327,8 +333,8 @@ struct [[nodiscard]] Rect2 {
|
||||
Vector2 t13 = (position - a) * ir;
|
||||
Vector2 t24 = (end - a) * ir;
|
||||
|
||||
float tmin = Math::max(Math::min(t13.x, t24.x), Math::min(t13.y, t24.y));
|
||||
float tmax = Math::min(Math::max(t13.x, t24.x), Math::max(t13.y, t24.y));
|
||||
const real_t tmin = MAX(MIN(t13.x, t24.x), MIN(t13.y, t24.y));
|
||||
const real_t tmax = MIN(MAX(t13.x, t24.x), MAX(t13.y, t24.y));
|
||||
|
||||
// if tmax < 0, ray (line) is intersecting AABB, but the whole AABB is behind us
|
||||
if (tmax < 0 || tmin > tmax || tmin >= l) {
|
||||
|
||||
@@ -88,7 +88,7 @@ struct [[nodiscard]] Rect2i {
|
||||
return size.x > 0 && size.y > 0;
|
||||
}
|
||||
|
||||
// Returns the intersection between two Rect2is or an empty Rect2i if there is no intersection
|
||||
// Returns the intersection between two Rect2is or an empty Rect2i if there is no intersection.
|
||||
inline Rect2i intersection(const Rect2i &p_rect) const {
|
||||
Rect2i new_rect = p_rect;
|
||||
|
||||
|
||||
@@ -39,21 +39,24 @@ namespace godot {
|
||||
class String;
|
||||
|
||||
struct [[nodiscard]] Transform2D {
|
||||
// Warning #1: basis of Transform2D is stored differently from Basis. In terms of columns array, the basis matrix looks like "on paper":
|
||||
// WARNING: The basis of Transform2D is stored differently from Basis.
|
||||
// In terms of columns array, the basis matrix looks like "on paper":
|
||||
// M = (columns[0][0] columns[1][0])
|
||||
// (columns[0][1] columns[1][1])
|
||||
// This is such that the columns, which can be interpreted as basis vectors of the coordinate system "painted" on the object, can be accessed as columns[i].
|
||||
// Note that this is the opposite of the indices in mathematical texts, meaning: $M_{12}$ in a math book corresponds to columns[1][0] here.
|
||||
// This is such that the columns, which can be interpreted as basis vectors
|
||||
// of the coordinate system "painted" on the object, can be accessed as columns[i].
|
||||
// NOTE: This is the opposite of the indices in mathematical texts,
|
||||
// meaning: $M_{12}$ in a math book corresponds to columns[1][0] here.
|
||||
// This requires additional care when working with explicit indices.
|
||||
// See https://en.wikipedia.org/wiki/Row-_and_column-major_order for further reading.
|
||||
|
||||
// Warning #2: 2D be aware that unlike 3D code, 2D code uses a left-handed coordinate system: Y-axis points down,
|
||||
// and angle is measure from +X to +Y in a clockwise-fashion.
|
||||
// WARNING: Be aware that unlike 3D code, 2D code uses a left-handed coordinate system:
|
||||
// Y-axis points down, and angle is measure from +X to +Y in a clockwise-fashion.
|
||||
|
||||
Vector2 columns[3];
|
||||
|
||||
_FORCE_INLINE_ real_t tdotx(const Vector2 &v) const { return columns[0][0] * v.x + columns[1][0] * v.y; }
|
||||
_FORCE_INLINE_ real_t tdoty(const Vector2 &v) const { return columns[0][1] * v.x + columns[1][1] * v.y; }
|
||||
_FORCE_INLINE_ real_t tdotx(const Vector2 &p_v) const { return columns[0][0] * p_v.x + columns[1][0] * p_v.y; }
|
||||
_FORCE_INLINE_ real_t tdoty(const Vector2 &p_v) const { return columns[0][1] * p_v.x + columns[1][1] * p_v.y; }
|
||||
|
||||
const Vector2 &operator[](int p_idx) const { return columns[p_idx]; }
|
||||
Vector2 &operator[](int p_idx) { return columns[p_idx]; }
|
||||
@@ -64,20 +67,20 @@ struct [[nodiscard]] Transform2D {
|
||||
void affine_invert();
|
||||
Transform2D affine_inverse() const;
|
||||
|
||||
void set_rotation(const real_t p_rot);
|
||||
void set_rotation(real_t p_rot);
|
||||
real_t get_rotation() const;
|
||||
real_t get_skew() const;
|
||||
void set_skew(const real_t p_angle);
|
||||
_FORCE_INLINE_ void set_rotation_and_scale(const real_t p_rot, const Size2 &p_scale);
|
||||
_FORCE_INLINE_ void set_rotation_scale_and_skew(const real_t p_rot, const Size2 &p_scale, const real_t p_skew);
|
||||
void rotate(const real_t p_angle);
|
||||
void set_skew(real_t p_angle);
|
||||
_FORCE_INLINE_ void set_rotation_and_scale(real_t p_rot, const Size2 &p_scale);
|
||||
_FORCE_INLINE_ void set_rotation_scale_and_skew(real_t p_rot, const Size2 &p_scale, real_t p_skew);
|
||||
void rotate(real_t p_angle);
|
||||
|
||||
void scale(const Size2 &p_scale);
|
||||
void scale_basis(const Size2 &p_scale);
|
||||
void translate_local(const real_t p_tx, const real_t p_ty);
|
||||
void translate_local(real_t p_tx, real_t p_ty);
|
||||
void translate_local(const Vector2 &p_translation);
|
||||
|
||||
real_t basis_determinant() const;
|
||||
real_t determinant() const;
|
||||
|
||||
Size2 get_scale() const;
|
||||
void set_scale(const Size2 &p_scale);
|
||||
@@ -85,18 +88,18 @@ struct [[nodiscard]] Transform2D {
|
||||
_FORCE_INLINE_ const Vector2 &get_origin() const { return columns[2]; }
|
||||
_FORCE_INLINE_ void set_origin(const Vector2 &p_origin) { columns[2] = p_origin; }
|
||||
|
||||
Transform2D basis_scaled(const Size2 &p_scale) const;
|
||||
Transform2D scaled(const Size2 &p_scale) const;
|
||||
Transform2D scaled_local(const Size2 &p_scale) const;
|
||||
Transform2D translated(const Vector2 &p_offset) const;
|
||||
Transform2D translated_local(const Vector2 &p_offset) const;
|
||||
Transform2D rotated(const real_t p_angle) const;
|
||||
Transform2D rotated_local(const real_t p_angle) const;
|
||||
Transform2D rotated(real_t p_angle) const;
|
||||
Transform2D rotated_local(real_t p_angle) const;
|
||||
|
||||
Transform2D untranslated() const;
|
||||
|
||||
void orthonormalize();
|
||||
Transform2D orthonormalized() const;
|
||||
bool is_conformal() const;
|
||||
bool is_equal_approx(const Transform2D &p_transform) const;
|
||||
bool is_finite() const;
|
||||
|
||||
@@ -107,10 +110,12 @@ struct [[nodiscard]] Transform2D {
|
||||
|
||||
void operator*=(const Transform2D &p_transform);
|
||||
Transform2D operator*(const Transform2D &p_transform) const;
|
||||
void operator*=(const real_t p_val);
|
||||
Transform2D operator*(const real_t p_val) const;
|
||||
void operator*=(real_t p_val);
|
||||
Transform2D operator*(real_t p_val) const;
|
||||
void operator/=(real_t p_val);
|
||||
Transform2D operator/(real_t p_val) const;
|
||||
|
||||
Transform2D interpolate_with(const Transform2D &p_transform, const real_t p_c) const;
|
||||
Transform2D interpolate_with(const Transform2D &p_transform, real_t p_c) const;
|
||||
|
||||
_FORCE_INLINE_ Vector2 basis_xform(const Vector2 &p_vec) const;
|
||||
_FORCE_INLINE_ Vector2 basis_xform_inv(const Vector2 &p_vec) const;
|
||||
@@ -123,13 +128,13 @@ struct [[nodiscard]] Transform2D {
|
||||
|
||||
operator String() const;
|
||||
|
||||
Transform2D(const real_t xx, const real_t xy, const real_t yx, const real_t yy, const real_t ox, const real_t oy) {
|
||||
columns[0][0] = xx;
|
||||
columns[0][1] = xy;
|
||||
columns[1][0] = yx;
|
||||
columns[1][1] = yy;
|
||||
columns[2][0] = ox;
|
||||
columns[2][1] = oy;
|
||||
Transform2D(real_t p_xx, real_t p_xy, real_t p_yx, real_t p_yy, real_t p_ox, real_t p_oy) {
|
||||
columns[0][0] = p_xx;
|
||||
columns[0][1] = p_xy;
|
||||
columns[1][0] = p_yx;
|
||||
columns[1][1] = p_yy;
|
||||
columns[2][0] = p_ox;
|
||||
columns[2][1] = p_oy;
|
||||
}
|
||||
|
||||
Transform2D(const Vector2 &p_x, const Vector2 &p_y, const Vector2 &p_origin) {
|
||||
@@ -138,9 +143,9 @@ struct [[nodiscard]] Transform2D {
|
||||
columns[2] = p_origin;
|
||||
}
|
||||
|
||||
Transform2D(const real_t p_rot, const Vector2 &p_pos);
|
||||
Transform2D(real_t p_rot, const Vector2 &p_pos);
|
||||
|
||||
Transform2D(const real_t p_rot, const Size2 &p_scale, const real_t p_skew, const Vector2 &p_pos);
|
||||
Transform2D(real_t p_rot, const Size2 &p_scale, real_t p_skew, const Vector2 &p_pos);
|
||||
|
||||
Transform2D() {
|
||||
columns[0][0] = 1.0;
|
||||
@@ -188,14 +193,14 @@ Rect2 Transform2D::xform(const Rect2 &p_rect) const {
|
||||
return new_rect;
|
||||
}
|
||||
|
||||
void Transform2D::set_rotation_and_scale(const real_t p_rot, const Size2 &p_scale) {
|
||||
void Transform2D::set_rotation_and_scale(real_t p_rot, const Size2 &p_scale) {
|
||||
columns[0][0] = Math::cos(p_rot) * p_scale.x;
|
||||
columns[1][1] = Math::cos(p_rot) * p_scale.y;
|
||||
columns[1][0] = -Math::sin(p_rot) * p_scale.y;
|
||||
columns[0][1] = Math::sin(p_rot) * p_scale.x;
|
||||
}
|
||||
|
||||
void Transform2D::set_rotation_scale_and_skew(const real_t p_rot, const Size2 &p_scale, const real_t p_skew) {
|
||||
void Transform2D::set_rotation_scale_and_skew(real_t p_rot, const Size2 &p_scale, real_t p_skew) {
|
||||
columns[0][0] = Math::cos(p_rot) * p_scale.x;
|
||||
columns[1][1] = Math::cos(p_rot + p_skew) * p_scale.y;
|
||||
columns[1][0] = -Math::sin(p_rot + p_skew) * p_scale.y;
|
||||
|
||||
@@ -54,8 +54,8 @@ struct [[nodiscard]] Transform3D {
|
||||
void rotate(const Vector3 &p_axis, real_t p_angle);
|
||||
void rotate_basis(const Vector3 &p_axis, real_t p_angle);
|
||||
|
||||
void set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0));
|
||||
Transform3D looking_at(const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0)) const;
|
||||
void set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0), bool p_use_model_front = false);
|
||||
Transform3D looking_at(const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0), bool p_use_model_front = false) const;
|
||||
|
||||
void scale(const Vector3 &p_scale);
|
||||
Transform3D scaled(const Vector3 &p_scale) const;
|
||||
@@ -104,8 +104,10 @@ struct [[nodiscard]] Transform3D {
|
||||
|
||||
void operator*=(const Transform3D &p_transform);
|
||||
Transform3D operator*(const Transform3D &p_transform) const;
|
||||
void operator*=(const real_t p_val);
|
||||
Transform3D operator*(const real_t p_val) const;
|
||||
void operator*=(real_t p_val);
|
||||
Transform3D operator*(real_t p_val) const;
|
||||
void operator/=(real_t p_val);
|
||||
Transform3D operator/(real_t p_val) const;
|
||||
|
||||
Transform3D interpolate_with(const Transform3D &p_transform, real_t p_c) const;
|
||||
|
||||
@@ -115,11 +117,11 @@ struct [[nodiscard]] Transform3D {
|
||||
basis.xform(v));
|
||||
}
|
||||
|
||||
void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t tx, real_t ty, real_t tz) {
|
||||
basis.set(xx, xy, xz, yx, yy, yz, zx, zy, zz);
|
||||
origin.x = tx;
|
||||
origin.y = ty;
|
||||
origin.z = tz;
|
||||
void set(real_t p_xx, real_t p_xy, real_t p_xz, real_t p_yx, real_t p_yy, real_t p_yz, real_t p_zx, real_t p_zy, real_t p_zz, real_t p_tx, real_t p_ty, real_t p_tz) {
|
||||
basis.set(p_xx, p_xy, p_xz, p_yx, p_yy, p_yz, p_zx, p_zy, p_zz);
|
||||
origin.x = p_tx;
|
||||
origin.y = p_ty;
|
||||
origin.z = p_tz;
|
||||
}
|
||||
|
||||
operator String() const;
|
||||
@@ -127,7 +129,7 @@ struct [[nodiscard]] Transform3D {
|
||||
Transform3D() {}
|
||||
Transform3D(const Basis &p_basis, const Vector3 &p_origin = Vector3());
|
||||
Transform3D(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z, const Vector3 &p_origin);
|
||||
Transform3D(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t ox, real_t oy, real_t oz);
|
||||
Transform3D(real_t p_xx, real_t p_xy, real_t p_xz, real_t p_yx, real_t p_yy, real_t p_yz, real_t p_zx, real_t p_zy, real_t p_zz, real_t p_ox, real_t p_oy, real_t p_oz);
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ Vector3 Transform3D::xform(const Vector3 &p_vector) const {
|
||||
|
||||
@@ -61,13 +61,13 @@ struct [[nodiscard]] Vector2 {
|
||||
real_t coord[2] = { 0 };
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ real_t &operator[](int p_idx) {
|
||||
DEV_ASSERT((unsigned int)p_idx < 2);
|
||||
return coord[p_idx];
|
||||
_FORCE_INLINE_ real_t &operator[](int p_axis) {
|
||||
DEV_ASSERT((unsigned int)p_axis < 2);
|
||||
return coord[p_axis];
|
||||
}
|
||||
_FORCE_INLINE_ const real_t &operator[](int p_idx) const {
|
||||
DEV_ASSERT((unsigned int)p_idx < 2);
|
||||
return coord[p_idx];
|
||||
_FORCE_INLINE_ const real_t &operator[](int p_axis) const {
|
||||
DEV_ASSERT((unsigned int)p_axis < 2);
|
||||
return coord[p_axis];
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2::Axis min_axis_index() const {
|
||||
@@ -84,7 +84,7 @@ struct [[nodiscard]] Vector2 {
|
||||
|
||||
real_t length() const;
|
||||
real_t length_squared() const;
|
||||
Vector2 limit_length(const real_t p_len = 1.0) const;
|
||||
Vector2 limit_length(real_t p_len = 1.0) const;
|
||||
|
||||
Vector2 min(const Vector2 &p_vector2) const {
|
||||
return Vector2(MIN(x, p_vector2.x), MIN(y, p_vector2.y));
|
||||
@@ -110,19 +110,20 @@ struct [[nodiscard]] Vector2 {
|
||||
|
||||
real_t dot(const Vector2 &p_other) const;
|
||||
real_t cross(const Vector2 &p_other) const;
|
||||
Vector2 posmod(const real_t p_mod) const;
|
||||
Vector2 posmod(real_t p_mod) const;
|
||||
Vector2 posmodv(const Vector2 &p_modv) const;
|
||||
Vector2 project(const Vector2 &p_to) const;
|
||||
|
||||
Vector2 plane_project(const real_t p_d, const Vector2 &p_vec) const;
|
||||
Vector2 plane_project(real_t p_d, const Vector2 &p_vec) const;
|
||||
|
||||
_FORCE_INLINE_ Vector2 lerp(const Vector2 &p_to, const real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector2 slerp(const Vector2 &p_to, const real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, const real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector2 cubic_interpolate_in_time(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, const real_t p_weight, const real_t &p_b_t, const real_t &p_pre_a_t, const real_t &p_post_b_t) const;
|
||||
_FORCE_INLINE_ Vector2 bezier_interpolate(const Vector2 &p_control_1, const Vector2 &p_control_2, const Vector2 &p_end, const real_t p_t) const;
|
||||
_FORCE_INLINE_ Vector2 lerp(const Vector2 &p_to, real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector2 slerp(const Vector2 &p_to, real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector2 cubic_interpolate_in_time(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_weight, real_t p_b_t, real_t p_pre_a_t, real_t p_post_b_t) const;
|
||||
_FORCE_INLINE_ Vector2 bezier_interpolate(const Vector2 &p_control_1, const Vector2 &p_control_2, const Vector2 &p_end, real_t p_t) const;
|
||||
_FORCE_INLINE_ Vector2 bezier_derivative(const Vector2 &p_control_1, const Vector2 &p_control_2, const Vector2 &p_end, real_t p_t) const;
|
||||
|
||||
Vector2 move_toward(const Vector2 &p_to, const real_t p_delta) const;
|
||||
Vector2 move_toward(const Vector2 &p_to, real_t p_delta) const;
|
||||
|
||||
Vector2 slide(const Vector2 &p_normal) const;
|
||||
Vector2 bounce(const Vector2 &p_normal) const;
|
||||
@@ -138,16 +139,16 @@ struct [[nodiscard]] Vector2 {
|
||||
void operator-=(const Vector2 &p_v);
|
||||
Vector2 operator*(const Vector2 &p_v1) const;
|
||||
|
||||
Vector2 operator*(const real_t &rvalue) const;
|
||||
void operator*=(const real_t &rvalue);
|
||||
void operator*=(const Vector2 &rvalue) { *this = *this * rvalue; }
|
||||
Vector2 operator*(real_t p_rvalue) const;
|
||||
void operator*=(real_t p_rvalue);
|
||||
void operator*=(const Vector2 &p_rvalue) { *this = *this * p_rvalue; }
|
||||
|
||||
Vector2 operator/(const Vector2 &p_v1) const;
|
||||
|
||||
Vector2 operator/(const real_t &rvalue) const;
|
||||
Vector2 operator/(real_t p_rvalue) const;
|
||||
|
||||
void operator/=(const real_t &rvalue);
|
||||
void operator/=(const Vector2 &rvalue) { *this = *this / rvalue; }
|
||||
void operator/=(real_t p_rvalue);
|
||||
void operator/=(const Vector2 &p_rvalue) { *this = *this / p_rvalue; }
|
||||
|
||||
Vector2 operator-() const;
|
||||
|
||||
@@ -160,13 +161,13 @@ struct [[nodiscard]] Vector2 {
|
||||
bool operator>=(const Vector2 &p_vec2) const { return x == p_vec2.x ? (y >= p_vec2.y) : (x > p_vec2.x); }
|
||||
|
||||
real_t angle() const;
|
||||
static Vector2 from_angle(const real_t p_angle);
|
||||
static Vector2 from_angle(real_t p_angle);
|
||||
|
||||
_FORCE_INLINE_ Vector2 abs() const {
|
||||
return Vector2(Math::abs(x), Math::abs(y));
|
||||
}
|
||||
|
||||
Vector2 rotated(const real_t p_by) const;
|
||||
Vector2 rotated(real_t p_by) const;
|
||||
Vector2 orthogonal() const {
|
||||
return Vector2(y, -x);
|
||||
}
|
||||
@@ -185,13 +186,13 @@ struct [[nodiscard]] Vector2 {
|
||||
operator Vector2i() const;
|
||||
|
||||
_FORCE_INLINE_ Vector2() {}
|
||||
_FORCE_INLINE_ Vector2(const real_t p_x, const real_t p_y) {
|
||||
_FORCE_INLINE_ Vector2(real_t p_x, real_t p_y) {
|
||||
x = p_x;
|
||||
y = p_y;
|
||||
}
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ Vector2 Vector2::plane_project(const real_t p_d, const Vector2 &p_vec) const {
|
||||
_FORCE_INLINE_ Vector2 Vector2::plane_project(real_t p_d, const Vector2 &p_vec) const {
|
||||
return p_vec - *this * (dot(p_vec) - p_d);
|
||||
}
|
||||
|
||||
@@ -217,26 +218,26 @@ _FORCE_INLINE_ Vector2 Vector2::operator*(const Vector2 &p_v1) const {
|
||||
return Vector2(x * p_v1.x, y * p_v1.y);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2 Vector2::operator*(const real_t &rvalue) const {
|
||||
return Vector2(x * rvalue, y * rvalue);
|
||||
_FORCE_INLINE_ Vector2 Vector2::operator*(real_t p_rvalue) const {
|
||||
return Vector2(x * p_rvalue, y * p_rvalue);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void Vector2::operator*=(const real_t &rvalue) {
|
||||
x *= rvalue;
|
||||
y *= rvalue;
|
||||
_FORCE_INLINE_ void Vector2::operator*=(real_t p_rvalue) {
|
||||
x *= p_rvalue;
|
||||
y *= p_rvalue;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2 Vector2::operator/(const Vector2 &p_v1) const {
|
||||
return Vector2(x / p_v1.x, y / p_v1.y);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2 Vector2::operator/(const real_t &rvalue) const {
|
||||
return Vector2(x / rvalue, y / rvalue);
|
||||
_FORCE_INLINE_ Vector2 Vector2::operator/(real_t p_rvalue) const {
|
||||
return Vector2(x / p_rvalue, y / p_rvalue);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void Vector2::operator/=(const real_t &rvalue) {
|
||||
x /= rvalue;
|
||||
y /= rvalue;
|
||||
_FORCE_INLINE_ void Vector2::operator/=(real_t p_rvalue) {
|
||||
x /= p_rvalue;
|
||||
y /= p_rvalue;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2 Vector2::operator-() const {
|
||||
@@ -251,16 +252,14 @@ _FORCE_INLINE_ bool Vector2::operator!=(const Vector2 &p_vec2) const {
|
||||
return x != p_vec2.x || y != p_vec2.y;
|
||||
}
|
||||
|
||||
Vector2 Vector2::lerp(const Vector2 &p_to, const real_t p_weight) const {
|
||||
Vector2 Vector2::lerp(const Vector2 &p_to, real_t p_weight) const {
|
||||
Vector2 res = *this;
|
||||
|
||||
res.x += (p_weight * (p_to.x - x));
|
||||
res.y += (p_weight * (p_to.y - y));
|
||||
|
||||
res.x = Math::lerp(res.x, p_to.x, p_weight);
|
||||
res.y = Math::lerp(res.y, p_to.y, p_weight);
|
||||
return res;
|
||||
}
|
||||
|
||||
Vector2 Vector2::slerp(const Vector2 &p_to, const real_t p_weight) const {
|
||||
Vector2 Vector2::slerp(const Vector2 &p_to, real_t p_weight) const {
|
||||
real_t start_length_sq = length_squared();
|
||||
real_t end_length_sq = p_to.length_squared();
|
||||
if (unlikely(start_length_sq == 0.0f || end_length_sq == 0.0f)) {
|
||||
@@ -273,31 +272,32 @@ Vector2 Vector2::slerp(const Vector2 &p_to, const real_t p_weight) const {
|
||||
return rotated(angle * p_weight) * (result_length / start_length);
|
||||
}
|
||||
|
||||
Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, const real_t p_weight) const {
|
||||
Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_weight) const {
|
||||
Vector2 res = *this;
|
||||
res.x = Math::cubic_interpolate(res.x, p_b.x, p_pre_a.x, p_post_b.x, p_weight);
|
||||
res.y = Math::cubic_interpolate(res.y, p_b.y, p_pre_a.y, p_post_b.y, p_weight);
|
||||
return res;
|
||||
}
|
||||
|
||||
Vector2 Vector2::cubic_interpolate_in_time(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, const real_t p_weight, const real_t &p_b_t, const real_t &p_pre_a_t, const real_t &p_post_b_t) const {
|
||||
Vector2 Vector2::cubic_interpolate_in_time(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_weight, real_t p_b_t, real_t p_pre_a_t, real_t p_post_b_t) const {
|
||||
Vector2 res = *this;
|
||||
res.x = Math::cubic_interpolate_in_time(res.x, p_b.x, p_pre_a.x, p_post_b.x, p_weight, p_b_t, p_pre_a_t, p_post_b_t);
|
||||
res.y = Math::cubic_interpolate_in_time(res.y, p_b.y, p_pre_a.y, p_post_b.y, p_weight, p_b_t, p_pre_a_t, p_post_b_t);
|
||||
return res;
|
||||
}
|
||||
|
||||
Vector2 Vector2::bezier_interpolate(const Vector2 &p_control_1, const Vector2 &p_control_2, const Vector2 &p_end, const real_t p_t) const {
|
||||
Vector2 Vector2::bezier_interpolate(const Vector2 &p_control_1, const Vector2 &p_control_2, const Vector2 &p_end, real_t p_t) const {
|
||||
Vector2 res = *this;
|
||||
res.x = Math::bezier_interpolate(res.x, p_control_1.x, p_control_2.x, p_end.x, p_t);
|
||||
res.y = Math::bezier_interpolate(res.y, p_control_1.y, p_control_2.y, p_end.y, p_t);
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Formula from Wikipedia article on Bezier curves. */
|
||||
real_t omt = (1.0 - p_t);
|
||||
real_t omt2 = omt * omt;
|
||||
real_t omt3 = omt2 * omt;
|
||||
real_t t2 = p_t * p_t;
|
||||
real_t t3 = t2 * p_t;
|
||||
|
||||
return res * omt3 + p_control_1 * omt2 * p_t * 3.0 + p_control_2 * omt * t2 * 3.0 + p_end * t3;
|
||||
Vector2 Vector2::bezier_derivative(const Vector2 &p_control_1, const Vector2 &p_control_2, const Vector2 &p_end, real_t p_t) const {
|
||||
Vector2 res = *this;
|
||||
res.x = Math::bezier_derivative(res.x, p_control_1.x, p_control_2.x, p_end.x, p_t);
|
||||
res.y = Math::bezier_derivative(res.y, p_control_1.y, p_control_2.y, p_end.y, p_t);
|
||||
return res;
|
||||
}
|
||||
|
||||
Vector2 Vector2::direction_to(const Vector2 &p_to) const {
|
||||
@@ -309,19 +309,19 @@ Vector2 Vector2::direction_to(const Vector2 &p_to) const {
|
||||
// Multiplication operators required to workaround issues with LLVM using implicit conversion
|
||||
// to Vector2i instead for integers where it should not.
|
||||
|
||||
_FORCE_INLINE_ Vector2 operator*(const float p_scalar, const Vector2 &p_vec) {
|
||||
_FORCE_INLINE_ Vector2 operator*(float p_scalar, const Vector2 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2 operator*(const double p_scalar, const Vector2 &p_vec) {
|
||||
_FORCE_INLINE_ Vector2 operator*(double p_scalar, const Vector2 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2 operator*(const int32_t p_scalar, const Vector2 &p_vec) {
|
||||
_FORCE_INLINE_ Vector2 operator*(int32_t p_scalar, const Vector2 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2 operator*(const int64_t p_scalar, const Vector2 &p_vec) {
|
||||
_FORCE_INLINE_ Vector2 operator*(int64_t p_scalar, const Vector2 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,13 +61,13 @@ struct [[nodiscard]] Vector2i {
|
||||
int32_t coord[2] = { 0 };
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ int32_t &operator[](int p_idx) {
|
||||
DEV_ASSERT((unsigned int)p_idx < 2);
|
||||
return coord[p_idx];
|
||||
_FORCE_INLINE_ int32_t &operator[](int p_axis) {
|
||||
DEV_ASSERT((unsigned int)p_axis < 2);
|
||||
return coord[p_axis];
|
||||
}
|
||||
_FORCE_INLINE_ const int32_t &operator[](int p_idx) const {
|
||||
DEV_ASSERT((unsigned int)p_idx < 2);
|
||||
return coord[p_idx];
|
||||
_FORCE_INLINE_ const int32_t &operator[](int p_axis) const {
|
||||
DEV_ASSERT((unsigned int)p_axis < 2);
|
||||
return coord[p_axis];
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2i::Axis min_axis_index() const {
|
||||
@@ -94,22 +94,30 @@ struct [[nodiscard]] Vector2i {
|
||||
return Vector2i(MAX(x, p_scalar), MAX(y, p_scalar));
|
||||
}
|
||||
|
||||
double distance_to(const Vector2i &p_to) const {
|
||||
return (p_to - *this).length();
|
||||
}
|
||||
|
||||
int64_t distance_squared_to(const Vector2i &p_to) const {
|
||||
return (p_to - *this).length_squared();
|
||||
}
|
||||
|
||||
Vector2i operator+(const Vector2i &p_v) const;
|
||||
void operator+=(const Vector2i &p_v);
|
||||
Vector2i operator-(const Vector2i &p_v) const;
|
||||
void operator-=(const Vector2i &p_v);
|
||||
Vector2i operator*(const Vector2i &p_v1) const;
|
||||
|
||||
Vector2i operator*(const int32_t &rvalue) const;
|
||||
void operator*=(const int32_t &rvalue);
|
||||
Vector2i operator*(int32_t p_rvalue) const;
|
||||
void operator*=(int32_t p_rvalue);
|
||||
|
||||
Vector2i operator/(const Vector2i &p_v1) const;
|
||||
Vector2i operator/(const int32_t &rvalue) const;
|
||||
void operator/=(const int32_t &rvalue);
|
||||
Vector2i operator/(int32_t p_rvalue) const;
|
||||
void operator/=(int32_t p_rvalue);
|
||||
|
||||
Vector2i operator%(const Vector2i &p_v1) const;
|
||||
Vector2i operator%(const int32_t &rvalue) const;
|
||||
void operator%=(const int32_t &rvalue);
|
||||
Vector2i operator%(int32_t p_rvalue) const;
|
||||
void operator%=(int32_t p_rvalue);
|
||||
|
||||
Vector2i operator-() const;
|
||||
bool operator<(const Vector2i &p_vec2) const { return (x == p_vec2.x) ? (y < p_vec2.y) : (x < p_vec2.x); }
|
||||
@@ -124,22 +132,19 @@ struct [[nodiscard]] Vector2i {
|
||||
int64_t length_squared() const;
|
||||
double length() const;
|
||||
|
||||
int64_t distance_squared_to(const Vector2i &p_to) const;
|
||||
double distance_to(const Vector2i &p_to) const;
|
||||
|
||||
real_t aspect() const { return width / (real_t)height; }
|
||||
Vector2i sign() const { return Vector2i(SIGN(x), SIGN(y)); }
|
||||
Vector2i abs() const { return Vector2i(Math::abs(x), Math::abs(y)); }
|
||||
Vector2i snapped(const Vector2i &p_step) const;
|
||||
Vector2i snappedi(int32_t p_step) const;
|
||||
Vector2i clamp(const Vector2i &p_min, const Vector2i &p_max) const;
|
||||
Vector2i clampi(int32_t p_min, int32_t p_max) const;
|
||||
Vector2i snapped(const Vector2i &p_step) const;
|
||||
Vector2i snappedi(int32_t p_step) const;
|
||||
|
||||
operator String() const;
|
||||
operator Vector2() const;
|
||||
|
||||
inline Vector2i() {}
|
||||
inline Vector2i(const int32_t p_x, const int32_t p_y) {
|
||||
inline Vector2i(int32_t p_x, int32_t p_y) {
|
||||
x = p_x;
|
||||
y = p_y;
|
||||
}
|
||||
@@ -147,19 +152,19 @@ struct [[nodiscard]] Vector2i {
|
||||
|
||||
// Multiplication operators required to workaround issues with LLVM using implicit conversion.
|
||||
|
||||
_FORCE_INLINE_ Vector2i operator*(const int32_t p_scalar, const Vector2i &p_vector) {
|
||||
_FORCE_INLINE_ Vector2i operator*(int32_t p_scalar, const Vector2i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2i operator*(const int64_t p_scalar, const Vector2i &p_vector) {
|
||||
_FORCE_INLINE_ Vector2i operator*(int64_t p_scalar, const Vector2i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2i operator*(const float p_scalar, const Vector2i &p_vector) {
|
||||
_FORCE_INLINE_ Vector2i operator*(float p_scalar, const Vector2i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2i operator*(const double p_scalar, const Vector2i &p_vector) {
|
||||
_FORCE_INLINE_ Vector2i operator*(double p_scalar, const Vector2i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,12 +59,12 @@ struct [[nodiscard]] Vector3 {
|
||||
real_t coord[3] = { 0 };
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ const real_t &operator[](const int p_axis) const {
|
||||
_FORCE_INLINE_ const real_t &operator[](int p_axis) const {
|
||||
DEV_ASSERT((unsigned int)p_axis < 3);
|
||||
return coord[p_axis];
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ real_t &operator[](const int p_axis) {
|
||||
_FORCE_INLINE_ real_t &operator[](int p_axis) {
|
||||
DEV_ASSERT((unsigned int)p_axis < 3);
|
||||
return coord[p_axis];
|
||||
}
|
||||
@@ -100,36 +100,38 @@ struct [[nodiscard]] Vector3 {
|
||||
_FORCE_INLINE_ Vector3 normalized() const;
|
||||
_FORCE_INLINE_ bool is_normalized() const;
|
||||
_FORCE_INLINE_ Vector3 inverse() const;
|
||||
Vector3 limit_length(const real_t p_len = 1.0) const;
|
||||
Vector3 limit_length(real_t p_len = 1.0) const;
|
||||
|
||||
_FORCE_INLINE_ void zero();
|
||||
|
||||
void snap(const Vector3 p_val);
|
||||
void snapf(real_t p_val);
|
||||
Vector3 snapped(const Vector3 p_val) const;
|
||||
Vector3 snappedf(real_t p_val) const;
|
||||
void snap(const Vector3 &p_step);
|
||||
void snapf(real_t p_step);
|
||||
Vector3 snapped(const Vector3 &p_step) const;
|
||||
Vector3 snappedf(real_t p_step) const;
|
||||
|
||||
void rotate(const Vector3 &p_axis, const real_t p_angle);
|
||||
Vector3 rotated(const Vector3 &p_axis, const real_t p_angle) const;
|
||||
void rotate(const Vector3 &p_axis, real_t p_angle);
|
||||
Vector3 rotated(const Vector3 &p_axis, real_t p_angle) const;
|
||||
|
||||
/* Static Methods between 2 vector3s */
|
||||
|
||||
_FORCE_INLINE_ Vector3 lerp(const Vector3 &p_to, const real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector3 slerp(const Vector3 &p_to, const real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector3 cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, const real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector3 cubic_interpolate_in_time(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, const real_t p_weight, const real_t &p_b_t, const real_t &p_pre_a_t, const real_t &p_post_b_t) const;
|
||||
_FORCE_INLINE_ Vector3 bezier_interpolate(const Vector3 &p_control_1, const Vector3 &p_control_2, const Vector3 &p_end, const real_t p_t) const;
|
||||
_FORCE_INLINE_ Vector3 lerp(const Vector3 &p_to, real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector3 slerp(const Vector3 &p_to, real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector3 cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const;
|
||||
_FORCE_INLINE_ Vector3 cubic_interpolate_in_time(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight, real_t p_b_t, real_t p_pre_a_t, real_t p_post_b_t) const;
|
||||
_FORCE_INLINE_ Vector3 bezier_interpolate(const Vector3 &p_control_1, const Vector3 &p_control_2, const Vector3 &p_end, real_t p_t) const;
|
||||
_FORCE_INLINE_ Vector3 bezier_derivative(const Vector3 &p_control_1, const Vector3 &p_control_2, const Vector3 &p_end, real_t p_t) const;
|
||||
|
||||
Vector3 move_toward(const Vector3 &p_to, const real_t p_delta) const;
|
||||
Vector3 move_toward(const Vector3 &p_to, real_t p_delta) const;
|
||||
|
||||
Vector2 octahedron_encode() const;
|
||||
static Vector3 octahedron_decode(const Vector2 &p_oct);
|
||||
Vector2 octahedron_tangent_encode(const float sign) const;
|
||||
static Vector3 octahedron_tangent_decode(const Vector2 &p_oct, float *sign);
|
||||
Vector2 octahedron_tangent_encode(float p_sign) const;
|
||||
static Vector3 octahedron_tangent_decode(const Vector2 &p_oct, float *r_sign);
|
||||
|
||||
_FORCE_INLINE_ Vector3 cross(const Vector3 &p_with) const;
|
||||
_FORCE_INLINE_ real_t dot(const Vector3 &p_with) const;
|
||||
Basis outer(const Vector3 &p_with) const;
|
||||
_FORCE_INLINE_ Vector3 get_any_perpendicular() const;
|
||||
|
||||
_FORCE_INLINE_ Vector3 abs() const;
|
||||
_FORCE_INLINE_ Vector3 floor() const;
|
||||
@@ -142,7 +144,7 @@ struct [[nodiscard]] Vector3 {
|
||||
_FORCE_INLINE_ real_t distance_to(const Vector3 &p_to) const;
|
||||
_FORCE_INLINE_ real_t distance_squared_to(const Vector3 &p_to) const;
|
||||
|
||||
_FORCE_INLINE_ Vector3 posmod(const real_t p_mod) const;
|
||||
_FORCE_INLINE_ Vector3 posmod(real_t p_mod) const;
|
||||
_FORCE_INLINE_ Vector3 posmodv(const Vector3 &p_modv) const;
|
||||
_FORCE_INLINE_ Vector3 project(const Vector3 &p_to) const;
|
||||
|
||||
@@ -169,10 +171,10 @@ struct [[nodiscard]] Vector3 {
|
||||
_FORCE_INLINE_ Vector3 &operator/=(const Vector3 &p_v);
|
||||
_FORCE_INLINE_ Vector3 operator/(const Vector3 &p_v) const;
|
||||
|
||||
_FORCE_INLINE_ Vector3 &operator*=(const real_t p_scalar);
|
||||
_FORCE_INLINE_ Vector3 operator*(const real_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector3 &operator/=(const real_t p_scalar);
|
||||
_FORCE_INLINE_ Vector3 operator/(const real_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector3 &operator*=(real_t p_scalar);
|
||||
_FORCE_INLINE_ Vector3 operator*(real_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector3 &operator/=(real_t p_scalar);
|
||||
_FORCE_INLINE_ Vector3 operator/(real_t p_scalar) const;
|
||||
|
||||
_FORCE_INLINE_ Vector3 operator-() const;
|
||||
|
||||
@@ -187,7 +189,7 @@ struct [[nodiscard]] Vector3 {
|
||||
operator Vector3i() const;
|
||||
|
||||
_FORCE_INLINE_ Vector3() {}
|
||||
_FORCE_INLINE_ Vector3(const real_t p_x, const real_t p_y, const real_t p_z) {
|
||||
_FORCE_INLINE_ Vector3(real_t p_x, real_t p_y, real_t p_z) {
|
||||
x = p_x;
|
||||
y = p_y;
|
||||
z = p_z;
|
||||
@@ -227,14 +229,15 @@ Vector3 Vector3::round() const {
|
||||
return Vector3(Math::round(x), Math::round(y), Math::round(z));
|
||||
}
|
||||
|
||||
Vector3 Vector3::lerp(const Vector3 &p_to, const real_t p_weight) const {
|
||||
return Vector3(
|
||||
x + (p_weight * (p_to.x - x)),
|
||||
y + (p_weight * (p_to.y - y)),
|
||||
z + (p_weight * (p_to.z - z)));
|
||||
Vector3 Vector3::lerp(const Vector3 &p_to, real_t p_weight) const {
|
||||
Vector3 res = *this;
|
||||
res.x = Math::lerp(res.x, p_to.x, p_weight);
|
||||
res.y = Math::lerp(res.y, p_to.y, p_weight);
|
||||
res.z = Math::lerp(res.z, p_to.z, p_weight);
|
||||
return res;
|
||||
}
|
||||
|
||||
Vector3 Vector3::slerp(const Vector3 &p_to, const real_t p_weight) const {
|
||||
Vector3 Vector3::slerp(const Vector3 &p_to, real_t p_weight) const {
|
||||
// This method seems more complicated than it really is, since we write out
|
||||
// the internals of some methods for efficiency (mainly, checking length).
|
||||
real_t start_length_sq = length_squared();
|
||||
@@ -256,7 +259,7 @@ Vector3 Vector3::slerp(const Vector3 &p_to, const real_t p_weight) const {
|
||||
return rotated(axis, angle * p_weight) * (result_length / start_length);
|
||||
}
|
||||
|
||||
Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, const real_t p_weight) const {
|
||||
Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const {
|
||||
Vector3 res = *this;
|
||||
res.x = Math::cubic_interpolate(res.x, p_b.x, p_pre_a.x, p_post_b.x, p_weight);
|
||||
res.y = Math::cubic_interpolate(res.y, p_b.y, p_pre_a.y, p_post_b.y, p_weight);
|
||||
@@ -264,7 +267,7 @@ Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, c
|
||||
return res;
|
||||
}
|
||||
|
||||
Vector3 Vector3::cubic_interpolate_in_time(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, const real_t p_weight, const real_t &p_b_t, const real_t &p_pre_a_t, const real_t &p_post_b_t) const {
|
||||
Vector3 Vector3::cubic_interpolate_in_time(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight, real_t p_b_t, real_t p_pre_a_t, real_t p_post_b_t) const {
|
||||
Vector3 res = *this;
|
||||
res.x = Math::cubic_interpolate_in_time(res.x, p_b.x, p_pre_a.x, p_post_b.x, p_weight, p_b_t, p_pre_a_t, p_post_b_t);
|
||||
res.y = Math::cubic_interpolate_in_time(res.y, p_b.y, p_pre_a.y, p_post_b.y, p_weight, p_b_t, p_pre_a_t, p_post_b_t);
|
||||
@@ -272,17 +275,20 @@ Vector3 Vector3::cubic_interpolate_in_time(const Vector3 &p_b, const Vector3 &p_
|
||||
return res;
|
||||
}
|
||||
|
||||
Vector3 Vector3::bezier_interpolate(const Vector3 &p_control_1, const Vector3 &p_control_2, const Vector3 &p_end, const real_t p_t) const {
|
||||
Vector3 Vector3::bezier_interpolate(const Vector3 &p_control_1, const Vector3 &p_control_2, const Vector3 &p_end, real_t p_t) const {
|
||||
Vector3 res = *this;
|
||||
res.x = Math::bezier_interpolate(res.x, p_control_1.x, p_control_2.x, p_end.x, p_t);
|
||||
res.y = Math::bezier_interpolate(res.y, p_control_1.y, p_control_2.y, p_end.y, p_t);
|
||||
res.z = Math::bezier_interpolate(res.z, p_control_1.z, p_control_2.z, p_end.z, p_t);
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Formula from Wikipedia article on Bezier curves. */
|
||||
real_t omt = (1.0 - p_t);
|
||||
real_t omt2 = omt * omt;
|
||||
real_t omt3 = omt2 * omt;
|
||||
real_t t2 = p_t * p_t;
|
||||
real_t t3 = t2 * p_t;
|
||||
|
||||
return res * omt3 + p_control_1 * omt2 * p_t * 3.0 + p_control_2 * omt * t2 * 3.0 + p_end * t3;
|
||||
Vector3 Vector3::bezier_derivative(const Vector3 &p_control_1, const Vector3 &p_control_2, const Vector3 &p_end, real_t p_t) const {
|
||||
Vector3 res = *this;
|
||||
res.x = Math::bezier_derivative(res.x, p_control_1.x, p_control_2.x, p_end.x, p_t);
|
||||
res.y = Math::bezier_derivative(res.y, p_control_1.y, p_control_2.y, p_end.y, p_t);
|
||||
res.z = Math::bezier_derivative(res.z, p_control_1.z, p_control_2.z, p_end.z, p_t);
|
||||
return res;
|
||||
}
|
||||
|
||||
real_t Vector3::distance_to(const Vector3 &p_to) const {
|
||||
@@ -293,7 +299,7 @@ real_t Vector3::distance_squared_to(const Vector3 &p_to) const {
|
||||
return (p_to - *this).length_squared();
|
||||
}
|
||||
|
||||
Vector3 Vector3::posmod(const real_t p_mod) const {
|
||||
Vector3 Vector3::posmod(real_t p_mod) const {
|
||||
return Vector3(Math::fposmod(x, p_mod), Math::fposmod(y, p_mod), Math::fposmod(z, p_mod));
|
||||
}
|
||||
|
||||
@@ -322,6 +328,16 @@ Vector3 Vector3::direction_to(const Vector3 &p_to) const {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Vector3 Vector3::get_any_perpendicular() const {
|
||||
// Return the any perpendicular vector by cross product with the Vector3.RIGHT or Vector3.UP,
|
||||
// whichever has the greater angle to the current vector with the sign of each element positive.
|
||||
// The only essence is "to avoid being parallel to the current vector", and there is no mathematical basis for using Vector3.RIGHT and Vector3.UP,
|
||||
// since it could be a different vector depending on the prior branching code Math::abs(x) <= Math::abs(y) && Math::abs(x) <= Math::abs(z).
|
||||
// However, it would be reasonable to use any of the axes of the basis, as it is simpler to calculate.
|
||||
ERR_FAIL_COND_V_MSG(is_zero_approx(), Vector3(0, 0, 0), "The Vector3 must not be zero.");
|
||||
return cross((Math::abs(x) <= Math::abs(y) && Math::abs(x) <= Math::abs(z)) ? Vector3(1, 0, 0) : Vector3(0, 1, 0)).normalized();
|
||||
}
|
||||
|
||||
/* Operators */
|
||||
|
||||
Vector3 &Vector3::operator+=(const Vector3 &p_v) {
|
||||
@@ -368,7 +384,7 @@ Vector3 Vector3::operator/(const Vector3 &p_v) const {
|
||||
return Vector3(x / p_v.x, y / p_v.y, z / p_v.z);
|
||||
}
|
||||
|
||||
Vector3 &Vector3::operator*=(const real_t p_scalar) {
|
||||
Vector3 &Vector3::operator*=(real_t p_scalar) {
|
||||
x *= p_scalar;
|
||||
y *= p_scalar;
|
||||
z *= p_scalar;
|
||||
@@ -378,34 +394,34 @@ Vector3 &Vector3::operator*=(const real_t p_scalar) {
|
||||
// Multiplication operators required to workaround issues with LLVM using implicit conversion
|
||||
// to Vector3i instead for integers where it should not.
|
||||
|
||||
_FORCE_INLINE_ Vector3 operator*(const float p_scalar, const Vector3 &p_vec) {
|
||||
_FORCE_INLINE_ Vector3 operator*(float p_scalar, const Vector3 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector3 operator*(const double p_scalar, const Vector3 &p_vec) {
|
||||
_FORCE_INLINE_ Vector3 operator*(double p_scalar, const Vector3 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector3 operator*(const int32_t p_scalar, const Vector3 &p_vec) {
|
||||
_FORCE_INLINE_ Vector3 operator*(int32_t p_scalar, const Vector3 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector3 operator*(const int64_t p_scalar, const Vector3 &p_vec) {
|
||||
_FORCE_INLINE_ Vector3 operator*(int64_t p_scalar, const Vector3 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
Vector3 Vector3::operator*(const real_t p_scalar) const {
|
||||
Vector3 Vector3::operator*(real_t p_scalar) const {
|
||||
return Vector3(x * p_scalar, y * p_scalar, z * p_scalar);
|
||||
}
|
||||
|
||||
Vector3 &Vector3::operator/=(const real_t p_scalar) {
|
||||
Vector3 &Vector3::operator/=(real_t p_scalar) {
|
||||
x /= p_scalar;
|
||||
y /= p_scalar;
|
||||
z /= p_scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector3 Vector3::operator/(const real_t p_scalar) const {
|
||||
Vector3 Vector3::operator/(real_t p_scalar) const {
|
||||
return Vector3(x / p_scalar, y / p_scalar, z / p_scalar);
|
||||
}
|
||||
|
||||
@@ -519,9 +535,9 @@ void Vector3::zero() {
|
||||
// slide returns the component of the vector along the given plane, specified by its normal vector.
|
||||
Vector3 Vector3::slide(const Vector3 &p_normal) const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!p_normal.is_normalized(), Vector3(), "The normal Vector3 must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_normal.is_normalized(), Vector3(), "The normal Vector3 " + p_normal.operator String() + " must be normalized.");
|
||||
#endif
|
||||
return *this - p_normal * this->dot(p_normal);
|
||||
return *this - p_normal * dot(p_normal);
|
||||
}
|
||||
|
||||
Vector3 Vector3::bounce(const Vector3 &p_normal) const {
|
||||
@@ -530,9 +546,9 @@ Vector3 Vector3::bounce(const Vector3 &p_normal) const {
|
||||
|
||||
Vector3 Vector3::reflect(const Vector3 &p_normal) const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!p_normal.is_normalized(), Vector3(), "The normal Vector3 must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_normal.is_normalized(), Vector3(), "The normal Vector3 " + p_normal.operator String() + " must be normalized.");
|
||||
#endif
|
||||
return 2.0f * p_normal * this->dot(p_normal) - *this;
|
||||
return 2.0f * p_normal * dot(p_normal) - *this;
|
||||
}
|
||||
|
||||
} // namespace godot
|
||||
|
||||
@@ -57,12 +57,12 @@ struct [[nodiscard]] Vector3i {
|
||||
int32_t coord[3] = { 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 < 3);
|
||||
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 < 3);
|
||||
return coord[p_axis];
|
||||
}
|
||||
@@ -89,17 +89,17 @@ struct [[nodiscard]] Vector3i {
|
||||
_FORCE_INLINE_ int64_t length_squared() const;
|
||||
_FORCE_INLINE_ double length() const;
|
||||
|
||||
_FORCE_INLINE_ int64_t distance_squared_to(const Vector3i &p_to) const;
|
||||
_FORCE_INLINE_ double distance_to(const Vector3i &p_to) const;
|
||||
|
||||
_FORCE_INLINE_ void zero();
|
||||
|
||||
_FORCE_INLINE_ Vector3i abs() const;
|
||||
_FORCE_INLINE_ Vector3i sign() const;
|
||||
Vector3i snapped(const Vector3i &p_step) const;
|
||||
Vector3i snappedi(int32_t p_step) const;
|
||||
Vector3i clamp(const Vector3i &p_min, const Vector3i &p_max) const;
|
||||
Vector3i clampi(int32_t p_min, int32_t p_max) const;
|
||||
Vector3i snapped(const Vector3i &p_step) const;
|
||||
Vector3i snappedi(int32_t p_step) const;
|
||||
|
||||
_FORCE_INLINE_ double distance_to(const Vector3i &p_to) const;
|
||||
_FORCE_INLINE_ int64_t distance_squared_to(const Vector3i &p_to) const;
|
||||
|
||||
/* Operators */
|
||||
|
||||
@@ -114,12 +114,12 @@ struct [[nodiscard]] Vector3i {
|
||||
_FORCE_INLINE_ Vector3i &operator%=(const Vector3i &p_v);
|
||||
_FORCE_INLINE_ Vector3i operator%(const Vector3i &p_v) const;
|
||||
|
||||
_FORCE_INLINE_ Vector3i &operator*=(const int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector3i operator*(const int32_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector3i &operator/=(const int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector3i operator/(const int32_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector3i &operator%=(const int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector3i operator%(const int32_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector3i &operator*=(int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector3i operator*(int32_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector3i &operator/=(int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector3i operator/(int32_t p_scalar) const;
|
||||
_FORCE_INLINE_ Vector3i &operator%=(int32_t p_scalar);
|
||||
_FORCE_INLINE_ Vector3i operator%(int32_t p_scalar) const;
|
||||
|
||||
_FORCE_INLINE_ Vector3i operator-() const;
|
||||
|
||||
@@ -134,7 +134,7 @@ struct [[nodiscard]] Vector3i {
|
||||
operator Vector3() const;
|
||||
|
||||
_FORCE_INLINE_ Vector3i() {}
|
||||
_FORCE_INLINE_ Vector3i(const int32_t p_x, const int32_t p_y, const int32_t p_z) {
|
||||
_FORCE_INLINE_ Vector3i(int32_t p_x, int32_t p_y, int32_t p_z) {
|
||||
x = p_x;
|
||||
y = p_y;
|
||||
z = p_z;
|
||||
@@ -149,14 +149,6 @@ double Vector3i::length() const {
|
||||
return Math::sqrt((double)length_squared());
|
||||
}
|
||||
|
||||
int64_t Vector3i::distance_squared_to(const Vector3i &p_to) const {
|
||||
return (p_to - *this).length_squared();
|
||||
}
|
||||
|
||||
double Vector3i::distance_to(const Vector3i &p_to) const {
|
||||
return (p_to - *this).length();
|
||||
}
|
||||
|
||||
Vector3i Vector3i::abs() const {
|
||||
return Vector3i(Math::abs(x), Math::abs(y), Math::abs(z));
|
||||
}
|
||||
@@ -165,6 +157,14 @@ Vector3i Vector3i::sign() const {
|
||||
return Vector3i(SIGN(x), SIGN(y), SIGN(z));
|
||||
}
|
||||
|
||||
double Vector3i::distance_to(const Vector3i &p_to) const {
|
||||
return (p_to - *this).length();
|
||||
}
|
||||
|
||||
int64_t Vector3i::distance_squared_to(const Vector3i &p_to) const {
|
||||
return (p_to - *this).length_squared();
|
||||
}
|
||||
|
||||
/* Operators */
|
||||
|
||||
Vector3i &Vector3i::operator+=(const Vector3i &p_v) {
|
||||
@@ -222,54 +222,54 @@ Vector3i Vector3i::operator%(const Vector3i &p_v) const {
|
||||
return Vector3i(x % p_v.x, y % p_v.y, z % p_v.z);
|
||||
}
|
||||
|
||||
Vector3i &Vector3i::operator*=(const int32_t p_scalar) {
|
||||
Vector3i &Vector3i::operator*=(int32_t p_scalar) {
|
||||
x *= p_scalar;
|
||||
y *= p_scalar;
|
||||
z *= p_scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector3i Vector3i::operator*(const int32_t p_scalar) const {
|
||||
Vector3i Vector3i::operator*(int32_t p_scalar) const {
|
||||
return Vector3i(x * p_scalar, y * p_scalar, z * p_scalar);
|
||||
}
|
||||
|
||||
// Multiplication operators required to workaround issues with LLVM using implicit conversion.
|
||||
|
||||
_FORCE_INLINE_ Vector3i operator*(const int32_t p_scalar, const Vector3i &p_vector) {
|
||||
_FORCE_INLINE_ Vector3i operator*(int32_t p_scalar, const Vector3i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector3i operator*(const int64_t p_scalar, const Vector3i &p_vector) {
|
||||
_FORCE_INLINE_ Vector3i operator*(int64_t p_scalar, const Vector3i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector3i operator*(const float p_scalar, const Vector3i &p_vector) {
|
||||
_FORCE_INLINE_ Vector3i operator*(float p_scalar, const Vector3i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector3i operator*(const double p_scalar, const Vector3i &p_vector) {
|
||||
_FORCE_INLINE_ Vector3i operator*(double p_scalar, const Vector3i &p_vector) {
|
||||
return p_vector * p_scalar;
|
||||
}
|
||||
|
||||
Vector3i &Vector3i::operator/=(const int32_t p_scalar) {
|
||||
Vector3i &Vector3i::operator/=(int32_t p_scalar) {
|
||||
x /= p_scalar;
|
||||
y /= p_scalar;
|
||||
z /= p_scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector3i Vector3i::operator/(const int32_t p_scalar) const {
|
||||
Vector3i Vector3i::operator/(int32_t p_scalar) const {
|
||||
return Vector3i(x / p_scalar, y / p_scalar, z / p_scalar);
|
||||
}
|
||||
|
||||
Vector3i &Vector3i::operator%=(const int32_t p_scalar) {
|
||||
Vector3i &Vector3i::operator%=(int32_t p_scalar) {
|
||||
x %= p_scalar;
|
||||
y %= p_scalar;
|
||||
z %= p_scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector3i Vector3i::operator%(const int32_t p_scalar) const {
|
||||
Vector3i Vector3i::operator%(int32_t p_scalar) const {
|
||||
return Vector3i(x % p_scalar, y % p_scalar, z % p_scalar);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
namespace godot {
|
||||
|
||||
class String;
|
||||
struct Vector4i;
|
||||
|
||||
struct [[nodiscard]] Vector4 {
|
||||
static const int AXIS_COUNT = 4;
|
||||
@@ -54,15 +55,14 @@ struct [[nodiscard]] Vector4 {
|
||||
real_t z;
|
||||
real_t w;
|
||||
};
|
||||
[[deprecated("Use coord instead")]] real_t components[4];
|
||||
real_t coord[4] = { 0, 0, 0, 0 };
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ real_t &operator[](const int p_axis) {
|
||||
_FORCE_INLINE_ real_t &operator[](int p_axis) {
|
||||
DEV_ASSERT((unsigned int)p_axis < 4);
|
||||
return coord[p_axis];
|
||||
}
|
||||
_FORCE_INLINE_ const real_t &operator[](const int p_axis) const {
|
||||
_FORCE_INLINE_ const real_t &operator[](int p_axis) const {
|
||||
DEV_ASSERT((unsigned int)p_axis < 4);
|
||||
return coord[p_axis];
|
||||
}
|
||||
@@ -104,11 +104,11 @@ struct [[nodiscard]] Vector4 {
|
||||
Vector4 floor() const;
|
||||
Vector4 ceil() const;
|
||||
Vector4 round() const;
|
||||
Vector4 lerp(const Vector4 &p_to, const real_t p_weight) const;
|
||||
Vector4 cubic_interpolate(const Vector4 &p_b, const Vector4 &p_pre_a, const Vector4 &p_post_b, const real_t p_weight) const;
|
||||
Vector4 cubic_interpolate_in_time(const Vector4 &p_b, const Vector4 &p_pre_a, const Vector4 &p_post_b, const real_t p_weight, const real_t &p_b_t, const real_t &p_pre_a_t, const real_t &p_post_b_t) const;
|
||||
Vector4 lerp(const Vector4 &p_to, real_t p_weight) const;
|
||||
Vector4 cubic_interpolate(const Vector4 &p_b, const Vector4 &p_pre_a, const Vector4 &p_post_b, real_t p_weight) const;
|
||||
Vector4 cubic_interpolate_in_time(const Vector4 &p_b, const Vector4 &p_pre_a, const Vector4 &p_post_b, real_t p_weight, real_t p_b_t, real_t p_pre_a_t, real_t p_post_b_t) const;
|
||||
|
||||
Vector4 posmod(const real_t p_mod) const;
|
||||
Vector4 posmod(real_t p_mod) const;
|
||||
Vector4 posmodv(const Vector4 &p_modv) const;
|
||||
void snap(const Vector4 &p_step);
|
||||
void snapf(real_t p_step);
|
||||
@@ -124,15 +124,15 @@ struct [[nodiscard]] Vector4 {
|
||||
_FORCE_INLINE_ void operator-=(const Vector4 &p_vec4);
|
||||
_FORCE_INLINE_ void operator*=(const Vector4 &p_vec4);
|
||||
_FORCE_INLINE_ void operator/=(const Vector4 &p_vec4);
|
||||
_FORCE_INLINE_ void operator*=(const real_t &s);
|
||||
_FORCE_INLINE_ void operator/=(const real_t &s);
|
||||
_FORCE_INLINE_ void operator*=(real_t p_s);
|
||||
_FORCE_INLINE_ void operator/=(real_t p_s);
|
||||
_FORCE_INLINE_ Vector4 operator+(const Vector4 &p_vec4) const;
|
||||
_FORCE_INLINE_ Vector4 operator-(const Vector4 &p_vec4) const;
|
||||
_FORCE_INLINE_ Vector4 operator*(const Vector4 &p_vec4) const;
|
||||
_FORCE_INLINE_ Vector4 operator/(const Vector4 &p_vec4) const;
|
||||
_FORCE_INLINE_ Vector4 operator-() const;
|
||||
_FORCE_INLINE_ Vector4 operator*(const real_t &s) const;
|
||||
_FORCE_INLINE_ Vector4 operator/(const real_t &s) const;
|
||||
_FORCE_INLINE_ Vector4 operator*(real_t p_s) const;
|
||||
_FORCE_INLINE_ Vector4 operator/(real_t p_s) const;
|
||||
|
||||
_FORCE_INLINE_ bool operator==(const Vector4 &p_vec4) const;
|
||||
_FORCE_INLINE_ bool operator!=(const Vector4 &p_vec4) const;
|
||||
@@ -142,28 +142,14 @@ struct [[nodiscard]] Vector4 {
|
||||
_FORCE_INLINE_ bool operator<=(const Vector4 &p_vec4) const;
|
||||
|
||||
operator String() const;
|
||||
operator Vector4i() const;
|
||||
|
||||
_FORCE_INLINE_ Vector4() {}
|
||||
|
||||
_FORCE_INLINE_ Vector4(real_t p_x, real_t p_y, real_t p_z, real_t p_w) :
|
||||
x(p_x),
|
||||
y(p_y),
|
||||
z(p_z),
|
||||
w(p_w) {
|
||||
}
|
||||
|
||||
Vector4(const Vector4 &p_vec4) :
|
||||
x(p_vec4.x),
|
||||
y(p_vec4.y),
|
||||
z(p_vec4.z),
|
||||
w(p_vec4.w) {
|
||||
}
|
||||
|
||||
void operator=(const Vector4 &p_vec4) {
|
||||
x = p_vec4.x;
|
||||
y = p_vec4.y;
|
||||
z = p_vec4.z;
|
||||
w = p_vec4.w;
|
||||
_FORCE_INLINE_ Vector4(real_t p_x, real_t p_y, real_t p_z, real_t p_w) {
|
||||
x = p_x;
|
||||
y = p_y;
|
||||
z = p_z;
|
||||
w = p_w;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -202,15 +188,15 @@ void Vector4::operator/=(const Vector4 &p_vec4) {
|
||||
z /= p_vec4.z;
|
||||
w /= p_vec4.w;
|
||||
}
|
||||
void Vector4::operator*=(const real_t &s) {
|
||||
x *= s;
|
||||
y *= s;
|
||||
z *= s;
|
||||
w *= s;
|
||||
void Vector4::operator*=(real_t p_s) {
|
||||
x *= p_s;
|
||||
y *= p_s;
|
||||
z *= p_s;
|
||||
w *= p_s;
|
||||
}
|
||||
|
||||
void Vector4::operator/=(const real_t &s) {
|
||||
*this *= 1.0f / s;
|
||||
void Vector4::operator/=(real_t p_s) {
|
||||
*this *= 1.0f / p_s;
|
||||
}
|
||||
|
||||
Vector4 Vector4::operator+(const Vector4 &p_vec4) const {
|
||||
@@ -233,12 +219,12 @@ Vector4 Vector4::operator-() const {
|
||||
return Vector4(-x, -y, -z, -w);
|
||||
}
|
||||
|
||||
Vector4 Vector4::operator*(const real_t &s) const {
|
||||
return Vector4(x * s, y * s, z * s, w * s);
|
||||
Vector4 Vector4::operator*(real_t p_s) const {
|
||||
return Vector4(x * p_s, y * p_s, z * p_s, w * p_s);
|
||||
}
|
||||
|
||||
Vector4 Vector4::operator/(const real_t &s) const {
|
||||
return *this * (1.0f / s);
|
||||
Vector4 Vector4::operator/(real_t p_s) const {
|
||||
return *this * (1.0f / p_s);
|
||||
}
|
||||
|
||||
bool Vector4::operator==(const Vector4 &p_vec4) const {
|
||||
@@ -301,19 +287,19 @@ bool Vector4::operator>=(const Vector4 &p_v) const {
|
||||
return x > p_v.x;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector4 operator*(const float p_scalar, const Vector4 &p_vec) {
|
||||
_FORCE_INLINE_ Vector4 operator*(float p_scalar, const Vector4 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector4 operator*(const double p_scalar, const Vector4 &p_vec) {
|
||||
_FORCE_INLINE_ Vector4 operator*(double p_scalar, const Vector4 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector4 operator*(const int32_t p_scalar, const Vector4 &p_vec) {
|
||||
_FORCE_INLINE_ Vector4 operator*(int32_t p_scalar, const Vector4 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector4 operator*(const int64_t p_scalar, const Vector4 &p_vec) {
|
||||
_FORCE_INLINE_ Vector4 operator*(int64_t p_scalar, const Vector4 &p_vec) {
|
||||
return p_vec * p_scalar;
|
||||
}
|
||||
|
||||
|
||||
@@ -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