summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_track_editor.cpp29
-rw-r--r--editor/animation_track_editor.h3
-rw-r--r--editor/editor_asset_installer.cpp4
-rw-r--r--editor/editor_node.cpp4
-rw-r--r--editor/editor_paths.cpp4
-rw-r--r--editor/icons/AudioStreamOggVorbis.svg (renamed from editor/icons/AudioStreamOGGVorbis.svg)0
-rw-r--r--editor/icons/AudioStreamWAV.svg (renamed from editor/icons/AudioStreamSample.svg)0
-rw-r--r--editor/import/resource_importer_wav.cpp26
-rw-r--r--editor/import/scene_import_settings.cpp2
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp2
-rw-r--r--editor/plugins/bone_map_editor_plugin.cpp46
-rw-r--r--editor/plugins/bone_map_editor_plugin.h1
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp4
-rw-r--r--editor/plugins/curve_editor_plugin.cpp4
-rw-r--r--editor/plugins/node_3d_editor_gizmos.cpp114
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp228
-rw-r--r--editor/plugins/node_3d_editor_plugin.h27
-rw-r--r--editor/plugins/replication_editor_plugin.cpp645
-rw-r--r--editor/plugins/replication_editor_plugin.h135
-rw-r--r--editor/plugins/shader_editor_plugin.cpp10
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp8
-rw-r--r--editor/plugins/tiles/tiles_editor_plugin.cpp12
-rw-r--r--editor/plugins/tiles/tiles_editor_plugin.h3
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp8
-rw-r--r--editor/project_converter_3_to_4.cpp4
-rw-r--r--editor/project_settings_editor.cpp8
-rw-r--r--editor/project_settings_editor.h2
-rw-r--r--editor/shader_globals_editor.cpp36
28 files changed, 419 insertions, 950 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 234bfb944c..f01a83ea4c 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -3746,19 +3746,7 @@ void AnimationTrackEditor::_insert_track(bool p_reset_wanted, bool p_create_bezi
undo_redo->commit_action();
if (advance) {
- float step = animation->get_step();
- if (step == 0) {
- step = 1;
- }
-
- float pos = timeline->get_play_position();
-
- pos = Math::snapped(pos + step, step);
- if (pos > animation->get_length()) {
- pos = animation->get_length();
- }
- set_anim_pos(pos);
- emit_signal(SNAME("timeline_changed"), pos, true, false);
+ _edit_menu_pressed(EDIT_GOTO_NEXT_STEP_TIMELINE_ONLY);
}
}
@@ -4086,12 +4074,20 @@ void AnimationTrackEditor::_confirm_insert_list() {
}
TrackIndices next_tracks(animation.ptr(), reset_anim.ptr());
+ bool advance = false;
while (insert_data.size()) {
+ if (insert_data.front()->get().advance) {
+ advance = true;
+ }
next_tracks = _confirm_insert(insert_data.front()->get(), next_tracks, create_reset, reset_anim, insert_confirm_bezier->is_pressed());
insert_data.pop_front();
}
undo_redo->commit_action();
+
+ if (advance) {
+ _edit_menu_pressed(EDIT_GOTO_NEXT_STEP_TIMELINE_ONLY);
+ }
}
PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_base_path, Variant *r_current_val) {
@@ -5597,7 +5593,7 @@ void AnimationTrackEditor::goto_prev_step(bool p_from_mouse_event) {
emit_signal(SNAME("timeline_changed"), pos, true, false);
}
-void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event) {
+void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event, bool p_timeline_only) {
if (animation.is_null()) {
return;
}
@@ -5621,7 +5617,7 @@ void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event) {
}
set_anim_pos(pos);
- emit_signal(SNAME("timeline_changed"), pos, true, false);
+ emit_signal(SNAME("timeline_changed"), pos, true, p_timeline_only);
}
void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
@@ -5969,8 +5965,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
_update_key_edit();
}
} break;
+ case EDIT_GOTO_NEXT_STEP_TIMELINE_ONLY:
case EDIT_GOTO_NEXT_STEP: {
- goto_next_step(false);
+ goto_next_step(false, p_option == EDIT_GOTO_NEXT_STEP_TIMELINE_ONLY);
} break;
case EDIT_GOTO_PREV_STEP: {
goto_prev_step(false);
diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h
index dede2e9bbe..18ce2ded63 100644
--- a/editor/animation_track_editor.h
+++ b/editor/animation_track_editor.h
@@ -518,6 +518,7 @@ public:
EDIT_ADD_RESET_KEY,
EDIT_DELETE_SELECTION,
EDIT_GOTO_NEXT_STEP,
+ EDIT_GOTO_NEXT_STEP_TIMELINE_ONLY, // Next step without updating animation.
EDIT_GOTO_PREV_STEP,
EDIT_APPLY_RESET,
EDIT_OPTIMIZE_ANIMATION,
@@ -563,7 +564,7 @@ public:
void goto_prev_step(bool p_from_mouse_event);
/** If `p_from_mouse_event` is `true`, handle Shift key presses for precise snapping. */
- void goto_next_step(bool p_from_mouse_event);
+ void goto_next_step(bool p_from_mouse_event, bool p_timeline_only = false);
MenuButton *get_edit_menu();
AnimationTrackEditor();
diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp
index 8fa486408e..8dc8a0ab6b 100644
--- a/editor/editor_asset_installer.cpp
+++ b/editor/editor_asset_installer.cpp
@@ -100,8 +100,8 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
extension_guess["tga"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
extension_guess["webp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
- extension_guess["wav"] = tree->get_theme_icon(SNAME("AudioStreamSample"), SNAME("EditorIcons"));
- extension_guess["ogg"] = tree->get_theme_icon(SNAME("AudioStreamOGGVorbis"), SNAME("EditorIcons"));
+ extension_guess["wav"] = tree->get_theme_icon(SNAME("AudioStreamWAV"), SNAME("EditorIcons"));
+ extension_guess["ogg"] = tree->get_theme_icon(SNAME("AudioStreamOggVorbis"), SNAME("EditorIcons"));
extension_guess["mp3"] = tree->get_theme_icon(SNAME("AudioStreamMP3"), SNAME("EditorIcons"));
extension_guess["scn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"));
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 37329c92f3..8294e2229a 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -175,7 +175,6 @@
#include "editor/plugins/polygon_2d_editor_plugin.h"
#include "editor/plugins/polygon_3d_editor_plugin.h"
#include "editor/plugins/ray_cast_2d_editor_plugin.h"
-#include "editor/plugins/replication_editor_plugin.h"
#include "editor/plugins/resource_preloader_editor_plugin.h"
#include "editor/plugins/root_motion_editor_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
@@ -1035,7 +1034,7 @@ void EditorNode::_sources_changed(bool p_exist) {
// Reload the global shader variables, but this time
// loading textures, as they are now properly imported.
- RenderingServer::get_singleton()->global_variables_load_settings(true);
+ RenderingServer::get_singleton()->global_shader_uniforms_load_settings(true);
// Start preview thread now that it's safe.
if (!singleton->cmdline_export_mode) {
@@ -7142,7 +7141,6 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(Path3DEditorPlugin));
add_editor_plugin(memnew(PhysicalBone3DEditorPlugin));
add_editor_plugin(memnew(Polygon3DEditorPlugin));
- add_editor_plugin(memnew(ReplicationEditorPlugin));
add_editor_plugin(memnew(ResourcePreloaderEditorPlugin));
add_editor_plugin(memnew(ShaderEditorPlugin));
add_editor_plugin(memnew(ShaderFileEditorPlugin));
diff --git a/editor/editor_paths.cpp b/editor/editor_paths.cpp
index a5c2fe093c..977af3cfae 100644
--- a/editor/editor_paths.cpp
+++ b/editor/editor_paths.cpp
@@ -153,8 +153,8 @@ EditorPaths::EditorPaths() {
}
}
- if (!dir->dir_exists("templates")) {
- dir->make_dir("templates");
+ if (!dir->dir_exists("export_templates")) {
+ dir->make_dir("export_templates");
}
}
diff --git a/editor/icons/AudioStreamOGGVorbis.svg b/editor/icons/AudioStreamOggVorbis.svg
index 2e54de9faa..2e54de9faa 100644
--- a/editor/icons/AudioStreamOGGVorbis.svg
+++ b/editor/icons/AudioStreamOggVorbis.svg
diff --git a/editor/icons/AudioStreamSample.svg b/editor/icons/AudioStreamWAV.svg
index 2e54de9faa..2e54de9faa 100644
--- a/editor/icons/AudioStreamSample.svg
+++ b/editor/icons/AudioStreamWAV.svg
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index f0ba1eb7a1..3a47bfb29f 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -33,7 +33,7 @@
#include "core/io/file_access.h"
#include "core/io/marshalls.h"
#include "core/io/resource_saver.h"
-#include "scene/resources/audio_stream_sample.h"
+#include "scene/resources/audio_stream_wav.h"
const float TRIM_DB_LIMIT = -50;
const int TRIM_FADE_OUT_FRAMES = 500;
@@ -55,7 +55,7 @@ String ResourceImporterWAV::get_save_extension() const {
}
String ResourceImporterWAV::get_resource_type() const {
- return "AudioStreamSample";
+ return "AudioStreamWAV";
}
bool ResourceImporterWAV::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
@@ -86,7 +86,7 @@ void ResourceImporterWAV::get_import_options(const String &p_path, List<ImportOp
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "force/max_rate_hz", PROPERTY_HINT_RANGE, "11025,192000,1,exp"), 44100));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/trim"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/normalize"), false));
- // Keep the `edit/loop_mode` enum in sync with AudioStreamSample::LoopMode (note: +1 offset due to "Detect From WAV").
+ // Keep the `edit/loop_mode` enum in sync with AudioStreamWAV::LoopMode (note: +1 offset due to "Detect From WAV").
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "edit/loop_mode", PROPERTY_HINT_ENUM, "Detect From WAV,Disabled,Forward,Ping-Pong,Backward", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "edit/loop_begin"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "edit/loop_end"), -1));
@@ -130,7 +130,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
int format_bits = 0;
int format_channels = 0;
- AudioStreamSample::LoopMode loop_mode = AudioStreamSample::LOOP_DISABLED;
+ AudioStreamWAV::LoopMode loop_mode = AudioStreamWAV::LOOP_DISABLED;
uint16_t compression_code = 1;
bool format_found = false;
bool data_found = false;
@@ -282,11 +282,11 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
int loop_type = file->get_32();
if (loop_type == 0x00 || loop_type == 0x01 || loop_type == 0x02) {
if (loop_type == 0x00) {
- loop_mode = AudioStreamSample::LOOP_FORWARD;
+ loop_mode = AudioStreamWAV::LOOP_FORWARD;
} else if (loop_type == 0x01) {
- loop_mode = AudioStreamSample::LOOP_PINGPONG;
+ loop_mode = AudioStreamWAV::LOOP_PINGPONG;
} else if (loop_type == 0x02) {
- loop_mode = AudioStreamSample::LOOP_BACKWARD;
+ loop_mode = AudioStreamWAV::LOOP_BACKWARD;
}
loop_begin = file->get_32();
loop_end = file->get_32();
@@ -386,7 +386,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
bool trim = p_options["edit/trim"];
- if (trim && (loop_mode != AudioStreamSample::LOOP_DISABLED) && format_channels > 0) {
+ if (trim && (loop_mode != AudioStreamWAV::LOOP_DISABLED) && format_channels > 0) {
int first = 0;
int last = (frames / format_channels) - 1;
bool found = false;
@@ -431,7 +431,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
}
if (import_loop_mode >= 2) {
- loop_mode = (AudioStreamSample::LoopMode)(import_loop_mode - 1);
+ loop_mode = (AudioStreamWAV::LoopMode)(import_loop_mode - 1);
loop_begin = p_options["edit/loop_begin"];
loop_end = p_options["edit/loop_end"];
// Wrap around to max frames, so `-1` can be used to select the end, etc.
@@ -463,10 +463,10 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
}
Vector<uint8_t> dst_data;
- AudioStreamSample::Format dst_format;
+ AudioStreamWAV::Format dst_format;
if (compression == 1) {
- dst_format = AudioStreamSample::FORMAT_IMA_ADPCM;
+ dst_format = AudioStreamWAV::FORMAT_IMA_ADPCM;
if (format_channels == 1) {
_compress_ima_adpcm(data, dst_data);
} else {
@@ -503,7 +503,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
}
} else {
- dst_format = is16 ? AudioStreamSample::FORMAT_16_BITS : AudioStreamSample::FORMAT_8_BITS;
+ dst_format = is16 ? AudioStreamWAV::FORMAT_16_BITS : AudioStreamWAV::FORMAT_8_BITS;
dst_data.resize(data.size() * (is16 ? 2 : 1));
{
uint8_t *w = dst_data.ptrw();
@@ -521,7 +521,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
}
}
- Ref<AudioStreamSample> sample;
+ Ref<AudioStreamWAV> sample;
sample.instantiate();
sample->set_data(dst_data);
sample->set_format(dst_format);
diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp
index 0e2967dc42..1c39c425b1 100644
--- a/editor/import/scene_import_settings.cpp
+++ b/editor/import/scene_import_settings.cpp
@@ -502,7 +502,7 @@ void SceneImportSettings::_update_camera() {
Transform3D xf;
xf.basis = Basis(Vector3(1, 0, 0), rot_x) * Basis(Vector3(0, 1, 0), rot_y);
xf.origin = center;
- xf.translate(0, 0, camera_size);
+ xf.translate_local(0, 0, camera_size);
camera->set_transform(xf);
}
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index 1258b9a03c..93dc0ff3c9 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -1018,7 +1018,7 @@ void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) {
anim->set_animation(animations_to_add[p_index]);
- String base_name = animations_to_add[p_index];
+ String base_name = animations_to_add[p_index].validate_node_name();
int base = 1;
String name = base_name;
while (state_machine->has_node(name)) {
diff --git a/editor/plugins/bone_map_editor_plugin.cpp b/editor/plugins/bone_map_editor_plugin.cpp
index 9a00bb93b8..3669971b1e 100644
--- a/editor/plugins/bone_map_editor_plugin.cpp
+++ b/editor/plugins/bone_map_editor_plugin.cpp
@@ -65,6 +65,9 @@ void BoneMapperButton::set_state(BoneMapState p_state) {
case BONE_MAP_STATE_SET: {
circle->set_modulate(EditorSettings::get_singleton()->get("editors/bone_mapper/handle_colors/set"));
} break;
+ case BONE_MAP_STATE_MISSING: {
+ circle->set_modulate(EditorSettings::get_singleton()->get("editors/bone_mapper/handle_colors/missing"));
+ } break;
case BONE_MAP_STATE_ERROR: {
circle->set_modulate(EditorSettings::get_singleton()->get("editors/bone_mapper/handle_colors/error"));
} break;
@@ -311,16 +314,48 @@ void BoneMapper::recreate_items() {
void BoneMapper::_update_state() {
int len = bone_mapper_buttons.size();
for (int i = 0; i < len; i++) {
- StringName sbn = bone_map->get_skeleton_bone_name(bone_mapper_buttons[i]->get_profile_bone_name());
- if (skeleton->find_bone(sbn) >= 0) {
+ StringName pbn = bone_mapper_buttons[i]->get_profile_bone_name();
+ StringName sbn = bone_map->get_skeleton_bone_name(pbn);
+ int bone_idx = skeleton->find_bone(sbn);
+ if (bone_idx >= 0) {
if (bone_map->get_skeleton_bone_name_count(sbn) == 1) {
- bone_mapper_buttons[i]->set_state(BoneMapperButton::BONE_MAP_STATE_SET);
+ Ref<SkeletonProfile> prof = bone_map->get_profile();
+
+ StringName parent_name = prof->get_bone_parent(prof->find_bone(pbn));
+ Vector<int> prof_parent_bones;
+ while (parent_name != StringName()) {
+ prof_parent_bones.push_back(skeleton->find_bone(bone_map->get_skeleton_bone_name(parent_name)));
+ if (prof->find_bone(parent_name) == -1) {
+ break;
+ }
+ parent_name = prof->get_bone_parent(prof->find_bone(parent_name));
+ }
+
+ int parent_id = skeleton->get_bone_parent(bone_idx);
+ Vector<int> skel_parent_bones;
+ while (parent_id >= 0) {
+ skel_parent_bones.push_back(parent_id);
+ parent_id = skeleton->get_bone_parent(parent_id);
+ }
+
+ bool is_broken = false;
+ for (int j = 0; j < prof_parent_bones.size(); j++) {
+ if (prof_parent_bones[j] != -1 && !skel_parent_bones.has(prof_parent_bones[j])) {
+ is_broken = true;
+ }
+ }
+
+ if (is_broken) {
+ bone_mapper_buttons[i]->set_state(BoneMapperButton::BONE_MAP_STATE_ERROR);
+ } else {
+ bone_mapper_buttons[i]->set_state(BoneMapperButton::BONE_MAP_STATE_SET);
+ }
} else {
bone_mapper_buttons[i]->set_state(BoneMapperButton::BONE_MAP_STATE_ERROR);
}
} else {
if (bone_mapper_buttons[i]->is_require()) {
- bone_mapper_buttons[i]->set_state(BoneMapperButton::BONE_MAP_STATE_ERROR);
+ bone_mapper_buttons[i]->set_state(BoneMapperButton::BONE_MAP_STATE_MISSING);
} else {
bone_mapper_buttons[i]->set_state(BoneMapperButton::BONE_MAP_STATE_UNSET);
}
@@ -441,9 +476,10 @@ void EditorInspectorPluginBoneMap::parse_begin(Object *p_object) {
BoneMapEditorPlugin::BoneMapEditorPlugin() {
// Register properties in editor settings.
+ EDITOR_DEF("editors/bone_mapper/handle_colors/unset", Color(0.3, 0.3, 0.3));
EDITOR_DEF("editors/bone_mapper/handle_colors/set", Color(0.1, 0.6, 0.25));
+ EDITOR_DEF("editors/bone_mapper/handle_colors/missing", Color(0.8, 0.2, 0.8));
EDITOR_DEF("editors/bone_mapper/handle_colors/error", Color(0.8, 0.2, 0.2));
- EDITOR_DEF("editors/bone_mapper/handle_colors/unset", Color(0.3, 0.3, 0.3));
Ref<EditorInspectorPluginBoneMap> inspector_plugin;
inspector_plugin.instantiate();
diff --git a/editor/plugins/bone_map_editor_plugin.h b/editor/plugins/bone_map_editor_plugin.h
index 79fb47505b..339547ea10 100644
--- a/editor/plugins/bone_map_editor_plugin.h
+++ b/editor/plugins/bone_map_editor_plugin.h
@@ -47,6 +47,7 @@ public:
enum BoneMapState {
BONE_MAP_STATE_UNSET,
BONE_MAP_STATE_SET,
+ BONE_MAP_STATE_MISSING,
BONE_MAP_STATE_ERROR
};
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 82772178e0..19239b8650 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -2793,10 +2793,10 @@ void CanvasItemEditor::_draw_rulers() {
if (grid_snap_active || _is_grid_visible()) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (snap_relative && selection.size() > 0) {
- ruler_transform.translate(_get_encompassing_rect_from_list(selection).position);
+ ruler_transform.translate_local(_get_encompassing_rect_from_list(selection).position);
ruler_transform.scale_basis(grid_step * Math::pow(2.0, grid_step_multiplier));
} else {
- ruler_transform.translate(grid_offset);
+ ruler_transform.translate_local(grid_offset);
ruler_transform.scale_basis(grid_step * Math::pow(2.0, grid_step_multiplier));
}
while ((transform * ruler_transform).get_scale().x < 50 || (transform * ruler_transform).get_scale().y < 50) {
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 66e58339ed..2954071054 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -542,11 +542,11 @@ void CurveEditor::update_view_transform() {
const Vector2 scale = view_size / world_rect.size;
Transform2D world_trans;
- world_trans.translate(-world_rect.position - Vector2(0, world_rect.size.y));
+ world_trans.translate_local(-world_rect.position - Vector2(0, world_rect.size.y));
world_trans.scale(Vector2(scale.x, -scale.y));
Transform2D view_trans;
- view_trans.translate(view_margin);
+ view_trans.translate_local(view_margin);
_world_to_view = view_trans * world_trans;
}
diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp
index 77cf1f0064..1ac986ed36 100644
--- a/editor/plugins/node_3d_editor_gizmos.cpp
+++ b/editor/plugins/node_3d_editor_gizmos.cpp
@@ -5044,8 +5044,8 @@ Basis JointGizmosDrawer::look_body_toward_z(const Transform3D &p_joint_transform
void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform3D &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse) {
if (p_limit_lower == p_limit_upper) {
- r_points.push_back(p_offset.translated(Vector3()).origin);
- r_points.push_back(p_offset.translated(p_base.xform(Vector3(0.5, 0, 0))).origin);
+ r_points.push_back(p_offset.translated_local(Vector3()).origin);
+ r_points.push_back(p_offset.translated_local(p_base.xform(Vector3(0.5, 0, 0))).origin);
} else {
if (p_limit_lower > p_limit_upper) {
@@ -5087,20 +5087,20 @@ void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const
}
if (i == points - 1) {
- r_points.push_back(p_offset.translated(to).origin);
- r_points.push_back(p_offset.translated(Vector3()).origin);
+ r_points.push_back(p_offset.translated_local(to).origin);
+ r_points.push_back(p_offset.translated_local(Vector3()).origin);
}
if (i == 0) {
- r_points.push_back(p_offset.translated(from).origin);
- r_points.push_back(p_offset.translated(Vector3()).origin);
+ r_points.push_back(p_offset.translated_local(from).origin);
+ r_points.push_back(p_offset.translated_local(Vector3()).origin);
}
- r_points.push_back(p_offset.translated(from).origin);
- r_points.push_back(p_offset.translated(to).origin);
+ r_points.push_back(p_offset.translated_local(from).origin);
+ r_points.push_back(p_offset.translated_local(to).origin);
}
- r_points.push_back(p_offset.translated(Vector3(0, p_radius * 1.5, 0)).origin);
- r_points.push_back(p_offset.translated(Vector3()).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(0, p_radius * 1.5, 0)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3()).origin);
}
}
@@ -5116,17 +5116,17 @@ void JointGizmosDrawer::draw_cone(const Transform3D &p_offset, const Basis &p_ba
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w;
Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * w;
- r_points.push_back(p_offset.translated(p_base.xform(Vector3(d, a.x, a.y))).origin);
- r_points.push_back(p_offset.translated(p_base.xform(Vector3(d, b.x, b.y))).origin);
+ r_points.push_back(p_offset.translated_local(p_base.xform(Vector3(d, a.x, a.y))).origin);
+ r_points.push_back(p_offset.translated_local(p_base.xform(Vector3(d, b.x, b.y))).origin);
if (i % 90 == 0) {
- r_points.push_back(p_offset.translated(p_base.xform(Vector3(d, a.x, a.y))).origin);
- r_points.push_back(p_offset.translated(p_base.xform(Vector3())).origin);
+ r_points.push_back(p_offset.translated_local(p_base.xform(Vector3(d, a.x, a.y))).origin);
+ r_points.push_back(p_offset.translated_local(p_base.xform(Vector3())).origin);
}
}
- r_points.push_back(p_offset.translated(p_base.xform(Vector3())).origin);
- r_points.push_back(p_offset.translated(p_base.xform(Vector3(1, 0, 0))).origin);
+ r_points.push_back(p_offset.translated_local(p_base.xform(Vector3())).origin);
+ r_points.push_back(p_offset.translated_local(p_base.xform(Vector3(1, 0, 0))).origin);
/// Twist
float ts = Math::rad2deg(p_twist);
@@ -5140,8 +5140,8 @@ void JointGizmosDrawer::draw_cone(const Transform3D &p_offset, const Basis &p_ba
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w * c;
Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * w * cn;
- r_points.push_back(p_offset.translated(p_base.xform(Vector3(c, a.x, a.y))).origin);
- r_points.push_back(p_offset.translated(p_base.xform(Vector3(cn, b.x, b.y))).origin);
+ r_points.push_back(p_offset.translated_local(p_base.xform(Vector3(c, a.x, a.y))).origin);
+ r_points.push_back(p_offset.translated_local(p_base.xform(Vector3(cn, b.x, b.y))).origin);
}
}
@@ -5325,17 +5325,17 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
void Joint3DGizmoPlugin::CreatePinJointGizmo(const Transform3D &p_offset, Vector<Vector3> &r_cursor_points) {
float cs = 0.25;
- r_cursor_points.push_back(p_offset.translated(Vector3(+cs, 0, 0)).origin);
- r_cursor_points.push_back(p_offset.translated(Vector3(-cs, 0, 0)).origin);
- r_cursor_points.push_back(p_offset.translated(Vector3(0, +cs, 0)).origin);
- r_cursor_points.push_back(p_offset.translated(Vector3(0, -cs, 0)).origin);
- r_cursor_points.push_back(p_offset.translated(Vector3(0, 0, +cs)).origin);
- r_cursor_points.push_back(p_offset.translated(Vector3(0, 0, -cs)).origin);
+ r_cursor_points.push_back(p_offset.translated_local(Vector3(+cs, 0, 0)).origin);
+ r_cursor_points.push_back(p_offset.translated_local(Vector3(-cs, 0, 0)).origin);
+ r_cursor_points.push_back(p_offset.translated_local(Vector3(0, +cs, 0)).origin);
+ r_cursor_points.push_back(p_offset.translated_local(Vector3(0, -cs, 0)).origin);
+ r_cursor_points.push_back(p_offset.translated_local(Vector3(0, 0, +cs)).origin);
+ r_cursor_points.push_back(p_offset.translated_local(Vector3(0, 0, -cs)).origin);
}
void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
- r_common_points.push_back(p_offset.translated(Vector3(0, 0, 0.5)).origin);
- r_common_points.push_back(p_offset.translated(Vector3(0, 0, -0.5)).origin);
+ r_common_points.push_back(p_offset.translated_local(Vector3(0, 0, 0.5)).origin);
+ r_common_points.push_back(p_offset.translated_local(Vector3(0, 0, -0.5)).origin);
if (!p_use_limit) {
p_limit_upper = -1;
@@ -5368,34 +5368,34 @@ void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform3D &p_offset, con
p_linear_limit_upper = -p_linear_limit_upper;
float cs = 0.25;
- r_points.push_back(p_offset.translated(Vector3(0, 0, 0.5)).origin);
- r_points.push_back(p_offset.translated(Vector3(0, 0, -0.5)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(0, 0, 0.5)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(0, 0, -0.5)).origin);
if (p_linear_limit_lower >= p_linear_limit_upper) {
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_upper, 0, 0)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, 0, 0)).origin);
-
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_upper, -cs, -cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_upper, -cs, cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_upper, -cs, cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_upper, cs, cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_upper, cs, cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_upper, cs, -cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_upper, cs, -cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_upper, -cs, -cs)).origin);
-
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, -cs, -cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, -cs, cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, -cs, cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, cs, cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, cs, cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, cs, -cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, cs, -cs)).origin);
- r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, -cs, -cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_upper, 0, 0)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_lower, 0, 0)).origin);
+
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_upper, -cs, -cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_upper, -cs, cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_upper, -cs, cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_upper, cs, cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_upper, cs, cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_upper, cs, -cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_upper, cs, -cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_upper, -cs, -cs)).origin);
+
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_lower, -cs, -cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_lower, -cs, cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_lower, -cs, cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_lower, cs, cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_lower, cs, cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_lower, cs, -cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_lower, cs, -cs)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(p_linear_limit_lower, -cs, -cs)).origin);
} else {
- r_points.push_back(p_offset.translated(Vector3(+cs * 2, 0, 0)).origin);
- r_points.push_back(p_offset.translated(Vector3(-cs * 2, 0, 0)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(+cs * 2, 0, 0)).origin);
+ r_points.push_back(p_offset.translated_local(Vector3(-cs * 2, 0, 0)).origin);
}
if (r_body_a_points) {
@@ -5518,13 +5518,13 @@ void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
break;
}
-#define ADD_VTX(x, y, z) \
- { \
- Vector3 v; \
- v[a1] = (x); \
- v[a2] = (y); \
- v[a3] = (z); \
- r_points.push_back(p_offset.translated(v).origin); \
+#define ADD_VTX(x, y, z) \
+ { \
+ Vector3 v; \
+ v[a1] = (x); \
+ v[a2] = (y); \
+ v[a3] = (z); \
+ r_points.push_back(p_offset.translated_local(v).origin); \
}
if (enable_lin && lll >= lul) {
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 44ab4e0a41..ffc60f9664 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -356,14 +356,14 @@ void Node3DEditorViewport::_update_camera(real_t p_interp_delta) {
Transform3D Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) const {
Transform3D camera_transform;
- camera_transform.translate(p_cursor.pos);
+ camera_transform.translate_local(p_cursor.pos);
camera_transform.basis.rotate(Vector3(1, 0, 0), -p_cursor.x_rot);
camera_transform.basis.rotate(Vector3(0, 1, 0), -p_cursor.y_rot);
if (orthogonal) {
- camera_transform.translate(0, 0, (get_zfar() - get_znear()) / 2.0);
+ camera_transform.translate_local(0, 0, (get_zfar() - get_znear()) / 2.0);
} else {
- camera_transform.translate(0, 0, p_cursor.distance);
+ camera_transform.translate_local(0, 0, p_cursor.distance);
}
return camera_transform;
@@ -515,7 +515,7 @@ void Node3DEditorViewport::_select_clicked(bool p_allow_locked) {
}
}
-ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos) {
+ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos) const {
Vector3 ray = _get_ray(p_pos);
Vector3 pos = _get_ray_pos(p_pos);
Vector2 shrinked_pos = p_pos / subviewport_container->get_stretch_shrink();
@@ -651,10 +651,10 @@ Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
Vector2 screen_he = cm.get_viewport_half_extents();
Transform3D camera_transform;
- camera_transform.translate(cursor.pos);
+ camera_transform.translate_local(cursor.pos);
camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot);
camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot);
- camera_transform.translate(0, 0, cursor.distance);
+ camera_transform.translate_local(0, 0, cursor.distance);
return camera_transform.xform(Vector3(((p_vector3.x / get_size().width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (p_vector3.y / get_size().height)) * 2.0 - 1.0) * screen_he.y, -(get_znear() + p_vector3.z)));
}
@@ -1260,7 +1260,9 @@ void Node3DEditorViewport::_surface_mouse_enter() {
}
void Node3DEditorViewport::_surface_mouse_exit() {
- _remove_preview();
+ _remove_preview_node();
+ _reset_preview_material();
+ _remove_preview_material();
}
void Node3DEditorViewport::_surface_focus_enter() {
@@ -2100,7 +2102,7 @@ void Node3DEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const
Transform3D camera_transform;
- camera_transform.translate(cursor.pos);
+ camera_transform.translate_local(cursor.pos);
camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot);
camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot);
const bool invert_x_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_x_axis");
@@ -2110,7 +2112,7 @@ void Node3DEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const
(invert_y_axis ? -1 : 1) * p_relative.y * pan_speed,
0);
translation *= cursor.distance / DISTANCE_DEFAULT;
- camera_transform.translate(translation);
+ camera_transform.translate_local(translation);
cursor.pos = camera_transform.origin;
}
@@ -2423,8 +2425,8 @@ void Node3DEditorViewport::_project_settings_changed() {
const float fsr_sharpness = GLOBAL_GET("rendering/scaling_3d/fsr_sharpness");
viewport->set_fsr_sharpness(fsr_sharpness);
- const float fsr_mipmap_bias = GLOBAL_GET("rendering/scaling_3d/fsr_mipmap_bias");
- viewport->set_fsr_mipmap_bias(fsr_mipmap_bias);
+ const float texture_mipmap_bias = GLOBAL_GET("rendering/textures/default_filters/texture_mipmap_bias");
+ viewport->set_texture_mipmap_bias(texture_mipmap_bias);
}
void Node3DEditorViewport::_notification(int p_what) {
@@ -2520,14 +2522,14 @@ void Node3DEditorViewport::_notification(int p_what) {
const Vector3 offset(0.005, 0.005, 0.005);
Basis aabb_s;
aabb_s.scale(se->aabb.size + offset);
- t.translate(se->aabb.position - offset / 2);
+ t.translate_local(se->aabb.position - offset / 2);
t.basis = t.basis * aabb_s;
}
{
const Vector3 offset(0.01, 0.01, 0.01);
Basis aabb_s;
aabb_s.scale(se->aabb.size + offset);
- t_offset.translate(se->aabb.position - offset / 2);
+ t_offset.translate_local(se->aabb.position - offset / 2);
t_offset.basis = t_offset.basis * aabb_s;
}
@@ -2703,6 +2705,13 @@ void Node3DEditorViewport::_notification(int p_what) {
cinema_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
locked_label->add_theme_style_override("normal", gui_base->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
} break;
+
+ case NOTIFICATION_DRAG_END: {
+ // Clear preview material when dropped outside applicable object.
+ if (spatial_editor->get_preview_material().is_valid() && !is_drag_successful()) {
+ _remove_preview_material();
+ }
+ } break;
}
}
@@ -3794,7 +3803,7 @@ Node *Node3DEditorViewport::_sanitize_preview_node(Node *p_node) const {
return p_node;
}
-void Node3DEditorViewport::_create_preview(const Vector<String> &files) const {
+void Node3DEditorViewport::_create_preview_node(const Vector<String> &files) const {
for (int i = 0; i < files.size(); i++) {
String path = files[i];
Ref<Resource> res = ResourceLoader::load(path);
@@ -3821,7 +3830,7 @@ void Node3DEditorViewport::_create_preview(const Vector<String> &files) const {
*preview_bounds = _calculate_spatial_bounds(preview_node);
}
-void Node3DEditorViewport::_remove_preview() {
+void Node3DEditorViewport::_remove_preview_node() {
if (preview_node->get_parent()) {
for (int i = preview_node->get_child_count() - 1; i >= 0; i--) {
Node *node = preview_node->get_child(i);
@@ -3832,6 +3841,106 @@ void Node3DEditorViewport::_remove_preview() {
}
}
+bool Node3DEditorViewport::_apply_preview_material(ObjectID p_target, const Point2 &p_point) const {
+ _reset_preview_material();
+
+ if (p_target.is_null()) {
+ return false;
+ }
+
+ spatial_editor->set_preview_material_target(p_target);
+
+ Object *target_inst = ObjectDB::get_instance(p_target);
+
+ bool is_ctrl = Input::get_singleton()->is_key_pressed(Key::CTRL);
+
+ MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(target_inst);
+ if (is_ctrl && mesh_instance) {
+ Ref<Mesh> mesh = mesh_instance->get_mesh();
+ int surface_count = mesh->get_surface_count();
+
+ Vector3 world_ray = _get_ray(p_point);
+ Vector3 world_pos = _get_ray_pos(p_point);
+
+ int closest_surface = -1;
+ float closest_dist = 1e20;
+
+ Transform3D gt = mesh_instance->get_global_transform();
+
+ Transform3D ai = gt.affine_inverse();
+ Vector3 xform_ray = ai.basis.xform(world_ray).normalized();
+ Vector3 xform_pos = ai.xform(world_pos);
+
+ for (int surface = 0; surface < surface_count; surface++) {
+ Ref<TriangleMesh> surface_mesh = mesh->generate_surface_triangle_mesh(surface);
+
+ Vector3 rpos, rnorm;
+ if (surface_mesh->intersect_ray(xform_pos, xform_ray, rpos, rnorm)) {
+ Vector3 hitpos = gt.xform(rpos);
+
+ const real_t dist = world_pos.distance_to(hitpos);
+
+ if (dist < 0) {
+ continue;
+ }
+
+ if (dist < closest_dist) {
+ closest_surface = surface;
+ closest_dist = dist;
+ }
+ }
+ }
+
+ if (closest_surface == -1) {
+ return false;
+ }
+
+ if (spatial_editor->get_preview_material() != mesh_instance->get_surface_override_material(closest_surface)) {
+ spatial_editor->set_preview_material_surface(closest_surface);
+ spatial_editor->set_preview_reset_material(mesh_instance->get_surface_override_material(closest_surface));
+ mesh_instance->set_surface_override_material(closest_surface, spatial_editor->get_preview_material());
+ }
+
+ return true;
+ }
+
+ GeometryInstance3D *geometry_instance = Object::cast_to<GeometryInstance3D>(target_inst);
+ if (geometry_instance && spatial_editor->get_preview_material() != geometry_instance->get_material_override()) {
+ spatial_editor->set_preview_reset_material(geometry_instance->get_material_override());
+ geometry_instance->set_material_override(spatial_editor->get_preview_material());
+ return true;
+ }
+
+ return false;
+}
+
+void Node3DEditorViewport::_reset_preview_material() const {
+ ObjectID last_target = spatial_editor->get_preview_material_target();
+ if (last_target.is_null()) {
+ return;
+ }
+ Object *last_target_inst = ObjectDB::get_instance(last_target);
+
+ MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(last_target_inst);
+ GeometryInstance3D *geometry_instance = Object::cast_to<GeometryInstance3D>(last_target_inst);
+ if (mesh_instance && spatial_editor->get_preview_material_surface() != -1) {
+ mesh_instance->set_surface_override_material(spatial_editor->get_preview_material_surface(), spatial_editor->get_preview_reset_material());
+ spatial_editor->set_preview_material_surface(-1);
+ } else if (geometry_instance) {
+ geometry_instance->set_material_override(spatial_editor->get_preview_reset_material());
+ }
+}
+
+void Node3DEditorViewport::_remove_preview_material() {
+ preview_material_label->hide();
+ preview_material_label_desc->hide();
+
+ spatial_editor->set_preview_material(Ref<Material>());
+ spatial_editor->set_preview_reset_material(Ref<Material>());
+ spatial_editor->set_preview_material_target(ObjectID());
+ spatial_editor->set_preview_material_surface(-1);
+}
+
bool Node3DEditorViewport::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
if (p_desired_node->get_scene_file_path() == p_target_scene_path) {
return true;
@@ -3930,7 +4039,26 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po
}
void Node3DEditorViewport::_perform_drop_data() {
- _remove_preview();
+ if (spatial_editor->get_preview_material_target().is_valid()) {
+ GeometryInstance3D *geometry_instance = Object::cast_to<GeometryInstance3D>(ObjectDB::get_instance(spatial_editor->get_preview_material_target()));
+ MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(ObjectDB::get_instance(spatial_editor->get_preview_material_target()));
+ if (mesh_instance && spatial_editor->get_preview_material_surface() != -1) {
+ editor_data->get_undo_redo().create_action(vformat(TTR("Set Surface %d Override Material"), spatial_editor->get_preview_material_surface()));
+ editor_data->get_undo_redo().add_do_method(geometry_instance, "set_surface_override_material", spatial_editor->get_preview_material_surface(), spatial_editor->get_preview_material());
+ editor_data->get_undo_redo().add_undo_method(geometry_instance, "set_surface_override_material", spatial_editor->get_preview_material_surface(), spatial_editor->get_preview_reset_material());
+ editor_data->get_undo_redo().commit_action();
+ } else if (geometry_instance) {
+ editor_data->get_undo_redo().create_action(TTR("Set Material Override"));
+ editor_data->get_undo_redo().add_do_method(geometry_instance, "set_material_override", spatial_editor->get_preview_material());
+ editor_data->get_undo_redo().add_undo_method(geometry_instance, "set_material_override", spatial_editor->get_preview_reset_material());
+ editor_data->get_undo_redo().commit_action();
+ }
+
+ _remove_preview_material();
+ return;
+ }
+
+ _remove_preview_node();
Vector<String> error_files;
@@ -3968,7 +4096,7 @@ void Node3DEditorViewport::_perform_drop_data() {
bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
bool can_instantiate = false;
- if (!preview_node->is_inside_tree()) {
+ if (!preview_node->is_inside_tree() && spatial_editor->get_preview_material().is_null()) {
Dictionary d = p_data;
if (d.has("type") && (String(d["type"]) == "files")) {
Vector<String> files = d["files"];
@@ -3977,40 +4105,78 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
List<String> mesh_extensions;
ResourceLoader::get_recognized_extensions_for_type("Mesh", &mesh_extensions);
+ List<String> material_extensions;
+ ResourceLoader::get_recognized_extensions_for_type("Material", &material_extensions);
+ List<String> texture_extensions;
+ ResourceLoader::get_recognized_extensions_for_type("Texture", &texture_extensions);
for (int i = 0; i < files.size(); i++) {
// Check if dragged files with mesh or scene extension can be created at least once.
- if (mesh_extensions.find(files[i].get_extension()) || scene_extensions.find(files[i].get_extension())) {
+ if (mesh_extensions.find(files[i].get_extension()) ||
+ scene_extensions.find(files[i].get_extension()) ||
+ material_extensions.find(files[i].get_extension()) ||
+ texture_extensions.find(files[i].get_extension())) {
Ref<Resource> res = ResourceLoader::load(files[i]);
if (res.is_null()) {
continue;
}
Ref<PackedScene> scn = res;
+ Ref<Material> mat = res;
+ Ref<Texture2D> tex = res;
if (scn.is_valid()) {
Node *instantiated_scene = scn->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!instantiated_scene) {
continue;
}
memdelete(instantiated_scene);
+ } else if (mat.is_valid()) {
+ Ref<BaseMaterial3D> base_mat = res;
+ Ref<ShaderMaterial> shader_mat = res;
+
+ if (base_mat.is_null() && !shader_mat.is_null()) {
+ break;
+ }
+
+ spatial_editor->set_preview_material(mat);
+ break;
+ } else if (tex.is_valid()) {
+ Ref<StandardMaterial3D> new_mat = memnew(StandardMaterial3D);
+ new_mat->set_texture(BaseMaterial3D::TEXTURE_ALBEDO, tex);
+
+ spatial_editor->set_preview_material(new_mat);
+ break;
+ } else {
+ continue;
}
can_instantiate = true;
break;
}
}
if (can_instantiate) {
- _create_preview(files);
+ _create_preview_node(files);
}
}
} else {
- can_instantiate = true;
+ if (preview_node->is_inside_tree()) {
+ can_instantiate = true;
+ }
}
if (can_instantiate) {
Transform3D global_transform = Transform3D(Basis(), _get_instance_position(p_point));
preview_node->set_global_transform(global_transform);
+ return true;
+ }
+
+ if (spatial_editor->get_preview_material().is_valid()) {
+ preview_material_label->show();
+ preview_material_label_desc->show();
+
+ ObjectID new_preview_material_target = _select_ray(p_point);
+ return _apply_preview_material(new_preview_material_target, p_point);
}
- return can_instantiate;
+ return false;
}
void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
@@ -4048,7 +4214,7 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_
} else {
accept->set_text(TTR("Cannot drag and drop into multiple selected nodes."));
accept->popup_centered();
- _remove_preview();
+ _remove_preview_node();
return;
}
@@ -4699,6 +4865,23 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
zoom_limit_label->hide();
surface->add_child(zoom_limit_label);
+ preview_material_label = memnew(Label);
+ preview_material_label->set_anchors_and_offsets_preset(LayoutPreset::PRESET_BOTTOM_LEFT);
+ preview_material_label->set_offset(Side::SIDE_TOP, -70 * EDSCALE);
+ preview_material_label->set_text(TTR("Overriding material..."));
+ preview_material_label->add_theme_color_override("font_color", Color(1, 1, 1, 1));
+ preview_material_label->hide();
+ surface->add_child(preview_material_label);
+
+ preview_material_label_desc = memnew(Label);
+ preview_material_label_desc->set_anchors_and_offsets_preset(LayoutPreset::PRESET_BOTTOM_LEFT);
+ preview_material_label_desc->set_offset(Side::SIDE_TOP, -50 * EDSCALE);
+ preview_material_label_desc->set_text(TTR("Drag and drop to override the material of any geometry node.\nHold Ctrl when dropping to override a specific surface."));
+ preview_material_label_desc->add_theme_color_override("font_color", Color(0.8, 0.8, 0.8, 1));
+ preview_material_label_desc->add_theme_constant_override("line_spacing", 0);
+ preview_material_label_desc->hide();
+ surface->add_child(preview_material_label_desc);
+
frame_time_gradient = memnew(Gradient);
// The color is set when the theme changes.
frame_time_gradient->add_point(0.5, Color());
@@ -8140,7 +8323,6 @@ void fragment() {
_preview_settings_changed();
}
}
-
Node3DEditor::~Node3DEditor() {
memdelete(preview_node);
}
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 244b461e16..4469271a38 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -227,6 +227,9 @@ private:
Label *locked_label = nullptr;
Label *zoom_limit_label = nullptr;
+ Label *preview_material_label = nullptr;
+ Label *preview_material_label_desc = nullptr;
+
VBoxContainer *top_right_vbox = nullptr;
ViewportRotationControl *rotation_control = nullptr;
Gradient *frame_time_gradient = nullptr;
@@ -244,7 +247,7 @@ private:
void _compute_edit(const Point2 &p_point);
void _clear_selected();
void _select_clicked(bool p_allow_locked);
- ObjectID _select_ray(const Point2 &p_pos);
+ ObjectID _select_ray(const Point2 &p_pos) const;
void _find_items_at_pos(const Point2 &p_pos, Vector<_RayResult> &r_results, bool p_include_locked);
Vector3 _get_ray_pos(const Vector2 &p_pos) const;
Vector3 _get_ray(const Vector2 &p_pos) const;
@@ -272,6 +275,7 @@ private:
float get_fov() const;
ObjectID clicked;
+ ObjectID material_target;
Vector<_RayResult> selection_results;
bool clicked_wants_append = false;
bool selection_in_progress = false;
@@ -399,8 +403,11 @@ private:
Node *_sanitize_preview_node(Node *p_node) const;
- void _create_preview(const Vector<String> &files) const;
- void _remove_preview();
+ void _create_preview_node(const Vector<String> &files) const;
+ void _remove_preview_node();
+ bool _apply_preview_material(ObjectID p_target, const Point2 &p_point) const;
+ void _reset_preview_material() const;
+ void _remove_preview_material();
bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
bool _create_instance(Node *parent, String &path, const Point2 &p_point);
void _perform_drop_data();
@@ -593,6 +600,11 @@ private:
Node3D *preview_node = nullptr;
AABB preview_bounds;
+ Ref<Material> preview_material;
+ Ref<Material> preview_reset_material;
+ ObjectID preview_material_target;
+ int preview_material_surface = -1;
+
struct Gizmo {
bool visible = false;
real_t scale = 0;
@@ -850,6 +862,15 @@ public:
void set_can_preview(Camera3D *p_preview);
+ void set_preview_material(Ref<Material> p_material) { preview_material = p_material; }
+ Ref<Material> get_preview_material() { return preview_material; }
+ void set_preview_reset_material(Ref<Material> p_material) { preview_reset_material = p_material; }
+ Ref<Material> get_preview_reset_material() const { return preview_reset_material; }
+ void set_preview_material_target(ObjectID p_object_id) { preview_material_target = p_object_id; }
+ ObjectID get_preview_material_target() const { return preview_material_target; }
+ void set_preview_material_surface(int p_surface) { preview_material_surface = p_surface; }
+ int get_preview_material_surface() const { return preview_material_surface; }
+
Node3DEditorViewport *get_editor_viewport(int p_idx) {
ERR_FAIL_INDEX_V(p_idx, static_cast<int>(VIEWPORTS_COUNT), nullptr);
return viewports[p_idx];
diff --git a/editor/plugins/replication_editor_plugin.cpp b/editor/plugins/replication_editor_plugin.cpp
deleted file mode 100644
index 3e06a6739f..0000000000
--- a/editor/plugins/replication_editor_plugin.cpp
+++ /dev/null
@@ -1,645 +0,0 @@
-/*************************************************************************/
-/* replication_editor_plugin.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* 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 "replication_editor_plugin.h"
-
-#include "editor/editor_node.h"
-#include "editor/editor_scale.h"
-#include "editor/inspector_dock.h"
-#include "scene/gui/dialogs.h"
-#include "scene/gui/tree.h"
-#include "scene/multiplayer/multiplayer_synchronizer.h"
-
-void ReplicationEditor::_pick_node_filter_text_changed(const String &p_newtext) {
- TreeItem *root_item = pick_node->get_scene_tree()->get_scene_tree()->get_root();
-
- Vector<Node *> select_candidates;
- Node *to_select = nullptr;
-
- String filter = pick_node->get_filter_line_edit()->get_text();
-
- _pick_node_select_recursive(root_item, filter, select_candidates);
-
- if (!select_candidates.is_empty()) {
- for (int i = 0; i < select_candidates.size(); ++i) {
- Node *candidate = select_candidates[i];
-
- if (((String)candidate->get_name()).to_lower().begins_with(filter.to_lower())) {
- to_select = candidate;
- break;
- }
- }
-
- if (!to_select) {
- to_select = select_candidates[0];
- }
- }
-
- pick_node->get_scene_tree()->set_selected(to_select);
-}
-
-void ReplicationEditor::_pick_node_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates) {
- if (!p_item) {
- return;
- }
-
- NodePath np = p_item->get_metadata(0);
- Node *node = get_node(np);
-
- if (!p_filter.is_empty() && ((String)node->get_name()).findn(p_filter) != -1) {
- p_select_candidates.push_back(node);
- }
-
- TreeItem *c = p_item->get_first_child();
-
- while (c) {
- _pick_node_select_recursive(c, p_filter, p_select_candidates);
- c = c->get_next();
- }
-}
-
-void ReplicationEditor::_pick_node_filter_input(const Ref<InputEvent> &p_ie) {
- Ref<InputEventKey> k = p_ie;
-
- if (k.is_valid()) {
- switch (k->get_keycode()) {
- case Key::UP:
- case Key::DOWN:
- case Key::PAGEUP:
- case Key::PAGEDOWN: {
- pick_node->get_scene_tree()->get_scene_tree()->gui_input(k);
- pick_node->get_filter_line_edit()->accept_event();
- } break;
- default:
- break;
- }
- }
-}
-
-void ReplicationEditor::_pick_node_selected(NodePath p_path) {
- Node *root = current->get_node(current->get_root_path());
- ERR_FAIL_COND(!root);
- Node *node = get_node(p_path);
- ERR_FAIL_COND(!node);
- NodePath path_to = root->get_path_to(node);
- adding_node_path = path_to;
- prop_selector->select_property_from_instance(node);
-}
-
-void ReplicationEditor::_pick_new_property() {
- if (current == nullptr) {
- EditorNode::get_singleton()->show_warning(TTR("Select a replicator node in order to pick a property to add to it."));
- return;
- }
- Node *root = current->get_node(current->get_root_path());
- if (!root) {
- EditorNode::get_singleton()->show_warning(TTR("Not possible to add a new property to synchronize without a root."));
- return;
- }
- pick_node->popup_scenetree_dialog();
- pick_node->get_filter_line_edit()->clear();
- pick_node->get_filter_line_edit()->grab_focus();
-}
-
-void ReplicationEditor::_add_sync_property(String p_path) {
- config = current->get_replication_config();
-
- if (config.is_valid() && config->has_property(p_path)) {
- EditorNode::get_singleton()->show_warning(TTR("Property is already being synchronized."));
- return;
- }
-
- UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
- undo_redo->create_action(TTR("Add property to synchronizer"));
-
- if (config.is_null()) {
- config.instantiate();
- current->set_replication_config(config);
- undo_redo->add_do_method(current, "set_replication_config", config);
- undo_redo->add_undo_method(current, "set_replication_config", Ref<SceneReplicationConfig>());
- _update_config();
- }
-
- undo_redo->add_do_method(config.ptr(), "add_property", p_path);
- undo_redo->add_undo_method(config.ptr(), "remove_property", p_path);
- undo_redo->add_do_method(this, "_update_config");
- undo_redo->add_undo_method(this, "_update_config");
- undo_redo->commit_action();
-}
-
-void ReplicationEditor::_pick_node_property_selected(String p_name) {
- String adding_prop_path = String(adding_node_path) + ":" + p_name;
-
- _add_sync_property(adding_prop_path);
-}
-
-/// ReplicationEditor
-ReplicationEditor::ReplicationEditor() {
- set_v_size_flags(SIZE_EXPAND_FILL);
- set_custom_minimum_size(Size2(0, 200) * EDSCALE);
-
- delete_dialog = memnew(ConfirmationDialog);
- delete_dialog->connect("cancelled", callable_mp(this, &ReplicationEditor::_dialog_closed), varray(false));
- delete_dialog->connect("confirmed", callable_mp(this, &ReplicationEditor::_dialog_closed), varray(true));
- add_child(delete_dialog);
-
- error_dialog = memnew(AcceptDialog);
- error_dialog->set_ok_button_text(TTR("Close"));
- error_dialog->set_title(TTR("Error!"));
- add_child(error_dialog);
-
- VBoxContainer *vb = memnew(VBoxContainer);
- vb->set_v_size_flags(SIZE_EXPAND_FILL);
- add_child(vb);
-
- pick_node = memnew(SceneTreeDialog);
- add_child(pick_node);
- pick_node->register_text_enter(pick_node->get_filter_line_edit());
- pick_node->set_title(TTR("Pick a node to synchronize:"));
- pick_node->connect("selected", callable_mp(this, &ReplicationEditor::_pick_node_selected));
- pick_node->get_filter_line_edit()->connect("text_changed", callable_mp(this, &ReplicationEditor::_pick_node_filter_text_changed));
- pick_node->get_filter_line_edit()->connect("gui_input", callable_mp(this, &ReplicationEditor::_pick_node_filter_input));
-
- prop_selector = memnew(PropertySelector);
- add_child(prop_selector);
- prop_selector->connect("selected", callable_mp(this, &ReplicationEditor::_pick_node_property_selected));
-
- HBoxContainer *hb = memnew(HBoxContainer);
- vb->add_child(hb);
-
- add_pick_button = memnew(Button);
- add_pick_button->connect("pressed", callable_mp(this, &ReplicationEditor::_pick_new_property));
- add_pick_button->set_text(TTR("Add property to sync.."));
- hb->add_child(add_pick_button);
- VSeparator *vs = memnew(VSeparator);
- vs->set_custom_minimum_size(Size2(30 * EDSCALE, 0));
- hb->add_child(vs);
- hb->add_child(memnew(Label(TTR("Path:"))));
- np_line_edit = memnew(LineEdit);
- np_line_edit->set_placeholder(":property");
- np_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
- hb->add_child(np_line_edit);
- add_from_path_button = memnew(Button);
- add_from_path_button->connect("pressed", callable_mp(this, &ReplicationEditor::_add_pressed));
- add_from_path_button->set_text(TTR("Add from path"));
- hb->add_child(add_from_path_button);
- vs = memnew(VSeparator);
- vs->set_custom_minimum_size(Size2(30 * EDSCALE, 0));
- hb->add_child(vs);
- pin = memnew(Button);
- pin->set_flat(true);
- pin->set_toggle_mode(true);
- hb->add_child(pin);
-
- tree = memnew(Tree);
- tree->set_hide_root(true);
- tree->set_columns(4);
- tree->set_column_titles_visible(true);
- tree->set_column_title(0, TTR("Properties"));
- tree->set_column_expand(0, true);
- tree->set_column_title(1, TTR("Spawn"));
- tree->set_column_expand(1, false);
- tree->set_column_custom_minimum_width(1, 100);
- tree->set_column_title(2, TTR("Sync"));
- tree->set_column_custom_minimum_width(2, 100);
- tree->set_column_expand(2, false);
- tree->set_column_expand(3, false);
- tree->create_item();
- tree->connect("button_clicked", callable_mp(this, &ReplicationEditor::_tree_button_pressed));
- tree->connect("item_edited", callable_mp(this, &ReplicationEditor::_tree_item_edited));
- tree->set_v_size_flags(SIZE_EXPAND_FILL);
- vb->add_child(tree);
-
- drop_label = memnew(Label);
- drop_label->set_text(TTR("Add properties using the buttons above or\ndrag them them from the inspector and drop them here."));
- drop_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
- drop_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
- tree->add_child(drop_label);
- drop_label->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
-
- tree->set_drag_forwarding(this);
-}
-
-void ReplicationEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_update_config"), &ReplicationEditor::_update_config);
- ClassDB::bind_method(D_METHOD("_update_checked", "property", "column", "checked"), &ReplicationEditor::_update_checked);
- ClassDB::bind_method("_can_drop_data_fw", &ReplicationEditor::_can_drop_data_fw);
- ClassDB::bind_method("_drop_data_fw", &ReplicationEditor::_drop_data_fw);
-
- ADD_SIGNAL(MethodInfo("keying_changed"));
-}
-
-bool ReplicationEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
- Dictionary d = p_data;
- if (!d.has("type")) {
- return false;
- }
- String t = d["type"];
- if (t != "obj_property") {
- return false;
- }
- Object *obj = d["object"];
- if (!obj) {
- return false;
- }
- Node *node = Object::cast_to<Node>(obj);
- if (!node) {
- return false;
- }
-
- return true;
-}
-
-void ReplicationEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
- if (current == nullptr) {
- EditorNode::get_singleton()->show_warning(TTR("Select a replicator node in order to pick a property to add to it."));
- return;
- }
- Node *root = current->get_node(current->get_root_path());
- if (!root) {
- EditorNode::get_singleton()->show_warning(TTR("Not possible to add a new property to synchronize without a root."));
- return;
- }
-
- Dictionary d = p_data;
- if (!d.has("type")) {
- return;
- }
- String t = d["type"];
- if (t != "obj_property") {
- return;
- }
- Object *obj = d["object"];
- if (!obj) {
- return;
- }
- Node *node = Object::cast_to<Node>(obj);
- if (!node) {
- return;
- }
-
- String path = root->get_path_to(node);
- path += ":" + String(d["property"]);
-
- _add_sync_property(path);
-}
-
-void ReplicationEditor::_notification(int p_what) {
- switch (p_what) {
- case NOTIFICATION_ENTER_TREE:
- case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel")));
- add_pick_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- pin->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")));
- } break;
-
- case NOTIFICATION_VISIBILITY_CHANGED: {
- update_keying();
- } break;
- }
-}
-
-void ReplicationEditor::_add_pressed() {
- if (!current) {
- error_dialog->set_text(TTR("Please select a MultiplayerSynchronizer first."));
- error_dialog->popup_centered();
- return;
- }
- if (current->get_root_path().is_empty()) {
- error_dialog->set_text(TTR("The MultiplayerSynchronizer needs a root path."));
- error_dialog->popup_centered();
- return;
- }
- String np_text = np_line_edit->get_text();
- if (np_text.find(":") == -1) {
- np_text = ":" + np_text;
- }
- NodePath prop = NodePath(np_text);
- if (prop.is_empty()) {
- return;
- }
- UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
- undo_redo->create_action(TTR("Add property"));
- config = current->get_replication_config();
- if (config.is_null()) {
- config.instantiate();
- current->set_replication_config(config);
- undo_redo->add_do_method(current, "set_replication_config", config);
- undo_redo->add_undo_method(current, "set_replication_config", Ref<SceneReplicationConfig>());
- _update_config();
- }
- undo_redo->add_do_method(config.ptr(), "add_property", prop);
- undo_redo->add_undo_method(config.ptr(), "remove_property", prop);
- undo_redo->add_do_method(this, "_update_config");
- undo_redo->add_undo_method(this, "_update_config");
- undo_redo->commit_action();
-}
-
-void ReplicationEditor::_tree_item_edited() {
- TreeItem *ti = tree->get_edited();
- if (!ti || config.is_null()) {
- return;
- }
- int column = tree->get_edited_column();
- ERR_FAIL_COND(column < 1 || column > 2);
- const NodePath prop = ti->get_metadata(0);
- UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
- bool value = ti->is_checked(column);
- String method;
- if (column == 1) {
- undo_redo->create_action(TTR("Set spawn property"));
- method = "property_set_spawn";
- } else {
- undo_redo->create_action(TTR("Set sync property"));
- method = "property_set_sync";
- }
- undo_redo->add_do_method(config.ptr(), method, prop, value);
- undo_redo->add_undo_method(config.ptr(), method, prop, !value);
- undo_redo->add_do_method(this, "_update_checked", prop, column, value);
- undo_redo->add_undo_method(this, "_update_checked", prop, column, !value);
- undo_redo->commit_action();
-}
-
-void ReplicationEditor::_tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) {
- if (p_button != MouseButton::LEFT) {
- return;
- }
-
- TreeItem *ti = Object::cast_to<TreeItem>(p_item);
- if (!ti) {
- return;
- }
- deleting = ti->get_metadata(0);
- delete_dialog->set_text(TTR("Delete Property?") + "\n\"" + ti->get_text(0) + "\"");
- delete_dialog->popup_centered();
-}
-
-void ReplicationEditor::_dialog_closed(bool p_confirmed) {
- if (deleting.is_empty() || config.is_null()) {
- return;
- }
- if (p_confirmed) {
- const NodePath prop = deleting;
- int idx = config->property_get_index(prop);
- bool spawn = config->property_get_spawn(prop);
- bool sync = config->property_get_sync(prop);
- UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
- undo_redo->create_action(TTR("Remove Property"));
- undo_redo->add_do_method(config.ptr(), "remove_property", prop);
- undo_redo->add_undo_method(config.ptr(), "add_property", prop, idx);
- undo_redo->add_undo_method(config.ptr(), "property_set_spawn", prop, spawn);
- undo_redo->add_undo_method(config.ptr(), "property_set_sync", prop, sync);
- undo_redo->add_do_method(this, "_update_config");
- undo_redo->add_undo_method(this, "_update_config");
- undo_redo->commit_action();
- }
- deleting = NodePath();
-}
-
-void ReplicationEditor::_update_checked(const NodePath &p_prop, int p_column, bool p_checked) {
- if (!tree->get_root()) {
- return;
- }
- TreeItem *ti = tree->get_root()->get_first_child();
- while (ti) {
- if (ti->get_metadata(0).operator NodePath() == p_prop) {
- ti->set_checked(p_column, p_checked);
- return;
- }
- ti = ti->get_next();
- }
-}
-
-void ReplicationEditor::update_keying() {
- /// TODO make keying usable.
-#if 0
- bool keying_enabled = false;
- EditorSelectionHistory *editor_history = EditorNode::get_singleton()->get_editor_selection_history();
- if (is_visible_in_tree() && config.is_valid() && editor_history->get_path_size() > 0) {
- Object *obj = ObjectDB::get_instance(editor_history->get_path_object(0));
- keying_enabled = Object::cast_to<Node>(obj) != nullptr;
- }
-
- if (keying_enabled == keying) {
- return;
- }
-
- keying = keying_enabled;
- emit_signal(SNAME("keying_changed"));
-#endif
-}
-
-void ReplicationEditor::_update_config() {
- deleting = NodePath();
- tree->clear();
- tree->create_item();
- drop_label->set_visible(true);
- if (!config.is_valid()) {
- update_keying();
- return;
- }
- TypedArray<NodePath> props = config->get_properties();
- if (props.size()) {
- drop_label->set_visible(false);
- }
- for (int i = 0; i < props.size(); i++) {
- const NodePath path = props[i];
- _add_property(path, config->property_get_spawn(path), config->property_get_sync(path));
- }
- update_keying();
-}
-
-void ReplicationEditor::edit(MultiplayerSynchronizer *p_sync) {
- if (current == p_sync) {
- return;
- }
- current = p_sync;
- if (current) {
- config = current->get_replication_config();
- } else {
- config.unref();
- }
- _update_config();
-}
-
-Ref<Texture2D> ReplicationEditor::_get_class_icon(const Node *p_node) {
- if (!p_node || !has_theme_icon(p_node->get_class(), "EditorIcons")) {
- return get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"));
- }
- return get_theme_icon(p_node->get_class(), "EditorIcons");
-}
-
-void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn, bool p_sync) {
- String prop = String(p_property);
- TreeItem *item = tree->create_item();
- item->set_selectable(0, false);
- item->set_selectable(1, false);
- item->set_selectable(2, false);
- item->set_selectable(3, false);
- item->set_text(0, prop);
- item->set_metadata(0, prop);
- Node *root_node = current && !current->get_root_path().is_empty() ? current->get_node(current->get_root_path()) : nullptr;
- Ref<Texture2D> icon = _get_class_icon(root_node);
- if (root_node) {
- String path = prop.substr(0, prop.find(":"));
- String subpath = prop.substr(path.size());
- Node *node = root_node->get_node_or_null(path);
- if (!node) {
- node = root_node;
- }
- item->set_text(0, String(node->get_name()) + ":" + subpath);
- icon = _get_class_icon(node);
- }
- item->set_icon(0, icon);
- item->add_button(3, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
- item->set_text_alignment(1, HORIZONTAL_ALIGNMENT_CENTER);
- item->set_cell_mode(1, TreeItem::CELL_MODE_CHECK);
- item->set_checked(1, p_spawn);
- item->set_editable(1, true);
- item->set_text_alignment(2, HORIZONTAL_ALIGNMENT_CENTER);
- item->set_cell_mode(2, TreeItem::CELL_MODE_CHECK);
- item->set_checked(2, p_sync);
- item->set_editable(2, true);
-}
-
-void ReplicationEditor::property_keyed(const String &p_property) {
- ERR_FAIL_COND(!current || config.is_null());
- Node *root = current->get_node(current->get_root_path());
- ERR_FAIL_COND(!root);
- EditorSelectionHistory *history = EditorNode::get_singleton()->get_editor_selection_history();
- ERR_FAIL_COND(history->get_path_size() == 0);
- Node *node = Object::cast_to<Node>(ObjectDB::get_instance(history->get_path_object(0)));
- ERR_FAIL_COND(!node);
- if (node->is_class("MultiplayerSynchronizer")) {
- error_dialog->set_text(TTR("Properties of 'MultiplayerSynchronizer' cannot be configured for replication."));
- error_dialog->popup_centered();
- return;
- }
- if (history->get_path_size() > 1 || p_property.get_slice_count(":") > 1) {
- error_dialog->set_text(TTR("Subresources cannot yet be configured for replication."));
- error_dialog->popup_centered();
- return;
- }
-
- String path = root->get_path_to(node);
- for (int i = 1; i < history->get_path_size(); i++) {
- String prop = history->get_path_property(i);
- ERR_FAIL_COND(prop == "");
- path += ":" + prop;
- }
- path += ":" + p_property;
-
- NodePath prop = path;
- UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
- undo_redo->create_action(TTR("Add property"));
- undo_redo->add_do_method(config.ptr(), "add_property", prop);
- undo_redo->add_undo_method(config.ptr(), "remove_property", prop);
- undo_redo->add_do_method(this, "_update_config");
- undo_redo->add_undo_method(this, "_update_config");
- undo_redo->commit_action();
-}
-
-/// ReplicationEditorPlugin
-ReplicationEditorPlugin::ReplicationEditorPlugin() {
- repl_editor = memnew(ReplicationEditor);
- button = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Replication"), repl_editor);
- button->hide();
- repl_editor->get_pin()->connect("pressed", callable_mp(this, &ReplicationEditorPlugin::_pinned));
-}
-
-ReplicationEditorPlugin::~ReplicationEditorPlugin() {
-}
-
-void ReplicationEditorPlugin::_keying_changed() {
- // TODO make lock usable.
- //InspectorDock::get_inspector_singleton()->set_keying(repl_editor->has_keying(), this);
-}
-
-void ReplicationEditorPlugin::_property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance) {
- if (!repl_editor->has_keying()) {
- return;
- }
- repl_editor->property_keyed(p_keyed);
-}
-
-void ReplicationEditorPlugin::_notification(int p_what) {
- switch (p_what) {
- case NOTIFICATION_ENTER_TREE: {
- //Node3DEditor::get_singleton()->connect("transform_key_request", callable_mp(this, &AnimationPlayerEditorPlugin::_transform_key_request));
- InspectorDock::get_inspector_singleton()->connect("property_keyed", callable_mp(this, &ReplicationEditorPlugin::_property_keyed));
- repl_editor->connect("keying_changed", callable_mp(this, &ReplicationEditorPlugin::_keying_changed));
- // TODO make lock usable.
- //InspectorDock::get_inspector_singleton()->connect("object_inspected", callable_mp(repl_editor, &ReplicationEditor::update_keying));
- get_tree()->connect("node_removed", callable_mp(this, &ReplicationEditorPlugin::_node_removed));
- } break;
- }
-}
-
-void ReplicationEditorPlugin::_node_removed(Node *p_node) {
- if (p_node && p_node == repl_editor->get_current()) {
- repl_editor->edit(nullptr);
- if (repl_editor->is_visible_in_tree()) {
- EditorNode::get_singleton()->hide_bottom_panel();
- }
- button->hide();
- repl_editor->get_pin()->set_pressed(false);
- }
-}
-
-void ReplicationEditorPlugin::_pinned() {
- if (!repl_editor->get_pin()->is_pressed()) {
- if (repl_editor->is_visible_in_tree()) {
- EditorNode::get_singleton()->hide_bottom_panel();
- }
- button->hide();
- }
-}
-
-void ReplicationEditorPlugin::edit(Object *p_object) {
- repl_editor->edit(Object::cast_to<MultiplayerSynchronizer>(p_object));
-}
-
-bool ReplicationEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("MultiplayerSynchronizer");
-}
-
-void ReplicationEditorPlugin::make_visible(bool p_visible) {
- if (p_visible) {
- //editor->hide_animation_player_editors();
- //editor->animation_panel_make_visible(true);
- button->show();
- EditorNode::get_singleton()->make_bottom_panel_item_visible(repl_editor);
- } else if (!repl_editor->get_pin()->is_pressed()) {
- if (repl_editor->is_visible_in_tree()) {
- EditorNode::get_singleton()->hide_bottom_panel();
- }
- button->hide();
- }
-}
diff --git a/editor/plugins/replication_editor_plugin.h b/editor/plugins/replication_editor_plugin.h
deleted file mode 100644
index df3d97f884..0000000000
--- a/editor/plugins/replication_editor_plugin.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*************************************************************************/
-/* replication_editor_plugin.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* 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. */
-/*************************************************************************/
-
-#ifndef REPLICATION_EDITOR_PLUGIN_H
-#define REPLICATION_EDITOR_PLUGIN_H
-
-#include "editor/editor_plugin.h"
-#include "scene/resources/scene_replication_config.h"
-
-#include "editor/editor_spin_slider.h"
-#include "editor/property_editor.h"
-#include "editor/property_selector.h"
-
-class ConfirmationDialog;
-class MultiplayerSynchronizer;
-class Tree;
-
-class ReplicationEditor : public VBoxContainer {
- GDCLASS(ReplicationEditor, VBoxContainer);
-
-private:
- MultiplayerSynchronizer *current = nullptr;
-
- AcceptDialog *error_dialog = nullptr;
- ConfirmationDialog *delete_dialog = nullptr;
- Button *add_pick_button = nullptr;
- Button *add_from_path_button = nullptr;
- LineEdit *np_line_edit = nullptr;
-
- Label *drop_label = nullptr;
-
- Ref<SceneReplicationConfig> config;
- NodePath deleting;
- Tree *tree = nullptr;
- bool keying = false;
-
- PropertySelector *prop_selector = nullptr;
- SceneTreeDialog *pick_node = nullptr;
- NodePath adding_node_path;
-
- Button *pin = nullptr;
-
- Ref<Texture2D> _get_class_icon(const Node *p_node);
-
- void _add_pressed();
- void _tree_item_edited();
- void _tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
- void _update_checked(const NodePath &p_prop, int p_column, bool p_checked);
- void _update_config();
- void _dialog_closed(bool p_confirmed);
- void _add_property(const NodePath &p_property, bool p_spawn = true, bool p_sync = true);
-
- void _pick_node_filter_text_changed(const String &p_newtext);
- void _pick_node_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates);
- void _pick_node_filter_input(const Ref<InputEvent> &p_ie);
- void _pick_node_selected(NodePath p_path);
-
- void _pick_new_property();
- void _pick_node_property_selected(String p_name);
-
- bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
- void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
-
- void _add_sync_property(String p_path);
-
-protected:
- static void _bind_methods();
-
- void _notification(int p_what);
-
-public:
- void update_keying();
- void edit(MultiplayerSynchronizer *p_object);
- bool has_keying() const { return keying; }
- MultiplayerSynchronizer *get_current() const { return current; }
- void property_keyed(const String &p_property);
-
- Button *get_pin() { return pin; }
- ReplicationEditor();
- ~ReplicationEditor() {}
-};
-
-class ReplicationEditorPlugin : public EditorPlugin {
- GDCLASS(ReplicationEditorPlugin, EditorPlugin);
-
-private:
- Button *button = nullptr;
- ReplicationEditor *repl_editor = nullptr;
-
- void _node_removed(Node *p_node);
- void _keying_changed();
- void _property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance);
-
- void _pinned();
-
-protected:
- void _notification(int p_what);
-
-public:
- virtual void edit(Object *p_object) override;
- virtual bool handles(Object *p_object) const override;
- virtual void make_visible(bool p_visible) override;
-
- ReplicationEditorPlugin();
- ~ReplicationEditorPlugin();
-};
-
-#endif // REPLICATION_EDITOR_PLUGIN_H
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index bdf566e991..54c72e4d27 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -309,9 +309,9 @@ void ShaderTextEditor::_check_shader_mode() {
}
}
-static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) {
- RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable);
- return (ShaderLanguage::DataType)RS::global_variable_type_get_shader_datatype(gvt);
+static ShaderLanguage::DataType _get_global_shader_uniform_type(const StringName &p_variable) {
+ RS::GlobalShaderUniformType gvt = RS::get_singleton()->global_shader_uniform_get_type(p_variable);
+ return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt);
}
static String complete_from_path;
@@ -358,7 +358,7 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLa
ShaderLanguage sl;
String calltip;
ShaderLanguage::ShaderCompileInfo info;
- info.global_variable_type_func = _get_global_variable_type;
+ info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
if (shader.is_null()) {
info.is_include = true;
@@ -448,7 +448,7 @@ void ShaderTextEditor::_validate_script() {
sl.set_warning_flags(flags);
ShaderLanguage::ShaderCompileInfo info;
- info.global_variable_type_func = _get_global_variable_type;
+ info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
if (shader.is_null()) {
info.is_include = true;
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index 20e548acba..88bbd7f1dd 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -1822,7 +1822,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
Vector2i position = texture_region.get_center() + tile_set_atlas_source->get_tile_effective_texture_offset(coords, 0);
Transform2D xform = tile_atlas_control->get_parent_control()->get_transform();
- xform.translate(position);
+ xform.translate_local(position);
if (tools_button_group->get_pressed_button() == tool_select_button && selection.has({ coords, 0 })) {
continue;
@@ -1845,7 +1845,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
Vector2i position = texture_region.get_center() + tile_set_atlas_source->get_tile_effective_texture_offset(E.tile, 0);
Transform2D xform = tile_atlas_control->get_parent_control()->get_transform();
- xform.translate(position);
+ xform.translate_local(position);
TileMapCell cell;
cell.source_id = tile_set_atlas_source_id;
@@ -1989,7 +1989,7 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() {
Vector2 position = rect.get_center();
Transform2D xform = alternative_tiles_control->get_parent_control()->get_transform();
- xform.translate(position);
+ xform.translate_local(position);
if (tools_button_group->get_pressed_button() == tool_select_button && selection.has({ coords, alternative_tile })) {
continue;
@@ -2013,7 +2013,7 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() {
Vector2 position = rect.get_center();
Transform2D xform = alternative_tiles_control->get_parent_control()->get_transform();
- xform.translate(position);
+ xform.translate_local(position);
TileMapCell cell;
cell.source_id = tile_set_atlas_source_id;
diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp
index 97553578ba..65dee0df1f 100644
--- a/editor/plugins/tiles/tiles_editor_plugin.cpp
+++ b/editor/plugins/tiles/tiles_editor_plugin.cpp
@@ -155,6 +155,9 @@ void TilesEditorPlugin::_update_editors() {
// Update the viewport.
CanvasItemEditor::get_singleton()->update_viewport();
+ // Make sure the tile set editor is visible if we have one assigned.
+ tileset_editor_button->set_visible(is_visible && tile_set.is_valid());
+
// Update visibility of bottom panel buttons.
if (tileset_editor_button->is_pressed() && !tile_set.is_valid()) {
if (tile_map) {
@@ -181,12 +184,14 @@ void TilesEditorPlugin::_notification(int p_what) {
}
void TilesEditorPlugin::make_visible(bool p_visible) {
- if (p_visible) {
+ is_visible = p_visible;
+
+ if (is_visible) {
// Disable and hide invalid editors.
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
tileset_editor_button->set_visible(tile_set.is_valid());
tilemap_editor_button->set_visible(tile_map);
- if (tile_map) {
+ if (tile_map && !is_editing_tile_set) {
EditorNode::get_singleton()->make_bottom_panel_item_visible(tilemap_editor);
} else {
EditorNode::get_singleton()->make_bottom_panel_item_visible(tileset_editor);
@@ -345,6 +350,8 @@ void TilesEditorPlugin::edit(Object *p_object) {
// Update edited objects.
tile_set = Ref<TileSet>();
+ is_editing_tile_set = false;
+
if (p_object) {
if (p_object->is_class("TileMap")) {
tile_map_id = p_object->get_instance_id();
@@ -359,6 +366,7 @@ void TilesEditorPlugin::edit(Object *p_object) {
tile_map_id = ObjectID();
}
}
+ is_editing_tile_set = true;
EditorNode::get_singleton()->make_bottom_panel_item_visible(tileset_editor);
}
}
diff --git a/editor/plugins/tiles/tiles_editor_plugin.h b/editor/plugins/tiles/tiles_editor_plugin.h
index a22e782b34..b1fe6f8df6 100644
--- a/editor/plugins/tiles/tiles_editor_plugin.h
+++ b/editor/plugins/tiles/tiles_editor_plugin.h
@@ -53,9 +53,12 @@ public:
};
private:
+ bool is_visible = false;
+
bool tile_map_changed_needs_update = false;
ObjectID tile_map_id;
Ref<TileSet> tile_set;
+ bool is_editing_tile_set = false;
Button *tilemap_editor_button = nullptr;
TileMapEditor *tilemap_editor = nullptr;
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 69a125a029..d6d45b8210 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -4563,9 +4563,9 @@ void VisualShaderEditor::_preview_size_changed() {
preview_vbox->set_custom_minimum_size(preview_window->get_size());
}
-static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) {
- RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable);
- return (ShaderLanguage::DataType)RS::global_variable_type_get_shader_datatype(gvt);
+static ShaderLanguage::DataType _get_global_shader_uniform_type(const StringName &p_variable) {
+ RS::GlobalShaderUniformType gvt = RS::get_singleton()->global_shader_uniform_get_type(p_variable);
+ return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt);
}
void VisualShaderEditor::_update_preview() {
@@ -4582,7 +4582,7 @@ void VisualShaderEditor::_update_preview() {
info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(visual_shader->get_mode()));
info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(visual_shader->get_mode()));
info.shader_types = ShaderTypes::get_singleton()->get_types();
- info.global_variable_type_func = _get_global_variable_type;
+ info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
ShaderLanguage sl;
diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp
index 6437e19404..97013da05e 100644
--- a/editor/project_converter_3_to_4.cpp
+++ b/editor/project_converter_3_to_4.cpp
@@ -120,7 +120,7 @@ static const char *enum_renames[][2] = {
{ "JOINT_PIN", "JOINT_TYPE_PIN" }, // PhysicsServer2D
{ "JOINT_SLIDER", "JOINT_TYPE_SLIDER" }, // PhysicsServer3D
{ "KEY_CONTROL", "KEY_CTRL" }, // Globals
- { "LOOP_PING_PONG", "LOOP_PINGPONG" }, //AudioStreamSample
+ { "LOOP_PING_PONG", "LOOP_PINGPONG" }, // AudioStreamWAV
{ "MATH_RAND", "MATH_RANDF_RANGE" }, // VisualScriptBuiltinFunc
{ "MATH_RANDOM", "MATH_RANDI_RANGE" }, // VisualScriptBuiltinFunc
{ "MATH_STEPIFY", "MATH_STEP_DECIMALS" }, // VisualScriptBuiltinFunc
@@ -1250,7 +1250,9 @@ static const char *class_renames[][2] = {
{ "AnimatedSprite", "AnimatedSprite2D" },
{ "AnimationTreePlayer", "AnimationTree" },
{ "Area", "Area3D" }, // Be careful, this will be used everywhere
+ { "AudioStreamOGGVorbis", "AudioStreamOggVorbis" },
{ "AudioStreamRandomPitch", "AudioStreamRandomizer" },
+ { "AudioStreamSample", "AudioStreamWAV" },
{ "BakedLightmap", "LightmapGI" },
{ "BakedLightmapData", "LightmapGIData" },
{ "BitmapFont", "FontFile" },
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 077dfc60c0..be1ad1ca9c 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -669,10 +669,10 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
autoload_settings->connect("autoload_changed", callable_mp(this, &ProjectSettingsEditor::queue_save));
tab_container->add_child(autoload_settings);
- shaders_global_variables_editor = memnew(ShaderGlobalsEditor);
- shaders_global_variables_editor->set_name(TTR("Shader Globals"));
- shaders_global_variables_editor->connect("globals_changed", callable_mp(this, &ProjectSettingsEditor::queue_save));
- tab_container->add_child(shaders_global_variables_editor);
+ shaders_global_shader_uniforms_editor = memnew(ShaderGlobalsEditor);
+ shaders_global_shader_uniforms_editor->set_name(TTR("Shader Globals"));
+ shaders_global_shader_uniforms_editor->connect("globals_changed", callable_mp(this, &ProjectSettingsEditor::queue_save));
+ tab_container->add_child(shaders_global_shader_uniforms_editor);
plugin_settings = memnew(EditorPluginSettings);
plugin_settings->set_name(TTR("Plugins"));
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index 24d61db443..455aaae11c 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -55,7 +55,7 @@ class ProjectSettingsEditor : public AcceptDialog {
ActionMapEditor *action_map_editor = nullptr;
LocalizationEditor *localization_editor = nullptr;
EditorAutoloadSettings *autoload_settings = nullptr;
- ShaderGlobalsEditor *shaders_global_variables_editor = nullptr;
+ ShaderGlobalsEditor *shaders_global_shader_uniforms_editor = nullptr;
EditorPluginSettings *plugin_settings = nullptr;
LineEdit *search_box = nullptr;
diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp
index 26bd3a5979..5bf7e958f6 100644
--- a/editor/shader_globals_editor.cpp
+++ b/editor/shader_globals_editor.cpp
@@ -79,7 +79,7 @@ protected:
}
bool _set(const StringName &p_name, const Variant &p_value) {
- Variant existing = RS::get_singleton()->global_variable_get(p_name);
+ Variant existing = RS::get_singleton()->global_shader_uniform_get(p_name);
if (existing.get_type() == Variant::NIL) {
return false;
@@ -88,9 +88,9 @@ protected:
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
undo_redo->create_action(TTR("Set Shader Global Variable"));
- undo_redo->add_do_method(RS::get_singleton(), "global_variable_set", p_name, p_value);
- undo_redo->add_undo_method(RS::get_singleton(), "global_variable_set", p_name, existing);
- RS::GlobalVariableType type = RS::get_singleton()->global_variable_get_type(p_name);
+ undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_set", p_name, p_value);
+ undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_set", p_name, existing);
+ RS::GlobalShaderUniformType type = RS::get_singleton()->global_shader_uniform_get_type(p_name);
Dictionary gv;
gv["type"] = global_var_type_names[type];
if (type >= RS::GLOBAL_VAR_TYPE_SAMPLER2D) {
@@ -117,17 +117,17 @@ protected:
}
bool _get(const StringName &p_name, Variant &r_ret) const {
- r_ret = RS::get_singleton()->global_variable_get(p_name);
+ r_ret = RS::get_singleton()->global_shader_uniform_get(p_name);
return r_ret.get_type() != Variant::NIL;
}
void _get_property_list(List<PropertyInfo> *p_list) const {
Vector<StringName> variables;
- variables = RS::get_singleton()->global_variable_get_list();
+ variables = RS::get_singleton()->global_shader_uniform_get_list();
for (int i = 0; i < variables.size(); i++) {
PropertyInfo pinfo;
pinfo.name = variables[i];
- switch (RS::get_singleton()->global_variable_get_type(variables[i])) {
+ switch (RS::get_singleton()->global_shader_uniform_get_type(variables[i])) {
case RS::GLOBAL_VAR_TYPE_BOOL: {
pinfo.type = Variant::BOOL;
} break;
@@ -241,7 +241,7 @@ public:
}
};
-static Variant create_var(RS::GlobalVariableType p_type) {
+static Variant create_var(RS::GlobalShaderUniformType p_type) {
switch (p_type) {
case RS::GLOBAL_VAR_TYPE_BOOL: {
return false;
@@ -376,12 +376,12 @@ static Variant create_var(RS::GlobalVariableType p_type) {
void ShaderGlobalsEditor::_variable_added() {
String var = variable_name->get_text().strip_edges();
if (var.is_empty() || !var.is_valid_identifier()) {
- EditorNode::get_singleton()->show_warning(TTR("Please specify a valid variable identifier name."));
+ EditorNode::get_singleton()->show_warning(TTR("Please specify a valid shader uniform identifier name."));
return;
}
- if (RenderingServer::get_singleton()->global_variable_get(var).get_type() != Variant::NIL) {
- EditorNode::get_singleton()->show_warning(vformat(TTR("Global variable '%s' already exists'"), var));
+ if (RenderingServer::get_singleton()->global_shader_uniform_get(var).get_type() != Variant::NIL) {
+ EditorNode::get_singleton()->show_warning(vformat(TTR("Global shader uniform '%s' already exists'"), var));
return;
}
@@ -395,11 +395,11 @@ void ShaderGlobalsEditor::_variable_added() {
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
- Variant value = create_var(RS::GlobalVariableType(variable_type->get_selected()));
+ Variant value = create_var(RS::GlobalShaderUniformType(variable_type->get_selected()));
- undo_redo->create_action(TTR("Add Shader Global Variable"));
- undo_redo->add_do_method(RS::get_singleton(), "global_variable_add", var, RS::GlobalVariableType(variable_type->get_selected()), value);
- undo_redo->add_undo_method(RS::get_singleton(), "global_variable_remove", var);
+ undo_redo->create_action(TTR("Add Shader Global Uniform"));
+ undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_add", var, RS::GlobalShaderUniformType(variable_type->get_selected()), value);
+ undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_remove", var);
Dictionary gv;
gv["type"] = global_var_type_names[variable_type->get_selected()];
gv["value"] = value;
@@ -414,9 +414,9 @@ void ShaderGlobalsEditor::_variable_added() {
void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) {
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
- undo_redo->create_action(TTR("Add Shader Global Variable"));
- undo_redo->add_do_method(RS::get_singleton(), "global_variable_remove", p_variable);
- undo_redo->add_undo_method(RS::get_singleton(), "global_variable_add", p_variable, RS::get_singleton()->global_variable_get_type(p_variable), RS::get_singleton()->global_variable_get(p_variable));
+ undo_redo->create_action(TTR("Add Shader Global Uniform"));
+ undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_remove", p_variable);
+ undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_add", p_variable, RS::get_singleton()->global_shader_uniform_get_type(p_variable), RS::get_singleton()->global_shader_uniform_get(p_variable));
undo_redo->add_do_property(ProjectSettings::get_singleton(), "shader_globals/" + p_variable, Variant());
undo_redo->add_undo_property(ProjectSettings::get_singleton(), "shader_globals/" + p_variable, ProjectSettings::get_singleton()->get("shader_globals/" + p_variable));