summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp10
-rw-r--r--editor/plugins/editor_preview_plugins.cpp12
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp15
3 files changed, 21 insertions, 16 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 498f9d5c19..72b143556d 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -216,8 +216,8 @@ public:
grid_step_x->set_value(p_grid_step.x);
grid_step_y->set_value(p_grid_step.y);
primary_grid_steps->set_value(p_primary_grid_steps);
- rotation_offset->set_value(p_rotation_offset * (180 / Math_PI));
- rotation_step->set_value(p_rotation_step * (180 / Math_PI));
+ rotation_offset->set_value(Math::rad2deg(p_rotation_offset));
+ rotation_step->set_value(Math::rad2deg(p_rotation_step));
scale_step->set_value(p_scale_step);
}
@@ -225,8 +225,8 @@ public:
p_grid_offset = Point2(grid_offset_x->get_value(), grid_offset_y->get_value());
p_grid_step = Point2(grid_step_x->get_value(), grid_step_y->get_value());
p_primary_grid_steps = int(primary_grid_steps->get_value());
- p_rotation_offset = rotation_offset->get_value() / (180 / Math_PI);
- p_rotation_step = rotation_step->get_value() / (180 / Math_PI);
+ p_rotation_offset = Math::deg2rad(rotation_offset->get_value());
+ p_rotation_step = Math::deg2rad(rotation_step->get_value());
p_scale_step = scale_step->get_value();
}
};
@@ -5638,7 +5638,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
primary_grid_steps = 8; // A power-of-two value works better as a default
grid_step_multiplier = 0;
snap_rotation_offset = 0;
- snap_rotation_step = 15 / (180 / Math_PI);
+ snap_rotation_step = Math::deg2rad(15.0);
snap_scale_step = 0.1f;
smart_snap_active = false;
grid_snap_active = false;
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index bdf88b82e4..63bb785c5e 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -382,7 +382,9 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
int lats = 32;
int lons = 32;
- float radius = 1.0;
+ 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;
@@ -391,20 +393,20 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
Basis tt = Basis(Vector3(0, 1, 0), Math_PI * 0.5);
for (int i = 1; i <= lats; i++) {
- double lat0 = Math_PI * (-0.5 + (double)(i - 1) / lats);
+ double lat0 = lat_step * (i - 1) - Math_TAU / 4;
double z0 = Math::sin(lat0);
double zr0 = Math::cos(lat0);
- double lat1 = Math_PI * (-0.5 + (double)i / lats);
+ double lat1 = lat_step * i - Math_TAU / 4;
double z1 = Math::sin(lat1);
double zr1 = Math::cos(lat1);
for (int j = lons; j >= 1; j--) {
- double lng0 = 2 * Math_PI * (double)(j - 1) / lons;
+ double lng0 = lon_step * (j - 1);
double x0 = Math::cos(lng0);
double y0 = Math::sin(lng0);
- double lng1 = 2 * Math_PI * (double)(j) / lons;
+ double lng1 = lon_step * j;
double x1 = Math::cos(lng1);
double y1 = Math::sin(lng1);
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 6cc28ab225..3cf25f3335 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -5314,9 +5314,10 @@ void Node3DEditor::_init_indicators() {
int arrow_sides = 16;
+ const real_t arrow_sides_step = Math_TAU / arrow_sides;
for (int k = 0; k < arrow_sides; k++) {
- Basis ma(ivec, Math_PI * 2 * float(k) / arrow_sides);
- Basis mb(ivec, Math_PI * 2 * float(k + 1) / arrow_sides);
+ Basis ma(ivec, k * arrow_sides_step);
+ Basis mb(ivec, (k + 1) * arrow_sides_step);
for (int j = 0; j < arrow_points - 1; j++) {
Vector3 points[4] = {
@@ -5391,13 +5392,14 @@ void Node3DEditor::_init_indicators() {
int n = 128; // number of circle segments
int m = 6; // number of thickness segments
+ real_t step = Math_TAU / n;
for (int j = 0; j < n; ++j) {
- Basis basis = Basis(ivec, (Math_PI * 2.0f * j) / n);
+ 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_PI * 2.0 * k) / m), Math::sin((Math_PI * 2.0 * 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));
@@ -5524,9 +5526,10 @@ void Node3DEditor::_init_indicators() {
int arrow_sides = 4;
+ const real_t arrow_sides_step = Math_TAU / arrow_sides;
for (int k = 0; k < 4; k++) {
- Basis ma(ivec, Math_PI * 2 * float(k) / arrow_sides);
- Basis mb(ivec, Math_PI * 2 * float(k + 1) / arrow_sides);
+ Basis ma(ivec, k * arrow_sides_step);
+ Basis mb(ivec, (k + 1) * arrow_sides_step);
for (int j = 0; j < arrow_points - 1; j++) {
Vector3 points[4] = {