godot/editor/plugins/node_3d_editor_plugin.cpp

/**************************************************************************/
/*  node_3d_editor_plugin.cpp                                             */
/**************************************************************************/
/*                         This file is part of:                          */
/*                             GODOT ENGINE                               */
/*                        https://godotengine.org                         */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */
/*                                                                        */
/* Permission is hereby granted, free of charge, to any person obtaining  */
/* a copy of this software and associated documentation files (the        */
/* "Software"), to deal in the Software without restriction, including    */
/* without limitation the rights to use, copy, modify, merge, publish,    */
/* distribute, sublicense, and/or sell copies of the Software, and to     */
/* permit persons to whom the Software is furnished to do so, subject to  */
/* the following conditions:                                              */
/*                                                                        */
/* The above copyright notice and this permission notice shall be         */
/* included in all copies or substantial portions of the Software.        */
/*                                                                        */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */
/**************************************************************************/

#include "node_3d_editor_plugin.h"

#include "core/config/project_settings.h"
#include "core/input/input.h"
#include "core/input/input_map.h"
#include "core/math/math_funcs.h"
#include "core/math/projection.h"
#include "core/os/keyboard.h"
#include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/gui/editor_run_bar.h"
#include "editor/gui/editor_spin_slider.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/gizmos/audio_listener_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/audio_stream_player_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/camera_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/collision_object_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/collision_polygon_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/collision_shape_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/cpu_particles_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/decal_gizmo_plugin.h"
#include "editor/plugins/gizmos/fog_volume_gizmo_plugin.h"
#include "editor/plugins/gizmos/geometry_instance_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/gpu_particles_collision_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/joint_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/label_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/light_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/lightmap_gi_gizmo_plugin.h"
#include "editor/plugins/gizmos/lightmap_probe_gizmo_plugin.h"
#include "editor/plugins/gizmos/marker_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/mesh_instance_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/navigation_link_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/navigation_region_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/occluder_instance_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/physics_bone_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/ray_cast_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/reflection_probe_gizmo_plugin.h"
#include "editor/plugins/gizmos/shape_cast_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/soft_body_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/spring_arm_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/sprite_base_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/vehicle_body_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/visible_on_screen_notifier_3d_gizmo_plugin.h"
#include "editor/plugins/gizmos/voxel_gi_gizmo_plugin.h"
#include "editor/plugins/node_3d_editor_gizmos.h"
#include "editor/scene_tree_dock.h"
#include "scene/3d/audio_stream_player_3d.h"
#include "scene/3d/camera_3d.h"
#include "scene/3d/decal.h"
#include "scene/3d/light_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/physics/collision_shape_3d.h"
#include "scene/3d/physics/physics_body_3d.h"
#include "scene/3d/sprite_3d.h"
#include "scene/3d/visual_instance_3d.h"
#include "scene/3d/world_environment.h"
#include "scene/gui/center_container.h"
#include "scene/gui/color_picker.h"
#include "scene/gui/flow_container.h"
#include "scene/gui/split_container.h"
#include "scene/gui/subviewport_container.h"
#include "scene/resources/3d/sky_material.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/surface_tool.h"

constexpr real_t DISTANCE_DEFAULT =;

constexpr real_t GIZMO_ARROW_SIZE =;
constexpr real_t GIZMO_RING_HALF_WIDTH =;
constexpr real_t GIZMO_PLANE_SIZE =;
constexpr real_t GIZMO_PLANE_DST =;
constexpr real_t GIZMO_CIRCLE_SIZE =;
constexpr real_t GIZMO_SCALE_OFFSET =;
constexpr real_t GIZMO_ARROW_OFFSET =;

constexpr real_t ZOOM_FREELOOK_MIN =;
constexpr real_t ZOOM_FREELOOK_MULTIPLIER =;
constexpr real_t ZOOM_FREELOOK_INDICATOR_DELAY_S =;

#ifdef REAL_T_IS_DOUBLE
constexpr double ZOOM_FREELOOK_MAX = 1'000'000'000'000;
#else
constexpr float ZOOM_FREELOOK_MAX =;
#endif

