mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
Merge pull request #105249 from Repiteo/core/math-defs-namespace
Core: Use `Math` namespace for constants
This commit is contained in:
commit
717df3ee88
181 changed files with 812 additions and 818 deletions
|
@ -4331,10 +4331,10 @@ Dictionary Image::compute_image_metrics(const Ref<Image> p_compared_image, bool
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Dictionary result;
|
||||
result["max"] = INFINITY;
|
||||
result["mean"] = INFINITY;
|
||||
result["mean_squared"] = INFINITY;
|
||||
result["root_mean_squared"] = INFINITY;
|
||||
result["max"] = Math::INF;
|
||||
result["mean"] = Math::INF;
|
||||
result["mean_squared"] = Math::INF;
|
||||
result["root_mean_squared"] = Math::INF;
|
||||
result["peak_snr"] = 0.0f;
|
||||
|
||||
ERR_FAIL_COND_V(p_compared_image.is_null(), result);
|
||||
|
|
|
@ -48,7 +48,7 @@ static real_t heuristic_manhattan(const Vector2i &p_from, const Vector2i &p_to)
|
|||
static real_t heuristic_octile(const Vector2i &p_from, const Vector2i &p_to) {
|
||||
real_t dx = (real_t)Math::abs(p_to.x - p_from.x);
|
||||
real_t dy = (real_t)Math::abs(p_to.y - p_from.y);
|
||||
real_t F = Math_SQRT2 - 1;
|
||||
real_t F = Math::SQRT2 - 1;
|
||||
return (dx < dy) ? F * dx + dy : F * dy + dx;
|
||||
}
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ Basis Basis::diagonalize() {
|
|||
// Compute the rotation angle
|
||||
real_t angle;
|
||||
if (Math::is_equal_approx(rows[j][j], rows[i][i])) {
|
||||
angle = Math_PI / 4;
|
||||
angle = Math::PI / 4;
|
||||
} else {
|
||||
angle = 0.5f * Math::atan(2 * rows[i][j] / (rows[j][j] - rows[i][i]));
|
||||
}
|
||||
|
@ -486,12 +486,12 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
}
|
||||
} else {
|
||||
euler.x = Math::atan2(rows[2][1], rows[1][1]);
|
||||
euler.y = -Math_PI / 2.0f;
|
||||
euler.y = -Math::PI / 2.0f;
|
||||
euler.z = 0.0f;
|
||||
}
|
||||
} else {
|
||||
euler.x = Math::atan2(rows[2][1], rows[1][1]);
|
||||
euler.y = Math_PI / 2.0f;
|
||||
euler.y = Math::PI / 2.0f;
|
||||
euler.z = 0.0f;
|
||||
}
|
||||
return euler;
|
||||
|
@ -515,13 +515,13 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
// It's -1
|
||||
euler.x = -Math::atan2(rows[1][2], rows[2][2]);
|
||||
euler.y = 0.0f;
|
||||
euler.z = Math_PI / 2.0f;
|
||||
euler.z = Math::PI / 2.0f;
|
||||
}
|
||||
} else {
|
||||
// It's 1
|
||||
euler.x = -Math::atan2(rows[1][2], rows[2][2]);
|
||||
euler.y = 0.0f;
|
||||
euler.z = -Math_PI / 2.0f;
|
||||
euler.z = -Math::PI / 2.0f;
|
||||
}
|
||||
return euler;
|
||||
}
|
||||
|
@ -551,12 +551,12 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
euler.z = atan2(rows[1][0], rows[1][1]);
|
||||
}
|
||||
} else { // m12 == -1
|
||||
euler.x = Math_PI * 0.5f;
|
||||
euler.x = Math::PI * 0.5f;
|
||||
euler.y = atan2(rows[0][1], rows[0][0]);
|
||||
euler.z = 0;
|
||||
}
|
||||
} else { // m12 == 1
|
||||
euler.x = -Math_PI * 0.5f;
|
||||
euler.x = -Math::PI * 0.5f;
|
||||
euler.y = -atan2(rows[0][1], rows[0][0]);
|
||||
euler.z = 0;
|
||||
}
|
||||
|
@ -582,13 +582,13 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
// It's -1
|
||||
euler.x = Math::atan2(rows[2][1], rows[2][2]);
|
||||
euler.y = 0.0f;
|
||||
euler.z = -Math_PI / 2.0f;
|
||||
euler.z = -Math::PI / 2.0f;
|
||||
}
|
||||
} else {
|
||||
// It's 1
|
||||
euler.x = Math::atan2(rows[2][1], rows[2][2]);
|
||||
euler.y = 0.0f;
|
||||
euler.z = Math_PI / 2.0f;
|
||||
euler.z = Math::PI / 2.0f;
|
||||
}
|
||||
return euler;
|
||||
} break;
|
||||
|
@ -608,13 +608,13 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
euler.z = Math::atan2(-rows[0][1], rows[1][1]);
|
||||
} else {
|
||||
// It's -1
|
||||
euler.x = -Math_PI / 2.0f;
|
||||
euler.x = -Math::PI / 2.0f;
|
||||
euler.y = Math::atan2(rows[0][2], rows[0][0]);
|
||||
euler.z = 0;
|
||||
}
|
||||
} else {
|
||||
// It's 1
|
||||
euler.x = Math_PI / 2.0f;
|
||||
euler.x = Math::PI / 2.0f;
|
||||
euler.y = Math::atan2(rows[0][2], rows[0][0]);
|
||||
euler.z = 0;
|
||||
}
|
||||
|
@ -637,13 +637,13 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
} else {
|
||||
// It's -1
|
||||
euler.x = 0;
|
||||
euler.y = Math_PI / 2.0f;
|
||||
euler.y = Math::PI / 2.0f;
|
||||
euler.z = -Math::atan2(rows[0][1], rows[1][1]);
|
||||
}
|
||||
} else {
|
||||
// It's 1
|
||||
euler.x = 0;
|
||||
euler.y = -Math_PI / 2.0f;
|
||||
euler.y = -Math::PI / 2.0f;
|
||||
euler.z = -Math::atan2(rows[0][1], rows[1][1]);
|
||||
}
|
||||
return euler;
|
||||
|
@ -778,8 +778,8 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
|
|||
if ((xx > yy) && (xx > zz)) { // rows[0][0] is the largest diagonal term.
|
||||
if (xx < CMP_EPSILON) {
|
||||
x = 0;
|
||||
y = Math_SQRT12;
|
||||
z = Math_SQRT12;
|
||||
y = Math::SQRT12;
|
||||
z = Math::SQRT12;
|
||||
} else {
|
||||
x = Math::sqrt(xx);
|
||||
y = xy / x;
|
||||
|
@ -787,9 +787,9 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
|
|||
}
|
||||
} else if (yy > zz) { // rows[1][1] is the largest diagonal term.
|
||||
if (yy < CMP_EPSILON) {
|
||||
x = Math_SQRT12;
|
||||
x = Math::SQRT12;
|
||||
y = 0;
|
||||
z = Math_SQRT12;
|
||||
z = Math::SQRT12;
|
||||
} else {
|
||||
y = Math::sqrt(yy);
|
||||
x = xy / y;
|
||||
|
@ -797,8 +797,8 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
|
|||
}
|
||||
} else { // rows[2][2] is the largest diagonal term so base result on this.
|
||||
if (zz < CMP_EPSILON) {
|
||||
x = Math_SQRT12;
|
||||
y = Math_SQRT12;
|
||||
x = Math::SQRT12;
|
||||
y = Math::SQRT12;
|
||||
z = 0;
|
||||
} else {
|
||||
z = Math::sqrt(zz);
|
||||
|
@ -807,7 +807,7 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
|
|||
}
|
||||
}
|
||||
r_axis = Vector3(x, y, z);
|
||||
r_angle = Math_PI;
|
||||
r_angle = Math::PI;
|
||||
return;
|
||||
}
|
||||
// As we have reached here there are no singularities so we can handle normally.
|
||||
|
|
|
@ -181,7 +181,7 @@ DynamicBVH::Volume DynamicBVH::_bounds(Node **leaves, int p_count) {
|
|||
|
||||
void DynamicBVH::_bottom_up(Node **leaves, int p_count) {
|
||||
while (p_count > 1) {
|
||||
real_t minsize = INFINITY;
|
||||
real_t minsize = Math::INF;
|
||||
int minidx[2] = { -1, -1 };
|
||||
for (int i = 0; i < p_count; ++i) {
|
||||
for (int j = i + 1; j < p_count; ++j) {
|
||||
|
|
|
@ -454,16 +454,16 @@ Error Expression::_get_token(Token &r_token) {
|
|||
r_token.value = false;
|
||||
} else if (id == "PI") {
|
||||
r_token.type = TK_CONSTANT;
|
||||
r_token.value = Math_PI;
|
||||
r_token.value = Math::PI;
|
||||
} else if (id == "TAU") {
|
||||
r_token.type = TK_CONSTANT;
|
||||
r_token.value = Math_TAU;
|
||||
r_token.value = Math::TAU;
|
||||
} else if (id == "INF") {
|
||||
r_token.type = TK_CONSTANT;
|
||||
r_token.value = INFINITY;
|
||||
r_token.value = Math::INF;
|
||||
} else if (id == "NAN") {
|
||||
r_token.type = TK_CONSTANT;
|
||||
r_token.value = NAN;
|
||||
r_token.value = Math::NaN;
|
||||
} else if (id == "not") {
|
||||
r_token.type = TK_OP_NOT;
|
||||
} else if (id == "or") {
|
||||
|
|
|
@ -744,7 +744,7 @@ Vector<Plane> Geometry3D::build_cylinder_planes(real_t p_radius, real_t p_height
|
|||
|
||||
Vector<Plane> planes;
|
||||
|
||||
const double sides_step = Math_TAU / p_sides;
|
||||
const double sides_step = Math::TAU / p_sides;
|
||||
for (int i = 0; i < p_sides; i++) {
|
||||
Vector3 normal;
|
||||
normal[(p_axis + 1) % 3] = Math::cos(i * sides_step);
|
||||
|
@ -775,7 +775,7 @@ Vector<Plane> Geometry3D::build_sphere_planes(real_t p_radius, int p_lats, int p
|
|||
axis_neg[(p_axis + 2) % 3] = 1.0;
|
||||
axis_neg[p_axis] = -1.0;
|
||||
|
||||
const double lon_step = Math_TAU / p_lons;
|
||||
const double lon_step = Math::TAU / p_lons;
|
||||
for (int i = 0; i < p_lons; i++) {
|
||||
Vector3 normal;
|
||||
normal[(p_axis + 1) % 3] = Math::cos(i * lon_step);
|
||||
|
@ -806,7 +806,7 @@ Vector<Plane> Geometry3D::build_capsule_planes(real_t p_radius, real_t p_height,
|
|||
axis_neg[(p_axis + 2) % 3] = 1.0;
|
||||
axis_neg[p_axis] = -1.0;
|
||||
|
||||
const double sides_step = Math_TAU / p_sides;
|
||||
const double sides_step = Math::TAU / p_sides;
|
||||
for (int i = 0; i < p_sides; i++) {
|
||||
Vector3 normal;
|
||||
normal[(p_axis + 1) % 3] = Math::cos(i * sides_step);
|
||||
|
@ -862,7 +862,6 @@ Vector<Vector3> Geometry3D::compute_convex_mesh_points(const Plane *p_planes, in
|
|||
}
|
||||
|
||||
#define square(m_s) ((m_s) * (m_s))
|
||||
#define INF 1e20
|
||||
|
||||
/* dt of 1d function using squared distance */
|
||||
static void edt(float *f, int stride, int n) {
|
||||
|
@ -872,8 +871,8 @@ static void edt(float *f, int stride, int n) {
|
|||
|
||||
int k = 0;
|
||||
v[0] = 0;
|
||||
z[0] = -INF;
|
||||
z[1] = +INF;
|
||||
z[0] = -Math::INF;
|
||||
z[1] = +Math::INF;
|
||||
for (int q = 1; q <= n - 1; q++) {
|
||||
float s = ((f[q * stride] + square(q)) - (f[v[k] * stride] + square(v[k]))) / (2 * q - 2 * v[k]);
|
||||
while (s <= z[k]) {
|
||||
|
@ -884,7 +883,7 @@ static void edt(float *f, int stride, int n) {
|
|||
v[k] = q;
|
||||
|
||||
z[k] = s;
|
||||
z[k + 1] = +INF;
|
||||
z[k + 1] = +Math::INF;
|
||||
}
|
||||
|
||||
k = 0;
|
||||
|
@ -909,7 +908,7 @@ Vector<uint32_t> Geometry3D::generate_edf(const Vector<bool> &p_voxels, const Ve
|
|||
|
||||
float *work_memory = memnew_arr(float, float_count);
|
||||
for (uint32_t i = 0; i < float_count; i++) {
|
||||
work_memory[i] = INF;
|
||||
work_memory[i] = Math::INF;
|
||||
}
|
||||
|
||||
uint32_t y_mult = p_size.x;
|
||||
|
|
|
@ -30,19 +30,29 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "core/typedefs.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace Math {
|
||||
inline constexpr double SQRT2 = 1.4142135623730950488016887242;
|
||||
inline constexpr double SQRT3 = 1.7320508075688772935274463415059;
|
||||
inline constexpr double SQRT12 = 0.7071067811865475244008443621048490;
|
||||
inline constexpr double SQRT13 = 0.57735026918962576450914878050196;
|
||||
inline constexpr double LN2 = 0.6931471805599453094172321215;
|
||||
inline constexpr double TAU = 6.2831853071795864769252867666;
|
||||
inline constexpr double PI = 3.1415926535897932384626433833;
|
||||
inline constexpr double E = 2.7182818284590452353602874714;
|
||||
inline constexpr double INF = std::numeric_limits<double>::infinity();
|
||||
inline constexpr double NaN = std::numeric_limits<double>::quiet_NaN();
|
||||
} // namespace Math
|
||||
|
||||
#define CMP_EPSILON 0.00001
|
||||
#define CMP_EPSILON2 (CMP_EPSILON * CMP_EPSILON)
|
||||
|
||||
#define CMP_NORMALIZE_TOLERANCE 0.000001
|
||||
#define CMP_POINT_IN_PLANE_EPSILON 0.00001
|
||||
|
||||
#define Math_SQRT12 0.7071067811865475244008443621048490
|
||||
#define Math_SQRT2 1.4142135623730950488016887242
|
||||
#define Math_LN2 0.6931471805599453094172321215
|
||||
#define Math_TAU 6.2831853071795864769252867666
|
||||
#define Math_PI 3.1415926535897932384626433833
|
||||
#define Math_E 2.7182818284590452353602874714
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
#define MATH_CHECKS
|
||||
#endif
|
||||
|
|
|
@ -75,10 +75,10 @@ _ALWAYS_INLINE_ float sinc(float p_x) {
|
|||
}
|
||||
|
||||
_ALWAYS_INLINE_ double sincn(double p_x) {
|
||||
return sinc(Math_PI * p_x);
|
||||
return sinc(PI * p_x);
|
||||
}
|
||||
_ALWAYS_INLINE_ float sincn(float p_x) {
|
||||
return sinc((float)Math_PI * p_x);
|
||||
return sinc((float)PI * p_x);
|
||||
}
|
||||
|
||||
_ALWAYS_INLINE_ double cosh(double p_x) {
|
||||
|
@ -97,18 +97,18 @@ _ALWAYS_INLINE_ float tanh(float p_x) {
|
|||
|
||||
// Always does clamping so always safe to use.
|
||||
_ALWAYS_INLINE_ double asin(double p_x) {
|
||||
return p_x < -1 ? (-Math_PI / 2) : (p_x > 1 ? (Math_PI / 2) : ::asin(p_x));
|
||||
return p_x < -1 ? (-PI / 2) : (p_x > 1 ? (PI / 2) : ::asin(p_x));
|
||||
}
|
||||
_ALWAYS_INLINE_ float asin(float p_x) {
|
||||
return p_x < -1 ? (-Math_PI / 2) : (p_x > 1 ? (Math_PI / 2) : ::asinf(p_x));
|
||||
return p_x < -1 ? (-(float)PI / 2) : (p_x > 1 ? ((float)PI / 2) : ::asinf(p_x));
|
||||
}
|
||||
|
||||
// Always does clamping so always safe to use.
|
||||
_ALWAYS_INLINE_ double acos(double p_x) {
|
||||
return p_x < -1 ? Math_PI : (p_x > 1 ? 0 : ::acos(p_x));
|
||||
return p_x < -1 ? PI : (p_x > 1 ? 0 : ::acos(p_x));
|
||||
}
|
||||
_ALWAYS_INLINE_ float acos(float p_x) {
|
||||
return p_x < -1 ? Math_PI : (p_x > 1 ? 0 : ::acosf(p_x));
|
||||
return p_x < -1 ? (float)PI : (p_x > 1 ? 0 : ::acosf(p_x));
|
||||
}
|
||||
|
||||
_ALWAYS_INLINE_ double atan(double p_x) {
|
||||
|
@ -142,10 +142,10 @@ _ALWAYS_INLINE_ float acosh(float p_x) {
|
|||
|
||||
// Always does clamping so always safe to use.
|
||||
_ALWAYS_INLINE_ double atanh(double p_x) {
|
||||
return p_x <= -1 ? -INFINITY : (p_x >= 1 ? INFINITY : ::atanh(p_x));
|
||||
return p_x <= -1 ? -INF : (p_x >= 1 ? INF : ::atanh(p_x));
|
||||
}
|
||||
_ALWAYS_INLINE_ float atanh(float p_x) {
|
||||
return p_x <= -1 ? -INFINITY : (p_x >= 1 ? INFINITY : ::atanhf(p_x));
|
||||
return p_x <= -1 ? (float)-INF : (p_x >= 1 ? (float)INF : ::atanhf(p_x));
|
||||
}
|
||||
|
||||
_ALWAYS_INLINE_ double sqrt(double p_x) {
|
||||
|
@ -383,17 +383,17 @@ _ALWAYS_INLINE_ int64_t posmod(int64_t p_x, int64_t p_y) {
|
|||
}
|
||||
|
||||
_ALWAYS_INLINE_ double deg_to_rad(double p_y) {
|
||||
return p_y * (Math_PI / 180.0);
|
||||
return p_y * (PI / 180.0);
|
||||
}
|
||||
_ALWAYS_INLINE_ float deg_to_rad(float p_y) {
|
||||
return p_y * (float)(Math_PI / 180.0);
|
||||
return p_y * ((float)PI / 180.0f);
|
||||
}
|
||||
|
||||
_ALWAYS_INLINE_ double rad_to_deg(double p_y) {
|
||||
return p_y * (180.0 / Math_PI);
|
||||
return p_y * (180.0 / PI);
|
||||
}
|
||||
_ALWAYS_INLINE_ float rad_to_deg(float p_y) {
|
||||
return p_y * (float)(180.0 / Math_PI);
|
||||
return p_y * (180.0f / (float)PI);
|
||||
}
|
||||
|
||||
_ALWAYS_INLINE_ double lerp(double p_from, double p_to, double p_weight) {
|
||||
|
@ -419,31 +419,31 @@ _ALWAYS_INLINE_ float cubic_interpolate(float p_from, float p_to, float p_pre, f
|
|||
}
|
||||
|
||||
_ALWAYS_INLINE_ double cubic_interpolate_angle(double p_from, double p_to, double p_pre, double p_post, double p_weight) {
|
||||
double from_rot = fmod(p_from, Math_TAU);
|
||||
double from_rot = fmod(p_from, TAU);
|
||||
|
||||
double pre_diff = fmod(p_pre - from_rot, Math_TAU);
|
||||
double pre_rot = from_rot + fmod(2.0 * pre_diff, Math_TAU) - pre_diff;
|
||||
double pre_diff = fmod(p_pre - from_rot, TAU);
|
||||
double pre_rot = from_rot + fmod(2.0 * pre_diff, TAU) - pre_diff;
|
||||
|
||||
double to_diff = fmod(p_to - from_rot, Math_TAU);
|
||||
double to_rot = from_rot + fmod(2.0 * to_diff, Math_TAU) - to_diff;
|
||||
double to_diff = fmod(p_to - from_rot, TAU);
|
||||
double to_rot = from_rot + fmod(2.0 * to_diff, TAU) - to_diff;
|
||||
|
||||
double post_diff = fmod(p_post - to_rot, Math_TAU);
|
||||
double post_rot = to_rot + fmod(2.0 * post_diff, Math_TAU) - post_diff;
|
||||
double post_diff = fmod(p_post - to_rot, TAU);
|
||||
double post_rot = to_rot + fmod(2.0 * post_diff, TAU) - post_diff;
|
||||
|
||||
return cubic_interpolate(from_rot, to_rot, pre_rot, post_rot, p_weight);
|
||||
}
|
||||
|
||||
_ALWAYS_INLINE_ float cubic_interpolate_angle(float p_from, float p_to, float p_pre, float p_post, float p_weight) {
|
||||
float from_rot = fmod(p_from, (float)Math_TAU);
|
||||
float from_rot = fmod(p_from, (float)TAU);
|
||||
|
||||
float pre_diff = fmod(p_pre - from_rot, (float)Math_TAU);
|
||||
float pre_rot = from_rot + fmod(2.0f * pre_diff, (float)Math_TAU) - pre_diff;
|
||||
float pre_diff = fmod(p_pre - from_rot, (float)TAU);
|
||||
float pre_rot = from_rot + fmod(2.0f * pre_diff, (float)TAU) - pre_diff;
|
||||
|
||||
float to_diff = fmod(p_to - from_rot, (float)Math_TAU);
|
||||
float to_rot = from_rot + fmod(2.0f * to_diff, (float)Math_TAU) - to_diff;
|
||||
float to_diff = fmod(p_to - from_rot, (float)TAU);
|
||||
float to_rot = from_rot + fmod(2.0f * to_diff, (float)TAU) - to_diff;
|
||||
|
||||
float post_diff = fmod(p_post - to_rot, (float)Math_TAU);
|
||||
float post_rot = to_rot + fmod(2.0f * post_diff, (float)Math_TAU) - post_diff;
|
||||
float post_diff = fmod(p_post - to_rot, (float)TAU);
|
||||
float post_rot = to_rot + fmod(2.0f * post_diff, (float)TAU) - post_diff;
|
||||
|
||||
return cubic_interpolate(from_rot, to_rot, pre_rot, post_rot, p_weight);
|
||||
}
|
||||
|
@ -473,31 +473,31 @@ _ALWAYS_INLINE_ float cubic_interpolate_in_time(float p_from, float p_to, float
|
|||
|
||||
_ALWAYS_INLINE_ double cubic_interpolate_angle_in_time(double p_from, double p_to, double p_pre, double p_post, double p_weight,
|
||||
double p_to_t, double p_pre_t, double p_post_t) {
|
||||
double from_rot = fmod(p_from, Math_TAU);
|
||||
double from_rot = fmod(p_from, TAU);
|
||||
|
||||
double pre_diff = fmod(p_pre - from_rot, Math_TAU);
|
||||
double pre_rot = from_rot + fmod(2.0 * pre_diff, Math_TAU) - pre_diff;
|
||||
double pre_diff = fmod(p_pre - from_rot, TAU);
|
||||
double pre_rot = from_rot + fmod(2.0 * pre_diff, TAU) - pre_diff;
|
||||
|
||||
double to_diff = fmod(p_to - from_rot, Math_TAU);
|
||||
double to_rot = from_rot + fmod(2.0 * to_diff, Math_TAU) - to_diff;
|
||||
double to_diff = fmod(p_to - from_rot, TAU);
|
||||
double to_rot = from_rot + fmod(2.0 * to_diff, TAU) - to_diff;
|
||||
|
||||
double post_diff = fmod(p_post - to_rot, Math_TAU);
|
||||
double post_rot = to_rot + fmod(2.0 * post_diff, Math_TAU) - post_diff;
|
||||
double post_diff = fmod(p_post - to_rot, TAU);
|
||||
double post_rot = to_rot + fmod(2.0 * post_diff, TAU) - post_diff;
|
||||
|
||||
return cubic_interpolate_in_time(from_rot, to_rot, pre_rot, post_rot, p_weight, p_to_t, p_pre_t, p_post_t);
|
||||
}
|
||||
_ALWAYS_INLINE_ float cubic_interpolate_angle_in_time(float p_from, float p_to, float p_pre, float p_post, float p_weight,
|
||||
float p_to_t, float p_pre_t, float p_post_t) {
|
||||
float from_rot = fmod(p_from, (float)Math_TAU);
|
||||
float from_rot = fmod(p_from, (float)TAU);
|
||||
|
||||
float pre_diff = fmod(p_pre - from_rot, (float)Math_TAU);
|
||||
float pre_rot = from_rot + fmod(2.0f * pre_diff, (float)Math_TAU) - pre_diff;
|
||||
float pre_diff = fmod(p_pre - from_rot, (float)TAU);
|
||||
float pre_rot = from_rot + fmod(2.0f * pre_diff, (float)TAU) - pre_diff;
|
||||
|
||||
float to_diff = fmod(p_to - from_rot, (float)Math_TAU);
|
||||
float to_rot = from_rot + fmod(2.0f * to_diff, (float)Math_TAU) - to_diff;
|
||||
float to_diff = fmod(p_to - from_rot, (float)TAU);
|
||||
float to_rot = from_rot + fmod(2.0f * to_diff, (float)TAU) - to_diff;
|
||||
|
||||
float post_diff = fmod(p_post - to_rot, (float)Math_TAU);
|
||||
float post_rot = to_rot + fmod(2.0f * post_diff, (float)Math_TAU) - post_diff;
|
||||
float post_diff = fmod(p_post - to_rot, (float)TAU);
|
||||
float post_rot = to_rot + fmod(2.0f * post_diff, (float)TAU) - post_diff;
|
||||
|
||||
return cubic_interpolate_in_time(from_rot, to_rot, pre_rot, post_rot, p_weight, p_to_t, p_pre_t, p_post_t);
|
||||
}
|
||||
|
@ -543,12 +543,12 @@ _ALWAYS_INLINE_ float bezier_derivative(float p_start, float p_control_1, float
|
|||
}
|
||||
|
||||
_ALWAYS_INLINE_ double angle_difference(double p_from, double p_to) {
|
||||
double difference = fmod(p_to - p_from, Math_TAU);
|
||||
return fmod(2.0 * difference, Math_TAU) - difference;
|
||||
double difference = fmod(p_to - p_from, TAU);
|
||||
return fmod(2.0 * difference, TAU) - difference;
|
||||
}
|
||||
_ALWAYS_INLINE_ float angle_difference(float p_from, float p_to) {
|
||||
float difference = fmod(p_to - p_from, (float)Math_TAU);
|
||||
return fmod(2.0f * difference, (float)Math_TAU) - difference;
|
||||
float difference = fmod(p_to - p_from, (float)TAU);
|
||||
return fmod(2.0f * difference, (float)TAU) - difference;
|
||||
}
|
||||
|
||||
_ALWAYS_INLINE_ double lerp_angle(double p_from, double p_to, double p_weight) {
|
||||
|
@ -662,13 +662,13 @@ _ALWAYS_INLINE_ double rotate_toward(double p_from, double p_to, double p_delta)
|
|||
double difference = angle_difference(p_from, p_to);
|
||||
double abs_difference = abs(difference);
|
||||
// When `p_delta < 0` move no further than to PI radians away from `p_to` (as PI is the max possible angle distance).
|
||||
return p_from + CLAMP(p_delta, abs_difference - Math_PI, abs_difference) * (difference >= 0.0 ? 1.0 : -1.0);
|
||||
return p_from + CLAMP(p_delta, abs_difference - PI, abs_difference) * (difference >= 0.0 ? 1.0 : -1.0);
|
||||
}
|
||||
_ALWAYS_INLINE_ float rotate_toward(float p_from, float p_to, float p_delta) {
|
||||
float difference = angle_difference(p_from, p_to);
|
||||
float abs_difference = abs(difference);
|
||||
// When `p_delta < 0` move no further than to PI radians away from `p_to` (as PI is the max possible angle distance).
|
||||
return p_from + CLAMP(p_delta, abs_difference - (float)Math_PI, abs_difference) * (difference >= 0.0f ? 1.0f : -1.0f);
|
||||
return p_from + CLAMP(p_delta, abs_difference - (float)PI, abs_difference) * (difference >= 0.0f ? 1.0f : -1.0f);
|
||||
}
|
||||
|
||||
_ALWAYS_INLINE_ double linear_to_db(double p_linear) {
|
||||
|
|
|
@ -134,14 +134,14 @@ public:
|
|||
if (temp < CMP_EPSILON) {
|
||||
temp += CMP_EPSILON; // To prevent generating of INF value in log function, resulting to return NaN value from this function.
|
||||
}
|
||||
return p_mean + p_deviation * (cos(Math_TAU * randd()) * sqrt(-2.0 * log(temp))); // Box-Muller transform.
|
||||
return p_mean + p_deviation * (cos(Math::TAU * randd()) * sqrt(-2.0 * log(temp))); // Box-Muller transform.
|
||||
}
|
||||
_FORCE_INLINE_ float randfn(float p_mean, float p_deviation) {
|
||||
float temp = randf();
|
||||
if (temp < CMP_EPSILON) {
|
||||
temp += CMP_EPSILON; // To prevent generating of INF value in log function, resulting to return NaN value from this function.
|
||||
}
|
||||
return p_mean + p_deviation * (cos((float)Math_TAU * randf()) * sqrt(-2.0 * log(temp))); // Box-Muller transform.
|
||||
return p_mean + p_deviation * (cos((float)Math::TAU * randf()) * sqrt(-2.0 * log(temp))); // Box-Muller transform.
|
||||
}
|
||||
|
||||
double random(double p_from, double p_to);
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
_FORCE_INLINE_ Ray(const Vector3 &p_org,
|
||||
const Vector3 &p_dir,
|
||||
float p_tnear = 0.0f,
|
||||
float p_tfar = INFINITY) :
|
||||
float p_tfar = Math::INF) :
|
||||
org(p_org),
|
||||
tnear(p_tnear),
|
||||
dir(p_dir),
|
||||
|
|
|
@ -71,12 +71,12 @@ void Transform2D::rotate(real_t p_angle) {
|
|||
|
||||
real_t Transform2D::get_skew() const {
|
||||
real_t det = determinant();
|
||||
return Math::acos(columns[0].normalized().dot(SIGN(det) * columns[1].normalized())) - (real_t)Math_PI * 0.5f;
|
||||
return Math::acos(columns[0].normalized().dot(SIGN(det) * columns[1].normalized())) - (real_t)Math::PI * 0.5f;
|
||||
}
|
||||
|
||||
void Transform2D::set_skew(real_t p_angle) {
|
||||
real_t det = determinant();
|
||||
columns[1] = SIGN(det) * columns[0].rotated(((real_t)Math_PI * 0.5f + p_angle)).normalized() * columns[1].length();
|
||||
columns[1] = SIGN(det) * columns[0].rotated(((real_t)Math::PI * 0.5f + p_angle)).normalized() * columns[1].length();
|
||||
}
|
||||
|
||||
real_t Transform2D::get_rotation() const {
|
||||
|
|
|
@ -149,7 +149,7 @@ static _FORCE_INLINE_ uint32_t hash_murmur3_one_float(float p_in, uint32_t p_see
|
|||
if (p_in == 0.0f) {
|
||||
u.f = 0.0;
|
||||
} else if (Math::is_nan(p_in)) {
|
||||
u.f = NAN;
|
||||
u.f = Math::NaN;
|
||||
} else {
|
||||
u.f = p_in;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ static _FORCE_INLINE_ uint32_t hash_murmur3_one_double(double p_in, uint32_t p_s
|
|||
if (p_in == 0.0f) {
|
||||
u.d = 0.0;
|
||||
} else if (Math::is_nan(p_in)) {
|
||||
u.d = NAN;
|
||||
u.d = Math::NaN;
|
||||
} else {
|
||||
u.d = p_in;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ static _FORCE_INLINE_ uint32_t hash_djb2_one_float(double p_in, uint32_t p_prev
|
|||
if (p_in == 0.0f) {
|
||||
u.d = 0.0;
|
||||
} else if (Math::is_nan(p_in)) {
|
||||
u.d = NAN;
|
||||
u.d = Math::NaN;
|
||||
} else {
|
||||
u.d = p_in;
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ static _FORCE_INLINE_ uint64_t hash_djb2_one_float_64(double p_in, uint64_t p_pr
|
|||
if (p_in == 0.0f) {
|
||||
u.d = 0.0;
|
||||
} else if (Math::is_nan(p_in)) {
|
||||
u.d = NAN;
|
||||
u.d = Math::NaN;
|
||||
} else {
|
||||
u.d = p_in;
|
||||
}
|
||||
|
|
|
@ -2796,7 +2796,7 @@ static void _register_variant_builtin_constants() {
|
|||
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR3, "ZERO", Vector3(0, 0, 0));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR3, "ONE", Vector3(1, 1, 1));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR3, "INF", Vector3(INFINITY, INFINITY, INFINITY));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR3, "INF", Vector3(Math::INF, Math::INF, Math::INF));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR3, "LEFT", Vector3(-1, 0, 0));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR3, "RIGHT", Vector3(1, 0, 0));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR3, "UP", Vector3(0, 1, 0));
|
||||
|
@ -2818,7 +2818,7 @@ static void _register_variant_builtin_constants() {
|
|||
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR4, "ZERO", Vector4(0, 0, 0, 0));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR4, "ONE", Vector4(1, 1, 1, 1));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR4, "INF", Vector4(INFINITY, INFINITY, INFINITY, INFINITY));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR4, "INF", Vector4(Math::INF, Math::INF, Math::INF, Math::INF));
|
||||
|
||||
_VariantCall::add_enum_constant(Variant::VECTOR3I, "Axis", "AXIS_X", Vector3i::AXIS_X);
|
||||
_VariantCall::add_enum_constant(Variant::VECTOR3I, "Axis", "AXIS_Y", Vector3i::AXIS_Y);
|
||||
|
@ -2853,7 +2853,7 @@ static void _register_variant_builtin_constants() {
|
|||
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR2, "ZERO", Vector2(0, 0));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR2, "ONE", Vector2(1, 1));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR2, "INF", Vector2(INFINITY, INFINITY));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR2, "INF", Vector2(Math::INF, Math::INF));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR2, "LEFT", Vector2(-1, 0));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR2, "RIGHT", Vector2(1, 0));
|
||||
_VariantCall::add_variant_constant(Variant::VECTOR2, "UP", Vector2(0, -1));
|
||||
|
|
|
@ -147,12 +147,12 @@ const char *VariantParser::tk_name[TK_MAX] = {
|
|||
|
||||
static double stor_fix(const String &p_str) {
|
||||
if (p_str == "inf") {
|
||||
return INFINITY;
|
||||
return Math::INF;
|
||||
} else if (p_str == "-inf" || p_str == "inf_neg") {
|
||||
// inf_neg kept for compatibility.
|
||||
return -INFINITY;
|
||||
return -Math::INF;
|
||||
} else if (p_str == "nan") {
|
||||
return NAN;
|
||||
return Math::NaN;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -698,12 +698,12 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||
} else if (id == "null" || id == "nil") {
|
||||
value = Variant();
|
||||
} else if (id == "inf") {
|
||||
value = INFINITY;
|
||||
value = Math::INF;
|
||||
} else if (id == "-inf" || id == "inf_neg") {
|
||||
// inf_neg kept for compatibility.
|
||||
value = -INFINITY;
|
||||
value = -Math::INF;
|
||||
} else if (id == "nan") {
|
||||
value = NAN;
|
||||
value = Math::NaN;
|
||||
} else if (id == "Vector2") {
|
||||
Vector<real_t> args;
|
||||
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||
|
|
|
@ -91,7 +91,7 @@ CubemapFilter::~CubemapFilter() {
|
|||
|
||||
Vector3 importance_sample_GGX(Vector2 xi, float roughness4) {
|
||||
// Compute distribution direction
|
||||
float phi = 2.0 * Math_PI * xi.x;
|
||||
float phi = 2.0 * Math::PI * xi.x;
|
||||
float cos_theta = sqrt((1.0 - xi.y) / (1.0 + (roughness4 - 1.0) * xi.y));
|
||||
float sin_theta = sqrt(1.0 - cos_theta * cos_theta);
|
||||
|
||||
|
@ -107,7 +107,7 @@ Vector3 importance_sample_GGX(Vector2 xi, float roughness4) {
|
|||
float distribution_GGX(float NdotH, float roughness4) {
|
||||
float NdotH2 = NdotH * NdotH;
|
||||
float denom = (NdotH2 * (roughness4 - 1.0) + 1.0);
|
||||
denom = Math_PI * denom * denom;
|
||||
denom = Math::PI * denom * denom;
|
||||
|
||||
return roughness4 / denom;
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ void CubemapFilter::filter_radiance(GLuint p_source_cubemap, GLuint p_dest_cubem
|
|||
float roughness4 = roughness * roughness;
|
||||
roughness4 *= roughness4;
|
||||
|
||||
float solid_angle_texel = 4.0 * Math_PI / float(6 * size * size);
|
||||
float solid_angle_texel = 4.0 * Math::PI / float(6 * size * size);
|
||||
|
||||
LocalVector<float> sample_directions;
|
||||
sample_directions.resize(4 * sample_count);
|
||||
|
|
|
@ -1692,7 +1692,7 @@ void RasterizerCanvasGLES3::light_update_shadow(RID p_rid, int p_shadow_index, c
|
|||
}
|
||||
|
||||
// Precomputed:
|
||||
// Vector3 cam_target = Basis::from_euler(Vector3(0, 0, Math_TAU * ((i + 3) / 4.0))).xform(Vector3(0, 1, 0));
|
||||
// Vector3 cam_target = Basis::from_euler(Vector3(0, 0, Math::TAU * ((i + 3) / 4.0))).xform(Vector3(0, 1, 0));
|
||||
// projection = projection * Projection(Transform3D().looking_at(cam_targets[i], Vector3(0, 0, -1)).affine_inverse());
|
||||
const Projection projections[4] = {
|
||||
projection * Projection(Vector4(0, 0, -1, 0), Vector4(1, 0, 0, 0), Vector4(0, -1, 0, 0), Vector4(0, 0, 0, 1)),
|
||||
|
|
|
@ -1672,7 +1672,7 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b
|
|||
if (is_using_physical_light_units()) {
|
||||
light_data.energy *= light_storage->light_get_param(base, RS::LIGHT_PARAM_INTENSITY);
|
||||
} else {
|
||||
light_data.energy *= Math_PI;
|
||||
light_data.energy *= Math::PI;
|
||||
}
|
||||
|
||||
if (p_render_data->camera_attributes.is_valid()) {
|
||||
|
@ -1862,14 +1862,14 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b
|
|||
|
||||
// Convert from Luminous Power to Luminous Intensity
|
||||
if (type == RS::LIGHT_OMNI) {
|
||||
energy *= 1.0 / (Math_PI * 4.0);
|
||||
energy *= 1.0 / (Math::PI * 4.0);
|
||||
} else {
|
||||
// Spot Lights are not physically accurate, Luminous Intensity should change in relation to the cone angle.
|
||||
// We make this assumption to keep them easy to control.
|
||||
energy *= 1.0 / Math_PI;
|
||||
energy *= 1.0 / Math::PI;
|
||||
}
|
||||
} else {
|
||||
energy *= Math_PI;
|
||||
energy *= Math::PI;
|
||||
}
|
||||
|
||||
if (p_render_data->camera_attributes.is_valid()) {
|
||||
|
|
|
@ -1143,9 +1143,9 @@ MaterialStorage::MaterialStorage() {
|
|||
actions.renames["CANVAS_MATRIX"] = "canvas_transform";
|
||||
actions.renames["SCREEN_MATRIX"] = "screen_transform";
|
||||
actions.renames["TIME"] = "time";
|
||||
actions.renames["PI"] = _MKSTR(Math_PI);
|
||||
actions.renames["TAU"] = _MKSTR(Math_TAU);
|
||||
actions.renames["E"] = _MKSTR(Math_E);
|
||||
actions.renames["PI"] = _MKSTR(Math::PI);
|
||||
actions.renames["TAU"] = _MKSTR(Math::TAU);
|
||||
actions.renames["E"] = _MKSTR(Math::E);
|
||||
actions.renames["AT_LIGHT_PASS"] = "false";
|
||||
actions.renames["INSTANCE_CUSTOM"] = "instance_custom";
|
||||
|
||||
|
@ -1238,9 +1238,9 @@ MaterialStorage::MaterialStorage() {
|
|||
|
||||
actions.renames["TIME"] = "scene_data.time";
|
||||
actions.renames["EXPOSURE"] = "(1.0 / scene_data.emissive_exposure_normalization)";
|
||||
actions.renames["PI"] = _MKSTR(Math_PI);
|
||||
actions.renames["TAU"] = _MKSTR(Math_TAU);
|
||||
actions.renames["E"] = _MKSTR(Math_E);
|
||||
actions.renames["PI"] = _MKSTR(Math::PI);
|
||||
actions.renames["TAU"] = _MKSTR(Math::TAU);
|
||||
actions.renames["E"] = _MKSTR(Math::E);
|
||||
actions.renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
|
||||
actions.renames["CLIP_SPACE_FAR"] = "SHADER_SPACE_FAR";
|
||||
actions.renames["VIEWPORT_SIZE"] = "scene_data.viewport_size";
|
||||
|
@ -1406,9 +1406,9 @@ MaterialStorage::MaterialStorage() {
|
|||
}
|
||||
actions.renames["TRANSFORM"] = "xform";
|
||||
actions.renames["TIME"] = "time";
|
||||
actions.renames["PI"] = _MKSTR(Math_PI);
|
||||
actions.renames["TAU"] = _MKSTR(Math_TAU);
|
||||
actions.renames["E"] = _MKSTR(Math_E);
|
||||
actions.renames["PI"] = _MKSTR(Math::PI);
|
||||
actions.renames["TAU"] = _MKSTR(Math::TAU);
|
||||
actions.renames["E"] = _MKSTR(Math::E);
|
||||
actions.renames["LIFETIME"] = "lifetime";
|
||||
actions.renames["DELTA"] = "local_delta";
|
||||
actions.renames["NUMBER"] = "particle_number";
|
||||
|
@ -1463,9 +1463,9 @@ MaterialStorage::MaterialStorage() {
|
|||
actions.renames["SCREEN_UV"] = "uv";
|
||||
actions.renames["TIME"] = "time";
|
||||
actions.renames["FRAGCOORD"] = "gl_FragCoord";
|
||||
actions.renames["PI"] = _MKSTR(Math_PI);
|
||||
actions.renames["TAU"] = _MKSTR(Math_TAU);
|
||||
actions.renames["E"] = _MKSTR(Math_E);
|
||||
actions.renames["PI"] = _MKSTR(Math::PI);
|
||||
actions.renames["TAU"] = _MKSTR(Math::TAU);
|
||||
actions.renames["E"] = _MKSTR(Math::E);
|
||||
actions.renames["HALF_RES_COLOR"] = "half_res_color";
|
||||
actions.renames["QUARTER_RES_COLOR"] = "quarter_res_color";
|
||||
actions.renames["RADIANCE"] = "radiance";
|
||||
|
|
|
@ -285,7 +285,7 @@ bool ActionMapEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d
|
|||
TreeItem *source = Object::cast_to<TreeItem>(ObjectDB::get_instance(d["source"].operator ObjectID()));
|
||||
TreeItem *selected = action_tree->get_selected();
|
||||
|
||||
TreeItem *item = (p_point == Vector2(INFINITY, INFINITY)) ? selected : action_tree->get_item_at_position(p_point);
|
||||
TreeItem *item = (p_point == Vector2(Math::INF, Math::INF)) ? selected : action_tree->get_item_at_position(p_point);
|
||||
if (!selected || !item || item == source) {
|
||||
return false;
|
||||
}
|
||||
|
@ -309,12 +309,12 @@ void ActionMapEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data,
|
|||
}
|
||||
|
||||
TreeItem *selected = action_tree->get_selected();
|
||||
TreeItem *target = (p_point == Vector2(INFINITY, INFINITY)) ? selected : action_tree->get_item_at_position(p_point);
|
||||
TreeItem *target = (p_point == Vector2(Math::INF, Math::INF)) ? selected : action_tree->get_item_at_position(p_point);
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool drop_above = ((p_point == Vector2(INFINITY, INFINITY)) ? action_tree->get_drop_section_at_position(action_tree->get_item_rect(target).position) : action_tree->get_drop_section_at_position(p_point)) == -1;
|
||||
bool drop_above = ((p_point == Vector2(Math::INF, Math::INF)) ? action_tree->get_drop_section_at_position(action_tree->get_item_rect(target).position) : action_tree->get_drop_section_at_position(p_point)) == -1;
|
||||
|
||||
Dictionary d = p_data;
|
||||
if (d["input_type"] == "action") {
|
||||
|
|
|
@ -824,8 +824,8 @@ void AnimationBezierTrackEdit::set_filtered(bool p_filtered) {
|
|||
|
||||
void AnimationBezierTrackEdit::auto_fit_vertically() {
|
||||
int track_count = animation->get_track_count();
|
||||
real_t minimum_value = INFINITY;
|
||||
real_t maximum_value = -INFINITY;
|
||||
real_t minimum_value = Math::INF;
|
||||
real_t maximum_value = -Math::INF;
|
||||
|
||||
int nb_track_visible = 0;
|
||||
for (int i = 0; i < track_count; ++i) {
|
||||
|
@ -1036,10 +1036,10 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
|
|||
return;
|
||||
}
|
||||
|
||||
real_t minimum_time = INFINITY;
|
||||
real_t maximum_time = -INFINITY;
|
||||
real_t minimum_value = INFINITY;
|
||||
real_t maximum_value = -INFINITY;
|
||||
real_t minimum_time = Math::INF;
|
||||
real_t maximum_time = -Math::INF;
|
||||
real_t minimum_value = Math::INF;
|
||||
real_t maximum_value = -Math::INF;
|
||||
|
||||
for (const IntPair &E : focused_keys) {
|
||||
IntPair key_pair = E;
|
||||
|
|
|
@ -6930,8 +6930,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
if (is_using_angle) {
|
||||
real_t a = from_v;
|
||||
real_t b = to_v;
|
||||
real_t to_diff = fmod(b - a, Math_TAU);
|
||||
to_v = a + fmod(2.0 * to_diff, Math_TAU) - to_diff;
|
||||
real_t to_diff = fmod(b - a, Math::TAU);
|
||||
to_v = a + fmod(2.0 * to_diff, Math::TAU) - to_diff;
|
||||
}
|
||||
Variant delta_v = Animation::subtract_variant(to_v, from_v);
|
||||
double duration = to_t - from_t;
|
||||
|
@ -8791,8 +8791,8 @@ PackedStringArray AnimationMarkerEdit::get_selected_section() const {
|
|||
PackedStringArray arr;
|
||||
arr.push_back(""); // Marker with smallest time.
|
||||
arr.push_back(""); // Marker with largest time.
|
||||
double min_time = INFINITY;
|
||||
double max_time = -INFINITY;
|
||||
double min_time = Math::INF;
|
||||
double max_time = -Math::INF;
|
||||
for (const StringName &marker_name : selection) {
|
||||
double time = animation->get_marker_time(marker_name);
|
||||
if (time < min_time) {
|
||||
|
|
|
@ -635,7 +635,7 @@ void CreateDialog::_favorite_activated() {
|
|||
}
|
||||
|
||||
Variant CreateDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
|
||||
TreeItem *ti = (p_point == Vector2(INFINITY, INFINITY)) ? favorites->get_selected() : favorites->get_item_at_position(p_point);
|
||||
TreeItem *ti = (p_point == Vector2(Math::INF, Math::INF)) ? favorites->get_selected() : favorites->get_item_at_position(p_point);
|
||||
if (ti) {
|
||||
Dictionary d;
|
||||
d["type"] = "create_favorite_drag";
|
||||
|
@ -667,13 +667,13 @@ bool CreateDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data
|
|||
void CreateDialog::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||
Dictionary d = p_data;
|
||||
|
||||
TreeItem *ti = (p_point == Vector2(INFINITY, INFINITY)) ? favorites->get_selected() : favorites->get_item_at_position(p_point);
|
||||
TreeItem *ti = (p_point == Vector2(Math::INF, Math::INF)) ? favorites->get_selected() : favorites->get_item_at_position(p_point);
|
||||
if (!ti) {
|
||||
return;
|
||||
}
|
||||
|
||||
String drop_at = ti->get_text(0);
|
||||
int ds = (p_point == Vector2(INFINITY, INFINITY)) ? favorites->get_drop_section_at_position(favorites->get_item_rect(ti).position) : favorites->get_drop_section_at_position(p_point);
|
||||
int ds = (p_point == Vector2(Math::INF, Math::INF)) ? favorites->get_drop_section_at_position(favorites->get_item_rect(ti).position) : favorites->get_drop_section_at_position(p_point);
|
||||
|
||||
int drop_idx = favorite_list.find(drop_at);
|
||||
if (drop_idx < 0) {
|
||||
|
|
|
@ -636,7 +636,7 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) {
|
|||
p->set_modulate(Color(1, 1, 1, 0.7));
|
||||
p->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("focus"), SNAME("Button")));
|
||||
p->set_size(get_size());
|
||||
p->set_position((p_point == Vector2(INFINITY, INFINITY)) ? Vector2() : -p_point);
|
||||
p->set_position((p_point == Vector2(Math::INF, Math::INF)) ? Vector2() : -p_point);
|
||||
set_drag_preview(c);
|
||||
Dictionary d;
|
||||
d["type"] = "move_audio_bus";
|
||||
|
@ -669,7 +669,7 @@ void EditorAudioBus::drop_data(const Point2 &p_point, const Variant &p_data) {
|
|||
}
|
||||
|
||||
Variant EditorAudioBus::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
|
||||
TreeItem *item = (p_point == Vector2(INFINITY, INFINITY)) ? effects->get_selected() : effects->get_item_at_position(p_point);
|
||||
TreeItem *item = (p_point == Vector2(Math::INF, Math::INF)) ? effects->get_selected() : effects->get_item_at_position(p_point);
|
||||
if (!item) {
|
||||
return Variant();
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ bool EditorAudioBus::can_drop_data_fw(const Point2 &p_point, const Variant &p_da
|
|||
return false;
|
||||
}
|
||||
|
||||
TreeItem *item = (p_point == Vector2(INFINITY, INFINITY)) ? effects->get_selected() : effects->get_item_at_position(p_point);
|
||||
TreeItem *item = (p_point == Vector2(Math::INF, Math::INF)) ? effects->get_selected() : effects->get_item_at_position(p_point);
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
|
@ -711,11 +711,11 @@ bool EditorAudioBus::can_drop_data_fw(const Point2 &p_point, const Variant &p_da
|
|||
void EditorAudioBus::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||
Dictionary d = p_data;
|
||||
|
||||
TreeItem *item = (p_point == Vector2(INFINITY, INFINITY)) ? effects->get_selected() : effects->get_item_at_position(p_point);
|
||||
TreeItem *item = (p_point == Vector2(Math::INF, Math::INF)) ? effects->get_selected() : effects->get_item_at_position(p_point);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
int pos = (p_point == Vector2(INFINITY, INFINITY)) ? effects->get_drop_section_at_position(effects->get_item_rect(item).position) : effects->get_drop_section_at_position(p_point);
|
||||
int pos = (p_point == Vector2(Math::INF, Math::INF)) ? effects->get_drop_section_at_position(effects->get_item_rect(item).position) : effects->get_drop_section_at_position(p_point);
|
||||
Variant md = item->get_metadata(0);
|
||||
|
||||
int paste_at;
|
||||
|
|
|
@ -659,13 +659,13 @@ bool EditorAutoloadSettings::can_drop_data_fw(const Point2 &p_point, const Varia
|
|||
}
|
||||
|
||||
if (drop_data.has("type")) {
|
||||
TreeItem *ti = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
TreeItem *ti = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
|
||||
if (!ti) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int section = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_drop_section_at_position(tree->get_item_rect(ti).position) : tree->get_drop_section_at_position(p_point);
|
||||
int section = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_drop_section_at_position(tree->get_item_rect(ti).position) : tree->get_drop_section_at_position(p_point);
|
||||
|
||||
return section >= -1;
|
||||
}
|
||||
|
@ -674,13 +674,13 @@ bool EditorAutoloadSettings::can_drop_data_fw(const Point2 &p_point, const Varia
|
|||
}
|
||||
|
||||
void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) {
|
||||
TreeItem *ti = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
TreeItem *ti = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
|
||||
if (!ti) {
|
||||
return;
|
||||
}
|
||||
|
||||
int section = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_drop_section_at_position(tree->get_item_rect(ti).position) : tree->get_drop_section_at_position(p_point);
|
||||
int section = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_drop_section_at_position(tree->get_item_rect(ti).position) : tree->get_drop_section_at_position(p_point);
|
||||
|
||||
if (section < -1) {
|
||||
return;
|
||||
|
|
|
@ -2783,7 +2783,7 @@ void EditorInspectorArray::drop_data_fw(const Point2 &p_point, const Variant &p_
|
|||
Dictionary dict = p_data;
|
||||
|
||||
int to_drop = dict["index"];
|
||||
int drop_position = (p_point == Vector2(INFINITY, INFINITY)) ? selected : _drop_position();
|
||||
int drop_position = (p_point == Vector2(Math::INF, Math::INF)) ? selected : _drop_position();
|
||||
if (drop_position < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -2801,7 +2801,7 @@ bool EditorInspectorArray::can_drop_data_fw(const Point2 &p_point, const Variant
|
|||
return false;
|
||||
}
|
||||
Dictionary dict = p_data;
|
||||
int drop_position = (p_point == Vector2(INFINITY, INFINITY)) ? selected : _drop_position();
|
||||
int drop_position = (p_point == Vector2(Math::INF, Math::INF)) ? selected : _drop_position();
|
||||
if (!dict.has("type") || dict["type"] != "property_array_element" || String(dict["property_array_prefix"]) != array_element_prefix || drop_position < 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -186,8 +186,8 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh
|
|||
Vector3 ofs = aabb.get_center();
|
||||
aabb.position -= ofs;
|
||||
Transform3D xform;
|
||||
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI / 6);
|
||||
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI / 6) * xform.basis;
|
||||
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math::PI / 6);
|
||||
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math::PI / 6) * xform.basis;
|
||||
AABB rot_aabb = xform.xform(aabb);
|
||||
float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
|
||||
if (m == 0) {
|
||||
|
@ -282,8 +282,8 @@ void EditorInterface::make_scene_preview(const String &p_path, Node *p_scene, in
|
|||
Vector3 center = scene_aabb.get_center();
|
||||
float camera_size = scene_aabb.get_longest_axis_size();
|
||||
|
||||
const float cam_rot_x = -Math_PI / 4;
|
||||
const float cam_rot_y = -Math_PI / 4;
|
||||
const float cam_rot_x = -Math::PI / 4;
|
||||
const float cam_rot_y = -Math::PI / 4;
|
||||
|
||||
camera->set_orthogonal(camera_size * 2.0, 0.0001, camera_size * 2.0);
|
||||
|
||||
|
@ -295,8 +295,8 @@ void EditorInterface::make_scene_preview(const String &p_path, Node *p_scene, in
|
|||
camera->set_transform(xf);
|
||||
|
||||
Transform3D xform;
|
||||
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI / 6);
|
||||
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI / 6) * xform.basis;
|
||||
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math::PI / 6);
|
||||
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math::PI / 6) * xform.basis;
|
||||
|
||||
light->set_transform(xform * Transform3D().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0)));
|
||||
light2->set_transform(xform * Transform3D().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0)));
|
||||
|
|
|
@ -759,7 +759,7 @@ Variant EditorSettingsDialog::get_drag_data_fw(const Point2 &p_point, Control *p
|
|||
|
||||
bool EditorSettingsDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||
TreeItem *selected = shortcuts->get_selected();
|
||||
TreeItem *item = (p_point == Vector2(INFINITY, INFINITY)) ? shortcuts->get_selected() : shortcuts->get_item_at_position(p_point);
|
||||
TreeItem *item = (p_point == Vector2(Math::INF, Math::INF)) ? shortcuts->get_selected() : shortcuts->get_item_at_position(p_point);
|
||||
if (!selected || !item || item == selected || (String)item->get_meta("type", "") != "event") {
|
||||
return false;
|
||||
}
|
||||
|
@ -778,7 +778,7 @@ void EditorSettingsDialog::drop_data_fw(const Point2 &p_point, const Variant &p_
|
|||
}
|
||||
|
||||
TreeItem *selected = shortcuts->get_selected();
|
||||
TreeItem *target = (p_point == Vector2(INFINITY, INFINITY)) ? shortcuts->get_selected() : shortcuts->get_item_at_position(p_point);
|
||||
TreeItem *target = (p_point == Vector2(Math::INF, Math::INF)) ? shortcuts->get_selected() : shortcuts->get_item_at_position(p_point);
|
||||
|
||||
if (!target) {
|
||||
return;
|
||||
|
|
|
@ -321,7 +321,7 @@ bool EditorUndoRedoManager::redo() {
|
|||
}
|
||||
|
||||
int selected_history = INVALID_HISTORY;
|
||||
double global_timestamp = INFINITY;
|
||||
double global_timestamp = Math::INF;
|
||||
|
||||
// Pick the history with lowest last action timestamp (either global or current scene).
|
||||
{
|
||||
|
|
|
@ -746,7 +746,7 @@ void ProjectExportDialog::_delete_preset_confirm() {
|
|||
Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
|
||||
if (p_from == presets) {
|
||||
int pos = -1;
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
if (presets->is_anything_selected()) {
|
||||
pos = presets->get_selected_items()[0];
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_
|
|||
return d;
|
||||
}
|
||||
} else if (p_from == patches) {
|
||||
TreeItem *item = (p_point == Vector2(INFINITY, INFINITY)) ? patches->get_selected() : patches->get_item_at_position(p_point);
|
||||
TreeItem *item = (p_point == Vector2(Math::INF, Math::INF)) ? patches->get_selected() : patches->get_item_at_position(p_point);
|
||||
|
||||
if (item) {
|
||||
int item_metadata = item->get_metadata(0);
|
||||
|
@ -800,7 +800,7 @@ bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant
|
|||
|
||||
int pos = -1;
|
||||
bool end = true;
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
if (presets->is_anything_selected()) {
|
||||
pos = presets->get_selected_items()[0];
|
||||
}
|
||||
|
@ -818,7 +818,7 @@ bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant
|
|||
return false;
|
||||
}
|
||||
|
||||
TreeItem *item = (p_point == Vector2(INFINITY, INFINITY)) ? patches->get_selected() : patches->get_item_at_position(p_point);
|
||||
TreeItem *item = (p_point == Vector2(Math::INF, Math::INF)) ? patches->get_selected() : patches->get_item_at_position(p_point);
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
|
@ -838,7 +838,7 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
|
|||
|
||||
int pos = -1;
|
||||
bool end = true;
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
if (presets->is_anything_selected()) {
|
||||
pos = presets->get_selected_items()[0];
|
||||
}
|
||||
|
@ -875,7 +875,7 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
|
|||
Dictionary d = p_data;
|
||||
int from_pos = d["patch"];
|
||||
|
||||
TreeItem *item = (p_point == Vector2(INFINITY, INFINITY)) ? patches->get_selected() : patches->get_item_at_position(p_point);
|
||||
TreeItem *item = (p_point == Vector2(Math::INF, Math::INF)) ? patches->get_selected() : patches->get_item_at_position(p_point);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
@ -883,7 +883,7 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
|
|||
int to_pos = item->get_metadata(0);
|
||||
|
||||
int pos = -1;
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
pos = patches->get_drop_section_at_position(patches->get_item_rect(item).position);
|
||||
} else {
|
||||
pos = patches->get_drop_section_at_position(p_point);
|
||||
|
|
|
@ -2855,12 +2855,12 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da
|
|||
}
|
||||
|
||||
// Moving favorite around.
|
||||
TreeItem *ti = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
TreeItem *ti = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
if (!ti) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int drop_section = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_drop_section_at_position(tree->get_item_rect(ti).position) : tree->get_drop_section_at_position(p_point);
|
||||
int drop_section = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_drop_section_at_position(tree->get_item_rect(ti).position) : tree->get_drop_section_at_position(p_point);
|
||||
if (ti == favorites_item) {
|
||||
return (drop_section == 1); // The parent, first fav.
|
||||
}
|
||||
|
@ -2933,11 +2933,11 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
|
|||
return;
|
||||
}
|
||||
// Moving favorite around.
|
||||
TreeItem *ti = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
TreeItem *ti = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
if (!ti) {
|
||||
return;
|
||||
}
|
||||
int drop_section = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_drop_section_at_position(tree->get_item_rect(ti).position) : tree->get_drop_section_at_position(p_point);
|
||||
int drop_section = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_drop_section_at_position(tree->get_item_rect(ti).position) : tree->get_drop_section_at_position(p_point);
|
||||
|
||||
int drop_position;
|
||||
Vector<String> drag_files = drag_data["files"];
|
||||
|
@ -3057,7 +3057,7 @@ void FileSystemDock::_get_drag_target_folder(String &target, bool &target_favori
|
|||
|
||||
// In the file list.
|
||||
if (p_from == files) {
|
||||
int pos = (p_point == Vector2(INFINITY, INFINITY)) ? -1 : files->get_item_at_position(p_point, true);
|
||||
int pos = (p_point == Vector2(Math::INF, Math::INF)) ? -1 : files->get_item_at_position(p_point, true);
|
||||
if (pos == -1) {
|
||||
target = get_current_directory();
|
||||
return;
|
||||
|
@ -3070,8 +3070,8 @@ void FileSystemDock::_get_drag_target_folder(String &target, bool &target_favori
|
|||
|
||||
// In the tree.
|
||||
if (p_from == tree) {
|
||||
TreeItem *ti = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
int section = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_drop_section_at_position(tree->get_item_rect(ti).position) : tree->get_drop_section_at_position(p_point);
|
||||
TreeItem *ti = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
int section = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_drop_section_at_position(tree->get_item_rect(ti).position) : tree->get_drop_section_at_position(p_point);
|
||||
if (ti) {
|
||||
// Check the favorites first.
|
||||
if (ti == tree->get_root()->get_first_child() && section >= 0) {
|
||||
|
|
|
@ -1864,12 +1864,12 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d
|
|||
return false;
|
||||
}
|
||||
|
||||
TreeItem *item = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
TreeItem *item = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int section = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_drop_section_at_position(tree->get_item_rect(item).position) : tree->get_drop_section_at_position(p_point);
|
||||
int section = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_drop_section_at_position(tree->get_item_rect(item).position) : tree->get_drop_section_at_position(p_point);
|
||||
if (section < -1 || (section == -1 && !item->get_parent())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1953,11 +1953,11 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data,
|
|||
return;
|
||||
}
|
||||
|
||||
TreeItem *item = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
TreeItem *item = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
int section = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_drop_section_at_position(tree->get_item_rect(item).position) : tree->get_drop_section_at_position(p_point);
|
||||
int section = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_drop_section_at_position(tree->get_item_rect(item).position) : tree->get_drop_section_at_position(p_point);
|
||||
if (section < -1) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1372,7 +1372,7 @@ Collada::Node *Collada::_parse_visual_instance_camera(XMLParser &p_parser) {
|
|||
cam->camera = _uri_to_id(p_parser.get_named_attribute_value_safe("url"));
|
||||
|
||||
if (state.up_axis == Vector3::AXIS_Z) { //collada weirdness
|
||||
cam->post_transform.basis.rotate(Vector3(1, 0, 0), -Math_PI * 0.5);
|
||||
cam->post_transform.basis.rotate(Vector3(1, 0, 0), -Math::PI * 0.5);
|
||||
}
|
||||
|
||||
if (p_parser.is_empty()) { //nothing else to parse...
|
||||
|
@ -1393,7 +1393,7 @@ Collada::Node *Collada::_parse_visual_instance_light(XMLParser &p_parser) {
|
|||
cam->light = _uri_to_id(p_parser.get_named_attribute_value_safe("url"));
|
||||
|
||||
if (state.up_axis == Vector3::AXIS_Z) { //collada weirdness
|
||||
cam->post_transform.basis.rotate(Vector3(1, 0, 0), -Math_PI * 0.5);
|
||||
cam->post_transform.basis.rotate(Vector3(1, 0, 0), -Math::PI * 0.5);
|
||||
}
|
||||
|
||||
if (p_parser.is_empty()) { //nothing else to parse...
|
||||
|
|
|
@ -826,7 +826,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, HashMap<R
|
|||
SeparationRayShape3D *rayShape = memnew(SeparationRayShape3D);
|
||||
rayShape->set_length(1);
|
||||
colshape->set_shape(rayShape);
|
||||
Object::cast_to<Node3D>(sb)->rotate_x(Math_PI / 2);
|
||||
Object::cast_to<Node3D>(sb)->rotate_x(Math::PI / 2);
|
||||
} else if (empty_draw_type == "IMAGE") {
|
||||
WorldBoundaryShape3D *world_boundary_shape = memnew(WorldBoundaryShape3D);
|
||||
colshape->set_shape(world_boundary_shape);
|
||||
|
|
|
@ -512,7 +512,7 @@ Transform3D ResourceImporterScene::get_collision_shapes_transform(const M &p_opt
|
|||
}
|
||||
|
||||
if (p_options.has(SNAME("primitive/rotation"))) {
|
||||
transform.basis = Basis::from_euler(p_options[SNAME("primitive/rotation")].operator Vector3() * (Math_PI / 180.0));
|
||||
transform.basis = Basis::from_euler(p_options[SNAME("primitive/rotation")].operator Vector3() * (Math::PI / 180.0));
|
||||
}
|
||||
}
|
||||
return transform;
|
||||
|
|
|
@ -744,8 +744,8 @@ void SceneImportSettingsDialog::open_settings(const String &p_path, const String
|
|||
selected_id = "";
|
||||
selected_type = "";
|
||||
|
||||
cam_rot_x = -Math_PI / 4;
|
||||
cam_rot_y = -Math_PI / 4;
|
||||
cam_rot_x = -Math::PI / 4;
|
||||
cam_rot_y = -Math::PI / 4;
|
||||
cam_zoom = 1;
|
||||
|
||||
{
|
||||
|
@ -1204,7 +1204,7 @@ void SceneImportSettingsDialog::_viewport_input(const Ref<InputEvent> &p_input)
|
|||
if (mm.is_valid() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) {
|
||||
(*rot_x) -= mm->get_relative().y * 0.01 * EDSCALE;
|
||||
(*rot_y) -= mm->get_relative().x * 0.01 * EDSCALE;
|
||||
(*rot_x) = CLAMP((*rot_x), -Math_PI / 2, Math_PI / 2);
|
||||
(*rot_x) = CLAMP((*rot_x), -Math::PI / 2, Math::PI / 2);
|
||||
_update_camera();
|
||||
}
|
||||
if (mm.is_valid() && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CURSOR_SHAPE)) {
|
||||
|
|
|
@ -128,8 +128,8 @@ class SceneImportSettingsDialog : public ConfirmationDialog {
|
|||
TreeItem *mesh_node = nullptr;
|
||||
TreeItem *material_node = nullptr;
|
||||
|
||||
float cam_rot_x = -Math_PI / 4;
|
||||
float cam_rot_y = -Math_PI / 4;
|
||||
float cam_rot_x = -Math::PI / 4;
|
||||
float cam_rot_y = -Math::PI / 4;
|
||||
float cam_zoom = 1;
|
||||
|
||||
HashMap<StringName, Variant> settings;
|
||||
|
@ -143,8 +143,8 @@ class SceneImportSettingsDialog : public ConfirmationDialog {
|
|||
TreeItem *scene_node = nullptr;
|
||||
TreeItem *mesh_node = nullptr;
|
||||
|
||||
float cam_rot_x = -Math_PI / 4;
|
||||
float cam_rot_y = -Math_PI / 4;
|
||||
float cam_rot_x = -Math::PI / 4;
|
||||
float cam_rot_y = -Math::PI / 4;
|
||||
float cam_zoom = 1;
|
||||
HashMap<StringName, Variant> settings;
|
||||
};
|
||||
|
|
|
@ -2864,14 +2864,14 @@ Control::CursorShape CanvasItemEditor::get_cursor_shape(const Point2 &p_pos) con
|
|||
|
||||
List<CanvasItem *> selection = _get_edited_canvas_items();
|
||||
if (selection.size() == 1) {
|
||||
const double angle = Math::fposmod((double)selection.front()->get()->get_global_transform_with_canvas().get_rotation(), Math_PI);
|
||||
if (angle > Math_PI * 7.0 / 8.0) {
|
||||
const double angle = Math::fposmod((double)selection.front()->get()->get_global_transform_with_canvas().get_rotation(), Math::PI);
|
||||
if (angle > Math::PI * 7.0 / 8.0) {
|
||||
rotation_array_index = 0;
|
||||
} else if (angle > Math_PI * 5.0 / 8.0) {
|
||||
} else if (angle > Math::PI * 5.0 / 8.0) {
|
||||
rotation_array_index = 1;
|
||||
} else if (angle > Math_PI * 3.0 / 8.0) {
|
||||
} else if (angle > Math::PI * 3.0 / 8.0) {
|
||||
rotation_array_index = 2;
|
||||
} else if (angle > Math_PI * 1.0 / 8.0) {
|
||||
} else if (angle > Math::PI * 1.0 / 8.0) {
|
||||
rotation_array_index = 3;
|
||||
} else {
|
||||
rotation_array_index = 0;
|
||||
|
@ -3103,7 +3103,7 @@ void CanvasItemEditor::_draw_rulers() {
|
|||
viewport->draw_line(Point2(0, position.y), Point2(RULER_WIDTH, position.y), graduation_color, Math::round(EDSCALE));
|
||||
real_t val = (ruler_transform * major_subdivide * minor_subdivide).xform(Point2(0, i)).y;
|
||||
|
||||
Transform2D text_xform = Transform2D(-Math_PI / 2.0, Point2(font->get_ascent(font_size) + Math::round(EDSCALE), position.y - 2));
|
||||
Transform2D text_xform = Transform2D(-Math::PI / 2.0, Point2(font->get_ascent(font_size) + Math::round(EDSCALE), position.y - 2));
|
||||
viewport->draw_set_transform_matrix(viewport->get_transform() * text_xform);
|
||||
viewport->draw_string(font, Point2(), TS->format_number(vformat(((int)val == val) ? "%d" : "%.1f", val)), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color);
|
||||
viewport->draw_set_transform_matrix(viewport->get_transform());
|
||||
|
@ -3210,7 +3210,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
|
|||
Vector2 length_vector = (begin - end).abs() / zoom;
|
||||
|
||||
const real_t horizontal_angle_rad = length_vector.angle();
|
||||
const real_t vertical_angle_rad = Math_PI / 2.0 - horizontal_angle_rad;
|
||||
const real_t vertical_angle_rad = Math::PI / 2.0 - horizontal_angle_rad;
|
||||
|
||||
Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts));
|
||||
int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts));
|
||||
|
@ -3246,15 +3246,15 @@ void CanvasItemEditor::_draw_ruler_tool() {
|
|||
const Vector2 end_to_begin = (end - begin);
|
||||
|
||||
real_t arc_1_start_angle = end_to_begin.x < 0
|
||||
? (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 - vertical_angle_rad : Math_PI / 2.0)
|
||||
: (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 : Math_PI / 2.0 - vertical_angle_rad);
|
||||
? (end_to_begin.y < 0 ? 3.0 * Math::PI / 2.0 - vertical_angle_rad : Math::PI / 2.0)
|
||||
: (end_to_begin.y < 0 ? 3.0 * Math::PI / 2.0 : Math::PI / 2.0 - vertical_angle_rad);
|
||||
real_t arc_1_end_angle = arc_1_start_angle + vertical_angle_rad;
|
||||
// Constrain arc to triangle height & max size.
|
||||
real_t arc_1_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, Math::abs(end_to_begin.y)), arc_max_radius);
|
||||
|
||||
real_t arc_2_start_angle = end_to_begin.x < 0
|
||||
? (end_to_begin.y < 0 ? 0.0 : -horizontal_angle_rad)
|
||||
: (end_to_begin.y < 0 ? Math_PI - horizontal_angle_rad : Math_PI);
|
||||
: (end_to_begin.y < 0 ? Math::PI - horizontal_angle_rad : Math::PI);
|
||||
real_t arc_2_end_angle = arc_2_start_angle + horizontal_angle_rad;
|
||||
// Constrain arc to triangle width & max size.
|
||||
real_t arc_2_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, Math::abs(end_to_begin.x)), arc_max_radius);
|
||||
|
@ -3275,8 +3275,8 @@ void CanvasItemEditor::_draw_ruler_tool() {
|
|||
viewport->draw_string(font, text_pos, TS->format_number(vformat("%.1f px", length_vector.length())), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color);
|
||||
|
||||
if (draw_secondary_lines) {
|
||||
const int horizontal_angle = round(180 * horizontal_angle_rad / Math_PI);
|
||||
const int vertical_angle = round(180 * vertical_angle_rad / Math_PI);
|
||||
const int horizontal_angle = round(180 * horizontal_angle_rad / Math::PI);
|
||||
const int vertical_angle = round(180 * vertical_angle_rad / Math::PI);
|
||||
|
||||
Point2 text_pos2 = text_pos;
|
||||
text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2);
|
||||
|
@ -3655,7 +3655,7 @@ void CanvasItemEditor::_draw_selection() {
|
|||
int next = (i + 1) % 4;
|
||||
|
||||
Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized();
|
||||
ofs *= Math_SQRT2 * (select_handle->get_size().width / 2);
|
||||
ofs *= Math::SQRT2 * (select_handle->get_size().width / 2);
|
||||
|
||||
select_handle->draw(vp_ci, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor());
|
||||
|
||||
|
@ -4257,8 +4257,8 @@ void CanvasItemEditor::_selection_changed() {
|
|||
}
|
||||
selected_from_canvas = false;
|
||||
|
||||
if (temp_pivot != Vector2(INFINITY, INFINITY)) {
|
||||
temp_pivot = Vector2(INFINITY, INFINITY);
|
||||
if (temp_pivot != Vector2(Math::INF, Math::INF)) {
|
||||
temp_pivot = Vector2(Math::INF, Math::INF);
|
||||
viewport->queue_redraw();
|
||||
}
|
||||
}
|
||||
|
@ -6175,7 +6175,7 @@ void CanvasItemEditorViewport::_perform_drop_data() {
|
|||
}
|
||||
|
||||
bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
return false;
|
||||
}
|
||||
Dictionary d = p_data;
|
||||
|
@ -6309,7 +6309,7 @@ bool CanvasItemEditorViewport::_is_any_texture_selected() const {
|
|||
}
|
||||
|
||||
void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) {
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
return;
|
||||
}
|
||||
bool is_shift = Input::get_singleton()->is_key_pressed(Key::SHIFT);
|
||||
|
|
|
@ -252,7 +252,7 @@ private:
|
|||
bool key_scale = false;
|
||||
|
||||
bool pan_pressed = false;
|
||||
Vector2 temp_pivot = Vector2(INFINITY, INFINITY);
|
||||
Vector2 temp_pivot = Vector2(Math::INF, Math::INF);
|
||||
|
||||
bool ruler_tool_active = false;
|
||||
Point2 ruler_tool_origin;
|
||||
|
|
|
@ -393,22 +393,22 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
|
|||
|
||||
int lats = 32;
|
||||
int lons = 32;
|
||||
const double lat_step = Math_TAU / lats;
|
||||
const double lon_step = Math_TAU / lons;
|
||||
const double lat_step = Math::TAU / lats;
|
||||
const double lon_step = Math::TAU / lons;
|
||||
real_t radius = 1.0;
|
||||
|
||||
Vector<Vector3> vertices;
|
||||
Vector<Vector3> normals;
|
||||
Vector<Vector2> uvs;
|
||||
Vector<real_t> tangents;
|
||||
Basis tt = Basis(Vector3(0, 1, 0), Math_PI * 0.5);
|
||||
Basis tt = Basis(Vector3(0, 1, 0), Math::PI * 0.5);
|
||||
|
||||
for (int i = 1; i <= lats; i++) {
|
||||
double lat0 = lat_step * (i - 1) - Math_TAU / 4;
|
||||
double lat0 = lat_step * (i - 1) - Math::TAU / 4;
|
||||
double z0 = Math::sin(lat0);
|
||||
double zr0 = Math::cos(lat0);
|
||||
|
||||
double lat1 = lat_step * i - Math_TAU / 4;
|
||||
double lat1 = lat_step * i - Math::TAU / 4;
|
||||
double z1 = Math::sin(lat1);
|
||||
double zr1 = Math::cos(lat1);
|
||||
|
||||
|
@ -433,7 +433,7 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
|
|||
vertices.push_back(v[m_idx] * radius); \
|
||||
{ \
|
||||
Vector2 uv(Math::atan2(v[m_idx].x, v[m_idx].z), Math::atan2(-v[m_idx].y, v[m_idx].z)); \
|
||||
uv /= Math_PI; \
|
||||
uv /= Math::PI; \
|
||||
uv *= 4.0; \
|
||||
uv = uv * 0.5 + Vector2(0.5, 0.5); \
|
||||
uvs.push_back(uv); \
|
||||
|
@ -736,8 +736,8 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const Ref<Resource> &p_from, co
|
|||
Vector3 ofs = aabb.get_center();
|
||||
aabb.position -= ofs;
|
||||
Transform3D xform;
|
||||
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.125);
|
||||
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.125) * xform.basis;
|
||||
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math::PI * 0.125);
|
||||
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math::PI * 0.125) * xform.basis;
|
||||
AABB rot_aabb = xform.xform(aabb);
|
||||
real_t m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
|
||||
if (m == 0) {
|
||||
|
|
|
@ -176,8 +176,8 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
// Number of points in an octant. So there will be 8 * points_in_octant points in total.
|
||||
// This corresponds to the smoothness of the circle.
|
||||
const uint32_t points_in_octant = 15;
|
||||
const real_t octant_angle = Math_PI / 4;
|
||||
const real_t inc = (Math_PI / (4 * points_in_octant));
|
||||
const real_t octant_angle = Math::PI / 4;
|
||||
const real_t inc = (Math::PI / (4 * points_in_octant));
|
||||
const real_t radius_squared = radius * radius;
|
||||
real_t r = 0;
|
||||
|
||||
|
@ -239,8 +239,8 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
const float radius = Math::sin(ha);
|
||||
|
||||
const uint32_t points_in_octant = 7;
|
||||
const real_t octant_angle = Math_PI / 4;
|
||||
const real_t inc = (Math_PI / (4 * points_in_octant));
|
||||
const real_t octant_angle = Math::PI / 4;
|
||||
const real_t inc = (Math::PI / (4 * points_in_octant));
|
||||
const real_t radius_squared = radius * radius;
|
||||
real_t r = 0;
|
||||
|
||||
|
|
|
@ -271,8 +271,8 @@ float Camera3DGizmoPlugin::_find_closest_angle_to_half_pi_arc(const Vector3 &p_f
|
|||
Vector3 min_p;
|
||||
|
||||
for (int i = 0; i < arc_test_points; i++) {
|
||||
float a = i * Math_PI * 0.5 / arc_test_points;
|
||||
float an = (i + 1) * Math_PI * 0.5 / arc_test_points;
|
||||
float a = i * Math::PI * 0.5 / arc_test_points;
|
||||
float an = (i + 1) * Math::PI * 0.5 / arc_test_points;
|
||||
Vector3 p = Vector3(Math::cos(a), 0, -Math::sin(a)) * p_arc_radius;
|
||||
Vector3 n = Vector3(Math::cos(an), 0, -Math::sin(an)) * p_arc_radius;
|
||||
|
||||
|
@ -287,6 +287,6 @@ float Camera3DGizmoPlugin::_find_closest_angle_to_half_pi_arc(const Vector3 &p_f
|
|||
}
|
||||
|
||||
//min_p = p_arc_xform.affine_inverse().xform(min_p);
|
||||
float a = (Math_PI * 0.5) - Vector2(min_p.x, -min_p.z).angle();
|
||||
float a = (Math::PI * 0.5) - Vector2(min_p.x, -min_p.z).angle();
|
||||
return Math::rad_to_deg(a);
|
||||
}
|
||||
|
|
|
@ -359,7 +359,7 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
// Number of points in an octant. So there will be 8 * points_in_octant * 2 points in total for one circle.
|
||||
// This Corresponds to the smoothness of the circle.
|
||||
const uint32_t points_in_octant = 16;
|
||||
const real_t inc = (Math_PI / (4 * points_in_octant));
|
||||
const real_t inc = (Math::PI / (4 * points_in_octant));
|
||||
const real_t radius_squared = radius * radius;
|
||||
real_t r = 0;
|
||||
|
||||
|
@ -429,8 +429,8 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
// Number of points in an octant. So there will be 8 * points_in_octant points in total.
|
||||
// This corresponds to the smoothness of the circle.
|
||||
const uint32_t points_in_octant = 16;
|
||||
const real_t octant_angle = Math_PI / 4;
|
||||
const real_t inc = (Math_PI / (4 * points_in_octant));
|
||||
const real_t octant_angle = Math::PI / 4;
|
||||
const real_t inc = (Math::PI / (4 * points_in_octant));
|
||||
const real_t radius_squared = radius * radius;
|
||||
real_t r = 0;
|
||||
|
||||
|
@ -539,7 +539,7 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
// Number of points in an octant. So there will be 8 * points_in_octant * 2 points in total for one circle.
|
||||
// This corresponds to the smoothness of the circle.
|
||||
const uint32_t points_in_octant = 16;
|
||||
const real_t inc = (Math_PI / (4 * points_in_octant));
|
||||
const real_t inc = (Math::PI / (4 * points_in_octant));
|
||||
const real_t radius_squared = radius * radius;
|
||||
real_t r = 0;
|
||||
|
||||
|
|
|
@ -200,8 +200,8 @@ void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
// Number of points in an octant. So there will be 8 * points_in_octant points in total.
|
||||
// This corresponds to the smoothness of the circle.
|
||||
const uint32_t points_in_octant = 16;
|
||||
const real_t octant_angle = Math_PI / 4;
|
||||
const real_t inc = (Math_PI / (4 * points_in_octant));
|
||||
const real_t octant_angle = Math::PI / 4;
|
||||
const real_t inc = (Math::PI / (4 * points_in_octant));
|
||||
const real_t radius_squared = radius * radius;
|
||||
real_t r = 0;
|
||||
|
||||
|
|
|
@ -179,8 +179,8 @@ void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const
|
|||
|
||||
} else {
|
||||
if (p_limit_lower > p_limit_upper) {
|
||||
p_limit_lower = -Math_PI;
|
||||
p_limit_upper = Math_PI;
|
||||
p_limit_lower = -Math::PI;
|
||||
p_limit_upper = Math::PI;
|
||||
}
|
||||
|
||||
const int points = 32;
|
||||
|
|
|
@ -179,7 +179,7 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
|
||||
for (int i = 0; i < arrow_sides; i++) {
|
||||
for (int j = 0; j < arrow_points; j++) {
|
||||
Basis ma(Vector3(0, 0, 1), Math_PI * i / arrow_sides);
|
||||
Basis ma(Vector3(0, 0, 1), Math::PI * i / arrow_sides);
|
||||
|
||||
Vector3 v1 = arrow[j] - Vector3(0, 0, arrow_length);
|
||||
Vector3 v2 = arrow[(j + 1) % arrow_points] - Vector3(0, 0, arrow_length);
|
||||
|
@ -295,8 +295,8 @@ float Light3DGizmoPlugin::_find_closest_angle_to_half_pi_arc(const Vector3 &p_fr
|
|||
Vector3 min_p;
|
||||
|
||||
for (int i = 0; i < arc_test_points; i++) {
|
||||
float a = i * Math_PI * 0.5 / arc_test_points;
|
||||
float an = (i + 1) * Math_PI * 0.5 / arc_test_points;
|
||||
float a = i * Math::PI * 0.5 / arc_test_points;
|
||||
float an = (i + 1) * Math::PI * 0.5 / arc_test_points;
|
||||
Vector3 p = Vector3(Math::cos(a), 0, -Math::sin(a)) * p_arc_radius;
|
||||
Vector3 n = Vector3(Math::cos(an), 0, -Math::sin(an)) * p_arc_radius;
|
||||
|
||||
|
@ -311,6 +311,6 @@ float Light3DGizmoPlugin::_find_closest_angle_to_half_pi_arc(const Vector3 &p_fr
|
|||
}
|
||||
|
||||
//min_p = p_arc_xform.affine_inverse().xform(min_p);
|
||||
float a = (Math_PI * 0.5) - Vector2(min_p.x, -min_p.z).angle();
|
||||
float a = (Math::PI * 0.5) - Vector2(min_p.x, -min_p.z).angle();
|
||||
return Math::rad_to_deg(a);
|
||||
}
|
||||
|
|
|
@ -123,8 +123,8 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
int stack_count = 8;
|
||||
int sector_count = 16;
|
||||
|
||||
float sector_step = (Math_PI * 2.0) / sector_count;
|
||||
float stack_step = Math_PI / stack_count;
|
||||
float sector_step = (Math::PI * 2.0) / sector_count;
|
||||
float stack_step = Math::PI / stack_count;
|
||||
|
||||
Vector<Vector3> vertices;
|
||||
Vector<Color> colors;
|
||||
|
@ -141,7 +141,7 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
}
|
||||
|
||||
for (int i = 0; i <= stack_count; ++i) {
|
||||
float stack_angle = Math_PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
|
||||
float stack_angle = Math::PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
|
||||
float xy = radius * Math::cos(stack_angle); // r * cos(u)
|
||||
float z = radius * Math::sin(stack_angle); // r * sin(u)
|
||||
|
||||
|
|
|
@ -66,14 +66,14 @@ void LightmapProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
int stack_count = 8;
|
||||
int sector_count = 16;
|
||||
|
||||
float sector_step = (Math_PI * 2.0) / sector_count;
|
||||
float stack_step = Math_PI / stack_count;
|
||||
float sector_step = (Math::PI * 2.0) / sector_count;
|
||||
float stack_step = Math::PI / stack_count;
|
||||
|
||||
Vector<Vector3> vertices;
|
||||
float radius = 0.2;
|
||||
|
||||
for (int i = 0; i <= stack_count; ++i) {
|
||||
float stack_angle = Math_PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
|
||||
float stack_angle = Math::PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
|
||||
float xy = radius * Math::cos(stack_angle); // r * cos(u)
|
||||
float z = radius * Math::sin(stack_angle); // r * sin(u)
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ void NavigationLink3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
// Number of points in an octant. So there will be 8 * points_in_octant points in total.
|
||||
// Correspond to the smoothness of the circle.
|
||||
const uint32_t points_in_octant = 8;
|
||||
real_t inc = (Math_PI / (4 * points_in_octant));
|
||||
real_t inc = (Math::PI / (4 * points_in_octant));
|
||||
|
||||
Vector<Vector3> lines;
|
||||
// points_in_octant * 8 * 2 per circle * 2 circles. 2 for the start-end. 4 for the arrow, and another 4 if bidirectionnal.
|
||||
|
|
|
@ -171,7 +171,7 @@ void SpringBoneSimulator3DGizmoPlugin::draw_sphere(Ref<SurfaceTool> &p_surface_t
|
|||
static const Vector3 VECTOR3_UP = Vector3(0, 1, 0);
|
||||
static const Vector3 VECTOR3_FORWARD = Vector3(0, 0, 1);
|
||||
static const int STEP = 16;
|
||||
static const float SPPI = Math_TAU / (float)STEP;
|
||||
static const float SPPI = Math::TAU / (float)STEP;
|
||||
|
||||
for (int i = 1; i <= STEP; i++) {
|
||||
p_surface_tool->set_color(p_color);
|
||||
|
@ -302,7 +302,7 @@ void SpringBoneCollision3DGizmoPlugin::draw_sphere(Ref<SurfaceTool> &p_surface_t
|
|||
static const Vector3 VECTOR3_UP = Vector3(0, 1, 0);
|
||||
static const Vector3 VECTOR3_FORWARD = Vector3(0, 0, 1);
|
||||
static const int STEP = 16;
|
||||
static const float SPPI = Math_TAU / (float)STEP;
|
||||
static const float SPPI = Math::TAU / (float)STEP;
|
||||
|
||||
for (int i = 1; i <= STEP; i++) {
|
||||
p_surface_tool->set_color(p_color);
|
||||
|
@ -330,8 +330,8 @@ void SpringBoneCollision3DGizmoPlugin::draw_capsule(Ref<SurfaceTool> &p_surface_
|
|||
static const Vector3 VECTOR3_FORWARD = Vector3(0, 0, 1);
|
||||
static const int STEP = 16;
|
||||
static const int HALF_STEP = 8;
|
||||
static const float SPPI = Math_TAU / (float)STEP;
|
||||
static const float HALF_PI = Math_PI * 0.5;
|
||||
static const float SPPI = Math::TAU / (float)STEP;
|
||||
static const float HALF_PI = Math::PI * 0.5;
|
||||
|
||||
Vector3 top = VECTOR3_UP * (p_height * 0.5 - p_radius);
|
||||
Vector3 bottom = -top;
|
||||
|
@ -376,7 +376,7 @@ void SpringBoneCollision3DGizmoPlugin::draw_capsule(Ref<SurfaceTool> &p_surface_
|
|||
|
||||
void SpringBoneCollision3DGizmoPlugin::draw_plane(Ref<SurfaceTool> &p_surface_tool, const Color &p_color) {
|
||||
static const Vector3 VECTOR3_UP = Vector3(0, 1, 0);
|
||||
static const float HALF_PI = Math_PI * 0.5;
|
||||
static const float HALF_PI = Math::PI * 0.5;
|
||||
static const float ARROW_LENGTH = 0.3;
|
||||
static const float ARROW_HALF_WIDTH = 0.05;
|
||||
static const float ARROW_TOP_HALF_WIDTH = 0.1;
|
||||
|
|
|
@ -62,7 +62,7 @@ void MaterialEditor::gui_input(const Ref<InputEvent> &p_event) {
|
|||
const real_t limit = Math::deg_to_rad(80.0);
|
||||
rot = rot.clampf(-limit, limit);
|
||||
} else {
|
||||
rot.x = CLAMP(rot.x, -Math_PI / 2, Math_PI / 2);
|
||||
rot.x = CLAMP(rot.x, -Math::PI / 2, Math::PI / 2);
|
||||
}
|
||||
_update_rotation();
|
||||
_store_rotation_metadata();
|
||||
|
|
|
@ -43,7 +43,7 @@ void MeshEditor::gui_input(const Ref<InputEvent> &p_event) {
|
|||
rot_x -= mm->get_relative().y * 0.01;
|
||||
rot_y -= mm->get_relative().x * 0.01;
|
||||
|
||||
rot_x = CLAMP(rot_x, -Math_PI / 2, Math_PI / 2);
|
||||
rot_x = CLAMP(rot_x, -Math::PI / 2, Math::PI / 2);
|
||||
_update_rotation();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,10 +174,10 @@ void MultiMeshEditor::_populate() {
|
|||
|
||||
Transform3D axis_xform;
|
||||
if (axis == Vector3::AXIS_Z) {
|
||||
axis_xform.rotate(Vector3(1, 0, 0), -Math_PI * 0.5);
|
||||
axis_xform.rotate(Vector3(1, 0, 0), -Math::PI * 0.5);
|
||||
}
|
||||
if (axis == Vector3::AXIS_X) {
|
||||
axis_xform.rotate(Vector3(0, 0, 1), -Math_PI * 0.5);
|
||||
axis_xform.rotate(Vector3(0, 0, 1), -Math::PI * 0.5);
|
||||
}
|
||||
|
||||
for (int i = 0; i < instance_count; i++) {
|
||||
|
@ -203,9 +203,9 @@ void MultiMeshEditor::_populate() {
|
|||
|
||||
Basis post_xform;
|
||||
|
||||
post_xform.rotate(xform.basis.get_column(1), -Math::random(-_rotate_random, _rotate_random) * Math_PI);
|
||||
post_xform.rotate(xform.basis.get_column(2), -Math::random(-_tilt_random, _tilt_random) * Math_PI);
|
||||
post_xform.rotate(xform.basis.get_column(0), -Math::random(-_tilt_random, _tilt_random) * Math_PI);
|
||||
post_xform.rotate(xform.basis.get_column(1), -Math::random(-_rotate_random, _rotate_random) * Math::PI);
|
||||
post_xform.rotate(xform.basis.get_column(2), -Math::random(-_tilt_random, _tilt_random) * Math::PI);
|
||||
post_xform.rotate(xform.basis.get_column(0), -Math::random(-_tilt_random, _tilt_random) * Math::PI);
|
||||
|
||||
xform.basis = post_xform * xform.basis;
|
||||
//xform.basis.orthonormalize();
|
||||
|
|
|
@ -2389,28 +2389,28 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
|||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_down", p_event)) {
|
||||
// Clamp rotation to roughly -90..90 degrees so the user can't look upside-down and end up disoriented.
|
||||
cursor.x_rot = CLAMP(cursor.x_rot - Math_PI / 12.0, -1.57, 1.57);
|
||||
cursor.x_rot = CLAMP(cursor.x_rot - Math::PI / 12.0, -1.57, 1.57);
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_up", p_event)) {
|
||||
// Clamp rotation to roughly -90..90 degrees so the user can't look upside-down and end up disoriented.
|
||||
cursor.x_rot = CLAMP(cursor.x_rot + Math_PI / 12.0, -1.57, 1.57);
|
||||
cursor.x_rot = CLAMP(cursor.x_rot + Math::PI / 12.0, -1.57, 1.57);
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_right", p_event)) {
|
||||
cursor.y_rot -= Math_PI / 12.0;
|
||||
cursor.y_rot -= Math::PI / 12.0;
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_left", p_event)) {
|
||||
cursor.y_rot += Math_PI / 12.0;
|
||||
cursor.y_rot += Math::PI / 12.0;
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_180", p_event)) {
|
||||
cursor.y_rot += Math_PI;
|
||||
cursor.y_rot += Math::PI;
|
||||
view_type = VIEW_TYPE_USER;
|
||||
_update_name();
|
||||
}
|
||||
|
@ -3505,7 +3505,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
|
|||
switch (p_option) {
|
||||
case VIEW_TOP: {
|
||||
cursor.y_rot = 0;
|
||||
cursor.x_rot = Math_PI / 2.0;
|
||||
cursor.x_rot = Math::PI / 2.0;
|
||||
set_message(TTR("Top View."), 2);
|
||||
view_type = VIEW_TYPE_TOP;
|
||||
_set_auto_orthogonal();
|
||||
|
@ -3514,7 +3514,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
|
|||
} break;
|
||||
case VIEW_BOTTOM: {
|
||||
cursor.y_rot = 0;
|
||||
cursor.x_rot = -Math_PI / 2.0;
|
||||
cursor.x_rot = -Math::PI / 2.0;
|
||||
set_message(TTR("Bottom View."), 2);
|
||||
view_type = VIEW_TYPE_BOTTOM;
|
||||
_set_auto_orthogonal();
|
||||
|
@ -3523,7 +3523,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
|
|||
} break;
|
||||
case VIEW_LEFT: {
|
||||
cursor.x_rot = 0;
|
||||
cursor.y_rot = Math_PI / 2.0;
|
||||
cursor.y_rot = Math::PI / 2.0;
|
||||
set_message(TTR("Left View."), 2);
|
||||
view_type = VIEW_TYPE_LEFT;
|
||||
_set_auto_orthogonal();
|
||||
|
@ -3532,7 +3532,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
|
|||
} break;
|
||||
case VIEW_RIGHT: {
|
||||
cursor.x_rot = 0;
|
||||
cursor.y_rot = -Math_PI / 2.0;
|
||||
cursor.y_rot = -Math::PI / 2.0;
|
||||
set_message(TTR("Right View."), 2);
|
||||
view_type = VIEW_TYPE_RIGHT;
|
||||
_set_auto_orthogonal();
|
||||
|
@ -3550,7 +3550,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
|
|||
} break;
|
||||
case VIEW_REAR: {
|
||||
cursor.x_rot = 0;
|
||||
cursor.y_rot = Math_PI;
|
||||
cursor.y_rot = Math::PI;
|
||||
set_message(TTR("Rear View."), 2);
|
||||
view_type = VIEW_TYPE_REAR;
|
||||
_set_auto_orthogonal();
|
||||
|
@ -3599,7 +3599,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
|
|||
// Adjust rotation to match Decal's default orientation.
|
||||
// This makes the decal "look" in the same direction as the camera,
|
||||
// rather than pointing down relative to the camera orientation.
|
||||
xform.basis.rotate_local(Vector3(1, 0, 0), Math_TAU * 0.25);
|
||||
xform.basis.rotate_local(Vector3(1, 0, 0), Math::TAU * 0.25);
|
||||
}
|
||||
|
||||
Node3D *parent = sp->get_parent_node_3d();
|
||||
|
@ -3637,7 +3637,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
|
|||
// Adjust rotation to match Decal's default orientation.
|
||||
// This makes the decal "look" in the same direction as the camera,
|
||||
// rather than pointing down relative to the camera orientation.
|
||||
basis.rotate_local(Vector3(1, 0, 0), Math_TAU * 0.25);
|
||||
basis.rotate_local(Vector3(1, 0, 0), Math::TAU * 0.25);
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(sp, "set_rotation", basis.get_euler_normalized());
|
||||
|
@ -4911,7 +4911,7 @@ void Node3DEditorViewport::_perform_drop_data() {
|
|||
}
|
||||
|
||||
bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
return false;
|
||||
}
|
||||
preview_node_viewport_pos = p_point;
|
||||
|
@ -5376,7 +5376,7 @@ void Node3DEditorViewport::update_transform(bool p_shift) {
|
|||
Vector3 projection_axis = plane.normal.cross(global_axis);
|
||||
Vector3 delta = intersection - click;
|
||||
float projection = delta.dot(projection_axis);
|
||||
angle = (projection * (Math_PI / 2.0f)) / (gizmo_scale * GIZMO_CIRCLE_SIZE);
|
||||
angle = (projection * (Math::PI / 2.0f)) / (gizmo_scale * GIZMO_CIRCLE_SIZE);
|
||||
} else {
|
||||
_edit.show_rotation_line = true;
|
||||
Vector3 click_axis = (click - _edit.center).normalized();
|
||||
|
@ -7324,7 +7324,7 @@ void fragment() {
|
|||
|
||||
int arrow_sides = 16;
|
||||
|
||||
const real_t arrow_sides_step = Math_TAU / arrow_sides;
|
||||
const real_t arrow_sides_step = Math::TAU / arrow_sides;
|
||||
for (int k = 0; k < arrow_sides; k++) {
|
||||
Basis ma(ivec, k * arrow_sides_step);
|
||||
Basis mb(ivec, (k + 1) * arrow_sides_step);
|
||||
|
@ -7363,7 +7363,7 @@ void fragment() {
|
|||
vec * GIZMO_PLANE_DST - ivec3 * GIZMO_PLANE_SIZE
|
||||
};
|
||||
|
||||
Basis ma(ivec, Math_PI / 2);
|
||||
Basis ma(ivec, Math::PI / 2);
|
||||
|
||||
Vector3 points[4] = {
|
||||
ma.xform(plane[0]),
|
||||
|
@ -7403,14 +7403,14 @@ void fragment() {
|
|||
int n = 128; // number of circle segments
|
||||
int m = 3; // number of thickness segments
|
||||
|
||||
real_t step = Math_TAU / n;
|
||||
real_t step = Math::TAU / n;
|
||||
for (int j = 0; j < n; ++j) {
|
||||
Basis basis = Basis(ivec, j * step);
|
||||
|
||||
Vector3 vertex = basis.xform(ivec2 * GIZMO_CIRCLE_SIZE);
|
||||
|
||||
for (int k = 0; k < m; ++k) {
|
||||
Vector2 ofs = Vector2(Math::cos((Math_TAU * k) / m), Math::sin((Math_TAU * k) / m));
|
||||
Vector2 ofs = Vector2(Math::cos((Math::TAU * k) / m), Math::sin((Math::TAU * k) / m));
|
||||
Vector3 normal = ivec * ofs.x + ivec2 * ofs.y;
|
||||
|
||||
surftool->set_normal(basis.xform(normal));
|
||||
|
@ -7547,7 +7547,7 @@ void fragment() {
|
|||
|
||||
int arrow_sides = 4;
|
||||
|
||||
const real_t arrow_sides_step = Math_TAU / arrow_sides;
|
||||
const real_t arrow_sides_step = Math::TAU / arrow_sides;
|
||||
for (int k = 0; k < 4; k++) {
|
||||
Basis ma(ivec, k * arrow_sides_step);
|
||||
Basis mb(ivec, (k + 1) * arrow_sides_step);
|
||||
|
@ -7586,7 +7586,7 @@ void fragment() {
|
|||
vec * GIZMO_PLANE_DST - ivec3 * GIZMO_PLANE_SIZE
|
||||
};
|
||||
|
||||
Basis ma(ivec, Math_PI / 2);
|
||||
Basis ma(ivec, Math::PI / 2);
|
||||
|
||||
Vector3 points[4] = {
|
||||
ma.xform(plane[0]),
|
||||
|
@ -8915,7 +8915,7 @@ void Node3DEditor::_sun_direction_input(const Ref<InputEvent> &p_event) {
|
|||
if (mm.is_valid() && mm->get_button_mask().has_flag(MouseButtonMask::LEFT)) {
|
||||
sun_rotation.x += mm->get_relative().y * (0.02 * EDSCALE);
|
||||
sun_rotation.y -= mm->get_relative().x * (0.02 * EDSCALE);
|
||||
sun_rotation.x = CLAMP(sun_rotation.x, -Math_TAU / 4, Math_TAU / 4);
|
||||
sun_rotation.x = CLAMP(sun_rotation.x, -Math::TAU / 4, Math::TAU / 4);
|
||||
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Set Preview Sun Direction"), UndoRedo::MergeMode::MERGE_ENDS);
|
||||
|
|
|
@ -472,7 +472,7 @@ void Path3DGizmo::redraw() {
|
|||
|
||||
const int n = 36;
|
||||
for (int i = 0; i <= n; i++) {
|
||||
const float a = Math_TAU * i / n;
|
||||
const float a = Math::TAU * i / n;
|
||||
const Vector3 edge = sin(a) * side + cos(a) * up;
|
||||
disk.append(pos + edge * disk_size);
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ void ResourcePreloaderEditor::edit(ResourcePreloader *p_preloader) {
|
|||
}
|
||||
|
||||
Variant ResourcePreloaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
|
||||
TreeItem *ti = (p_point == Vector2(INFINITY, INFINITY)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
TreeItem *ti = (p_point == Vector2(Math::INF, Math::INF)) ? tree->get_selected() : tree->get_item_at_position(p_point);
|
||||
if (!ti) {
|
||||
return Variant();
|
||||
}
|
||||
|
|
|
@ -3273,7 +3273,7 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
|
|||
int new_index = 0;
|
||||
if (script_list->get_item_count() > 0) {
|
||||
int pos = 0;
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
if (script_list->is_anything_selected()) {
|
||||
pos = script_list->get_selected_items()[0];
|
||||
}
|
||||
|
@ -3301,7 +3301,7 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
|
|||
int new_index = 0;
|
||||
if (script_list->get_item_count() > 0) {
|
||||
int pos = 0;
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
if (script_list->is_anything_selected()) {
|
||||
pos = script_list->get_selected_items()[0];
|
||||
}
|
||||
|
@ -3322,7 +3322,7 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
|
|||
int new_index = 0;
|
||||
if (script_list->get_item_count() > 0) {
|
||||
int pos = 0;
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
if (script_list->is_anything_selected()) {
|
||||
pos = script_list->get_selected_items()[0];
|
||||
}
|
||||
|
|
|
@ -1958,7 +1958,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
|
|||
Dictionary d = p_data;
|
||||
|
||||
CodeEdit *te = code_editor->get_text_editor();
|
||||
Point2i pos = (p_point == Vector2(INFINITY, INFINITY)) ? Point2i(te->get_caret_line(0), te->get_caret_column(0)) : te->get_line_column_at_pos(p_point);
|
||||
Point2i pos = (p_point == Vector2(Math::INF, Math::INF)) ? Point2i(te->get_caret_line(0), te->get_caret_column(0)) : te->get_line_column_at_pos(p_point);
|
||||
int drop_at_line = pos.y;
|
||||
int drop_at_column = pos.x;
|
||||
int selection_index = te->get_selection_at_line_column(drop_at_line, drop_at_column);
|
||||
|
|
|
@ -642,7 +642,7 @@ Variant ShaderEditorPlugin::get_drag_data_fw(const Point2 &p_point, Control *p_f
|
|||
}
|
||||
|
||||
int idx = 0;
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
if (shader_list->is_anything_selected()) {
|
||||
idx = shader_list->get_selected_items()[0];
|
||||
}
|
||||
|
@ -726,7 +726,7 @@ void ShaderEditorPlugin::drop_data_fw(const Point2 &p_point, const Variant &p_da
|
|||
if (String(d["type"]) == "shader_list_element") {
|
||||
int idx = d["shader_list_element"];
|
||||
int new_idx = 0;
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
if (shader_list->is_anything_selected()) {
|
||||
new_idx = shader_list->get_selected_items()[0];
|
||||
}
|
||||
|
|
|
@ -701,7 +701,7 @@ Variant Skeleton3DEditor::get_drag_data_fw(const Point2 &p_point, Control *p_fro
|
|||
}
|
||||
|
||||
bool Skeleton3DEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||
TreeItem *target = (p_point == Vector2(INFINITY, INFINITY)) ? joint_tree->get_selected() : joint_tree->get_item_at_position(p_point);
|
||||
TreeItem *target = (p_point == Vector2(Math::INF, Math::INF)) ? joint_tree->get_selected() : joint_tree->get_item_at_position(p_point);
|
||||
if (!target) {
|
||||
return false;
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ void Skeleton3DEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
|
|||
return;
|
||||
}
|
||||
|
||||
TreeItem *target = (p_point == Vector2(INFINITY, INFINITY)) ? joint_tree->get_selected() : joint_tree->get_item_at_position(p_point);
|
||||
TreeItem *target = (p_point == Vector2(Math::INF, Math::INF)) ? joint_tree->get_selected() : joint_tree->get_item_at_position(p_point);
|
||||
TreeItem *selected = Object::cast_to<TreeItem>(Dictionary(p_data)["node"]);
|
||||
|
||||
const BoneId target_boneidx = String(target->get_metadata(0)).get_slicec('/', 1).to_int();
|
||||
|
|
|
@ -1662,7 +1662,7 @@ Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
|
|||
}
|
||||
|
||||
int idx = -1;
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
if (frame_list->is_anything_selected()) {
|
||||
idx = frame_list->get_selected_items()[0];
|
||||
}
|
||||
|
@ -1744,7 +1744,7 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
|
|||
}
|
||||
|
||||
int at_pos = -1;
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
if (frame_list->is_anything_selected()) {
|
||||
at_pos = frame_list->get_selected_items()[0];
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ void TextureRegionEditor::_texture_overlay_draw() {
|
|||
int next = (i + 1) % 4;
|
||||
|
||||
Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized();
|
||||
ofs *= Math_SQRT2 * (select_handle->get_size().width / 2);
|
||||
ofs *= Math::SQRT2 * (select_handle->get_size().width / 2);
|
||||
|
||||
texture_overlay->draw_line(endpoints[i] - draw_ofs * draw_zoom, endpoints[next] - draw_ofs * draw_zoom, color, 2);
|
||||
|
||||
|
|
|
@ -80,14 +80,14 @@ struct FloatConstantDef {
|
|||
};
|
||||
|
||||
static FloatConstantDef float_constant_defs[] = {
|
||||
{ "E", Math_E, TTRC("E constant (2.718282). Represents the base of the natural logarithm.") },
|
||||
{ "E", Math::E, TTRC("E constant (2.718282). Represents the base of the natural logarithm.") },
|
||||
{ "Epsilon", CMP_EPSILON, TTRC("Epsilon constant (0.00001). Smallest possible scalar number.") },
|
||||
{ "Phi", 1.618034f, TTRC("Phi constant (1.618034). Golden ratio.") },
|
||||
{ "Pi/4", Math_PI / 4, TTRC("Pi/4 constant (0.785398) or 45 degrees.") },
|
||||
{ "Pi/2", Math_PI / 2, TTRC("Pi/2 constant (1.570796) or 90 degrees.") },
|
||||
{ "Pi", Math_PI, TTRC("Pi constant (3.141593) or 180 degrees.") },
|
||||
{ "Tau", Math_TAU, TTRC("Tau constant (6.283185) or 360 degrees.") },
|
||||
{ "Sqrt2", Math_SQRT2, TTRC("Sqrt2 constant (1.414214). Square root of 2.") }
|
||||
{ "Pi/4", Math::PI / 4, TTRC("Pi/4 constant (0.785398) or 45 degrees.") },
|
||||
{ "Pi/2", Math::PI / 2, TTRC("Pi/2 constant (1.570796) or 90 degrees.") },
|
||||
{ "Pi", Math::PI, TTRC("Pi constant (3.141593) or 180 degrees.") },
|
||||
{ "Tau", Math::TAU, TTRC("Tau constant (6.283185) or 360 degrees.") },
|
||||
{ "Sqrt2", Math::SQRT2, TTRC("Sqrt2 constant (1.414214). Square root of 2.") }
|
||||
};
|
||||
|
||||
constexpr int MAX_FLOAT_CONST_DEFS = std::size(float_constant_defs);
|
||||
|
@ -6122,7 +6122,7 @@ void VisualShaderEditor::_connection_menu_id_pressed(int p_idx) {
|
|||
}
|
||||
|
||||
Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
return Variant();
|
||||
}
|
||||
|
||||
|
@ -6151,7 +6151,7 @@ Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
|
|||
}
|
||||
|
||||
bool VisualShaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -6170,7 +6170,7 @@ bool VisualShaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
|
|||
}
|
||||
|
||||
void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||
if (p_point == Vector2(INFINITY, INFINITY)) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1348,14 +1348,14 @@ CSGBrush *CSGSphere3D::_build_brush() {
|
|||
|
||||
// We want to follow an order that's convenient for UVs.
|
||||
// For latitude step we start at the top and move down like in an image.
|
||||
const double latitude_step = -Math_PI / rings;
|
||||
const double longitude_step = Math_TAU / radial_segments;
|
||||
const double latitude_step = -Math::PI / rings;
|
||||
const double longitude_step = Math::TAU / radial_segments;
|
||||
int face = 0;
|
||||
for (int i = 0; i < rings; i++) {
|
||||
double cos0 = 0;
|
||||
double sin0 = 1;
|
||||
if (i > 0) {
|
||||
double latitude0 = latitude_step * i + Math_TAU / 4;
|
||||
double latitude0 = latitude_step * i + Math::TAU / 4;
|
||||
cos0 = Math::cos(latitude0);
|
||||
sin0 = Math::sin(latitude0);
|
||||
}
|
||||
|
@ -1364,7 +1364,7 @@ CSGBrush *CSGSphere3D::_build_brush() {
|
|||
double cos1 = 0;
|
||||
double sin1 = -1;
|
||||
if (i < rings - 1) {
|
||||
double latitude1 = latitude_step * (i + 1) + Math_TAU / 4;
|
||||
double latitude1 = latitude_step * (i + 1) + Math::TAU / 4;
|
||||
cos1 = Math::cos(latitude1);
|
||||
sin1 = Math::sin(latitude1);
|
||||
}
|
||||
|
@ -1727,8 +1727,8 @@ CSGBrush *CSGCylinder3D::_build_brush() {
|
|||
inc_n = 0;
|
||||
}
|
||||
|
||||
float ang = inc * Math_TAU;
|
||||
float ang_n = inc_n * Math_TAU;
|
||||
float ang = inc * Math::TAU;
|
||||
float ang_n = inc_n * Math::TAU;
|
||||
|
||||
Vector3 face_base(Math::cos(ang), 0, Math::sin(ang));
|
||||
Vector3 face_base_n(Math::cos(ang_n), 0, Math::sin(ang_n));
|
||||
|
@ -1970,8 +1970,8 @@ CSGBrush *CSGTorus3D::_build_brush() {
|
|||
inci_n = 0;
|
||||
}
|
||||
|
||||
float angi = inci * Math_TAU;
|
||||
float angi_n = inci_n * Math_TAU;
|
||||
float angi = inci * Math::TAU;
|
||||
float angi_n = inci_n * Math::TAU;
|
||||
|
||||
Vector3 normali = Vector3(Math::cos(angi), 0, Math::sin(angi));
|
||||
Vector3 normali_n = Vector3(Math::cos(angi_n), 0, Math::sin(angi_n));
|
||||
|
@ -1983,8 +1983,8 @@ CSGBrush *CSGTorus3D::_build_brush() {
|
|||
incj_n = 0;
|
||||
}
|
||||
|
||||
float angj = incj * Math_TAU;
|
||||
float angj_n = incj_n * Math_TAU;
|
||||
float angj = incj * Math::TAU;
|
||||
float angj_n = incj_n * Math::TAU;
|
||||
|
||||
Vector2 normalj = Vector2(Math::cos(angj), Math::sin(angj)) * radius + Vector2(min_radius + radius, 0);
|
||||
Vector2 normalj_n = Vector2(Math::cos(angj_n), Math::sin(angj_n)) * radius + Vector2(min_radius + radius, 0);
|
||||
|
|
|
@ -2254,10 +2254,10 @@ void GDScriptLanguage::init() {
|
|||
_add_global(StaticCString::create(CoreConstants::get_global_constant_name(i)), CoreConstants::get_global_constant_value(i));
|
||||
}
|
||||
|
||||
_add_global(StaticCString::create("PI"), Math_PI);
|
||||
_add_global(StaticCString::create("TAU"), Math_TAU);
|
||||
_add_global(StaticCString::create("INF"), INFINITY);
|
||||
_add_global(StaticCString::create("NAN"), NAN);
|
||||
_add_global(StaticCString::create("PI"), Math::PI);
|
||||
_add_global(StaticCString::create("TAU"), Math::TAU);
|
||||
_add_global(StaticCString::create("INF"), Math::INF);
|
||||
_add_global(StaticCString::create("NAN"), Math::NaN);
|
||||
|
||||
//populate native classes
|
||||
|
||||
|
|
|
@ -488,22 +488,22 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const
|
|||
void GDScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_constants) const {
|
||||
Pair<String, Variant> pi;
|
||||
pi.first = "PI";
|
||||
pi.second = Math_PI;
|
||||
pi.second = Math::PI;
|
||||
p_constants->push_back(pi);
|
||||
|
||||
Pair<String, Variant> tau;
|
||||
tau.first = "TAU";
|
||||
tau.second = Math_TAU;
|
||||
tau.second = Math::TAU;
|
||||
p_constants->push_back(tau);
|
||||
|
||||
Pair<String, Variant> infinity;
|
||||
infinity.first = "INF";
|
||||
infinity.second = INFINITY;
|
||||
infinity.second = Math::INF;
|
||||
p_constants->push_back(infinity);
|
||||
|
||||
Pair<String, Variant> nan;
|
||||
nan.first = "NAN";
|
||||
nan.second = NAN;
|
||||
nan.second = Math::NaN;
|
||||
p_constants->push_back(nan);
|
||||
}
|
||||
|
||||
|
|
|
@ -2720,16 +2720,16 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_builtin_constant(Expressio
|
|||
|
||||
switch (op_type) {
|
||||
case GDScriptTokenizer::Token::CONST_PI:
|
||||
constant->value = Math_PI;
|
||||
constant->value = Math::PI;
|
||||
break;
|
||||
case GDScriptTokenizer::Token::CONST_TAU:
|
||||
constant->value = Math_TAU;
|
||||
constant->value = Math::TAU;
|
||||
break;
|
||||
case GDScriptTokenizer::Token::CONST_INF:
|
||||
constant->value = INFINITY;
|
||||
constant->value = Math::INF;
|
||||
break;
|
||||
case GDScriptTokenizer::Token::CONST_NAN:
|
||||
constant->value = NAN;
|
||||
constant->value = Math::NaN;
|
||||
break;
|
||||
default:
|
||||
return nullptr; // Unreachable.
|
||||
|
|
|
@ -232,7 +232,7 @@ Dictionary GLTFLight::to_dictionary() const {
|
|||
if (intensity != 1.0f) {
|
||||
d["intensity"] = intensity;
|
||||
}
|
||||
if (light_type != "directional" && range != INFINITY) {
|
||||
if (light_type != "directional" && range != Math::INF) {
|
||||
d["range"] = range;
|
||||
}
|
||||
if (light_type == "spot") {
|
||||
|
|
|
@ -48,9 +48,9 @@ private:
|
|||
Color color = Color(1.0f, 1.0f, 1.0f);
|
||||
float intensity = 1.0f;
|
||||
String light_type;
|
||||
float range = INFINITY;
|
||||
float range = Math::INF;
|
||||
float inner_cone_angle = 0.0f;
|
||||
float outer_cone_angle = Math_TAU / 8.0f;
|
||||
float outer_cone_angle = Math::TAU / 8.0f;
|
||||
Dictionary additional_data;
|
||||
|
||||
public:
|
||||
|
|
|
@ -6973,7 +6973,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
|
|||
animation->set_loop_mode(Animation::LOOP_LINEAR);
|
||||
}
|
||||
|
||||
double anim_start = p_trimming ? INFINITY : 0.0;
|
||||
double anim_start = p_trimming ? Math::INF : 0.0;
|
||||
double anim_end = 0.0;
|
||||
|
||||
for (const KeyValue<int, GLTFAnimation::NodeTrack> &track_i : anim->get_node_tracks()) {
|
||||
|
@ -7660,7 +7660,7 @@ bool GLTFDocument::_convert_animation_node_track(Ref<GLTFState> p_state, GLTFAni
|
|||
} else {
|
||||
Vector3 rotation_euler = p_godot_animation->track_get_key_value(p_godot_anim_track_index, key_i);
|
||||
if (node_prop == "rotation_degrees") {
|
||||
rotation_euler *= Math_TAU / 360.0;
|
||||
rotation_euler *= Math::TAU / 360.0;
|
||||
}
|
||||
rotation_quaternion = Quaternion::from_euler(rotation_euler);
|
||||
}
|
||||
|
|
|
@ -563,7 +563,7 @@ void GodotBody2D::integrate_forces(real_t p_step) {
|
|||
linear_velocity = constant_linear_velocity + motion / p_step;
|
||||
|
||||
real_t rot = new_transform.get_rotation() - get_transform().get_rotation();
|
||||
angular_velocity = constant_angular_velocity + remainder(rot, 2.0 * Math_PI) / p_step;
|
||||
angular_velocity = constant_angular_velocity + remainder(rot, 2.0 * Math::PI) / p_step;
|
||||
|
||||
do_motion = true;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#define ACCUMULATE_IMPULSES
|
||||
|
||||
#define MIN_VELOCITY 0.001
|
||||
#define MAX_BIAS_ROTATION (Math_PI / 8)
|
||||
#define MAX_BIAS_ROTATION (Math::PI / 8)
|
||||
|
||||
void GodotBodyPair2D::_add_contact(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_self) {
|
||||
GodotBodyPair2D *self = static_cast<GodotBodyPair2D *>(p_self);
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "godot_space_3d.h"
|
||||
|
||||
#define MIN_VELOCITY 0.0001
|
||||
#define MAX_BIAS_ROTATION (Math_PI / 8)
|
||||
#define MAX_BIAS_ROTATION (Math::PI / 8)
|
||||
|
||||
void GodotBodyPair3D::_contact_added_callback(const Vector3 &p_point_A, int p_index_A, const Vector3 &p_point_B, int p_index_B, const Vector3 &normal, void *p_userdata) {
|
||||
GodotBodyPair3D *pair = static_cast<GodotBodyPair3D *>(p_userdata);
|
||||
|
|
|
@ -61,8 +61,8 @@ bool GodotCollisionSolver3D::solve_static_world_boundary(const GodotShape3D *p_s
|
|||
// Use 3 equidistant points on the circle.
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
Vector3 vertex_pos = circle_pos;
|
||||
vertex_pos += circle_axis_1 * Math::cos(2.0 * Math_PI * i / 3.0);
|
||||
vertex_pos += circle_axis_2 * Math::sin(2.0 * Math_PI * i / 3.0);
|
||||
vertex_pos += circle_axis_1 * Math::cos(2.0 * Math::PI * i / 3.0);
|
||||
vertex_pos += circle_axis_2 * Math::sin(2.0 * Math::PI * i / 3.0);
|
||||
supports[i] = vertex_pos;
|
||||
}
|
||||
}
|
||||
|
@ -488,8 +488,8 @@ bool GodotCollisionSolver3D::solve_distance_world_boundary(const GodotShape3D *p
|
|||
// Use 3 equidistant points on the circle.
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
Vector3 vertex_pos = circle_pos;
|
||||
vertex_pos += circle_axis_1 * Math::cos(2.0 * Math_PI * i / 3.0);
|
||||
vertex_pos += circle_axis_2 * Math::sin(2.0 * Math_PI * i / 3.0);
|
||||
vertex_pos += circle_axis_1 * Math::cos(2.0 * Math::PI * i / 3.0);
|
||||
vertex_pos += circle_axis_2 * Math::sin(2.0 * Math::PI * i / 3.0);
|
||||
supports[i] = vertex_pos;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ static void _generate_contacts_face_circle(const Vector3 *p_points_A, int p_poin
|
|||
static const int circle_segments = 8;
|
||||
Vector3 circle_points[circle_segments];
|
||||
|
||||
real_t angle_delta = 2.0 * Math_PI / circle_segments;
|
||||
real_t angle_delta = 2.0 * Math::PI / circle_segments;
|
||||
|
||||
for (int i = 0; i < circle_segments; ++i) {
|
||||
Vector3 point_pos = circle_B_pos;
|
||||
|
@ -511,8 +511,8 @@ static void _generate_contacts_circle_circle(const Vector3 *p_points_A, int p_po
|
|||
// Circle A inside circle B.
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
Vector3 circle_A_point = circle_A_pos;
|
||||
circle_A_point += circle_A_line_1 * Math::cos(2.0 * Math_PI * i / 3.0);
|
||||
circle_A_point += circle_A_line_2 * Math::sin(2.0 * Math_PI * i / 3.0);
|
||||
circle_A_point += circle_A_line_1 * Math::cos(2.0 * Math::PI * i / 3.0);
|
||||
circle_A_point += circle_A_line_2 * Math::sin(2.0 * Math::PI * i / 3.0);
|
||||
|
||||
contact_points[num_points] = circle_A_point;
|
||||
++num_points;
|
||||
|
@ -521,8 +521,8 @@ static void _generate_contacts_circle_circle(const Vector3 *p_points_A, int p_po
|
|||
// Circle B inside circle A.
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
Vector3 circle_B_point = circle_B_pos;
|
||||
circle_B_point += circle_B_line_1 * Math::cos(2.0 * Math_PI * i / 3.0);
|
||||
circle_B_point += circle_B_line_2 * Math::sin(2.0 * Math_PI * i / 3.0);
|
||||
circle_B_point += circle_B_line_1 * Math::cos(2.0 * Math::PI * i / 3.0);
|
||||
circle_B_point += circle_B_line_2 * Math::sin(2.0 * Math::PI * i / 3.0);
|
||||
|
||||
Vector3 circle_A_point = circle_B_point - norm_proj;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ protected:
|
|||
bool dynamic_B = false;
|
||||
|
||||
void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) {
|
||||
if (Math::abs(n.z) > Math_SQRT12) {
|
||||
if (Math::abs(n.z) > Math::SQRT12) {
|
||||
// choose p in y-z plane
|
||||
real_t a = n[1] * n[1] + n[2] * n[2];
|
||||
real_t k = 1.0 / Math::sqrt(a);
|
||||
|
@ -57,7 +57,7 @@ protected:
|
|||
}
|
||||
|
||||
_FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) {
|
||||
real_t coeff_1 = Math_PI / 4.0f;
|
||||
real_t coeff_1 = Math::PI / 4.0f;
|
||||
real_t coeff_2 = 3.0f * coeff_1;
|
||||
real_t abs_y = Math::abs(y);
|
||||
real_t angle;
|
||||
|
|
|
@ -119,7 +119,7 @@ class GodotWorldBoundaryShape3D : public GodotShape3D {
|
|||
public:
|
||||
Plane get_plane() const;
|
||||
|
||||
virtual real_t get_volume() const override { return INFINITY; }
|
||||
virtual real_t get_volume() const override { return Math::INF; }
|
||||
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_WORLD_BOUNDARY; }
|
||||
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
|
||||
virtual Vector3 get_support(const Vector3 &p_normal) const override;
|
||||
|
@ -172,7 +172,7 @@ class GodotSphereShape3D : public GodotShape3D {
|
|||
public:
|
||||
real_t get_radius() const;
|
||||
|
||||
virtual real_t get_volume() const override { return 4.0 / 3.0 * Math_PI * radius * radius * radius; }
|
||||
virtual real_t get_volume() const override { return 4.0 / 3.0 * Math::PI * radius * radius * radius; }
|
||||
|
||||
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_SPHERE; }
|
||||
|
||||
|
@ -226,7 +226,7 @@ public:
|
|||
_FORCE_INLINE_ real_t get_height() const { return height; }
|
||||
_FORCE_INLINE_ real_t get_radius() const { return radius; }
|
||||
|
||||
virtual real_t get_volume() const override { return 4.0 / 3.0 * Math_PI * radius * radius * radius + (height - radius * 2.0) * Math_PI * radius * radius; }
|
||||
virtual real_t get_volume() const override { return 4.0 / 3.0 * Math::PI * radius * radius * radius + (height - radius * 2.0) * Math::PI * radius * radius; }
|
||||
|
||||
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CAPSULE; }
|
||||
|
||||
|
@ -255,7 +255,7 @@ public:
|
|||
_FORCE_INLINE_ real_t get_height() const { return height; }
|
||||
_FORCE_INLINE_ real_t get_radius() const { return radius; }
|
||||
|
||||
virtual real_t get_volume() const override { return height * Math_PI * radius * radius; }
|
||||
virtual real_t get_volume() const override { return height * Math::PI * radius * radius; }
|
||||
|
||||
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CYLINDER; }
|
||||
|
||||
|
|
|
@ -1245,7 +1245,7 @@ struct _SoftBodyIntersectSegmentInfo {
|
|||
Vector3 dir;
|
||||
Vector3 hit_position;
|
||||
uint32_t hit_face_index = -1;
|
||||
real_t hit_dist_sq = INFINITY;
|
||||
real_t hit_dist_sq = Math::INF;
|
||||
|
||||
static bool process_hit(uint32_t p_face_index, void *p_userdata) {
|
||||
_SoftBodyIntersectSegmentInfo &query_info = *(static_cast<_SoftBodyIntersectSegmentInfo *>(p_userdata));
|
||||
|
@ -1276,7 +1276,7 @@ bool GodotSoftBodyShape3D::intersect_segment(const Vector3 &p_begin, const Vecto
|
|||
|
||||
soft_body->query_ray(p_begin, p_end, _SoftBodyIntersectSegmentInfo::process_hit, &query_info);
|
||||
|
||||
if (query_info.hit_dist_sq != INFINITY) {
|
||||
if (query_info.hit_dist_sq != Math::INF) {
|
||||
r_result = query_info.hit_position;
|
||||
r_normal = soft_body->get_face_normal(query_info.hit_face_index);
|
||||
return true;
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
real_t m_biasFactor = 0.3;
|
||||
real_t m_relaxationFactor = 1.0;
|
||||
|
||||
real_t m_swingSpan1 = Math_TAU / 8.0;
|
||||
real_t m_swingSpan1 = Math::TAU / 8.0;
|
||||
real_t m_swingSpan2 = 0.0;
|
||||
real_t m_twistSpan = 0.0;
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ class GodotHingeJoint3D : public GodotJoint3D {
|
|||
real_t m_biasFactor = 0.3;
|
||||
real_t m_relaxationFactor = 1.0;
|
||||
|
||||
real_t m_lowerLimit = Math_PI;
|
||||
real_t m_upperLimit = -Math_PI;
|
||||
real_t m_lowerLimit = Math::PI;
|
||||
real_t m_upperLimit = -Math::PI;
|
||||
|
||||
real_t m_kHinge = 0.0;
|
||||
|
||||
|
|
|
@ -98,14 +98,14 @@ void GridMapEditor::_menu_option(int p_option) {
|
|||
Basis r;
|
||||
if (input_action == INPUT_PASTE) {
|
||||
r = node->get_basis_with_orthogonal_index(paste_indicator.orientation);
|
||||
r.rotate(Vector3(0, 1, 0), -Math_PI / 2.0);
|
||||
r.rotate(Vector3(0, 1, 0), -Math::PI / 2.0);
|
||||
paste_indicator.orientation = node->get_orthogonal_index_from_basis(r);
|
||||
_update_paste_indicator();
|
||||
break;
|
||||
}
|
||||
|
||||
r = node->get_basis_with_orthogonal_index(cursor_rot);
|
||||
r.rotate(Vector3(0, 1, 0), -Math_PI / 2.0);
|
||||
r.rotate(Vector3(0, 1, 0), -Math::PI / 2.0);
|
||||
cursor_rot = node->get_orthogonal_index_from_basis(r);
|
||||
_update_cursor_transform();
|
||||
} break;
|
||||
|
@ -113,14 +113,14 @@ void GridMapEditor::_menu_option(int p_option) {
|
|||
Basis r;
|
||||
if (input_action == INPUT_PASTE) {
|
||||
r = node->get_basis_with_orthogonal_index(paste_indicator.orientation);
|
||||
r.rotate(Vector3(1, 0, 0), -Math_PI / 2.0);
|
||||
r.rotate(Vector3(1, 0, 0), -Math::PI / 2.0);
|
||||
paste_indicator.orientation = node->get_orthogonal_index_from_basis(r);
|
||||
_update_paste_indicator();
|
||||
break;
|
||||
}
|
||||
|
||||
r = node->get_basis_with_orthogonal_index(cursor_rot);
|
||||
r.rotate(Vector3(1, 0, 0), -Math_PI / 2.0);
|
||||
r.rotate(Vector3(1, 0, 0), -Math::PI / 2.0);
|
||||
cursor_rot = node->get_orthogonal_index_from_basis(r);
|
||||
_update_cursor_transform();
|
||||
} break;
|
||||
|
@ -128,14 +128,14 @@ void GridMapEditor::_menu_option(int p_option) {
|
|||
Basis r;
|
||||
if (input_action == INPUT_PASTE) {
|
||||
r = node->get_basis_with_orthogonal_index(paste_indicator.orientation);
|
||||
r.rotate(Vector3(0, 0, 1), -Math_PI / 2.0);
|
||||
r.rotate(Vector3(0, 0, 1), -Math::PI / 2.0);
|
||||
paste_indicator.orientation = node->get_orthogonal_index_from_basis(r);
|
||||
_update_paste_indicator();
|
||||
break;
|
||||
}
|
||||
|
||||
r = node->get_basis_with_orthogonal_index(cursor_rot);
|
||||
r.rotate(Vector3(0, 0, 1), -Math_PI / 2.0);
|
||||
r.rotate(Vector3(0, 0, 1), -Math::PI / 2.0);
|
||||
cursor_rot = node->get_orthogonal_index_from_basis(r);
|
||||
_update_cursor_transform();
|
||||
} break;
|
||||
|
@ -143,14 +143,14 @@ void GridMapEditor::_menu_option(int p_option) {
|
|||
Basis r;
|
||||
if (input_action == INPUT_PASTE) {
|
||||
r = node->get_basis_with_orthogonal_index(paste_indicator.orientation);
|
||||
r.rotate(Vector3(0, 1, 0), Math_PI / 2.0);
|
||||
r.rotate(Vector3(0, 1, 0), Math::PI / 2.0);
|
||||
paste_indicator.orientation = node->get_orthogonal_index_from_basis(r);
|
||||
_update_paste_indicator();
|
||||
break;
|
||||
}
|
||||
|
||||
r = node->get_basis_with_orthogonal_index(cursor_rot);
|
||||
r.rotate(Vector3(0, 1, 0), Math_PI / 2.0);
|
||||
r.rotate(Vector3(0, 1, 0), Math::PI / 2.0);
|
||||
cursor_rot = node->get_orthogonal_index_from_basis(r);
|
||||
_update_cursor_transform();
|
||||
} break;
|
||||
|
@ -158,14 +158,14 @@ void GridMapEditor::_menu_option(int p_option) {
|
|||
Basis r;
|
||||
if (input_action == INPUT_PASTE) {
|
||||
r = node->get_basis_with_orthogonal_index(paste_indicator.orientation);
|
||||
r.rotate(Vector3(1, 0, 0), Math_PI / 2.0);
|
||||
r.rotate(Vector3(1, 0, 0), Math::PI / 2.0);
|
||||
paste_indicator.orientation = node->get_orthogonal_index_from_basis(r);
|
||||
_update_paste_indicator();
|
||||
break;
|
||||
}
|
||||
|
||||
r = node->get_basis_with_orthogonal_index(cursor_rot);
|
||||
r.rotate(Vector3(1, 0, 0), Math_PI / 2.0);
|
||||
r.rotate(Vector3(1, 0, 0), Math::PI / 2.0);
|
||||
cursor_rot = node->get_orthogonal_index_from_basis(r);
|
||||
_update_cursor_transform();
|
||||
} break;
|
||||
|
@ -173,14 +173,14 @@ void GridMapEditor::_menu_option(int p_option) {
|
|||
Basis r;
|
||||
if (input_action == INPUT_PASTE) {
|
||||
r = node->get_basis_with_orthogonal_index(paste_indicator.orientation);
|
||||
r.rotate(Vector3(0, 0, 1), Math_PI / 2.0);
|
||||
r.rotate(Vector3(0, 0, 1), Math::PI / 2.0);
|
||||
paste_indicator.orientation = node->get_orthogonal_index_from_basis(r);
|
||||
_update_paste_indicator();
|
||||
break;
|
||||
}
|
||||
|
||||
r = node->get_basis_with_orthogonal_index(cursor_rot);
|
||||
r.rotate(Vector3(0, 0, 1), Math_PI / 2.0);
|
||||
r.rotate(Vector3(0, 0, 1), Math::PI / 2.0);
|
||||
cursor_rot = node->get_orthogonal_index_from_basis(r);
|
||||
_update_cursor_transform();
|
||||
} break;
|
||||
|
|
|
@ -111,7 +111,7 @@ bool JoltPhysicsDirectSpaceState3D::_cast_motion_impl(const JPH::Shape &p_jolt_s
|
|||
};
|
||||
|
||||
// Figure out the number of steps we need in our binary search in order to achieve millimeter precision, within reason.
|
||||
const int step_count = CLAMP(int(logf(1000.0f * motion_length) / (float)Math_LN2), 4, 16);
|
||||
const int step_count = CLAMP(int(logf(1000.0f * motion_length) / (float)Math::LN2), 4, 16);
|
||||
|
||||
bool collided = false;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ constexpr double DEFAULT_CONTACT_MAX_SEPARATION = 0.05;
|
|||
constexpr double DEFAULT_CONTACT_MAX_ALLOWED_PENETRATION = 0.01;
|
||||
constexpr double DEFAULT_CONTACT_DEFAULT_BIAS = 0.8;
|
||||
constexpr double DEFAULT_SLEEP_THRESHOLD_LINEAR = 0.1;
|
||||
constexpr double DEFAULT_SLEEP_THRESHOLD_ANGULAR = 8.0 * Math_PI / 180;
|
||||
constexpr double DEFAULT_SLEEP_THRESHOLD_ANGULAR = 8.0 * Math::PI / 180;
|
||||
constexpr double DEFAULT_SOLVER_ITERATIONS = 8;
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -253,7 +253,7 @@ void OpenXRHandTrackingExtension::on_process() {
|
|||
// SKELETON_RIG_HUMANOID bone adjustment. This rotation performs:
|
||||
// OpenXR Z+ -> Godot Humanoid Y- (Back along the bone)
|
||||
// OpenXR Y+ -> Godot Humanoid Z- (Out the back of the hand)
|
||||
const Quaternion bone_adjustment(0.0, -Math_SQRT12, Math_SQRT12, 0.0);
|
||||
const Quaternion bone_adjustment(0.0, -Math::SQRT12, Math::SQRT12, 0.0);
|
||||
|
||||
for (int joint = 0; joint < XR_HAND_JOINT_COUNT_EXT; joint++) {
|
||||
const XrHandJointLocationEXT &location = hand_trackers[i].joint_locations[joint];
|
||||
|
|
|
@ -77,7 +77,7 @@ Ref<Mesh> OpenXRCompositionLayerCylinder::_create_fallback_mesh() {
|
|||
Vector<int> indices;
|
||||
|
||||
float delta_angle = central_angle / fallback_segments;
|
||||
float start_angle = (-Math_PI / 2.0) - (central_angle / 2.0);
|
||||
float start_angle = (-Math::PI / 2.0) - (central_angle / 2.0);
|
||||
|
||||
for (uint32_t i = 0; i < fallback_segments + 1; i++) {
|
||||
float current_angle = start_angle + (delta_angle * i);
|
||||
|
@ -192,7 +192,7 @@ Vector2 OpenXRCompositionLayerCylinder::intersects_ray(const Vector3 &p_origin,
|
|||
Vector3 intersection = p_origin + p_direction * t;
|
||||
|
||||
Basis correction = cylinder_transform.basis.inverse();
|
||||
correction.rotate(Vector3(0.0, 1.0, 0.0), -Math_PI / 2.0);
|
||||
correction.rotate(Vector3(0.0, 1.0, 0.0), -Math::PI / 2.0);
|
||||
Vector3 relative_point = correction.xform(intersection - cylinder_transform.origin);
|
||||
|
||||
Vector2 projected_point = Vector2(relative_point.x, relative_point.z);
|
||||
|
|
|
@ -46,13 +46,13 @@ class OpenXRCompositionLayerCylinder : public OpenXRCompositionLayer {
|
|||
{}, // subImage
|
||||
{ { 0, 0, 0, 0 }, { 0, 0, 0 } }, // pose
|
||||
1.0, // radius
|
||||
Math_PI / 2.0, // centralAngle
|
||||
Math::PI / 2.0, // centralAngle
|
||||
1.0, // aspectRatio
|
||||
};
|
||||
|
||||
float radius = 1.0;
|
||||
float aspect_ratio = 1.0;
|
||||
float central_angle = Math_PI / 2.0;
|
||||
float central_angle = Math::PI / 2.0;
|
||||
uint32_t fallback_segments = 10;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -80,7 +80,7 @@ Ref<Mesh> OpenXRCompositionLayerEquirect::_create_fallback_mesh() {
|
|||
float step_horizontal = central_horizontal_angle / fallback_segments;
|
||||
float step_vertical = (upper_vertical_angle + lower_vertical_angle) / fallback_segments;
|
||||
|
||||
float start_horizontal_angle = Math_PI - (central_horizontal_angle / 2.0);
|
||||
float start_horizontal_angle = Math::PI - (central_horizontal_angle / 2.0);
|
||||
|
||||
for (uint32_t i = 0; i < fallback_segments + 1; i++) {
|
||||
for (uint32_t j = 0; j < fallback_segments + 1; j++) {
|
||||
|
@ -155,7 +155,7 @@ float OpenXRCompositionLayerEquirect::get_central_horizontal_angle() const {
|
|||
}
|
||||
|
||||
void OpenXRCompositionLayerEquirect::set_upper_vertical_angle(float p_angle) {
|
||||
ERR_FAIL_COND(p_angle <= 0 || p_angle > (Math_PI / 2.0));
|
||||
ERR_FAIL_COND(p_angle <= 0 || p_angle > (Math::PI / 2.0));
|
||||
upper_vertical_angle = p_angle;
|
||||
composition_layer.upperVerticalAngle = p_angle;
|
||||
update_fallback_mesh();
|
||||
|
@ -166,7 +166,7 @@ float OpenXRCompositionLayerEquirect::get_upper_vertical_angle() const {
|
|||
}
|
||||
|
||||
void OpenXRCompositionLayerEquirect::set_lower_vertical_angle(float p_angle) {
|
||||
ERR_FAIL_COND(p_angle <= 0 || p_angle > (Math_PI / 2.0));
|
||||
ERR_FAIL_COND(p_angle <= 0 || p_angle > (Math::PI / 2.0));
|
||||
lower_vertical_angle = p_angle;
|
||||
composition_layer.lowerVerticalAngle = -p_angle;
|
||||
update_fallback_mesh();
|
||||
|
@ -209,7 +209,7 @@ Vector2 OpenXRCompositionLayerEquirect::intersects_ray(const Vector3 &p_origin,
|
|||
Vector3 intersection = p_origin + p_direction * t;
|
||||
|
||||
Basis correction = equirect_transform.basis.inverse();
|
||||
correction.rotate(Vector3(0.0, 1.0, 0.0), -Math_PI / 2.0);
|
||||
correction.rotate(Vector3(0.0, 1.0, 0.0), -Math::PI / 2.0);
|
||||
Vector3 relative_point = correction.xform(intersection - equirect_transform.origin);
|
||||
|
||||
float horizontal_intersection_angle = Math::atan2(relative_point.z, relative_point.x);
|
||||
|
@ -217,7 +217,7 @@ Vector2 OpenXRCompositionLayerEquirect::intersects_ray(const Vector3 &p_origin,
|
|||
return Vector2(-1.0, -1.0);
|
||||
}
|
||||
|
||||
float vertical_intersection_angle = Math::acos(relative_point.y / radius) - (Math_PI / 2.0);
|
||||
float vertical_intersection_angle = Math::acos(relative_point.y / radius) - (Math::PI / 2.0);
|
||||
if (vertical_intersection_angle < 0) {
|
||||
if (Math::abs(vertical_intersection_angle) > upper_vertical_angle) {
|
||||
return Vector2(-1.0, -1.0);
|
||||
|
|
|
@ -46,15 +46,15 @@ class OpenXRCompositionLayerEquirect : public OpenXRCompositionLayer {
|
|||
{}, // subImage
|
||||
{ { 0, 0, 0, 0 }, { 0, 0, 0 } }, // pose
|
||||
1.0, // radius
|
||||
Math_PI / 2.0, // centralHorizontalAngle
|
||||
Math_PI / 4.0, // upperVerticalAngle
|
||||
-Math_PI / 4.0, // lowerVerticalAngle
|
||||
Math::PI / 2.0, // centralHorizontalAngle
|
||||
Math::PI / 4.0, // upperVerticalAngle
|
||||
-Math::PI / 4.0, // lowerVerticalAngle
|
||||
};
|
||||
|
||||
float radius = 1.0;
|
||||
float central_horizontal_angle = Math_PI / 2.0;
|
||||
float upper_vertical_angle = Math_PI / 4.0;
|
||||
float lower_vertical_angle = Math_PI / 4.0;
|
||||
float central_horizontal_angle = Math::PI / 2.0;
|
||||
float upper_vertical_angle = Math::PI / 4.0;
|
||||
float lower_vertical_angle = Math::PI / 4.0;
|
||||
uint32_t fallback_segments = 10;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -311,7 +311,7 @@ void OpenXRHand::_update_skeleton() {
|
|||
// SKELETON_RIG_HUMANOID bone adjustment. This rotation performs:
|
||||
// OpenXR Z+ -> Godot Humanoid Y- (Back along the bone)
|
||||
// OpenXR Y+ -> Godot Humanoid Z- (Out the back of the hand)
|
||||
Quaternion(0.0, -Math_SQRT12, Math_SQRT12, 0.0),
|
||||
Quaternion(0.0, -Math::SQRT12, Math::SQRT12, 0.0),
|
||||
};
|
||||
|
||||
// we cache our transforms so we can quickly calculate local transforms
|
||||
|
|
|
@ -454,22 +454,22 @@ static const float earth_gravity = 9.80665;
|
|||
|
||||
switch (interfaceOrientation) {
|
||||
case UIInterfaceOrientationLandscapeLeft: {
|
||||
DisplayServerIOS::get_singleton()->update_gravity(Vector3(gravity.x, gravity.y, gravity.z).rotated(Vector3(0, 0, 1), -Math_PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_accelerometer(Vector3(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z).rotated(Vector3(0, 0, 1), -Math_PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_magnetometer(Vector3(magnetic.x, magnetic.y, magnetic.z).rotated(Vector3(0, 0, 1), -Math_PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_gyroscope(Vector3(rotation.x, rotation.y, rotation.z).rotated(Vector3(0, 0, 1), -Math_PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_gravity(Vector3(gravity.x, gravity.y, gravity.z).rotated(Vector3(0, 0, 1), -Math::PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_accelerometer(Vector3(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z).rotated(Vector3(0, 0, 1), -Math::PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_magnetometer(Vector3(magnetic.x, magnetic.y, magnetic.z).rotated(Vector3(0, 0, 1), -Math::PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_gyroscope(Vector3(rotation.x, rotation.y, rotation.z).rotated(Vector3(0, 0, 1), -Math::PI * 0.5));
|
||||
} break;
|
||||
case UIInterfaceOrientationLandscapeRight: {
|
||||
DisplayServerIOS::get_singleton()->update_gravity(Vector3(gravity.x, gravity.y, gravity.z).rotated(Vector3(0, 0, 1), Math_PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_accelerometer(Vector3(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z).rotated(Vector3(0, 0, 1), Math_PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_magnetometer(Vector3(magnetic.x, magnetic.y, magnetic.z).rotated(Vector3(0, 0, 1), Math_PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_gyroscope(Vector3(rotation.x, rotation.y, rotation.z).rotated(Vector3(0, 0, 1), Math_PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_gravity(Vector3(gravity.x, gravity.y, gravity.z).rotated(Vector3(0, 0, 1), Math::PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_accelerometer(Vector3(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z).rotated(Vector3(0, 0, 1), Math::PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_magnetometer(Vector3(magnetic.x, magnetic.y, magnetic.z).rotated(Vector3(0, 0, 1), Math::PI * 0.5));
|
||||
DisplayServerIOS::get_singleton()->update_gyroscope(Vector3(rotation.x, rotation.y, rotation.z).rotated(Vector3(0, 0, 1), Math::PI * 0.5));
|
||||
} break;
|
||||
case UIInterfaceOrientationPortraitUpsideDown: {
|
||||
DisplayServerIOS::get_singleton()->update_gravity(Vector3(gravity.x, gravity.y, gravity.z).rotated(Vector3(0, 0, 1), Math_PI));
|
||||
DisplayServerIOS::get_singleton()->update_accelerometer(Vector3(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z).rotated(Vector3(0, 0, 1), Math_PI));
|
||||
DisplayServerIOS::get_singleton()->update_magnetometer(Vector3(magnetic.x, magnetic.y, magnetic.z).rotated(Vector3(0, 0, 1), Math_PI));
|
||||
DisplayServerIOS::get_singleton()->update_gyroscope(Vector3(rotation.x, rotation.y, rotation.z).rotated(Vector3(0, 0, 1), Math_PI));
|
||||
DisplayServerIOS::get_singleton()->update_gravity(Vector3(gravity.x, gravity.y, gravity.z).rotated(Vector3(0, 0, 1), Math::PI));
|
||||
DisplayServerIOS::get_singleton()->update_accelerometer(Vector3(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z).rotated(Vector3(0, 0, 1), Math::PI));
|
||||
DisplayServerIOS::get_singleton()->update_magnetometer(Vector3(magnetic.x, magnetic.y, magnetic.z).rotated(Vector3(0, 0, 1), Math::PI));
|
||||
DisplayServerIOS::get_singleton()->update_gyroscope(Vector3(rotation.x, rotation.y, rotation.z).rotated(Vector3(0, 0, 1), Math::PI));
|
||||
} break;
|
||||
default: { // assume portrait
|
||||
DisplayServerIOS::get_singleton()->update_gravity(Vector3(gravity.x, gravity.y, gravity.z));
|
||||
|
|
|
@ -5008,8 +5008,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
|||
windows[window_id].last_pressure_update = 0;
|
||||
|
||||
float pressure = float(packet.pkNormalPressure - windows[window_id].min_pressure) / float(windows[window_id].max_pressure - windows[window_id].min_pressure);
|
||||
double azim = (packet.pkOrientation.orAzimuth / 10.0f) * (Math_PI / 180);
|
||||
double alt = Math::tan((Math::abs(packet.pkOrientation.orAltitude / 10.0f)) * (Math_PI / 180));
|
||||
double azim = (packet.pkOrientation.orAzimuth / 10.0f) * (Math::PI / 180);
|
||||
double alt = Math::tan((Math::abs(packet.pkOrientation.orAltitude / 10.0f)) * (Math::PI / 180));
|
||||
bool inverted = packet.pkStatus & TPS_INVERT;
|
||||
|
||||
Vector2 tilt = (windows[window_id].tilt_supported) ? Vector2(Math::atan(Math::sin(azim) / alt), Math::atan(Math::cos(azim) / alt)) : Vector2();
|
||||
|
|
|
@ -891,12 +891,12 @@ void CPUParticles2D::_particles_process(double p_delta) {
|
|||
//do none
|
||||
} break;
|
||||
case EMISSION_SHAPE_SPHERE: {
|
||||
real_t t = Math_TAU * rng->randf();
|
||||
real_t t = Math::TAU * rng->randf();
|
||||
real_t radius = emission_sphere_radius * rng->randf();
|
||||
p.transform[2] = Vector2(Math::cos(t), Math::sin(t)) * radius;
|
||||
} break;
|
||||
case EMISSION_SHAPE_SPHERE_SURFACE: {
|
||||
real_t s = rng->randf(), t = Math_TAU * rng->randf();
|
||||
real_t s = rng->randf(), t = Math::TAU * rng->randf();
|
||||
real_t radius = emission_sphere_radius * Math::sqrt(1.0 - s * s);
|
||||
p.transform[2] = Vector2(Math::cos(t), Math::sin(t)) * radius;
|
||||
} break;
|
||||
|
@ -1013,7 +1013,7 @@ void CPUParticles2D::_particles_process(double p_delta) {
|
|||
//orbit velocity
|
||||
real_t orbit_amount = tex_orbit_velocity * Math::lerp(parameters_min[PARAM_ORBIT_VELOCITY], parameters_max[PARAM_ORBIT_VELOCITY], rand_from_seed(_seed));
|
||||
if (orbit_amount != 0.0) {
|
||||
real_t ang = orbit_amount * local_delta * Math_TAU;
|
||||
real_t ang = orbit_amount * local_delta * Math::TAU;
|
||||
// Not sure why the ParticleProcessMaterial code uses a clockwise rotation matrix,
|
||||
// but we use -ang here to reproduce its behavior.
|
||||
Transform2D rot = Transform2D(-ang, Vector2());
|
||||
|
@ -1067,7 +1067,7 @@ void CPUParticles2D::_particles_process(double p_delta) {
|
|||
tex_hue_variation = curve_parameters[PARAM_HUE_VARIATION]->sample(tv);
|
||||
}
|
||||
|
||||
real_t hue_rot_angle = (tex_hue_variation)*Math_TAU * Math::lerp(parameters_min[PARAM_HUE_VARIATION], parameters_max[PARAM_HUE_VARIATION], p.hue_rot_rand);
|
||||
real_t hue_rot_angle = (tex_hue_variation)*Math::TAU * Math::lerp(parameters_min[PARAM_HUE_VARIATION], parameters_max[PARAM_HUE_VARIATION], p.hue_rot_rand);
|
||||
real_t hue_rot_c = Math::cos(hue_rot_angle);
|
||||
real_t hue_rot_s = Math::sin(hue_rot_angle);
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ void LineBuilder::build() {
|
|||
} else if (texture_mode == Line2D::LINE_TEXTURE_STRETCH) {
|
||||
uvx0 = width * width_factor / total_distance;
|
||||
}
|
||||
new_arc(pos0, pos_up0 - pos0, -Math_PI, color0, Rect2(0.f, 0.f, uvx0 * 2, 1.f));
|
||||
new_arc(pos0, pos_up0 - pos0, -Math::PI, color0, Rect2(0.f, 0.f, uvx0 * 2, 1.f));
|
||||
current_distance0 += modified_hw;
|
||||
current_distance1 = current_distance0;
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ void LineBuilder::build() {
|
|||
} else if (texture_mode == Line2D::LINE_TEXTURE_STRETCH) {
|
||||
dist = width * width_factor / total_distance;
|
||||
}
|
||||
new_arc(pos1, pos_up1 - pos1, Math_PI, color, Rect2(uvx1 - 0.5f * dist, 0.f, dist, 1.f));
|
||||
new_arc(pos1, pos_up1 - pos1, Math::PI, color, Rect2(uvx1 - 0.5f * dist, 0.f, dist, 1.f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ void LineBuilder::strip_add_arc(Vector2 center, float angle_delta, Orientation o
|
|||
Orientation opposite_orientation = orientation == UP ? DOWN : UP;
|
||||
Vector2 vbegin = vertices[_last_index[opposite_orientation]] - center;
|
||||
float radius = vbegin.length();
|
||||
float angle_step = Math_PI / static_cast<float>(round_precision);
|
||||
float angle_step = Math::PI / static_cast<float>(round_precision);
|
||||
float steps = Math::abs(angle_delta) / angle_step;
|
||||
|
||||
if (angle_delta < 0.f) {
|
||||
|
@ -536,7 +536,7 @@ void LineBuilder::new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Col
|
|||
// with undistorted UVs from within a square section
|
||||
|
||||
float radius = vbegin.length();
|
||||
float angle_step = Math_PI / static_cast<float>(round_precision);
|
||||
float angle_step = Math::PI / static_cast<float>(round_precision);
|
||||
float steps = Math::abs(angle_delta) / angle_step;
|
||||
|
||||
if (angle_delta < 0.f) {
|
||||
|
@ -546,7 +546,7 @@ void LineBuilder::new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Col
|
|||
float t = Vector2(1, 0).angle_to(vbegin);
|
||||
float end_angle = t + angle_delta;
|
||||
Vector2 rpos(0, 0);
|
||||
float tt_begin = -Math_PI / 2.0f;
|
||||
float tt_begin = -Math::PI / 2.0f;
|
||||
float tt = tt_begin;
|
||||
|
||||
// Center vertice
|
||||
|
|
|
@ -396,8 +396,8 @@ void NavigationLink2D::_update_debug_mesh() {
|
|||
real_t radius = NavigationServer2D::get_singleton()->map_get_link_connection_radius(get_world_2d()->get_navigation_map());
|
||||
|
||||
draw_line(get_start_position(), get_end_position(), color);
|
||||
draw_arc(get_start_position(), radius, 0, Math_TAU, 10, color);
|
||||
draw_arc(get_end_position(), radius, 0, Math_TAU, 10, color);
|
||||
draw_arc(get_start_position(), radius, 0, Math::TAU, 10, color);
|
||||
draw_arc(get_end_position(), radius, 0, Math::TAU, 10, color);
|
||||
|
||||
const Vector2 link_segment = end_position - start_position;
|
||||
const float arror_len = 5.0;
|
||||
|
|
|
@ -382,7 +382,7 @@ void NavigationObstacle2D::navmesh_parse_source_geometry(const Ref<NavigationPol
|
|||
|
||||
obstruction_circle_vertices.resize(circle_points);
|
||||
Vector2 *circle_vertices_ptrw = obstruction_circle_vertices.ptrw();
|
||||
const real_t circle_point_step = Math_TAU / circle_points;
|
||||
const real_t circle_point_step = Math::TAU / circle_points;
|
||||
|
||||
for (int i = 0; i < circle_points; i++) {
|
||||
const float angle = i * circle_point_step;
|
||||
|
|
|
@ -623,8 +623,8 @@ void NavigationRegion2D::_update_debug_edge_connections_mesh() {
|
|||
|
||||
// Draw a circle to illustrate the margins.
|
||||
real_t angle = a.angle_to_point(b);
|
||||
draw_arc(a, radius, angle + Math_PI / 2.0, angle - Math_PI / 2.0 + Math_TAU, 10, debug_edge_connection_color);
|
||||
draw_arc(b, radius, angle - Math_PI / 2.0, angle + Math_PI / 2.0, 10, debug_edge_connection_color);
|
||||
draw_arc(a, radius, angle + Math::PI / 2.0, angle - Math::PI / 2.0 + Math::TAU, 10, debug_edge_connection_color);
|
||||
draw_arc(b, radius, angle - Math::PI / 2.0, angle + Math::PI / 2.0, 10, debug_edge_connection_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,8 +157,8 @@ void CollisionPolygon2D::_notification(int p_what) {
|
|||
|
||||
Vector<Vector2> pts = {
|
||||
line_to + Vector2(0, tsize),
|
||||
line_to + Vector2(Math_SQRT12 * tsize, 0),
|
||||
line_to + Vector2(-Math_SQRT12 * tsize, 0)
|
||||
line_to + Vector2(Math::SQRT12 * tsize, 0),
|
||||
line_to + Vector2(-Math::SQRT12 * tsize, 0)
|
||||
};
|
||||
|
||||
Vector<Color> cols{ dcol, dcol, dcol };
|
||||
|
|
|
@ -120,8 +120,8 @@ void CollisionShape2D::_notification(int p_what) {
|
|||
|
||||
Vector<Vector2> pts{
|
||||
line_to + Vector2(0, tsize),
|
||||
line_to + Vector2(Math_SQRT12 * tsize, 0),
|
||||
line_to + Vector2(-Math_SQRT12 * tsize, 0)
|
||||
line_to + Vector2(Math::SQRT12 * tsize, 0),
|
||||
line_to + Vector2(-Math::SQRT12 * tsize, 0)
|
||||
};
|
||||
|
||||
Vector<Color> cols{ draw_col, draw_col, draw_col };
|
||||
|
|
|
@ -159,7 +159,7 @@ void StaticBody2D::navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p
|
|||
const real_t capsule_radius = capsule_shape->get_radius();
|
||||
|
||||
Vector<Vector2> shape_outline;
|
||||
const real_t turn_step = Math_TAU / 12.0;
|
||||
const real_t turn_step = Math::TAU / 12.0;
|
||||
shape_outline.resize(14);
|
||||
int shape_outline_inx = 0;
|
||||
for (int i = 0; i < 12; i++) {
|
||||
|
@ -184,7 +184,7 @@ void StaticBody2D::navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p
|
|||
int circle_edge_count = 12;
|
||||
shape_outline.resize(circle_edge_count);
|
||||
|
||||
const real_t turn_step = Math_TAU / real_t(circle_edge_count);
|
||||
const real_t turn_step = Math::TAU / real_t(circle_edge_count);
|
||||
for (int i = 0; i < circle_edge_count; i++) {
|
||||
shape_outline.write[i] = static_body_xform.xform(Vector2(Math::cos(i * turn_step), Math::sin(i * turn_step)) * circle_radius);
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ bool Bone2D::_editor_get_bone_shape(Vector<Vector2> *p_shape, Vector<Vector2> *p
|
|||
rel = Vector2(Math::cos(bone_angle), Math::sin(bone_angle)) * length * get_global_scale();
|
||||
}
|
||||
|
||||
Vector2 relt = rel.rotated(Math_PI * 0.5).normalized() * bone_width;
|
||||
Vector2 relt = rel.rotated(Math::PI * 0.5).normalized() * bone_width;
|
||||
Vector2 reln = rel.normalized();
|
||||
Vector2 reltn = relt.normalized();
|
||||
|
||||
|
|
|
@ -886,14 +886,14 @@ void CPUParticles3D::_particles_process(double p_delta) {
|
|||
} break;
|
||||
case EMISSION_SHAPE_SPHERE: {
|
||||
real_t s = 2.0 * rng->randf() - 1.0;
|
||||
real_t t = Math_TAU * rng->randf();
|
||||
real_t t = Math::TAU * rng->randf();
|
||||
real_t x = rng->randf();
|
||||
real_t radius = emission_sphere_radius * Math::sqrt(1.0 - s * s);
|
||||
p.transform.origin = Vector3(0, 0, 0).lerp(Vector3(radius * Math::cos(t), radius * Math::sin(t), emission_sphere_radius * s), x);
|
||||
} break;
|
||||
case EMISSION_SHAPE_SPHERE_SURFACE: {
|
||||
real_t s = 2.0 * rng->randf() - 1.0;
|
||||
real_t t = Math_TAU * rng->randf();
|
||||
real_t t = Math::TAU * rng->randf();
|
||||
real_t radius = emission_sphere_radius * Math::sqrt(1.0 - s * s);
|
||||
p.transform.origin = Vector3(radius * Math::cos(t), radius * Math::sin(t), emission_sphere_radius * s);
|
||||
} break;
|
||||
|
@ -945,7 +945,7 @@ void CPUParticles3D::_particles_process(double p_delta) {
|
|||
real_t y_pos = rng->randf();
|
||||
real_t skew = MAX(MIN(radius_clamped, top_radius) / MAX(radius_clamped, top_radius), 0.5);
|
||||
y_pos = radius_clamped < top_radius ? Math::pow(y_pos, skew) : 1.0 - Math::pow(y_pos, skew);
|
||||
real_t ring_random_angle = rng->randf() * Math_TAU;
|
||||
real_t ring_random_angle = rng->randf() * Math::TAU;
|
||||
real_t ring_random_radius = Math::sqrt(rng->randf() * (radius_clamped * radius_clamped - emission_ring_inner_radius * emission_ring_inner_radius) + emission_ring_inner_radius * emission_ring_inner_radius);
|
||||
ring_random_radius = Math::lerp(ring_random_radius, ring_random_radius * (top_radius / radius_clamped), y_pos);
|
||||
Vector3 axis = emission_ring_axis == Vector3(0.0, 0.0, 0.0) ? Vector3(0.0, 0.0, 1.0) : emission_ring_axis.normalized();
|
||||
|
@ -1064,7 +1064,7 @@ void CPUParticles3D::_particles_process(double p_delta) {
|
|||
if (particle_flags[PARTICLE_FLAG_DISABLE_Z]) {
|
||||
real_t orbit_amount = tex_orbit_velocity * Math::lerp(parameters_min[PARAM_ORBIT_VELOCITY], parameters_max[PARAM_ORBIT_VELOCITY], rand_from_seed(alt_seed));
|
||||
if (orbit_amount != 0.0) {
|
||||
real_t ang = orbit_amount * local_delta * Math_TAU;
|
||||
real_t ang = orbit_amount * local_delta * Math::TAU;
|
||||
// Not sure why the ParticleProcessMaterial code uses a clockwise rotation matrix,
|
||||
// but we use -ang here to reproduce its behavior.
|
||||
Transform2D rot = Transform2D(-ang, Vector2());
|
||||
|
@ -1126,7 +1126,7 @@ void CPUParticles3D::_particles_process(double p_delta) {
|
|||
tex_hue_variation = curve_parameters[PARAM_HUE_VARIATION]->sample(tv);
|
||||
}
|
||||
|
||||
real_t hue_rot_angle = (tex_hue_variation)*Math_TAU * Math::lerp(parameters_min[PARAM_HUE_VARIATION], parameters_max[PARAM_HUE_VARIATION], p.hue_rot_rand);
|
||||
real_t hue_rot_angle = (tex_hue_variation)*Math::TAU * Math::lerp(parameters_min[PARAM_HUE_VARIATION], parameters_max[PARAM_HUE_VARIATION], p.hue_rot_rand);
|
||||
real_t hue_rot_c = Math::cos(hue_rot_angle);
|
||||
real_t hue_rot_s = Math::sin(hue_rot_angle);
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue