diff --git a/editor/animation/animation_player_editor_plugin.cpp b/editor/animation/animation_player_editor_plugin.cpp index 5d4aeb561e..0663d5bf7c 100644 --- a/editor/animation/animation_player_editor_plugin.cpp +++ b/editor/animation/animation_player_editor_plugin.cpp @@ -2351,7 +2351,7 @@ AnimationPlayerEditor::~AnimationPlayerEditor() { void AnimationPlayerEditorPlugin::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - Node3DEditor::get_singleton()->connect(SNAME("transform_key_request"), callable_mp(this, &AnimationPlayerEditorPlugin::_transform_key_request)); + Node3DEditor::get_singleton()->connect(SNAME("transform_3d_key_request"), callable_mp(this, &AnimationPlayerEditorPlugin::_transform_3d_key_request)); InspectorDock::get_inspector_singleton()->connect(SNAME("property_keyed"), callable_mp(this, &AnimationPlayerEditorPlugin::_property_keyed)); anim_editor->get_track_editor()->connect(SNAME("keying_changed"), callable_mp(this, &AnimationPlayerEditorPlugin::_update_keying)); InspectorDock::get_inspector_singleton()->connect(SNAME("edited_object_changed"), callable_mp(anim_editor->get_track_editor(), &AnimationTrackEditor::update_keying)); @@ -2369,7 +2369,7 @@ void AnimationPlayerEditorPlugin::_property_keyed(const String &p_keyed, const V te->insert_value_key(p_keyed, p_advance); } -void AnimationPlayerEditorPlugin::_transform_key_request(Object *sp, const String &p_sub, const Transform3D &p_key) { +void AnimationPlayerEditorPlugin::_transform_3d_key_request(Object *sp, const String &p_sub, const Transform3D &p_key) { if (!anim_editor->get_track_editor()->has_keying()) { return; } @@ -2377,9 +2377,9 @@ void AnimationPlayerEditorPlugin::_transform_key_request(Object *sp, const Strin if (!s) { return; } - anim_editor->get_track_editor()->insert_transform_key(s, p_sub, Animation::TYPE_POSITION_3D, p_key.origin); - anim_editor->get_track_editor()->insert_transform_key(s, p_sub, Animation::TYPE_ROTATION_3D, p_key.basis.get_rotation_quaternion()); - anim_editor->get_track_editor()->insert_transform_key(s, p_sub, Animation::TYPE_SCALE_3D, p_key.basis.get_scale()); + anim_editor->get_track_editor()->insert_transform_3d_key(s, p_sub, Animation::TYPE_POSITION_3D, p_key.origin); + anim_editor->get_track_editor()->insert_transform_3d_key(s, p_sub, Animation::TYPE_ROTATION_3D, p_key.basis.get_rotation_quaternion()); + anim_editor->get_track_editor()->insert_transform_3d_key(s, p_sub, Animation::TYPE_SCALE_3D, p_key.basis.get_scale()); } void AnimationPlayerEditorPlugin::_update_keying() { diff --git a/editor/animation/animation_player_editor_plugin.h b/editor/animation/animation_player_editor_plugin.h index b178dd0f9a..66476edf1a 100644 --- a/editor/animation/animation_player_editor_plugin.h +++ b/editor/animation/animation_player_editor_plugin.h @@ -296,7 +296,7 @@ protected: void _notification(int p_what); void _property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance); - void _transform_key_request(Object *sp, const String &p_sub, const Transform3D &p_key); + void _transform_3d_key_request(Object *sp, const String &p_sub, const Transform3D &p_key); void _update_keying(); public: diff --git a/editor/animation/animation_track_editor.cpp b/editor/animation/animation_track_editor.cpp index 3fb2c21d48..f95c7979cb 100644 --- a/editor/animation/animation_track_editor.cpp +++ b/editor/animation/animation_track_editor.cpp @@ -4536,7 +4536,7 @@ void AnimationTrackEditor::_insert_track(bool p_reset_wanted, bool p_create_bezi } } -void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type, const Variant &p_value) { +void AnimationTrackEditor::insert_transform_3d_key(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type, const Variant &p_value) { if (read_only) { popup_read_only_dialog(); return; @@ -4584,7 +4584,7 @@ void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_ _query_insert(id); } -bool AnimationTrackEditor::has_track(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type) { +bool AnimationTrackEditor::has_transform_3d_track(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type) { ERR_FAIL_NULL_V(root, false); if (!keying) { return false; diff --git a/editor/animation/animation_track_editor.h b/editor/animation/animation_track_editor.h index 6cc330aac5..5ee3cdbf67 100644 --- a/editor/animation/animation_track_editor.h +++ b/editor/animation/animation_track_editor.h @@ -973,8 +973,8 @@ public: void set_anim_pos(float p_pos); void insert_node_value_key(Node *p_node, const String &p_property, bool p_only_if_exists = false, bool p_advance = false); void insert_value_key(const String &p_property, bool p_advance); - void insert_transform_key(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type, const Variant &p_value); - bool has_track(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type); + void insert_transform_3d_key(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type, const Variant &p_value); + bool has_transform_3d_track(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type); void make_insert_queue(); void commit_insert_queue(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 2fa0303d63..4ad825c58f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5227,9 +5227,9 @@ void EditorNode::get_preload_scene_modification_table( new_additive_node_entry.owner = p_node->get_owner(); new_additive_node_entry.index = p_node->get_index(); - Node2D *node_2d = Object::cast_to(p_node); - if (node_2d) { - new_additive_node_entry.transform_2d = node_2d->get_transform(); + CanvasItem *canvas_item = Object::cast_to(p_node); + if (canvas_item) { + new_additive_node_entry.transform_2d = canvas_item->get_transform(); } Node3D *node_3d = Object::cast_to(p_node); if (node_3d) { @@ -8572,14 +8572,14 @@ EditorNode::EditorNode() { import_wav.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_wav); - Ref import_obj; - import_obj.instantiate(); - ResourceFormatImporter::get_singleton()->add_importer(import_obj); - Ref import_shader_file; import_shader_file.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_shader_file); + Ref import_obj; + import_obj.instantiate(); + ResourceFormatImporter::get_singleton()->add_importer(import_obj); + Ref import_model_as_scene; import_model_as_scene.instantiate("PackedScene"); ResourceFormatImporter::get_singleton()->add_importer(import_model_as_scene); @@ -9456,14 +9456,6 @@ EditorNode::EditorNode() { resource_preview->add_preview_generator(Ref(memnew(EditorGradientPreviewPlugin))); { - Ref spatial_mat_convert; - spatial_mat_convert.instantiate(); - resource_conversion_plugins.push_back(spatial_mat_convert); - - Ref orm_mat_convert; - orm_mat_convert.instantiate(); - resource_conversion_plugins.push_back(orm_mat_convert); - Ref canvas_item_mat_convert; canvas_item_mat_convert.instantiate(); resource_conversion_plugins.push_back(canvas_item_mat_convert); @@ -9476,6 +9468,14 @@ EditorNode::EditorNode() { particles_mat_convert.instantiate(); resource_conversion_plugins.push_back(particles_mat_convert); + Ref spatial_mat_convert; + spatial_mat_convert.instantiate(); + resource_conversion_plugins.push_back(spatial_mat_convert); + + Ref orm_mat_convert; + orm_mat_convert.instantiate(); + resource_conversion_plugins.push_back(orm_mat_convert); + Ref procedural_sky_mat_convert; procedural_sky_mat_convert.instantiate(); resource_conversion_plugins.push_back(procedural_sky_mat_convert); @@ -9615,7 +9615,7 @@ EditorNode::EditorNode() { ResourceLoader::set_load_callback(_resource_loaded); // Apply setting presets in case the editor_settings file is missing values. - EditorSettingsDialog::update_navigation_preset(); + EditorSettingsDialog::update_3d_navigation_preset(); screenshot_timer = memnew(Timer); screenshot_timer->set_one_shot(true); diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp index 814f52fa0b..593953ae7d 100644 --- a/editor/import/3d/resource_importer_scene.cpp +++ b/editor/import/3d/resource_importer_scene.cpp @@ -791,7 +791,53 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, HashMap(p_node); + if (mi) { + Ref mesh = mi->get_mesh(); + + if (mesh.is_valid()) { + if (r_occluder_arrays) { + OccluderInstance3D::bake_single_node(mi, 0.0f, r_occluder_arrays->first, r_occluder_arrays->second); + } + if (_teststr(name, "occ")) { + String fixed_name = _fixstr(name, "occ"); + if (!fixed_name.is_empty()) { + if (mi->get_parent() && !mi->get_parent()->has_node(fixed_name)) { + mi->set_name(fixed_name); + } + } + } else { + p_node->set_owner(nullptr); + memdelete(p_node); + p_node = nullptr; + } + } + } + } else if (_teststr(name, "navmesh") && Object::cast_to(p_node)) { + if (isroot) { + return p_node; + } + + ImporterMeshInstance3D *mi = Object::cast_to(p_node); + + Ref mesh = mi->get_mesh(); + ERR_FAIL_COND_V(mesh.is_null(), nullptr); + NavigationRegion3D *nmi = memnew(NavigationRegion3D); + + nmi->set_name(_fixstr(name, "navmesh")); + Ref nmesh = mesh->create_navigation_mesh(); + nmi->set_navigation_mesh(nmesh); + Object::cast_to(nmi)->set_transform(mi->get_transform()); + _copy_meta(p_node, nmi); + p_node->replace_by(nmi); + p_node->set_owner(nullptr); + memdelete(p_node); + p_node = nmi; + } else if (_teststr(name, "colonly") || _teststr(name, "convcolonly")) { if (isroot) { return p_node; } @@ -942,53 +988,6 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, HashMap(p_node)) { - if (isroot) { - return p_node; - } - - ImporterMeshInstance3D *mi = Object::cast_to(p_node); - - Ref mesh = mi->get_mesh(); - ERR_FAIL_COND_V(mesh.is_null(), nullptr); - NavigationRegion3D *nmi = memnew(NavigationRegion3D); - - nmi->set_name(_fixstr(name, "navmesh")); - Ref nmesh = mesh->create_navigation_mesh(); - nmi->set_navigation_mesh(nmesh); - Object::cast_to(nmi)->set_transform(mi->get_transform()); - _copy_meta(p_node, nmi); - p_node->replace_by(nmi); - p_node->set_owner(nullptr); - memdelete(p_node); - p_node = nmi; - } else if (_teststr(name, "occ") || _teststr(name, "occonly")) { - if (isroot) { - return p_node; - } - ImporterMeshInstance3D *mi = Object::cast_to(p_node); - if (mi) { - Ref mesh = mi->get_mesh(); - - if (mesh.is_valid()) { - if (r_occluder_arrays) { - OccluderInstance3D::bake_single_node(mi, 0.0f, r_occluder_arrays->first, r_occluder_arrays->second); - } - if (_teststr(name, "occ")) { - String fixed_name = _fixstr(name, "occ"); - if (!fixed_name.is_empty()) { - if (mi->get_parent() && !mi->get_parent()->has_node(fixed_name)) { - mi->set_name(fixed_name); - } - } - } else { - p_node->set_owner(nullptr); - memdelete(p_node); - p_node = nullptr; - } - } - } } else if (_teststr(name, "vehicle")) { if (isroot) { return p_node; diff --git a/editor/inspector/editor_properties.cpp b/editor/inspector/editor_properties.cpp index efe22da981..6599556281 100644 --- a/editor/inspector/editor_properties.cpp +++ b/editor/inspector/editor_properties.cpp @@ -3551,10 +3551,10 @@ void EditorPropertyResource::_update_preferred_shader() { // Set preferred shader based on edited parent type. if ((Object::cast_to(ed_object) || Object::cast_to(ed_object)) && ed_property == SNAME("process_material")) { shader_picker->set_preferred_mode(Shader::MODE_PARTICLES); - } else if (Object::cast_to(ed_object)) { - shader_picker->set_preferred_mode(Shader::MODE_FOG); } else if (Object::cast_to(ed_object)) { shader_picker->set_preferred_mode(Shader::MODE_CANVAS_ITEM); + } else if (Object::cast_to(ed_object)) { + shader_picker->set_preferred_mode(Shader::MODE_FOG); } else if (Object::cast_to(ed_object) || Object::cast_to(ed_object)) { shader_picker->set_preferred_mode(Shader::MODE_SPATIAL); } else if (Object::cast_to(ed_object)) { diff --git a/editor/plugins/editor_plugin.cpp b/editor/plugins/editor_plugin.cpp index ecc4b8409c..3e9e1330d8 100644 --- a/editor/plugins/editor_plugin.cpp +++ b/editor/plugins/editor_plugin.cpp @@ -491,16 +491,6 @@ void EditorPlugin::remove_node_3d_gizmo_plugin(const Refremove_gizmo_plugin(p_gizmo_plugin); } -void EditorPlugin::add_inspector_plugin(const Ref &p_plugin) { - ERR_FAIL_COND(p_plugin.is_null()); - EditorInspector::add_inspector_plugin(p_plugin); -} - -void EditorPlugin::remove_inspector_plugin(const Ref &p_plugin) { - ERR_FAIL_COND(p_plugin.is_null()); - EditorInspector::remove_inspector_plugin(p_plugin); -} - void EditorPlugin::add_scene_format_importer_plugin(const Ref &p_importer, bool p_first_priority) { ERR_FAIL_COND(p_importer.is_null()); ResourceImporterScene::add_scene_importer(p_importer, p_first_priority); @@ -519,6 +509,16 @@ void EditorPlugin::remove_scene_post_import_plugin(const Ref &p_plugin) { + ERR_FAIL_COND(p_plugin.is_null()); + EditorInspector::add_inspector_plugin(p_plugin); +} + +void EditorPlugin::remove_inspector_plugin(const Ref &p_plugin) { + ERR_FAIL_COND(p_plugin.is_null()); + EditorInspector::remove_inspector_plugin(p_plugin); +} + void EditorPlugin::add_context_menu_plugin(EditorContextMenuPlugin::ContextMenuSlot p_slot, const Ref &p_plugin) { EditorContextMenuPluginManager::get_singleton()->add_plugin(p_slot, p_plugin); } @@ -662,16 +662,10 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_translation_parser_plugin", "parser"), &EditorPlugin::remove_translation_parser_plugin); ClassDB::bind_method(D_METHOD("add_import_plugin", "importer", "first_priority"), &EditorPlugin::add_import_plugin, DEFVAL(false)); ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin); - ClassDB::bind_method(D_METHOD("add_scene_format_importer_plugin", "scene_format_importer", "first_priority"), &EditorPlugin::add_scene_format_importer_plugin, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("remove_scene_format_importer_plugin", "scene_format_importer"), &EditorPlugin::remove_scene_format_importer_plugin); - ClassDB::bind_method(D_METHOD("add_scene_post_import_plugin", "scene_import_plugin", "first_priority"), &EditorPlugin::add_scene_post_import_plugin, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("remove_scene_post_import_plugin", "scene_import_plugin"), &EditorPlugin::remove_scene_post_import_plugin); ClassDB::bind_method(D_METHOD("add_export_plugin", "plugin"), &EditorPlugin::add_export_plugin); ClassDB::bind_method(D_METHOD("remove_export_plugin", "plugin"), &EditorPlugin::remove_export_plugin); ClassDB::bind_method(D_METHOD("add_export_platform", "platform"), &EditorPlugin::add_export_platform); ClassDB::bind_method(D_METHOD("remove_export_platform", "platform"), &EditorPlugin::remove_export_platform); - ClassDB::bind_method(D_METHOD("add_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::add_node_3d_gizmo_plugin); - ClassDB::bind_method(D_METHOD("remove_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::remove_node_3d_gizmo_plugin); ClassDB::bind_method(D_METHOD("add_inspector_plugin", "plugin"), &EditorPlugin::add_inspector_plugin); ClassDB::bind_method(D_METHOD("remove_inspector_plugin", "plugin"), &EditorPlugin::remove_inspector_plugin); ClassDB::bind_method(D_METHOD("add_resource_conversion_plugin", "plugin"), &EditorPlugin::add_resource_conversion_plugin); @@ -681,6 +675,13 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("add_context_menu_plugin", "slot", "plugin"), &EditorPlugin::add_context_menu_plugin); ClassDB::bind_method(D_METHOD("remove_context_menu_plugin", "plugin"), &EditorPlugin::remove_context_menu_plugin); + ClassDB::bind_method(D_METHOD("add_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::add_node_3d_gizmo_plugin); + ClassDB::bind_method(D_METHOD("remove_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::remove_node_3d_gizmo_plugin); + ClassDB::bind_method(D_METHOD("add_scene_format_importer_plugin", "scene_format_importer", "first_priority"), &EditorPlugin::add_scene_format_importer_plugin, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("remove_scene_format_importer_plugin", "scene_format_importer"), &EditorPlugin::remove_scene_format_importer_plugin); + ClassDB::bind_method(D_METHOD("add_scene_post_import_plugin", "scene_import_plugin", "first_priority"), &EditorPlugin::add_scene_post_import_plugin, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("remove_scene_post_import_plugin", "scene_import_plugin"), &EditorPlugin::remove_scene_post_import_plugin); + ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorPlugin::get_editor_interface); ClassDB::bind_method(D_METHOD("get_script_create_dialog"), &EditorPlugin::get_script_create_dialog); ClassDB::bind_method(D_METHOD("add_debugger_plugin", "script"), &EditorPlugin::add_debugger_plugin); diff --git a/editor/plugins/editor_plugin.h b/editor/plugins/editor_plugin.h index a12ff25b51..bcd329e1cd 100644 --- a/editor/plugins/editor_plugin.h +++ b/editor/plugins/editor_plugin.h @@ -246,15 +246,15 @@ public: void add_node_3d_gizmo_plugin(const Ref &p_gizmo_plugin); void remove_node_3d_gizmo_plugin(const Ref &p_gizmo_plugin); - void add_inspector_plugin(const Ref &p_plugin); - void remove_inspector_plugin(const Ref &p_plugin); - void add_scene_format_importer_plugin(const Ref &p_importer, bool p_first_priority = false); void remove_scene_format_importer_plugin(const Ref &p_importer); void add_scene_post_import_plugin(const Ref &p_importer, bool p_first_priority = false); void remove_scene_post_import_plugin(const Ref &p_importer); + void add_inspector_plugin(const Ref &p_plugin); + void remove_inspector_plugin(const Ref &p_plugin); + void add_autoload_singleton(const String &p_name, const String &p_path); void remove_autoload_singleton(const String &p_name); diff --git a/editor/register_editor_types.cpp b/editor/register_editor_types.cpp index c66d3bd1da..4d79bece16 100644 --- a/editor/register_editor_types.cpp +++ b/editor/register_editor_types.cpp @@ -162,8 +162,6 @@ void register_editor_types() { GDREGISTER_CLASS(EditorFileDialog); GDREGISTER_VIRTUAL_CLASS(EditorSettings); GDREGISTER_ABSTRACT_CLASS(EditorToaster); - GDREGISTER_CLASS(EditorNode3DGizmo); - GDREGISTER_CLASS(EditorNode3DGizmoPlugin); GDREGISTER_ABSTRACT_CLASS(EditorResourcePreview); GDREGISTER_CLASS(EditorResourcePreviewGenerator); GDREGISTER_CLASS(EditorResourceTooltipPlugin); @@ -184,8 +182,6 @@ void register_editor_types() { register_exporter_types(); GDREGISTER_CLASS(EditorResourceConversionPlugin); - GDREGISTER_CLASS(EditorSceneFormatImporter); - GDREGISTER_CLASS(EditorScenePostImportPlugin); GDREGISTER_CLASS(EditorInspector); GDREGISTER_CLASS(EditorInspectorPlugin); GDREGISTER_CLASS(EditorProperty); @@ -200,11 +196,17 @@ void register_editor_types() { GDREGISTER_ABSTRACT_CLASS(FileSystemDock); GDREGISTER_VIRTUAL_CLASS(EditorFileSystemImportFormatSupportQuery); - GDREGISTER_CLASS(EditorScenePostImport); GDREGISTER_VIRTUAL_CLASS(EditorCommandPalette); GDREGISTER_CLASS(EditorDebuggerPlugin); GDREGISTER_ABSTRACT_CLASS(EditorDebuggerSession); + // 3D editor foundational classes. + GDREGISTER_CLASS(EditorNode3DGizmo); + GDREGISTER_CLASS(EditorNode3DGizmoPlugin); + GDREGISTER_CLASS(EditorSceneFormatImporter); + GDREGISTER_CLASS(EditorScenePostImportPlugin); + GDREGISTER_CLASS(EditorScenePostImport); + // Required to document import options in the class reference. GDREGISTER_CLASS(ResourceImporterBitMap); GDREGISTER_CLASS(ResourceImporterBMFont); @@ -221,42 +223,27 @@ void register_editor_types() { GDREGISTER_CLASS(ResourceImporterTextureAtlas); GDREGISTER_CLASS(ResourceImporterWAV); - // This list is alphabetized, and plugins that depend on Node2D are in their own section below. + // This list is alphabetized, and plugins that depend on Node2D or Node3D are in their own section below. EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); if (!Engine::get_singleton()->is_recovery_mode_hint()) { EditorPlugins::add_by_type(); } EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); @@ -267,31 +254,50 @@ void register_editor_types() { EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); -#ifndef DISABLE_DEPRECATED - EditorPlugins::add_by_type(); -#endif - // 2D + // Node2D-based editor plugins. EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); EditorPlugins::add_by_type(); + // 2D physics editor plugins. + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); #ifndef DISABLE_DEPRECATED EditorPlugins::add_by_type(); #endif + // 3D editor plugins. + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); + // 3D physics editor plugins. + EditorPlugins::add_by_type(); +#ifndef DISABLE_DEPRECATED + EditorPlugins::add_by_type(); +#endif + // For correct doc generation. GLOBAL_DEF(PropertyInfo(Variant::STRING, "editor/run/main_run_args", PROPERTY_HINT_NONE, "monospace"), ""); diff --git a/editor/scene/3d/node_3d_editor_plugin.cpp b/editor/scene/3d/node_3d_editor_plugin.cpp index e9aa2377e0..43a978882b 100644 --- a/editor/scene/3d/node_3d_editor_plugin.cpp +++ b/editor/scene/3d/node_3d_editor_plugin.cpp @@ -2842,17 +2842,12 @@ void Node3DEditor::_register_all_gizmos() { add_gizmo_plugin(Ref(memnew(AudioListener3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(MeshInstance3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(OccluderInstance3DGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(SoftBody3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(SpriteBase3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(Label3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(GeometryInstance3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(Marker3DGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(RayCast3DGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(ShapeCast3DGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(SpringArm3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(SpringBoneCollision3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(SpringBoneSimulator3DGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(VehicleWheel3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(VisibleOnScreenNotifier3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(GPUParticles3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(GPUParticlesCollision3DGizmoPlugin))); @@ -2863,14 +2858,20 @@ void Node3DEditor::_register_all_gizmos() { add_gizmo_plugin(Ref(memnew(VoxelGIGizmoPlugin))); add_gizmo_plugin(Ref(memnew(LightmapGIGizmoPlugin))); add_gizmo_plugin(Ref(memnew(LightmapProbeGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(FogVolumeGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(TwoBoneIK3DGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(ChainIK3DGizmoPlugin))); + // Physics gizmo plugins. add_gizmo_plugin(Ref(memnew(CollisionObject3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(CollisionShape3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(CollisionPolygon3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(Joint3DGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(SoftBody3DGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(ShapeCast3DGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(SpringArm3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(PhysicalBone3DGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(FogVolumeGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(TwoBoneIK3DGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(ChainIK3DGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(VehicleWheel3DGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(RayCast3DGizmoPlugin))); } void Node3DEditor::_bind_methods() { @@ -2885,7 +2886,7 @@ void Node3DEditor::_bind_methods() { ClassDB::bind_method("update_all_gizmos", &Node3DEditor::update_all_gizmos); ClassDB::bind_method("update_transform_gizmo", &Node3DEditor::update_transform_gizmo); - ADD_SIGNAL(MethodInfo("transform_key_request")); + ADD_SIGNAL(MethodInfo("transform_3d_key_request")); ADD_SIGNAL(MethodInfo("item_lock_status_changed")); ADD_SIGNAL(MethodInfo("item_group_status_changed")); } diff --git a/editor/scene/3d/node_3d_editor_viewport.cpp b/editor/scene/3d/node_3d_editor_viewport.cpp index 9ab17877dd..4c894fbd8f 100644 --- a/editor/scene/3d/node_3d_editor_viewport.cpp +++ b/editor/scene/3d/node_3d_editor_viewport.cpp @@ -2905,7 +2905,7 @@ void Node3DEditorViewport::_sinput(const Ref &p_event) { continue; } - spatial_editor->emit_signal(SNAME("transform_key_request"), sp, "", sp->get_transform()); + spatial_editor->emit_signal(SNAME("transform_3d_key_request"), sp, "", sp->get_transform()); } set_message(TTR("Animation Key Inserted.")); @@ -5380,18 +5380,18 @@ void Node3DEditorViewport::assign_pending_data_pointers(Node3D *p_preview_node, accept = p_accept; } -void _insert_rid_recursive(Node *node, HashSet &rids) { - CollisionObject3D *co = Object::cast_to(node); +void _insert_collision_object_rid_recursive(Node *p_node, HashSet &p_col_obj_rids) { + CollisionObject3D *col_obj = Object::cast_to(p_node); - if (co) { - rids.insert(co->get_rid()); - } else if (node->is_class("CSGShape3D")) { // HACK: We should avoid referencing module logic. - rids.insert(node->call("_get_root_collision_instance")); + if (col_obj) { + p_col_obj_rids.insert(col_obj->get_rid()); + } else if (p_node->is_class("CSGShape3D")) { // HACK: We should avoid referencing module logic. + p_col_obj_rids.insert(p_node->call("_get_root_collision_instance")); } - for (int i = 0; i < node->get_child_count(); i++) { - Node *child = node->get_child(i); - _insert_rid_recursive(child, rids); + for (int i = 0; i < p_node->get_child_count(); i++) { + Node *child = p_node->get_child(i); + _insert_collision_object_rid_recursive(child, p_col_obj_rids); } } @@ -5402,27 +5402,26 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos, Node3D Vector3 world_ray = get_ray(p_pos); Vector3 world_pos = get_ray_pos(p_pos); - PhysicsDirectSpaceState3D *ss = get_tree()->get_root()->get_world_3d()->get_direct_space_state(); - - HashSet rids; + HashSet col_obj_rids_to_exclude; if (preview_node && preview_node->get_child_count() > 0) { - _insert_rid_recursive(preview_node, rids); + _insert_collision_object_rid_recursive(preview_node, col_obj_rids_to_exclude); } else if (!preview_node->is_inside_tree() && !ruler->is_inside_tree()) { const List &selection = editor_selection->get_top_selected_node_list(); Node3D *first_selected_node = Object::cast_to(selection.front()->get()); if (first_selected_node) { - _insert_rid_recursive(first_selected_node, rids); + _insert_collision_object_rid_recursive(first_selected_node, col_obj_rids_to_exclude); } } PhysicsDirectSpaceState3D::RayParameters ray_params; - ray_params.exclude = rids; + ray_params.exclude = col_obj_rids_to_exclude; ray_params.from = world_pos; ray_params.to = world_pos + world_ray * camera->get_far(); + PhysicsDirectSpaceState3D *ss = get_tree()->get_root()->get_world_3d()->get_direct_space_state(); PhysicsDirectSpaceState3D::RayResult result; if (ss->intersect_ray(ray_params, result) && (preview_node->get_child_count() > 0 || !preview_node->is_inside_tree())) { // Calculate an offset for the `p_node` such that the its bounding box is on top of and touching the contact surface's plane. diff --git a/editor/scene/3d/skeleton_3d_editor_plugin.cpp b/editor/scene/3d/skeleton_3d_editor_plugin.cpp index 8d60face3b..ef508983f3 100644 --- a/editor/scene/3d/skeleton_3d_editor_plugin.cpp +++ b/editor/scene/3d/skeleton_3d_editor_plugin.cpp @@ -293,13 +293,13 @@ void BonePropertiesEditor::_property_keyed(const String &p_path, bool p_advance) if (split.size() == 3 && split[0] == "bones") { int bone_idx = split[1].to_int(); if (split[2] == "position") { - te->insert_transform_key(skeleton, skeleton->get_bone_name(bone_idx), Animation::TYPE_POSITION_3D, (Vector3)skeleton->get(p_path) / skeleton->get_motion_scale()); + te->insert_transform_3d_key(skeleton, skeleton->get_bone_name(bone_idx), Animation::TYPE_POSITION_3D, (Vector3)skeleton->get(p_path) / skeleton->get_motion_scale()); } if (split[2] == "rotation") { - te->insert_transform_key(skeleton, skeleton->get_bone_name(bone_idx), Animation::TYPE_ROTATION_3D, skeleton->get(p_path)); + te->insert_transform_3d_key(skeleton, skeleton->get_bone_name(bone_idx), Animation::TYPE_ROTATION_3D, skeleton->get(p_path)); } if (split[2] == "scale") { - te->insert_transform_key(skeleton, skeleton->get_bone_name(bone_idx), Animation::TYPE_SCALE_3D, skeleton->get(p_path)); + te->insert_transform_3d_key(skeleton, skeleton->get_bone_name(bone_idx), Animation::TYPE_SCALE_3D, skeleton->get(p_path)); } } } @@ -510,14 +510,14 @@ void Skeleton3DEditor::_insert_keys(const bool p_all_bones) { continue; } - if (pos_enabled && (p_all_bones || te->has_track(skeleton, name, Animation::TYPE_POSITION_3D))) { - te->insert_transform_key(skeleton, name, Animation::TYPE_POSITION_3D, skeleton->get_bone_pose_position(i) / skeleton->get_motion_scale()); + if (pos_enabled && (p_all_bones || te->has_transform_3d_track(skeleton, name, Animation::TYPE_POSITION_3D))) { + te->insert_transform_3d_key(skeleton, name, Animation::TYPE_POSITION_3D, skeleton->get_bone_pose_position(i) / skeleton->get_motion_scale()); } - if (rot_enabled && (p_all_bones || te->has_track(skeleton, name, Animation::TYPE_ROTATION_3D))) { - te->insert_transform_key(skeleton, name, Animation::TYPE_ROTATION_3D, skeleton->get_bone_pose_rotation(i)); + if (rot_enabled && (p_all_bones || te->has_transform_3d_track(skeleton, name, Animation::TYPE_ROTATION_3D))) { + te->insert_transform_3d_key(skeleton, name, Animation::TYPE_ROTATION_3D, skeleton->get_bone_pose_rotation(i)); } - if (scl_enabled && (p_all_bones || te->has_track(skeleton, name, Animation::TYPE_SCALE_3D))) { - te->insert_transform_key(skeleton, name, Animation::TYPE_SCALE_3D, skeleton->get_bone_pose_scale(i)); + if (scl_enabled && (p_all_bones || te->has_transform_3d_track(skeleton, name, Animation::TYPE_SCALE_3D))) { + te->insert_transform_3d_key(skeleton, name, Animation::TYPE_SCALE_3D, skeleton->get_bone_pose_scale(i)); } } te->commit_insert_queue(); diff --git a/editor/scene/material_editor_plugin.h b/editor/scene/material_editor_plugin.h index ceaa08da7a..21929f7e5c 100644 --- a/editor/scene/material_editor_plugin.h +++ b/editor/scene/material_editor_plugin.h @@ -34,6 +34,7 @@ #include "editor/plugins/editor_plugin.h" #include "editor/plugins/editor_resource_conversion_plugin.h" #include "scene/resources/3d/primitive_meshes.h" +#include "scene/resources/environment.h" #include "scene/resources/material.h" class Camera3D; diff --git a/editor/scene/sprite_frames_editor_plugin.cpp b/editor/scene/sprite_frames_editor_plugin.cpp index 1ae4afaacf..8bbec7715b 100644 --- a/editor/scene/sprite_frames_editor_plugin.cpp +++ b/editor/scene/sprite_frames_editor_plugin.cpp @@ -2042,9 +2042,7 @@ void SpriteFramesEditor::_fetch_sprite_node() { } bool show_node_edit = false; - AnimatedSprite2D *as2d = Object::cast_to(selected); - AnimatedSprite3D *as3d = Object::cast_to(selected); - if (as2d || as3d) { + if (selected->has_method("get_sprite_frames")) { if (frames != selected->call("get_sprite_frames")) { _remove_sprite_node(); } else { diff --git a/editor/scene/texture/texture_region_editor_plugin.cpp b/editor/scene/texture/texture_region_editor_plugin.cpp index 96685a32d9..9b0cfb4f59 100644 --- a/editor/scene/texture/texture_region_editor_plugin.cpp +++ b/editor/scene/texture/texture_region_editor_plugin.cpp @@ -383,13 +383,7 @@ void TextureRegionEditor::_commit_drag() { edited_margin = -1; } else { undo_redo->create_action(TTR("Set Region Rect")); - if (node_sprite_2d) { - undo_redo->add_do_method(node_sprite_2d, "set_region_rect", node_sprite_2d->get_region_rect()); - undo_redo->add_undo_method(node_sprite_2d, "set_region_rect", rect_prev); - } else if (node_sprite_3d) { - undo_redo->add_do_method(node_sprite_3d, "set_region_rect", node_sprite_3d->get_region_rect()); - undo_redo->add_undo_method(node_sprite_3d, "set_region_rect", rect_prev); - } else if (node_ninepatch) { + if (node_ninepatch) { undo_redo->add_do_method(node_ninepatch, "set_region_rect", node_ninepatch->get_region_rect()); undo_redo->add_undo_method(node_ninepatch, "set_region_rect", rect_prev); } else if (res_stylebox.is_valid()) { @@ -398,6 +392,12 @@ void TextureRegionEditor::_commit_drag() { } else if (res_atlas_texture.is_valid()) { undo_redo->add_do_method(res_atlas_texture.ptr(), "set_region", res_atlas_texture->get_region()); undo_redo->add_undo_method(res_atlas_texture.ptr(), "set_region", rect_prev); + } else if (node_sprite_2d) { + undo_redo->add_do_method(node_sprite_2d, "set_region_rect", node_sprite_2d->get_region_rect()); + undo_redo->add_undo_method(node_sprite_2d, "set_region_rect", rect_prev); + } else if (node_sprite_3d) { + undo_redo->add_do_method(node_sprite_3d, "set_region_rect", node_sprite_3d->get_region_rect()); + undo_redo->add_undo_method(node_sprite_3d, "set_region_rect", rect_prev); } drag_index = -1; } @@ -461,30 +461,13 @@ void TextureRegionEditor::_texture_overlay_input(const Ref &p_input) if (E.has_point(point)) { rect = E; if (Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL) && !(Input::get_singleton()->is_key_pressed(Key(Key::SHIFT | Key::ALT)))) { - Rect2 r; - if (node_sprite_2d) { - r = node_sprite_2d->get_region_rect(); - } else if (node_sprite_3d) { - r = node_sprite_3d->get_region_rect(); - } else if (node_ninepatch) { - r = node_ninepatch->get_region_rect(); - } else if (res_stylebox.is_valid()) { - r = res_stylebox->get_region_rect(); - } else if (res_atlas_texture.is_valid()) { - r = res_atlas_texture->get_region(); - } + Rect2 r = _get_edited_object_region(); rect.expand_to(r.position); rect.expand_to(r.get_end()); } undo_redo->create_action(TTR("Set Region Rect")); - if (node_sprite_2d) { - undo_redo->add_do_method(node_sprite_2d, "set_region_rect", rect); - undo_redo->add_undo_method(node_sprite_2d, "set_region_rect", node_sprite_2d->get_region_rect()); - } else if (node_sprite_3d) { - undo_redo->add_do_method(node_sprite_3d, "set_region_rect", rect); - undo_redo->add_undo_method(node_sprite_3d, "set_region_rect", node_sprite_3d->get_region_rect()); - } else if (node_ninepatch) { + if (node_ninepatch) { undo_redo->add_do_method(node_ninepatch, "set_region_rect", rect); undo_redo->add_undo_method(node_ninepatch, "set_region_rect", node_ninepatch->get_region_rect()); } else if (res_stylebox.is_valid()) { @@ -493,6 +476,12 @@ void TextureRegionEditor::_texture_overlay_input(const Ref &p_input) } else if (res_atlas_texture.is_valid()) { undo_redo->add_do_method(res_atlas_texture.ptr(), "set_region", rect); undo_redo->add_undo_method(res_atlas_texture.ptr(), "set_region", res_atlas_texture->get_region()); + } else if (node_sprite_2d) { + undo_redo->add_do_method(node_sprite_2d, "set_region_rect", rect); + undo_redo->add_undo_method(node_sprite_2d, "set_region_rect", node_sprite_2d->get_region_rect()); + } else if (node_sprite_3d) { + undo_redo->add_do_method(node_sprite_3d, "set_region_rect", rect); + undo_redo->add_undo_method(node_sprite_3d, "set_region_rect", node_sprite_3d->get_region_rect()); } undo_redo->add_do_method(this, "_update_rect"); @@ -1043,16 +1032,16 @@ Ref TextureRegionEditor::_get_edited_object_texture() const { Rect2 TextureRegionEditor::_get_edited_object_region() const { Rect2 region; - if (node_sprite_2d) { - region = node_sprite_2d->get_region_rect(); - } else if (node_sprite_3d) { - region = node_sprite_3d->get_region_rect(); - } else if (node_ninepatch) { + if (node_ninepatch) { region = node_ninepatch->get_region_rect(); } else if (res_stylebox.is_valid()) { region = res_stylebox->get_region_rect(); } else if (res_atlas_texture.is_valid()) { region = res_atlas_texture->get_region(); + } else if (node_sprite_2d) { + region = node_sprite_2d->get_region_rect(); + } else if (node_sprite_3d) { + region = node_sprite_3d->get_region_rect(); } const Ref object_texture = _get_edited_object_texture(); @@ -1083,7 +1072,9 @@ void TextureRegionEditor::_edit_region() { } CanvasItem::TextureFilter filter = CanvasItem::TEXTURE_FILTER_NEAREST_WITH_MIPMAPS; - if (node_sprite_2d) { + if (node_ninepatch) { + filter = node_ninepatch->get_texture_filter_in_tree(); + } else if (node_sprite_2d) { filter = node_sprite_2d->get_texture_filter_in_tree(); } else if (node_sprite_3d) { StandardMaterial3D::TextureFilter filter_3d = node_sprite_3d->get_texture_filter(); @@ -1112,8 +1103,6 @@ void TextureRegionEditor::_edit_region() { filter = CanvasItem::TEXTURE_FILTER_PARENT_NODE; break; } - } else if (node_ninepatch) { - filter = node_ninepatch->get_texture_filter_in_tree(); } // occurs when get_texture_filter_in_tree reaches the scene root diff --git a/editor/settings/editor_settings_dialog.cpp b/editor/settings/editor_settings_dialog.cpp index 24e69db554..327bc1d80f 100644 --- a/editor/settings/editor_settings_dialog.cpp +++ b/editor/settings/editor_settings_dialog.cpp @@ -90,12 +90,12 @@ void EditorSettingsDialog::_settings_property_edited() { } else if (full_name == "editors/3d/navigation/orbit_mouse_button" || full_name == "editors/3d/navigation/pan_mouse_button" || full_name == "editors/3d/navigation/zoom_mouse_button" || full_name == "editors/3d/navigation/emulate_3_button_mouse") { EditorSettings::get_singleton()->set_manually("editors/3d/navigation/navigation_scheme", (int)View3DController::NAV_SCHEME_CUSTOM); } else if (full_name == "editors/3d/navigation/navigation_scheme") { - update_navigation_preset(); + update_3d_navigation_preset(); _update_shortcuts(); } } -void EditorSettingsDialog::update_navigation_preset() { +void EditorSettingsDialog::update_3d_navigation_preset() { View3DController::NavigationScheme nav_scheme = (View3DController::NavigationScheme)EDITOR_GET("editors/3d/navigation/navigation_scheme").operator int(); View3DController::NavigationMouseButton set_orbit_mouse_button = View3DController::NAV_MOUSE_BUTTON_LEFT; View3DController::NavigationMouseButton set_pan_mouse_button = View3DController::NAV_MOUSE_BUTTON_LEFT; diff --git a/editor/settings/editor_settings_dialog.h b/editor/settings/editor_settings_dialog.h index 356fb064a0..f5ae0c1b6c 100644 --- a/editor/settings/editor_settings_dialog.h +++ b/editor/settings/editor_settings_dialog.h @@ -130,7 +130,7 @@ protected: public: void popup_edit_settings(); - static void update_navigation_preset(); + static void update_3d_navigation_preset(); void set_current_section(const String &p_section); void set_advanced_mode_enabled(bool p_enabled); diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index c9ef3a0fbd..30774c63c8 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -104,19 +104,19 @@ void CSGShape3D::set_use_collision(bool p_enable) { if (use_collision) { root_collision_shape.instantiate(); - root_collision_instance = PhysicsServer3D::get_singleton()->body_create(); - PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC); - PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); - PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid()); - PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world_3d()->get_space()); - PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id()); + root_collision_body = PhysicsServer3D::get_singleton()->body_create(); + PhysicsServer3D::get_singleton()->body_set_mode(root_collision_body, PhysicsServer3D::BODY_MODE_STATIC); + PhysicsServer3D::get_singleton()->body_set_state(root_collision_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); + PhysicsServer3D::get_singleton()->body_add_shape(root_collision_body, root_collision_shape->get_rid()); + PhysicsServer3D::get_singleton()->body_set_space(root_collision_body, get_world_3d()->get_space()); + PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_body, get_instance_id()); set_collision_layer(collision_layer); set_collision_mask(collision_mask); set_collision_priority(collision_priority); _make_dirty(); //force update } else { - PhysicsServer3D::get_singleton()->free_rid(root_collision_instance); - root_collision_instance = RID(); + PhysicsServer3D::get_singleton()->free_rid(root_collision_body); + root_collision_body = RID(); root_collision_shape.unref(); } notify_property_list_changed(); @@ -129,8 +129,8 @@ bool CSGShape3D::is_using_collision() const { void CSGShape3D::set_collision_layer(uint32_t p_layer) { collision_layer = p_layer; - if (root_collision_instance.is_valid()) { - PhysicsServer3D::get_singleton()->body_set_collision_layer(root_collision_instance, p_layer); + if (root_collision_body.is_valid()) { + PhysicsServer3D::get_singleton()->body_set_collision_layer(root_collision_body, p_layer); } } @@ -140,8 +140,8 @@ uint32_t CSGShape3D::get_collision_layer() const { void CSGShape3D::set_collision_mask(uint32_t p_mask) { collision_mask = p_mask; - if (root_collision_instance.is_valid()) { - PhysicsServer3D::get_singleton()->body_set_collision_mask(root_collision_instance, p_mask); + if (root_collision_body.is_valid()) { + PhysicsServer3D::get_singleton()->body_set_collision_mask(root_collision_body, p_mask); } } @@ -186,8 +186,8 @@ bool CSGShape3D::get_collision_mask_value(int p_layer_number) const { } RID CSGShape3D::_get_root_collision_instance() const { - if (root_collision_instance.is_valid()) { - return root_collision_instance; + if (root_collision_body.is_valid()) { + return root_collision_body; } else if (parent_shape) { return parent_shape->_get_root_collision_instance(); } @@ -197,8 +197,8 @@ RID CSGShape3D::_get_root_collision_instance() const { void CSGShape3D::set_collision_priority(real_t p_priority) { collision_priority = p_priority; - if (root_collision_instance.is_valid()) { - PhysicsServer3D::get_singleton()->body_set_collision_priority(root_collision_instance, p_priority); + if (root_collision_body.is_valid()) { + PhysicsServer3D::get_singleton()->body_set_collision_priority(root_collision_body, p_priority); } } @@ -1059,12 +1059,12 @@ void CSGShape3D::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { if (use_collision && is_root_shape()) { root_collision_shape.instantiate(); - root_collision_instance = PhysicsServer3D::get_singleton()->body_create(); - PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC); - PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); - PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid()); - PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world_3d()->get_space()); - PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id()); + root_collision_body = PhysicsServer3D::get_singleton()->body_create(); + PhysicsServer3D::get_singleton()->body_set_mode(root_collision_body, PhysicsServer3D::BODY_MODE_STATIC); + PhysicsServer3D::get_singleton()->body_set_state(root_collision_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); + PhysicsServer3D::get_singleton()->body_add_shape(root_collision_body, root_collision_shape->get_rid()); + PhysicsServer3D::get_singleton()->body_set_space(root_collision_body, get_world_3d()->get_space()); + PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_body, get_instance_id()); set_collision_layer(collision_layer); set_collision_mask(collision_mask); set_collision_priority(collision_priority); @@ -1074,17 +1074,17 @@ void CSGShape3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - if (use_collision && is_root_shape() && root_collision_instance.is_valid()) { - PhysicsServer3D::get_singleton()->free_rid(root_collision_instance); - root_collision_instance = RID(); + if (use_collision && is_root_shape() && root_collision_body.is_valid()) { + PhysicsServer3D::get_singleton()->free_rid(root_collision_body); + root_collision_body = RID(); root_collision_shape.unref(); _clear_debug_collision_shape(); } } break; case NOTIFICATION_TRANSFORM_CHANGED: { - if (use_collision && is_root_shape() && root_collision_instance.is_valid()) { - PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); + if (use_collision && is_root_shape() && root_collision_body.is_valid()) { + PhysicsServer3D::get_singleton()->body_set_state(root_collision_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); } _on_transform_changed(); } break; diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h index 5ac05a5e65..3dc696b469 100644 --- a/modules/csg/csg_shape.h +++ b/modules/csg/csg_shape.h @@ -77,7 +77,7 @@ private: uint32_t collision_mask = 1; real_t collision_priority = 1.0; Ref root_collision_shape; - RID root_collision_instance; + RID root_collision_body; RID root_collision_debug_instance; Transform3D debug_shape_old_transform; #endif // PHYSICS_3D_DISABLED diff --git a/modules/visual_shader/editor/visual_shader_editor_plugin.h b/modules/visual_shader/editor/visual_shader_editor_plugin.h index f31d8de44f..0be10630b4 100644 --- a/modules/visual_shader/editor/visual_shader_editor_plugin.h +++ b/modules/visual_shader/editor/visual_shader_editor_plugin.h @@ -35,6 +35,7 @@ #include "editor/plugins/editor_resource_conversion_plugin.h" #include "editor/shader/shader_editor.h" #include "scene/gui/graph_edit.h" +#include "scene/resources/environment.h" #include "scene/resources/material.h" #include "scene/resources/syntax_highlighter.h"