constexpr real_t MIN_Z =;
constexpr real_t MAX_Z =;

constexpr real_t MIN_FOV =;
constexpr real_t MAX_FOV =;

void ViewportNavigationControl::_notification(int p_what) {}

void ViewportNavigationControl::_draw() {}

void ViewportNavigationControl::_process_click(int p_index, Vector2 p_position, bool p_pressed) {}

void ViewportNavigationControl::_process_drag(int p_index, Vector2 p_position, Vector2 p_relative_position) {}

void ViewportNavigationControl::gui_input(const Ref<InputEvent> &p_event) {}

void ViewportNavigationControl::_update_navigation() {}

void ViewportNavigationControl::_on_mouse_entered() {}

void ViewportNavigationControl::_on_mouse_exited() {}

void ViewportNavigationControl::set_navigation_mode(Node3DEditorViewport::NavigationMode p_nav_mode) {}

void ViewportNavigationControl::set_viewport(Node3DEditorViewport *p_viewport) {}

void ViewportRotationControl::_notification(int p_what) {}

void ViewportRotationControl::_draw() {}

void ViewportRotationControl::_draw_axis(const Axis2D &p_axis) {}

void ViewportRotationControl::_get_sorted_axis(Vector<Axis2D> &r_axis) {}

void ViewportRotationControl::_process_click(int p_index, Vector2 p_position, bool p_pressed) {}

void ViewportRotationControl::_process_drag(Ref<InputEventWithModifiers> p_event, int p_index, Vector2 p_position, Vector2 p_relative_position) {}

void ViewportRotationControl::gui_input(const Ref<InputEvent> &p_event) {}

void ViewportRotationControl::_update_focus() {}

void ViewportRotationControl::_on_mouse_exited() {}

void ViewportRotationControl::set_viewport(Node3DEditorViewport *p_viewport) {}

void Node3DEditorViewport::_view_settings_confirmed(real_t p_interp_delta) {}

void Node3DEditorViewport::_update_navigation_controls_visibility() {}

void Node3DEditorViewport::_update_camera(real_t p_interp_delta) {}

Transform3D Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) const {}

int Node3DEditorViewport::get_selected_count() const {}

void Node3DEditorViewport::cancel_transform() {}

void Node3DEditorViewport::_update_shrink() {}

float Node3DEditorViewport::get_znear() const {}

float Node3DEditorViewport::get_zfar() const {}

float Node3DEditorViewport::get_fov() const {}

Transform3D Node3DEditorViewport::_get_camera_transform() const {}

Vector3 Node3DEditorViewport::_get_camera_position() const {}

Point2 Node3DEditorViewport::point_to_screen(const Vector3 &p_point) {}

Vector3 Node3DEditorViewport::get_ray_pos(const Vector2 &p_pos) const {}

Vector3 Node3DEditorViewport::_get_camera_normal() const {}

Vector3 Node3DEditorViewport::get_ray(const Vector2 &p_pos) const {}

void Node3DEditorViewport::_clear_selected() {}

void Node3DEditorViewport::_select_clicked(bool p_allow_locked) {}

ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos) const {}

void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, Vector<_RayResult> &r_results, bool p_include_locked_nodes) {}

Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {}

void Node3DEditorViewport::_select_region() {}

void Node3DEditorViewport::_update_name() {}

void Node3DEditorViewport::_compute_edit(const Point2 &p_point) {}

static Key _get_key_modifier_setting(const String &p_property) {}

static Key _get_key_modifier(Ref<InputEventWithModifiers> e) {}

bool Node3DEditorViewport::_transform_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) {}

void Node3DEditorViewport::_transform_gizmo_apply(Node3D *p_node, const Transform3D &p_transform, bool p_local) {}

Transform3D Node3DEditorViewport::_compute_transform(TransformMode p_mode, const Transform3D &p_original, const Transform3D &p_original_local, Vector3 p_motion, double p_extra, bool p_local, bool p_orthogonal) {}

void Node3DEditorViewport::_surface_mouse_enter() {}

void Node3DEditorViewport::_surface_mouse_exit() {}

