Repository: godotengine/godot
File: editor/plugins/spatial_editor_plugin.cpp (C++)

Code before:
#include "scene/resources/surface_tool.h"

#define DISTANCE_DEFAULT 4

#define GIZMO_ARROW_SIZE 0.35
#define GIZMO_RING_HALF_WIDTH 0.1
#define GIZMO_SCALE_DEFAULT 0.15
#define GIZMO_PLANE_SIZE 0.2
#define GIZMO_PLANE_DST 0.3
#define GIZMO_CIRCLE_SIZE 1.1
#define GIZMO_SCALE_OFFSET (GIZMO_CIRCLE_SIZE + 0.3)
#define GIZMO_ARROW_OFFSET (GIZMO_CIRCLE_SIZE + 0.3)

#define ZOOM_FREELOOK_MIN 0.01
#define ZOOM_FREELOOK_MULTIPLIER 1.08
#define ZOOM_FREELOOK_INDICATOR_DELAY_S 1.5

#define ZOOM_FREELOOK_MAX 10'000

#define MIN_Z 0.01
#define MAX_Z 1000000.0

#define MIN_FOV 0.01
#define MAX_FOV 179

void ViewportRotationControl::_notification(int p_what) {

	if (p_what == NOTIFICATION_ENTER_TREE) {
		axis_menu_options.clear();
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_RIGHT);
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_TOP);
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_FRONT);
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_LEFT);
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_BOTTOM);
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_REAR);

		axis_colors.clear();
		axis_colors.push_back(get_color("axis_x_color", "Editor"));
		axis_colors.push_back(get_color("axis_y_color", "Editor"));
		axis_colors.push_back(get_color("axis_z_color", "Editor"));
		update();

		if (!is_connected("mouse_exited", this, "_on_mouse_exited")) {
			connect("mouse_exited", this, "_on_mouse_exited");
		}
	}

	if (p_what == NOTIFICATION_DRAW && viewport != nullptr) {
		_draw();
	}
}

Review comment (suggestion):
We don't normally use namespaces in Godot code. This should likely just be a normal static method or a private class method.

Code after:
#include "scene/resources/surface_tool.h"

#define DISTANCE_DEFAULT 4

#define GIZMO_ARROW_SIZE 0.35
#define GIZMO_RING_HALF_WIDTH 0.1
#define GIZMO_SCALE_DEFAULT 0.15
#define GIZMO_PLANE_SIZE 0.2
#define GIZMO_PLANE_DST 0.3
#define GIZMO_CIRCLE_SIZE 1.1
#define GIZMO_SCALE_OFFSET (GIZMO_CIRCLE_SIZE + 0.3)
#define GIZMO_ARROW_OFFSET (GIZMO_CIRCLE_SIZE + 0.3)

#define ZOOM_FREELOOK_MIN 0.01
#define ZOOM_FREELOOK_MULTIPLIER 1.08
#define ZOOM_FREELOOK_INDICATOR_DELAY_S 1.5

#define ZOOM_FREELOOK_MAX 10'000

#define MIN_Z 0.01
#define MAX_Z 1000000.0

#define MIN_FOV 0.01
#define MAX_FOV 179

static Node *get_deepest_visible_node(Node *start_node, Node const *edited_scene) {
	Node const *iterated_item = start_node;
	Node *node = start_node;

	while (iterated_item->get_owner() && iterated_item->get_owner() != edited_scene) {
		if (!edited_scene->is_editable_instance(iterated_item->get_owner()))
			node = iterated_item->get_owner();

		iterated_item = iterated_item->get_owner();
	}

	return node;
}

void ViewportRotationControl::_notification(int p_what) {

	if (p_what == NOTIFICATION_ENTER_TREE) {
		axis_menu_options.clear();
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_RIGHT);
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_TOP);
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_FRONT);
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_LEFT);
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_BOTTOM);
		axis_menu_options.push_back(SpatialEditorViewport::VIEW_REAR);

		axis_colors.clear();