You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +00:00
Core: Use Math namespace for constants
This commit is contained in:
@@ -2386,28 +2386,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();
|
||||
}
|
||||
@@ -3502,7 +3502,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();
|
||||
@@ -3511,7 +3511,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();
|
||||
@@ -3520,7 +3520,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();
|
||||
@@ -3529,7 +3529,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();
|
||||
@@ -3547,7 +3547,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();
|
||||
@@ -3596,7 +3596,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();
|
||||
@@ -3634,7 +3634,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());
|
||||
@@ -4908,7 +4908,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;
|
||||
@@ -5373,7 +5373,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();
|
||||
@@ -7321,7 +7321,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);
|
||||
@@ -7360,7 +7360,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]),
|
||||
@@ -7400,14 +7400,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));
|
||||
@@ -7544,7 +7544,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);
|
||||
@@ -7583,7 +7583,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]),
|
||||
@@ -8912,7 +8912,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);
|
||||
|
||||
Reference in New Issue
Block a user