void Node3DEditorViewport::_surface_focus_enter() {}

void Node3DEditorViewport::_surface_focus_exit() {}

bool Node3DEditorViewport::_is_node_locked(const Node *p_node) const {}

void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) {}

// This is only active during instant transforms,
// to capture and wrap mouse events outside the control.
void Node3DEditorViewport::input(const Ref<InputEvent> &p_event) {}

void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {}

int Node3DEditorViewport::_get_shortcut_input_count(const String &p_name) {}

Node3DEditorViewport::NavigationMode Node3DEditorViewport::_get_nav_mode_from_shortcut_check(ViewportNavMouseButton p_mouse_button, Vector<ShortcutCheckSet> p_shortcut_check_sets, bool p_use_not_empty) {}

void Node3DEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {}

void Node3DEditorViewport::_nav_zoom(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {}

void Node3DEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {}

void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {}

void Node3DEditorViewport::set_freelook_active(bool active_now) {}

void Node3DEditorViewport::scale_fov(real_t p_fov_offset) {}

void Node3DEditorViewport::reset_fov() {}

void Node3DEditorViewport::scale_cursor_distance(real_t scale) {}

void Node3DEditorViewport::scale_freelook_speed(real_t scale) {}

bool Node3DEditorViewport::_is_nav_modifier_pressed(const String &p_name) {}

bool Node3DEditorViewport::_is_shortcut_empty(const String &p_name) {}

Point2 Node3DEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const {}

void Node3DEditorViewport::_update_freelook(real_t delta) {}

void Node3DEditorViewport::set_message(const String &p_message, float p_time) {}

void Node3DEditorPlugin::edited_scene_changed() {}

void Node3DEditorViewport::_project_settings_changed() {}

void Node3DEditorViewport::_notification(int p_what) {}

static void draw_indicator_bar(Control &p_surface, real_t p_fill, const Ref<Texture2D> p_icon, const Ref<Font> p_font, int p_font_size, const String &p_text, const Color &p_color) {}

void Node3DEditorViewport::_draw() {}

void Node3DEditorViewport::_menu_option(int p_option) {}

void Node3DEditorViewport::_set_auto_orthogonal() {}

void Node3DEditorViewport::_preview_exited_scene() {}

void Node3DEditorViewport::_init_gizmo_instance(int p_idx) {}

void Node3DEditorViewport::_finish_gizmo_instances() {}

void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) {}

void Node3DEditorViewport::_toggle_cinema_preview(bool p_activate) {}

void Node3DEditorViewport::_selection_result_pressed(int p_result) {}

void Node3DEditorViewport::_selection_menu_hide() {}

void Node3DEditorViewport::set_can_preview(Camera3D *p_preview) {}

void Node3DEditorViewport::update_transform_gizmo_view() {}

void Node3DEditorViewport::set_state(const Dictionary &p_state) {}

Dictionary Node3DEditorViewport::get_state() const {}

void Node3DEditorViewport::_bind_methods() {}

void Node3DEditorViewport::reset() {}

void Node3DEditorViewport::focus_selection() {}

void Node3DEditorViewport::assign_pending_data_pointers(Node3D *p_preview_node, AABB *p_preview_bounds, AcceptDialog *p_accept) {}

void _insert_rid_recursive(Node *node, HashSet<RID> &rids) {}

Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos, Node3D *p_node) const {}

AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, bool p_omit_top_level, const Transform3D *p_bounds_orientation) {}

Node *Node3DEditorViewport::_sanitize_preview_node(Node *p_node) const {}

void Node3DEditorViewport::_create_preview_node(const Vector<String> &files) const {}

void Node3DEditorViewport::_remove_preview_node() {}

bool Node3DEditorViewport::_apply_preview_material(ObjectID p_target, const Point2 &p_point) const {}

void Node3DEditorViewport::_reset_preview_material() const {}

void Node3DEditorViewport::_remove_preview_material() {}

bool Node3DEditorViewport::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) const {}

bool Node3DEditorViewport::_create_instance(Node *p_parent, const String &p_path, const Point2 &p_point) {}

