Skip to content

Commit 89ef6ed

Browse files
committed
Remove ABS in favor of Math::abs
1 parent 3d9b05a commit 89ef6ed

File tree

68 files changed

+142
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+142
-146
lines changed

core/io/image.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ Image::Format Image::get_format() const {
799799
}
800800

801801
static double _bicubic_interp_kernel(double x) {
802-
x = ABS(x);
802+
x = Math::abs(x);
803803

804804
double bc = 0;
805805

core/math/a_star_grid_2d.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,27 @@
3434
#include "core/variant/typed_array.h"
3535

3636
static real_t heuristic_euclidean(const Vector2i &p_from, const Vector2i &p_to) {
37-
real_t dx = (real_t)ABS(p_to.x - p_from.x);
38-
real_t dy = (real_t)ABS(p_to.y - p_from.y);
37+
real_t dx = (real_t)Math::abs(p_to.x - p_from.x);
38+
real_t dy = (real_t)Math::abs(p_to.y - p_from.y);
3939
return (real_t)Math::sqrt(dx * dx + dy * dy);
4040
}
4141

4242
static real_t heuristic_manhattan(const Vector2i &p_from, const Vector2i &p_to) {
43-
real_t dx = (real_t)ABS(p_to.x - p_from.x);
44-
real_t dy = (real_t)ABS(p_to.y - p_from.y);
43+
real_t dx = (real_t)Math::abs(p_to.x - p_from.x);
44+
real_t dy = (real_t)Math::abs(p_to.y - p_from.y);
4545
return dx + dy;
4646
}
4747

4848
static real_t heuristic_octile(const Vector2i &p_from, const Vector2i &p_to) {
49-
real_t dx = (real_t)ABS(p_to.x - p_from.x);
50-
real_t dy = (real_t)ABS(p_to.y - p_from.y);
49+
real_t dx = (real_t)Math::abs(p_to.x - p_from.x);
50+
real_t dy = (real_t)Math::abs(p_to.y - p_from.y);
5151
real_t F = Math_SQRT2 - 1;
5252
return (dx < dy) ? F * dx + dy : F * dy + dx;
5353
}
5454

5555
static real_t heuristic_chebyshev(const Vector2i &p_from, const Vector2i &p_to) {
56-
real_t dx = (real_t)ABS(p_to.x - p_from.x);
57-
real_t dy = (real_t)ABS(p_to.y - p_from.y);
56+
real_t dx = (real_t)Math::abs(p_to.x - p_from.x);
57+
real_t dy = (real_t)Math::abs(p_to.y - p_from.y);
5858
return MAX(dx, dy);
5959
}
6060

core/math/delaunay_3d.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Delaunay3D {
186186
Plane p(p_points[p_simplex.points[i]], p_points[p_simplex.points[(i + 1) % 4]], p_points[p_simplex.points[(i + 2) % 4]]);
187187
// This tolerance should not be smaller than the one used with
188188
// Plane::has_point() when creating the LightmapGI probe BSP tree.
189-
if (ABS(p.distance_to(p_points[p_simplex.points[(i + 3) % 4]])) < 0.001) {
189+
if (Math::abs(p.distance_to(p_points[p_simplex.points[(i + 3) % 4]])) < 0.001) {
190190
return true;
191191
}
192192
}

core/math/face3.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void Face3::get_support(const Vector3 &p_normal, const Transform3D &p_transform,
263263

264264
// check if edge is valid as a support
265265
real_t dot = (vertex[i] - vertex[(i + 1) % 3]).normalized().dot(n);
266-
dot = ABS(dot);
266+
dot = Math::abs(dot);
267267
if (dot < edge_support_threshold) {
268268
*p_count = MIN(2, p_max);
269269

core/math/geometry_3d.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ Geometry3D::MeshData Geometry3D::build_convex_mesh(const Vector<Plane> &p_planes
593593

594594
Vector3 ref = Vector3(0.0, 1.0, 0.0);
595595

596-
if (ABS(p.normal.dot(ref)) > 0.95f) {
596+
if (Math::abs(p.normal.dot(ref)) > 0.95f) {
597597
ref = Vector3(0.0, 0.0, 1.0); // Change axis.
598598
}
599599

core/math/geometry_3d.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ class Geometry3D {
419419

420420
real_t ad = axis.dot(n2);
421421

422-
if (ABS(ad) > p_sphere_radius) {
422+
if (Math::abs(ad) > p_sphere_radius) {
423423
// No chance with this edge, too far away.
424424
continue;
425425
}

core/math/math_funcs.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ class Math {
221221

222222
static _ALWAYS_INLINE_ double abs(double g) { return absd(g); }
223223
static _ALWAYS_INLINE_ float abs(float g) { return absf(g); }
224-
static _ALWAYS_INLINE_ int abs(int g) { return g > 0 ? g : -g; }
224+
static _ALWAYS_INLINE_ int8_t abs(int8_t g) { return g > 0 ? g : -g; }
225+
static _ALWAYS_INLINE_ int16_t abs(int16_t g) { return g > 0 ? g : -g; }
226+
static _ALWAYS_INLINE_ int32_t abs(int32_t g) { return ::abs(g); }
227+
static _ALWAYS_INLINE_ int64_t abs(int64_t g) { return ::labs(g); }
225228

226229
static _ALWAYS_INLINE_ double fposmod(double p_x, double p_y) {
227230
double value = Math::fmod(p_x, p_y);

core/math/plane.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Vector3 Plane::get_any_perpendicular_normal() const {
5858
static const Vector3 p2 = Vector3(0, 1, 0);
5959
Vector3 p;
6060

61-
if (ABS(normal.dot(p1)) > 0.99f) { // if too similar to p1
61+
if (Math::abs(normal.dot(p1)) > 0.99f) { // if too similar to p1
6262
p = p2; // use p2
6363
} else {
6464
p = p1; // use p1

core/math/plane.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ real_t Plane::distance_to(const Vector3 &p_point) const {
100100

101101
bool Plane::has_point(const Vector3 &p_point, real_t p_tolerance) const {
102102
real_t dist = normal.dot(p_point) - d;
103-
dist = ABS(dist);
103+
dist = Math::abs(dist);
104104
return (dist <= p_tolerance);
105105
}
106106

core/string/ustring.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ String String::num_int64(int64_t p_num, int base, bool capitalize_hex) {
17161716
c[chars] = 0;
17171717
n = p_num;
17181718
do {
1719-
int mod = ABS(n % base);
1719+
int mod = Math::abs(n % base);
17201720
if (mod >= 10) {
17211721
char a = (capitalize_hex ? 'A' : 'a');
17221722
c[--chars] = a + (mod - 10);
@@ -5593,7 +5593,7 @@ String String::sprintf(const Array &values, bool *error) const {
55935593
// Get basic number.
55945594
String str;
55955595
if (!as_unsigned) {
5596-
str = String::num_int64(ABS(value), base, capitalize);
5596+
str = String::num_int64(Math::abs(value), base, capitalize);
55975597
} else {
55985598
uint64_t uvalue = *((uint64_t *)&value);
55995599
// In unsigned hex, if the value fits in 32 bits, trim it down to that.

core/typedefs.h

-7
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,11 @@ static_assert(__cplusplus >= 201703L);
107107
#endif
108108

109109
// Make room for our constexpr's below by overriding potential system-specific macros.
110-
#undef ABS
111110
#undef SIGN
112111
#undef MIN
113112
#undef MAX
114113
#undef CLAMP
115114

116-
// Generic ABS function, for math uses please use Math::abs.
117-
template <typename T>
118-
constexpr T ABS(T m_v) {
119-
return m_v < 0 ? -m_v : m_v;
120-
}
121-
122115
template <typename T>
123116
constexpr const T SIGN(const T m_v) {
124117
return m_v > 0 ? +1.0f : (m_v < 0 ? -1.0f : 0.0f);

core/variant/variant_utility.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ Variant VariantUtilityFunctions::abs(const Variant &x, Callable::CallError &r_er
244244
r_error.error = Callable::CallError::CALL_OK;
245245
switch (x.get_type()) {
246246
case Variant::INT: {
247-
return ABS(VariantInternalAccessor<int64_t>::get(&x));
247+
return Math::abs(VariantInternalAccessor<int64_t>::get(&x));
248248
} break;
249249
case Variant::FLOAT: {
250250
return Math::absd(VariantInternalAccessor<double>::get(&x));
@@ -281,7 +281,7 @@ double VariantUtilityFunctions::absf(double x) {
281281
}
282282

283283
int64_t VariantUtilityFunctions::absi(int64_t x) {
284-
return ABS(x);
284+
return Math::abs(x);
285285
}
286286

287287
Variant VariantUtilityFunctions::sign(const Variant &x, Callable::CallError &r_error) {

drivers/gles3/rasterizer_canvas_gles3.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ void RasterizerCanvasGLES3::light_update_directional_shadow(RID p_rid, int p_sha
17671767

17681768
Vector2 center = p_clip_rect.get_center();
17691769

1770-
float to_edge_distance = ABS(light_dir.dot(p_clip_rect.get_support(-light_dir)) - light_dir.dot(center));
1770+
float to_edge_distance = Math::abs(light_dir.dot(p_clip_rect.get_support(-light_dir)) - light_dir.dot(center));
17711771

17721772
Vector2 from_pos = center - light_dir * (to_edge_distance + p_cull_distance);
17731773
float distance = to_edge_distance * 2.0 + p_cull_distance;

drivers/gles3/storage/light_storage.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ void LightStorage::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point,
11811181
return; // Nothing could be done.
11821182
}
11831183

1184-
node = ABS(node) - 1;
1184+
node = Math::abs(node) - 1;
11851185

11861186
uint32_t *tetrahedron = (uint32_t *)&lm->tetrahedra[node * 4];
11871187
Vector3 points[4] = { lm->points[tetrahedron[0]], lm->points[tetrahedron[1]], lm->points[tetrahedron[2]], lm->points[tetrahedron[3]] };

drivers/wasapi/audio_driver_wasapi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_i
458458
// so we need to select the closest multiple to the user-specified latency.
459459
UINT32 desired_period_frames = target_latency_ms * mix_rate / 1000;
460460
UINT32 period_frames = (desired_period_frames / fundamental_period_frames) * fundamental_period_frames;
461-
if (ABS((int64_t)period_frames - (int64_t)desired_period_frames) > ABS((int64_t)(period_frames + fundamental_period_frames) - (int64_t)desired_period_frames)) {
461+
if (Math::abs((int64_t)period_frames - (int64_t)desired_period_frames) > Math::abs((int64_t)(period_frames + fundamental_period_frames) - (int64_t)desired_period_frames)) {
462462
period_frames = period_frames + fundamental_period_frames;
463463
}
464464
period_frames = CLAMP(period_frames, min_period_frames, max_period_frames);

editor/animation_track_editor.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -2806,7 +2806,7 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
28062806

28072807
if (rect.has_point(p_pos)) {
28082808
if (const_cast<AnimationTrackEdit *>(this)->is_key_selectable_by_distance()) {
2809-
float distance = ABS(offset - p_pos.x);
2809+
float distance = Math::abs(offset - p_pos.x);
28102810
if (key_idx == -1 || distance < key_distance) {
28112811
key_idx = i;
28122812
key_distance = distance;
@@ -3211,7 +3211,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
32113211

32123212
if (rect.has_point(pos)) {
32133213
if (is_key_selectable_by_distance()) {
3214-
const float distance = ABS(offset - pos.x);
3214+
const float distance = Math::abs(offset - pos.x);
32153215
if (key_idx == -1 || distance < key_distance) {
32163216
key_idx = i;
32173217
key_distance = distance;
@@ -3275,7 +3275,7 @@ bool AnimationTrackEdit::_try_select_at_ui_pos(const Point2 &p_pos, bool p_aggre
32753275

32763276
if (rect.has_point(p_pos)) {
32773277
if (is_key_selectable_by_distance()) {
3278-
float distance = ABS(offset - p_pos.x);
3278+
float distance = Math::abs(offset - p_pos.x);
32793279
if (key_idx == -1 || distance < key_distance) {
32803280
key_idx = i;
32813281
key_distance = distance;
@@ -6737,7 +6737,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
67376737
to_restore.push_back(amr);
67386738
}
67396739

6740-
#define NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * ABS(s) + from_t
6740+
#define NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * Math::abs(s) + from_t
67416741
// 3 - Move the keys (re insert them).
67426742
for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
67436743
float newpos = NEW_POS(E->get().pos);
@@ -8675,7 +8675,7 @@ String AnimationMarkerEdit::get_tooltip(const Point2 &p_pos) const {
86758675

86768676
if (rect.has_point(p_pos)) {
86778677
if (const_cast<AnimationMarkerEdit *>(this)->is_key_selectable_by_distance()) {
8678-
float distance = ABS(offset - p_pos.x);
8678+
float distance = Math::abs(offset - p_pos.x);
86798679
if (key_idx == -1 || distance < key_distance) {
86808680
key_idx = i;
86818681
key_distance = distance;

editor/animation_track_editor_plugins.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1051,13 +1051,13 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) {
10511051

10521052
int end = ofs + len * get_timeline()->get_zoom_scale();
10531053

1054-
if (end >= get_timeline()->get_name_limit() && end <= get_size().width - get_timeline()->get_buttons_width() && ABS(mm->get_position().x - end) < 5 * EDSCALE) {
1054+
if (end >= get_timeline()->get_name_limit() && end <= get_size().width - get_timeline()->get_buttons_width() && Math::abs(mm->get_position().x - end) < 5 * EDSCALE) {
10551055
len_resizing_start = false;
10561056
use_hsize_cursor = true;
10571057
len_resizing_index = i;
10581058
}
10591059

1060-
if (ofs >= get_timeline()->get_name_limit() && ofs <= get_size().width - get_timeline()->get_buttons_width() && ABS(mm->get_position().x - ofs) < 5 * EDSCALE) {
1060+
if (ofs >= get_timeline()->get_name_limit() && ofs <= get_size().width - get_timeline()->get_buttons_width() && Math::abs(mm->get_position().x - ofs) < 5 * EDSCALE) {
10611061
len_resizing_start = true;
10621062
use_hsize_cursor = true;
10631063
len_resizing_index = i;

editor/debugger/editor_profiler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_ca
146146

147147
Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) const {
148148
Color bc = get_theme_color(SNAME("error_color"), EditorStringName(Editor));
149-
double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF));
149+
double rot = Math::abs(double(p_signature.hash()) / double(0x7FFFFFFF));
150150
Color c;
151151
c.set_hsv(rot, bc.get_s(), bc.get_v());
152152
return c.lerp(get_theme_color(SNAME("base_color"), EditorStringName(Editor)), 0.07);

editor/debugger/editor_visual_profiler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ String EditorVisualProfiler::_get_time_as_text(float p_time) {
136136

137137
Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signature) const {
138138
Color bc = get_theme_color(SNAME("error_color"), EditorStringName(Editor));
139-
double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF));
139+
double rot = Math::abs(double(p_signature.hash()) / double(0x7FFFFFFF));
140140
Color c;
141141
c.set_hsv(rot, bc.get_s(), bc.get_v());
142142
return c.lerp(get_theme_color(SNAME("base_color"), EditorStringName(Editor)), 0.07);

editor/editor_properties_array_dict.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ void EditorPropertyArray::_reorder_button_gui_input(const Ref<InputEvent> &p_eve
885885
}
886886

887887
float required_y_distance = 20.0f * EDSCALE;
888-
if (ABS(reorder_mouse_y_delta) > required_y_distance) {
888+
if (Math::abs(reorder_mouse_y_delta) > required_y_distance) {
889889
int direction = reorder_mouse_y_delta > 0.0f ? 1 : -1;
890890
reorder_mouse_y_delta -= required_y_distance * direction;
891891

editor/gui/editor_spin_slider.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) {
9595
}
9696
grabbing_spinner_dist_cache += diff_x * grabbing_spinner_speed;
9797

98-
if (!grabbing_spinner && ABS(grabbing_spinner_dist_cache) > 4 * grabbing_spinner_speed * EDSCALE) {
98+
if (!grabbing_spinner && Math::abs(grabbing_spinner_dist_cache) > 4 * grabbing_spinner_speed * EDSCALE) {
9999
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
100100
grabbing_spinner = true;
101101
}

editor/plugins/abstract_polygon_2d_editor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
423423
//Move the point in a single axis. Should only work when editing a polygon and while holding shift.
424424
if (mode == MODE_EDIT && mm->is_shift_pressed()) {
425425
Vector2 old_point = pre_move_edit.get(selected_point.vertex);
426-
if (ABS(cpoint.x - old_point.x) > ABS(cpoint.y - old_point.y)) {
426+
if (Math::abs(cpoint.x - old_point.x) > Math::abs(cpoint.y - old_point.y)) {
427427
cpoint.y = old_point.y;
428428
} else {
429429
cpoint.x = old_point.x;

editor/plugins/animation_state_machine_editor.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -464,14 +464,14 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
464464
}
465465
Vector2 npos = state_machine->get_node_position(E);
466466

467-
float d_x = ABS(npos.x - cpos.x);
467+
float d_x = Math::abs(npos.x - cpos.x);
468468
if (d_x < MIN(5, best_d_x)) {
469469
drag_ofs.x -= cpos.x - npos.x;
470470
best_d_x = d_x;
471471
snap_x = E;
472472
}
473473

474-
float d_y = ABS(npos.y - cpos.y);
474+
float d_y = Math::abs(npos.y - cpos.y);
475475
if (d_y < MIN(5, best_d_y)) {
476476
drag_ofs.y -= cpos.y - npos.y;
477477
best_d_y = d_y;

editor/plugins/canvas_item_editor_plugin.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
11161116
if (m.is_valid() && m->get_position().x < RULER_WIDTH) {
11171117
// Check if we are hovering an existing horizontal guide
11181118
for (int i = 0; i < hguides.size(); i++) {
1119-
if (ABS(xform.xform(Point2(0, hguides[i])).y - m->get_position().y) < MIN(minimum, 8)) {
1119+
if (Math::abs(xform.xform(Point2(0, hguides[i])).y - m->get_position().y) < MIN(minimum, 8)) {
11201120
is_hovering_h_guide = true;
11211121
is_hovering_v_guide = false;
11221122
break;
@@ -1126,7 +1126,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
11261126
} else if (m.is_valid() && m->get_position().y < RULER_WIDTH) {
11271127
// Check if we are hovering an existing vertical guide
11281128
for (int i = 0; i < vguides.size(); i++) {
1129-
if (ABS(xform.xform(Point2(vguides[i], 0)).x - m->get_position().x) < MIN(minimum, 8)) {
1129+
if (Math::abs(xform.xform(Point2(vguides[i], 0)).x - m->get_position().x) < MIN(minimum, 8)) {
11301130
is_hovering_v_guide = true;
11311131
is_hovering_h_guide = false;
11321132
break;
@@ -1146,7 +1146,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
11461146
// Check if we drag an existing horizontal guide
11471147
dragged_guide_index = -1;
11481148
for (int i = 0; i < hguides.size(); i++) {
1149-
if (ABS(xform.xform(Point2(0, hguides[i])).y - b->get_position().y) < MIN(minimum, 8)) {
1149+
if (Math::abs(xform.xform(Point2(0, hguides[i])).y - b->get_position().y) < MIN(minimum, 8)) {
11501150
dragged_guide_index = i;
11511151
}
11521152
}
@@ -1163,7 +1163,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
11631163
// Check if we drag an existing vertical guide
11641164
dragged_guide_index = -1;
11651165
for (int i = 0; i < vguides.size(); i++) {
1166-
if (ABS(xform.xform(Point2(vguides[i], 0)).x - b->get_position().x) < MIN(minimum, 8)) {
1166+
if (Math::abs(xform.xform(Point2(vguides[i], 0)).x - b->get_position().x) < MIN(minimum, 8)) {
11671167
dragged_guide_index = i;
11681168
}
11691169
}
@@ -2220,7 +2220,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
22202220

22212221
bool single_axis = m->is_shift_pressed();
22222222
if (single_axis) {
2223-
if (ABS(new_pos.x - previous_pos.x) > ABS(new_pos.y - previous_pos.y)) {
2223+
if (Math::abs(new_pos.x - previous_pos.x) > Math::abs(new_pos.y - previous_pos.y)) {
22242224
new_pos.y = previous_pos.y;
22252225
} else {
22262226
new_pos.x = previous_pos.x;
@@ -3240,14 +3240,14 @@ void CanvasItemEditor::_draw_ruler_tool() {
32403240
: (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 : Math_PI / 2.0 - vertical_angle_rad);
32413241
real_t arc_1_end_angle = arc_1_start_angle + vertical_angle_rad;
32423242
// Constrain arc to triangle height & max size.
3243-
real_t arc_1_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.y)), arc_max_radius);
3243+
real_t arc_1_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, Math::abs(end_to_begin.y)), arc_max_radius);
32443244

32453245
real_t arc_2_start_angle = end_to_begin.x < 0
32463246
? (end_to_begin.y < 0 ? 0.0 : -horizontal_angle_rad)
32473247
: (end_to_begin.y < 0 ? Math_PI - horizontal_angle_rad : Math_PI);
32483248
real_t arc_2_end_angle = arc_2_start_angle + horizontal_angle_rad;
32493249
// Constrain arc to triangle width & max size.
3250-
real_t arc_2_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.x)), arc_max_radius);
3250+
real_t arc_2_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, Math::abs(end_to_begin.x)), arc_max_radius);
32513251

32523252
viewport->draw_arc(begin, arc_1_radius, arc_1_start_angle, arc_1_end_angle, arc_point_count, ruler_primary_color, Math::round(EDSCALE * arc_line_width));
32533253
viewport->draw_arc(end, arc_2_radius, arc_2_start_angle, arc_2_end_angle, arc_point_count, ruler_primary_color, Math::round(EDSCALE * arc_line_width));
@@ -3288,13 +3288,13 @@ void CanvasItemEditor::_draw_ruler_tool() {
32883288
h_angle_text_pos.x = CLAMP(end.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width);
32893289
if (begin.y < end.y) {
32903290
h_angle_text_pos.y = end.y + text_height * 1.5;
3291-
if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) {
3291+
if (Math::abs(text_pos2.x - h_angle_text_pos.x) < text_width) {
32923292
int height_multiplier = 1.5 + (int)grid_snap_active;
32933293
h_angle_text_pos.y = MAX(text_pos.y + height_multiplier * text_height, MAX(end.y + text_height * 1.5, text_pos2.y + height_multiplier * text_height));
32943294
}
32953295
} else {
32963296
h_angle_text_pos.y = end.y - text_height * 0.5;
3297-
if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) {
3297+
if (Math::abs(text_pos2.x - h_angle_text_pos.x) < text_width) {
32983298
int height_multiplier = 1 + (int)grid_snap_active;
32993299
h_angle_text_pos.y = MIN(text_pos.y - height_multiplier * text_height, MIN(end.y - text_height * 0.5, text_pos2.y - height_multiplier * text_height));
33003300
}

0 commit comments

Comments
 (0)