bool Node3DEditorViewport::_create_audio_node(Node *p_parent, const String &p_path, const Point2 &p_point) {}

void Node3DEditorViewport::_perform_drop_data() {}

bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {}

void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {}

void Node3DEditorViewport::begin_transform(TransformMode p_mode, bool instant) {}

// Apply the current transform operation.
void Node3DEditorViewport::commit_transform() {}

void Node3DEditorViewport::apply_transform(Vector3 p_motion, double p_snap) {}

// Update the current transform operation in response to an input.
void Node3DEditorViewport::update_transform(bool p_shift) {}

void Node3DEditorViewport::update_transform_numeric() {}

// Perform cleanup after a transform operation is committed or canceled.
void Node3DEditorViewport::finish_transform() {}

// Register a shortcut and also add it as an input action with the same events.
void Node3DEditorViewport::register_shortcut_action(const String &p_path, const String &p_name, Key p_keycode, bool p_physical) {}

// Update the action in the InputMap to the provided shortcut events.
void Node3DEditorViewport::shortcut_changed_callback(const Ref<Shortcut> p_shortcut, const String &p_shortcut_path) {}

void Node3DEditorViewport::_set_lock_view_rotation(bool p_lock_rotation) {}

Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p_index) {}

Node3DEditorViewport::~Node3DEditorViewport() {}

//////////////////////////////////////////////////////////////

void Node3DEditorViewportContainer::gui_input(const Ref<InputEvent> &p_event) {}

void Node3DEditorViewportContainer::_notification(int p_what) {}

void Node3DEditorViewportContainer::set_view(View p_view) {}

Node3DEditorViewportContainer::View Node3DEditorViewportContainer::get_view() {}

Node3DEditorViewportContainer::Node3DEditorViewportContainer() {}

///////////////////////////////////////////////////////////////////

Node3DEditor *Node3DEditor::singleton =;

Node3DEditorSelectedItem::~Node3DEditorSelectedItem() {}

void Node3DEditor::select_gizmo_highlight_axis(int p_axis) {}

void Node3DEditor::update_transform_gizmo() {}

void _update_all_gizmos(Node *p_node) {}

void Node3DEditor::update_all_gizmos(Node *p_node) {}

Object *Node3DEditor::_get_editor_data(Object *p_what) {}

void Node3DEditor::_generate_selection_boxes() {}

Dictionary Node3DEditor::get_state() const {}

void Node3DEditor::set_state(const Dictionary &p_state) {}

void Node3DEditor::edit(Node3D *p_spatial) {}

void Node3DEditor::_snap_changed() {}

void Node3DEditor::_snap_update() {}

void Node3DEditor::_xform_dialog_action() {}

void Node3DEditor::_menu_item_toggled(bool pressed, int p_option) {}

void Node3DEditor::_menu_gizmo_toggled(int p_option) {}

void Node3DEditor::_update_camera_override_button(bool p_game_running) {}

void Node3DEditor::_update_camera_override_viewport(Object *p_viewport) {}

void Node3DEditor::_menu_item_pressed(int p_option) {}

void Node3DEditor::_init_indicators() {}

void Node3DEditor::_update_gizmos_menu() {}

void Node3DEditor::_update_gizmos_menu_theme() {}

void Node3DEditor::_init_grid() {}

void Node3DEditor::_finish_indicators() {}

void Node3DEditor::_finish_grid() {}

void Node3DEditor::update_grid() {}

void Node3DEditor::_selection_changed() {}

void Node3DEditor::_refresh_menu_icons() {}

template <typename T>
HashSet<T *> _get_child_nodes(Node *parent_node) {}

HashSet<RID> _get_physics_bodies_rid(Node *node) {}

void Node3DEditor::snap_selected_nodes_to_floor() {}

void Node3DEditor::_snap_selected_nodes_to_floor() {}

void Node3DEditor::shortcut_input(const Ref<InputEvent> &p_event) {}

void Node3DEditor::_sun_environ_settings_pressed() {}

void Node3DEditor::_add_sun_to_scene(bool p_already_added_environment) {}

void Node3DEditor::_add_environment_to_scene(bool p_already_added_sun) {}

void Node3DEditor::_update_theme() {}

void Node3DEditor::_notification(int p_what) {}

bool Node3DEditor::is_subgizmo_selected(int p_id) {}

bool Node3DEditor::is_current_selected_gizmo(const EditorNode3DGizmo *p_gizmo) {}

Vector<int> Node3DEditor::get_subgizmo_selection() {}

void Node3DEditor::clear_subgizmo_selection(Object *p_obj) {}

void Node3DEditor::add_control_to_menu_panel(Control *p_control) {}

void Node3DEditor::remove_control_from_menu_panel(Control *p_control) {}

void Node3DEditor::_update_context_toolbar() {}

void Node3DEditor::set_can_preview(Camera3D *p_preview) {}

VSplitContainer *Node3DEditor::get_shader_split() {}

void Node3DEditor::add_control_to_left_panel(Control *p_control) {}

void Node3DEditor::add_control_to_right_panel(Control *p_control) {}

void Node3DEditor::remove_control_from_left_panel(Control *p_control) {}

void Node3DEditor::remove_control_from_right_panel(Control *p_control) {}

void Node3DEditor::move_control_to_left_panel(Control *p_control) {}

void Node3DEditor::move_control_to_right_panel(Control *p_control) {}

void Node3DEditor::_request_gizmo(Object *p_obj) {}

void Node3DEditor::_request_gizmo_for_id(ObjectID p_id) {}

void Node3DEditor::_set_subgizmo_selection(Object *p_obj, Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform) {}

void Node3DEditor::_clear_subgizmo_selection(Object *p_obj) {}

void Node3DEditor::_toggle_maximize_view(Object *p_viewport) {}

void Node3DEditor::_node_added(Node *p_node) {}

void Node3DEditor::_node_removed(Node *p_node) {}

void Node3DEditor::_register_all_gizmos() {}

void Node3DEditor::_bind_methods() {}

void Node3DEditor::clear() {}

void Node3DEditor::_sun_direction_draw() {}

void Node3DEditor::_preview_settings_changed() {}

void Node3DEditor::_load_default_preview_settings() {}

void Node3DEditor::_update_preview_environment() {}

void Node3DEditor::_sun_direction_input(const Ref<InputEvent> &p_event) {}

void Node3DEditor::_sun_direction_angle_set() {}

Node3DEditor::Node3DEditor() {}
Node3DEditor::~Node3DEditor() {}

void Node3DEditorPlugin::make_visible(bool p_visible) {}

void Node3DEditorPlugin::edit(Object *p_object) {}

bool Node3DEditorPlugin::handles(Object *p_object) const {}

Dictionary Node3DEditorPlugin::get_state() const {}

void Node3DEditorPlugin::set_state(const Dictionary &p_state) {}

Vector3 Node3DEditor::snap_point(Vector3 p_target, Vector3 p_start) const {}

bool Node3DEditor::is_gizmo_visible() const {}

real_t Node3DEditor::get_translate_snap() const {}

real_t Node3DEditor::get_rotate_snap() const {}

real_t Node3DEditor::get_scale_snap() const {}

struct _GizmoPluginPriorityComparator {};

struct _GizmoPluginNameComparator {};

void Node3DEditor::add_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) {}

void Node3DEditor::remove_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) {}

DynamicBVH::ID Node3DEditor::insert_gizmo_bvh_node(Node3D *p_node, const AABB &p_aabb) {}

void Node3DEditor::update_gizmo_bvh_node(DynamicBVH::ID p_id, const AABB &p_aabb) {}

void Node3DEditor::remove_gizmo_bvh_node(DynamicBVH::ID p_id) {}

Vector<Node3D *> Node3DEditor::gizmo_bvh_ray_query(const Vector3 &p_ray_start, const Vector3 &p_ray_end) {}

Vector<Node3D *> Node3DEditor::gizmo_bvh_frustum_query(const Vector<Plane> &p_frustum) {}

Node3DEditorPlugin::Node3DEditorPlugin() {}

Node3DEditorPlugin::~Node3DEditorPlugin() {}