summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/image.cpp6
-rw-r--r--core/image.h1
-rw-r--r--core/io/resource_format_binary.cpp21
-rw-r--r--core/object.cpp2
-rw-r--r--core/object.h7
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp29
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h17
-rw-r--r--editor/code_editor.cpp9
-rw-r--r--editor/editor_audio_buses.cpp18
-rw-r--r--editor/editor_audio_buses.h4
-rw-r--r--editor/editor_help.cpp30
-rw-r--r--editor/editor_node.cpp1029
-rw-r--r--editor/editor_node.h85
-rw-r--r--editor/editor_plugin.cpp210
-rw-r--r--editor/editor_plugin.h54
-rw-r--r--editor/editor_run_script.cpp6
-rw-r--r--editor/editor_run_script.h4
-rw-r--r--editor/editor_settings.cpp44
-rw-r--r--editor/editor_settings.h3
-rw-r--r--editor/import/resource_importer_scene.cpp4
-rw-r--r--editor/io_plugins/editor_scene_import_plugin.cpp8
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp5
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp (renamed from editor/asset_library_editor_plugin.cpp)0
-rw-r--r--editor/plugins/asset_library_editor_plugin.h (renamed from editor/asset_library_editor_plugin.h)0
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp4
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h1
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.cpp3
-rw-r--r--editor/plugins/curve_editor_plugin.cpp2
-rw-r--r--editor/plugins/editor_preview_plugins.cpp18
-rw-r--r--editor/plugins/editor_preview_plugins.h3
-rw-r--r--editor/plugins/material_editor_plugin.cpp6
-rw-r--r--editor/plugins/material_editor_plugin.h7
-rw-r--r--editor/plugins/rich_text_editor_plugin.cpp151
-rw-r--r--editor/plugins/rich_text_editor_plugin.h90
-rw-r--r--editor/plugins/sample_editor_plugin.cpp452
-rw-r--r--editor/plugins/sample_editor_plugin.h93
-rw-r--r--editor/plugins/sample_library_editor_plugin.cpp547
-rw-r--r--editor/plugins/sample_library_editor_plugin.h108
-rw-r--r--editor/plugins/sample_player_editor_plugin.cpp202
-rw-r--r--editor/plugins/sample_player_editor_plugin.h91
-rw-r--r--editor/plugins/script_editor_plugin.cpp17
-rw-r--r--editor/plugins/shader_editor_plugin.cpp13
-rw-r--r--editor/plugins/shader_graph_editor_plugin.cpp4
-rw-r--r--editor/plugins/shader_graph_editor_plugin.h9
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp96
-rw-r--r--editor/plugins/spatial_editor_plugin.h3
-rw-r--r--editor/project_manager.cpp3
-rw-r--r--editor/project_manager.h2
-rw-r--r--editor/project_settings_editor.cpp92
-rw-r--r--editor/project_settings_editor.h15
-rw-r--r--editor/property_editor.cpp331
-rw-r--r--editor/property_editor.h9
-rw-r--r--editor/resources_dock.cpp378
-rw-r--r--editor/resources_dock.h99
-rw-r--r--editor/scene_tree_dock.cpp134
-rw-r--r--editor/scene_tree_dock.h19
-rw-r--r--editor/script_create_dialog.cpp3
-rw-r--r--editor/script_editor_debugger.cpp9
-rw-r--r--editor/spatial_editor_gizmos.cpp370
-rw-r--r--editor/spatial_editor_gizmos.h65
-rw-r--r--modules/gdscript/gd_editor.cpp8
-rw-r--r--modules/gridmap/grid_map.cpp427
-rw-r--r--modules/gridmap/grid_map.h48
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp363
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h13
-rw-r--r--platform/android/java_class_wrapper.cpp2
-rw-r--r--platform/x11/os_x11.cpp2
-rw-r--r--scene/3d/portal.cpp2
-rw-r--r--scene/3d/portal.h4
-rw-r--r--scene/3d/room_instance.cpp2
-rw-r--r--scene/3d/room_instance.h5
-rw-r--r--scene/3d/spatial.cpp23
-rw-r--r--scene/3d/spatial.h1
-rw-r--r--scene/3d/visual_instance.cpp27
-rw-r--r--scene/3d/visual_instance.h1
-rw-r--r--scene/gui/text_edit.cpp4
-rw-r--r--scene/gui/tree.cpp28
-rwxr-xr-xscene/main/node.cpp18
-rw-r--r--scene/main/scene_tree.cpp5
-rw-r--r--scene/main/viewport.cpp2
-rw-r--r--scene/register_scene_types.cpp229
-rw-r--r--scene/resources/gibberish_stream.cpp337
-rw-r--r--scene/resources/gibberish_stream.h118
-rw-r--r--scene/resources/material.cpp1
-rw-r--r--scene/resources/room.cpp3
-rw-r--r--scene/resources/room.h4
-rw-r--r--servers/visual/rasterizer.h17
-rw-r--r--servers/visual/visual_server_raster.h18
-rw-r--r--servers/visual/visual_server_scene.cpp584
-rw-r--r--servers/visual/visual_server_scene.h42
-rw-r--r--servers/visual/visual_server_wrap_mt.h18
-rw-r--r--servers/visual_server.h21
92 files changed, 1132 insertions, 6290 deletions
diff --git a/core/image.cpp b/core/image.cpp
index 91572e44e4..0f09fbc0c1 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -343,6 +343,11 @@ int Image::get_height() const {
return height;
}
+Vector2 Image::get_size() const {
+
+ return Vector2(width, height);
+}
+
bool Image::has_mipmaps() const {
return mipmaps;
@@ -2215,6 +2220,7 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_width"), &Image::get_width);
ClassDB::bind_method(D_METHOD("get_height"), &Image::get_height);
+ ClassDB::bind_method(D_METHOD("get_size"), &Image::get_size);
ClassDB::bind_method(D_METHOD("has_mipmaps"), &Image::has_mipmaps);
ClassDB::bind_method(D_METHOD("get_format"), &Image::get_format);
ClassDB::bind_method(D_METHOD("get_data"), &Image::get_data);
diff --git a/core/image.h b/core/image.h
index 7acc4744e9..2d61032896 100644
--- a/core/image.h
+++ b/core/image.h
@@ -177,6 +177,7 @@ private:
public:
int get_width() const; ///< Get image width
int get_height() const; ///< Get image height
+ Vector2 get_size() const;
bool has_mipmaps() const;
int get_mipmap_count() const;
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index b8e0bbf557..0977b03e2f 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -28,12 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_format_binary.h"
-#include "image.h"
-#include "io/file_access_compressed.h"
-#include "io/marshalls.h"
-#include "os/dir_access.h"
-#include "project_settings.h"
-#include "version.h"
+
+#include "core/image.h"
+#include "core/io/file_access_compressed.h"
+#include "core/io/marshalls.h"
+#include "core/os/dir_access.h"
+#include "core/project_settings.h"
+#include "core/version.h"
+
//#define print_bl(m_what) print_line(m_what)
#define print_bl(m_what)
@@ -1798,7 +1800,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
}
ERR_FAIL_COND_V(err, err);
- FileAccessRef _fref(f);
relative_paths = p_flags & ResourceSaver::FLAG_RELATIVE_PATHS;
skip_editor = p_flags & ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
@@ -1810,7 +1811,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
takeover_paths = false;
local_path = p_path.get_base_dir();
- //bin_meta_idx = get_string_index("__bin_meta__"); //is often used, so create
_find_resources(p_resource, true);
@@ -1836,7 +1836,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
return ERR_CANT_CREATE;
}
- //f->store_32(saved_resources.size()+external_resources.size()); // load steps -not needed
save_unicode_string(p_resource->get_class());
uint64_t md_at = f->get_pos();
f->store_64(0); //offset to impoty metadata
@@ -1875,7 +1874,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
f->store_32(strings.size()); //string table size
for (int i = 0; i < strings.size(); i++) {
- //print_bl("saving string: "+strings[i]);
save_unicode_string(strings[i]);
}
@@ -1944,9 +1942,8 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
}
Vector<uint64_t> ofs_table;
- //int saved_idx=0;
- //now actually save the resources
+ //now actually save the resources
for (List<ResourceData>::Element *E = resources.front(); E; E = E->next()) {
ResourceData &rd = E->get();
diff --git a/core/object.cpp b/core/object.cpp
index 5e6c809f7a..cd084a0c4a 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1472,7 +1472,7 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
Signal::Target target(p_to_object->get_instance_id(), p_to_method);
if (s->slot_map.has(target)) {
- ERR_EXPLAIN("Signal '" + p_signal + "'' already connected to given method '" + p_to_method + "' in that object.");
+ ERR_EXPLAIN("Signal '" + p_signal + "' is already connected to given method '" + p_to_method + "' in that object.");
ERR_FAIL_COND_V(s->slot_map.has(target), ERR_INVALID_PARAMETER);
}
diff --git a/core/object.h b/core/object.h
index 88229d27b6..746450ef6a 100644
--- a/core/object.h
+++ b/core/object.h
@@ -185,6 +185,7 @@ struct MethodInfo {
uint32_t flags;
int id;
+ inline bool operator==(const MethodInfo &p_method) const { return id == p_method.id; }
inline bool operator<(const MethodInfo &p_method) const { return id == p_method.id ? (name < p_method.name) : (id < p_method.id); }
operator Dictionary() const;
@@ -571,8 +572,8 @@ public:
#else
if (!p_object)
return NULL;
- if (p_pobject->is_class_ptr(T::get_class_ptr_static()))
- return static_cast<T *>(p_pobject);
+ if (p_object->is_class_ptr(T::get_class_ptr_static()))
+ return static_cast<T *>(p_object);
else
return NULL;
#endif
@@ -591,7 +592,7 @@ public:
#else
if (!p_object)
return NULL;
- if (p_pobject->is_class_ptr(T::get_class_ptr_static()))
+ if (p_object->is_class_ptr(T::get_class_ptr_static()))
return static_cast<const T *>(p_object);
else
return NULL;
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 68731308a9..dcf8ef2277 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -4854,35 +4854,6 @@ float RasterizerStorageGLES3::reflection_probe_get_origin_max_distance(RID p_pro
return reflection_probe->max_distance;
}
-/* ROOM API */
-
-RID RasterizerStorageGLES3::room_create() {
-
- return RID();
-}
-void RasterizerStorageGLES3::room_add_bounds(RID p_room, const PoolVector<Vector2> &p_convex_polygon, float p_height, const Transform &p_transform) {
-}
-void RasterizerStorageGLES3::room_clear_bounds(RID p_room) {
-}
-
-/* PORTAL API */
-
-// portals are only (x/y) points, forming a convex shape, which its clockwise
-// order points outside. (z is 0);
-
-RID RasterizerStorageGLES3::portal_create() {
-
- return RID();
-}
-void RasterizerStorageGLES3::portal_set_shape(RID p_portal, const Vector<Point2> &p_shape) {
-}
-void RasterizerStorageGLES3::portal_set_enabled(RID p_portal, bool p_enabled) {
-}
-void RasterizerStorageGLES3::portal_set_disable_distance(RID p_portal, float p_distance) {
-}
-void RasterizerStorageGLES3::portal_set_disabled_color(RID p_portal, const Color &p_color) {
-}
-
RID RasterizerStorageGLES3::gi_probe_create() {
GIProbe *gip = memnew(GIProbe);
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index f612d9e879..b0cb04569e 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -953,23 +953,6 @@ public:
virtual float reflection_probe_get_origin_max_distance(RID p_probe) const;
virtual bool reflection_probe_renders_shadows(RID p_probe) const;
- /* ROOM API */
-
- virtual RID room_create();
- virtual void room_add_bounds(RID p_room, const PoolVector<Vector2> &p_convex_polygon, float p_height, const Transform &p_transform);
- virtual void room_clear_bounds(RID p_room);
-
- /* PORTAL API */
-
- // portals are only (x/y) points, forming a convex shape, which its clockwise
- // order points outside. (z is 0);
-
- virtual RID portal_create();
- virtual void portal_set_shape(RID p_portal, const Vector<Point2> &p_shape);
- virtual void portal_set_enabled(RID p_portal, bool p_enabled);
- virtual void portal_set_disable_distance(RID p_portal, float p_distance);
- virtual void portal_set_disabled_color(RID p_portal, const Color &p_color);
-
/* GI PROBE API */
struct GIProbe : public Instantiable {
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index d49b240c80..a9dc81dc54 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1093,12 +1093,7 @@ void CodeTextEditor::update_editor_settings() {
void CodeTextEditor::set_error(const String &p_error) {
- if (p_error != "") {
- error->set_text(p_error);
- error->show();
- } else {
- error->hide();
- }
+ error->set_text(p_error);
}
void CodeTextEditor::_update_font() {
@@ -1223,12 +1218,10 @@ CodeTextEditor::CodeTextEditor() {
error = memnew(Label);
status_bar->add_child(error);
- error->hide();
error->set_clip_text(true); //do not change, or else very long errors can push the whole container to the right
error->set_valign(Label::VALIGN_CENTER);
error->add_color_override("font_color", Color(1, 0.7, 0.6, 0.9));
error->set_h_size_flags(SIZE_EXPAND_FILL); //required for it to display, given now it's clipping contents, do not touch
- //status_bar->add_spacer();
Label *line_txt = memnew(Label);
status_bar->add_child(line_txt);
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index 1f72a59a14..9df952b017 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -403,12 +403,13 @@ void EditorAudioBus::_gui_input(const Ref<InputEvent> &p_event) {
if (mb.is_valid() && mb->get_button_index() == 2 && mb->is_pressed()) {
Vector2 pos = Vector2(mb->get_position().x, mb->get_position().y);
- delete_popup->set_position(get_global_position() + pos);
- delete_popup->popup();
+ bus_popup->set_position(get_global_position() + pos);
+ bus_popup->set_item_disabled(1, get_index() == 0);
+ bus_popup->popup();
}
}
-void EditorAudioBus::_delete_pressed(int p_option) {
+void EditorAudioBus::_bus_popup_pressed(int p_option) {
if (p_option == 1) {
emit_signal("delete_request");
@@ -604,7 +605,7 @@ void EditorAudioBus::_bind_methods() {
ClassDB::bind_method("_effect_selected", &EditorAudioBus::_effect_selected);
ClassDB::bind_method("_effect_add", &EditorAudioBus::_effect_add);
ClassDB::bind_method("_gui_input", &EditorAudioBus::_gui_input);
- ClassDB::bind_method("_delete_pressed", &EditorAudioBus::_delete_pressed);
+ ClassDB::bind_method("_bus_popup_pressed", &EditorAudioBus::_bus_popup_pressed);
ClassDB::bind_method("get_drag_data_fw", &EditorAudioBus::get_drag_data_fw);
ClassDB::bind_method("can_drop_data_fw", &EditorAudioBus::can_drop_data_fw);
ClassDB::bind_method("drop_data_fw", &EditorAudioBus::drop_data_fw);
@@ -735,11 +736,10 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses) {
effect_options->set_item_icon(effect_options->get_item_count() - 1, icon);
}
- delete_popup = bus_options->get_popup();
- delete_popup->add_item(TTR("Duplicate"));
- delete_popup->add_item(TTR("Delete"));
- add_child(delete_popup);
- delete_popup->connect("index_pressed", this, "_delete_pressed");
+ bus_popup = bus_options->get_popup();
+ bus_popup->add_item(TTR("Duplicate"));
+ bus_popup->add_item(TTR("Delete"));
+ bus_popup->connect("index_pressed", this, "_bus_popup_pressed");
delete_effect_popup = memnew(PopupMenu);
delete_effect_popup->add_item(TTR("Delete Effect"));
diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h
index ef7f5e0adf..9d80ff67d1 100644
--- a/editor/editor_audio_buses.h
+++ b/editor/editor_audio_buses.h
@@ -66,7 +66,7 @@ class EditorAudioBus : public PanelContainer {
OptionButton *send;
PopupMenu *effect_options;
- PopupMenu *delete_popup;
+ PopupMenu *bus_popup;
PopupMenu *delete_effect_popup;
Button *solo;
@@ -78,7 +78,7 @@ class EditorAudioBus : public PanelContainer {
bool updating_bus;
void _gui_input(const Ref<InputEvent> &p_event);
- void _delete_pressed(int p_option);
+ void _bus_popup_pressed(int p_option);
void _name_changed(const String &p_new_name);
void _name_focus_exit() { _name_changed(track_name->get_text()); }
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 86f31d7589..17105606df 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -294,7 +294,6 @@ EditorHelpSearch::EditorHelpSearch() {
VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
- HBoxContainer *sb_hb = memnew(HBoxContainer);
search_box = memnew(LineEdit);
vbc->add_child(search_box);
search_box->connect("text_changed", this, "_text_changed");
@@ -893,6 +892,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
for (int i = 0; i < methods.size(); i++) {
+ bool is_vararg = methods[i].qualifiers.find("vararg") != -1;
+
class_desc->push_cell();
method_line[methods[i].name] = class_desc->get_line_count() - 2; //gets overridden if description
@@ -916,7 +917,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
if (methods[i].description != "")
class_desc->pop();
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
- class_desc->add_text(methods[i].arguments.size() ? "( " : "(");
+ class_desc->add_text(methods[i].arguments.size() || is_vararg ? "( " : "(");
class_desc->pop();
for (int j = 0; j < methods[i].arguments.size(); j++) {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
@@ -936,17 +937,18 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
class_desc->pop();
}
- if (methods[i].qualifiers.find("vararg") != -1) {
+ if (is_vararg) {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
- class_desc->add_text(",");
+ if (methods[i].arguments.size())
+ class_desc->add_text(", ");
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
- class_desc->add_text(" ... ");
+ class_desc->add_text("...");
class_desc->pop();
class_desc->pop();
}
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
- class_desc->add_text(methods[i].arguments.size() ? " )" : ")");
+ class_desc->add_text(methods[i].arguments.size() || is_vararg ? " )" : ")");
class_desc->pop();
if (methods[i].qualifiers != "") {
@@ -1313,6 +1315,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
for (int i = 0; i < methods.size(); i++) {
+ bool is_vararg = methods[i].qualifiers.find("vararg") != -1;
+
method_line[methods[i].name] = class_desc->get_line_count() - 2;
class_desc->push_font(doc_code_font);
@@ -1323,7 +1327,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
_add_text(methods[i].name);
class_desc->pop();
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
- class_desc->add_text(methods[i].arguments.size() ? "( " : "(");
+ class_desc->add_text(methods[i].arguments.size() || is_vararg ? "( " : "(");
class_desc->pop();
for (int j = 0; j < methods[i].arguments.size(); j++) {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
@@ -1343,8 +1347,18 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
class_desc->pop();
}
+ if (is_vararg) {
+ class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
+ if (methods[i].arguments.size())
+ class_desc->add_text(", ");
+ class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
+ class_desc->add_text("...");
+ class_desc->pop();
+ class_desc->pop();
+ }
+
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
- class_desc->add_text(methods[i].arguments.size() ? " )" : ")");
+ class_desc->add_text(methods[i].arguments.size() || is_vararg ? " )" : ")");
class_desc->pop();
if (methods[i].qualifiers != "") {
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 9bf3372e1f..06e9860552 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -29,102 +29,96 @@
/*************************************************************************/
#include "editor_node.h"
-#include "animation_editor.h"
-#include "bind/core_bind.h"
-#include "class_db.h"
+#include "core/bind/core_bind.h"
+#include "core/class_db.h"
+#include "core/io/config_file.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
-#include "editor_file_system.h"
-#include "editor_help.h"
-#include "editor_settings.h"
-#include "editor_themes.h"
-#include "io/config_file.h"
-#include "io/stream_peer_ssl.h"
-#include "io/zip_io.h"
+#include "core/io/stream_peer_ssl.h"
+#include "core/io/zip_io.h"
+#include "core/message_queue.h"
+#include "core/os/file_access.h"
+#include "core/os/input.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "core/path_remap.h"
+#include "core/print_string.h"
+#include "core/project_settings.h"
+#include "core/translation.h"
+#include "core/version.h"
#include "main/input_default.h"
-#include "message_queue.h"
-#include "os/file_access.h"
-#include "os/input.h"
-#include "os/keyboard.h"
-#include "os/os.h"
-#include "path_remap.h"
-#include "print_string.h"
-#include "project_settings.h"
-#include "pvrtc_compress.h"
-#include "register_exporters.h"
#include "scene/resources/packed_scene.h"
#include "servers/physics_2d_server.h"
-#include "translation.h"
-#include "version.h"
+
+#include "editor/animation_editor.h"
+#include "editor/editor_audio_buses.h"
+#include "editor/editor_file_system.h"
+#include "editor/editor_help.h"
+#include "editor/editor_initialize_ssl.h"
+#include "editor/editor_settings.h"
+#include "editor/editor_settings.h"
+#include "editor/editor_themes.h"
+#include "editor/import/editor_import_collada.h"
+#include "editor/import/editor_scene_importer_gltf.h"
+#include "editor/import/resource_importer_csv_translation.h"
+#include "editor/import/resource_importer_obj.h"
+#include "editor/import/resource_importer_scene.h"
+#include "editor/import/resource_importer_texture.h"
+#include "editor/import/resource_importer_wav.h"
+#include "editor/io_plugins/editor_bitmask_import_plugin.h"
+#include "editor/io_plugins/editor_export_scene.h"
+#include "editor/io_plugins/editor_font_import_plugin.h"
+#include "editor/io_plugins/editor_mesh_import_plugin.h"
+#include "editor/io_plugins/editor_scene_import_plugin.h"
+#include "editor/io_plugins/editor_scene_importer_fbxconv.h"
+#include "editor/io_plugins/editor_texture_import_plugin.h"
+#include "editor/io_plugins/editor_translation_import_plugin.h"
+#include "editor/plugins/animation_player_editor_plugin.h"
+#include "editor/plugins/animation_tree_editor_plugin.h"
+#include "editor/plugins/asset_library_editor_plugin.h"
+#include "editor/plugins/baked_light_editor_plugin.h"
+#include "editor/plugins/camera_editor_plugin.h"
+#include "editor/plugins/canvas_item_editor_plugin.h"
+#include "editor/plugins/collision_polygon_2d_editor_plugin.h"
+#include "editor/plugins/collision_polygon_editor_plugin.h"
+#include "editor/plugins/collision_shape_2d_editor_plugin.h"
+#include "editor/plugins/cube_grid_theme_editor_plugin.h"
+#include "editor/plugins/curve_editor_plugin.h"
+#include "editor/plugins/editor_preview_plugins.h"
+#include "editor/plugins/gi_probe_editor_plugin.h"
+#include "editor/plugins/gradient_editor_plugin.h"
+#include "editor/plugins/item_list_editor_plugin.h"
+#include "editor/plugins/light_occluder_2d_editor_plugin.h"
+#include "editor/plugins/line_2d_editor_plugin.h"
+#include "editor/plugins/material_editor_plugin.h"
+#include "editor/plugins/mesh_editor_plugin.h"
+#include "editor/plugins/mesh_instance_editor_plugin.h"
+#include "editor/plugins/multimesh_editor_plugin.h"
+#include "editor/plugins/navigation_polygon_editor_plugin.h"
+#include "editor/plugins/particles_2d_editor_plugin.h"
+#include "editor/plugins/particles_editor_plugin.h"
+#include "editor/plugins/path_2d_editor_plugin.h"
+#include "editor/plugins/path_editor_plugin.h"
+#include "editor/plugins/polygon_2d_editor_plugin.h"
+#include "editor/plugins/resource_preloader_editor_plugin.h"
+#include "editor/plugins/script_editor_plugin.h"
+#include "editor/plugins/script_text_editor.h"
+#include "editor/plugins/shader_editor_plugin.h"
+#include "editor/plugins/shader_graph_editor_plugin.h"
+#include "editor/plugins/spatial_editor_plugin.h"
+#include "editor/plugins/sprite_frames_editor_plugin.h"
+#include "editor/plugins/stream_editor_plugin.h"
+#include "editor/plugins/style_box_editor_plugin.h"
+#include "editor/plugins/texture_editor_plugin.h"
+#include "editor/plugins/texture_region_editor_plugin.h"
+#include "editor/plugins/theme_editor_plugin.h"
+#include "editor/plugins/tile_map_editor_plugin.h"
+#include "editor/plugins/tile_set_editor_plugin.h"
+#include "editor/pvrtc_compress.h"
+#include "editor/register_exporters.h"
+#include "editor/script_editor_debugger.h"
+
#include <stdio.h>
-// plugins
-#include "asset_library_editor_plugin.h"
-#include "import/resource_importer_csv_translation.h"
-#include "import/resource_importer_obj.h"
-#include "import/resource_importer_scene.h"
-#include "import/resource_importer_texture.h"
-#include "import/resource_importer_wav.h"
-#include "plugins/animation_player_editor_plugin.h"
-#include "plugins/animation_tree_editor_plugin.h"
-#include "plugins/baked_light_editor_plugin.h"
-#include "plugins/camera_editor_plugin.h"
-#include "plugins/canvas_item_editor_plugin.h"
-#include "plugins/collision_polygon_2d_editor_plugin.h"
-#include "plugins/collision_polygon_editor_plugin.h"
-#include "plugins/collision_shape_2d_editor_plugin.h"
-#include "plugins/cube_grid_theme_editor_plugin.h"
-#include "plugins/curve_editor_plugin.h"
-#include "plugins/gi_probe_editor_plugin.h"
-#include "plugins/gradient_editor_plugin.h"
-#include "plugins/item_list_editor_plugin.h"
-#include "plugins/light_occluder_2d_editor_plugin.h"
-#include "plugins/line_2d_editor_plugin.h"
-#include "plugins/material_editor_plugin.h"
-#include "plugins/mesh_editor_plugin.h"
-#include "plugins/mesh_instance_editor_plugin.h"
-#include "plugins/multimesh_editor_plugin.h"
-#include "plugins/navigation_polygon_editor_plugin.h"
-#include "plugins/particles_2d_editor_plugin.h"
-#include "plugins/particles_editor_plugin.h"
-#include "plugins/path_2d_editor_plugin.h"
-#include "plugins/path_editor_plugin.h"
-#include "plugins/polygon_2d_editor_plugin.h"
-#include "plugins/resource_preloader_editor_plugin.h"
-#include "plugins/rich_text_editor_plugin.h"
-#include "plugins/sample_editor_plugin.h"
-#include "plugins/sample_library_editor_plugin.h"
-#include "plugins/sample_player_editor_plugin.h"
-#include "plugins/script_editor_plugin.h"
-#include "plugins/script_text_editor.h"
-#include "plugins/shader_editor_plugin.h"
-#include "plugins/shader_graph_editor_plugin.h"
-#include "plugins/spatial_editor_plugin.h"
-#include "plugins/sprite_frames_editor_plugin.h"
-#include "plugins/stream_editor_plugin.h"
-#include "plugins/style_box_editor_plugin.h"
-#include "plugins/texture_editor_plugin.h"
-#include "plugins/texture_region_editor_plugin.h"
-#include "plugins/theme_editor_plugin.h"
-#include "plugins/tile_map_editor_plugin.h"
-#include "plugins/tile_set_editor_plugin.h"
-// end
-#include "editor_settings.h"
-#include "import/editor_import_collada.h"
-#include "import/editor_scene_importer_gltf.h"
-#include "io_plugins/editor_bitmask_import_plugin.h"
-#include "io_plugins/editor_export_scene.h"
-#include "io_plugins/editor_font_import_plugin.h"
-#include "io_plugins/editor_mesh_import_plugin.h"
-#include "io_plugins/editor_sample_import_plugin.h"
-#include "io_plugins/editor_scene_import_plugin.h"
-#include "io_plugins/editor_scene_importer_fbxconv.h"
-#include "io_plugins/editor_texture_import_plugin.h"
-#include "io_plugins/editor_translation_import_plugin.h"
-
-#include "editor_audio_buses.h"
-#include "editor_initialize_ssl.h"
-#include "plugins/editor_preview_plugins.h"
-#include "script_editor_debugger.h"
EditorNode *EditorNode::singleton = NULL;
@@ -223,18 +217,6 @@ void EditorNode::_notification(int p_what) {
}
if (p_what == NOTIFICATION_PROCESS) {
-//force the whole tree viewport
-#if 0
- {
- Rect2 grect = scene_root_base->get_global_rect();
- Rect2 grectsrp = scene_root_parent->get_global_rect();
- if (grect!=grectsrp) {
- scene_root_parent->set_position(grect.pos);
- scene_root_parent->set_size(grect.size);
- }
- }
-
-#endif
if (opening_prev && !confirmation->is_visible())
opening_prev = false;
@@ -249,8 +231,6 @@ void EditorNode::_notification(int p_what) {
last_checked_version = editor_data.get_undo_redo().get_version();
}
- //get_root_node()->set_rect(viewport->get_global_rect());
-
//update the circle
uint64_t frame = Engine::get_singleton()->get_frames_drawn();
uint32_t tick = OS::get_singleton()->get_ticks_msec();
@@ -280,14 +260,10 @@ void EditorNode::_notification(int p_what) {
Engine::get_singleton()->set_editor_hint(true);
get_tree()->get_root()->set_disable_3d(true);
- //MessageQueue::get_singleton()->push_call(this,"_get_scene_metadata");
get_tree()->get_root()->set_as_audio_listener(false);
get_tree()->get_root()->set_as_audio_listener_2d(false);
get_tree()->set_auto_accept_quit(false);
get_tree()->connect("files_dropped", this, "_dropped_files");
- //VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport(),false);
-
- //import_monitor->scan_changes();
}
if (p_what == NOTIFICATION_EXIT_TREE) {
@@ -302,25 +278,6 @@ void EditorNode::_notification(int p_what) {
_editor_select(EDITOR_3D);
_update_debug_options();
-
- /*
- if (defer_optimize!="") {
- Error ok = save_optimized_copy(defer_optimize,defer_optimize_preset);
- defer_optimize_preset="";
- if (ok!=OK)
- OS::get_singleton()->set_exit_code(255);
- get_scene()->quit();
- }
-*/
-
- /* // moved to "_sources_changed"
- if (export_defer.platform!="") {
-
- project_export_settings->export_platform(export_defer.platform,export_defer.path,export_defer.debug,export_defer.password,true);
- export_defer.platform="";
- }
-
- */
}
if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
@@ -391,13 +348,12 @@ void EditorNode::_fs_changed() {
}
{
-
//reload changed resources
List<Ref<Resource> > changed;
List<Ref<Resource> > cached;
ResourceCache::get_cached_resources(&cached);
- //this should probably be done in a thread..
+ // FIXME: This should be done in a thread.
for (List<Ref<Resource> >::Element *E = cached.front(); E; E = E->next()) {
if (!E->get()->editor_can_reload_from_file())
@@ -410,7 +366,6 @@ void EditorNode::_fs_changed() {
if (E->get()->get_import_path() != String()) {
//imported resource
uint64_t mt = FileAccess::get_modified_time(E->get()->get_import_path());
- print_line("testing modified: " + E->get()->get_import_path() + " " + itos(mt) + " vs " + itos(E->get()->get_import_last_modified_time()));
if (mt != E->get()->get_import_last_modified_time()) {
print_line("success");
@@ -427,11 +382,8 @@ void EditorNode::_fs_changed() {
}
if (changed.size()) {
- //EditorProgress ep("reload_res","Reload Modified Resources",changed.size());
int idx = 0;
for (List<Ref<Resource> >::Element *E = changed.front(); E; E = E->next()) {
-
- //ep.step(E->get()->get_path(),idx++);
E->get()->reload_from_file();
}
}
@@ -521,8 +473,6 @@ void EditorNode::open_resource(const String &p_type) {
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
- //file->set_current_path(current_path);
-
file->popup_centered_ratio();
current_option = RESOURCE_LOAD;
}
@@ -533,10 +483,6 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St
int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
flg |= ResourceSaver::FLAG_COMPRESS;
- /*
- if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
- flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
- */
String path = ProjectSettings::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
@@ -546,7 +492,6 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St
accept->popup_centered_minsize();
return;
}
- //EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
((Resource *)p_resource.ptr())->set_path(path);
emit_signal("resource_saved", p_resource);
@@ -582,8 +527,6 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
preferred.push_back(extensions[i]);
}
- //file->set_current_path(current_path);
-
if (p_at_path != String()) {
file->set_current_dir(p_at_path);
@@ -632,7 +575,6 @@ void EditorNode::_dialog_display_file_error(String p_file, Error p_error) {
if (p_error) {
current_option = -1;
- //accept->"()->hide();
accept->get_ok()->set_text(TTR("I see.."));
switch (p_error) {
@@ -736,8 +678,6 @@ bool EditorNode::_find_and_save_resource(RES p_res, Map<RES, bool> &processed, i
bool subchanged = _find_and_save_edited_subresources(p_res.ptr(), processed, flags);
- //print_line("checking if edited: "+p_res->get_type()+" :: "+p_res->get_name()+" :: "+p_res->get_path()+" :: "+itos(changed)+" :: SR "+itos(subchanged));
-
if (p_res->get_path().is_resource_file()) {
if (changed || subchanged) {
//save
@@ -782,8 +722,6 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool>
RES res = v;
if (_find_and_save_resource(res, processed, flags))
ret_changed = true;
-
- //_find_resources(v);
}
} break;
@@ -836,11 +774,11 @@ void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) {
void EditorNode::_save_scene_with_preview(String p_file) {
- int c2d = 0;
- int c3d = 0;
-
EditorProgress save("save", TTR("Saving Scene"), 4);
save.step(TTR("Analyzing"), 0);
+
+ int c2d = 0;
+ int c3d = 0;
_find_node_types(editor_data.get_edited_scene_root(), c2d, c3d);
RID viewport;
@@ -911,7 +849,6 @@ void EditorNode::_save_scene(String p_file, int idx) {
if (!scene) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation can't be done without a tree root."));
accept->popup_centered_minsize();
@@ -943,7 +880,6 @@ void EditorNode::_save_scene(String p_file, int idx) {
if (err != OK) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Couldn't save scene. Likely dependencies (instances) couldn't be satisfied."));
accept->popup_centered_minsize();
@@ -958,10 +894,6 @@ void EditorNode::_save_scene(String p_file, int idx) {
int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
flg |= ResourceSaver::FLAG_COMPRESS;
- /*
- if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
- flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
- */
flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
err = ResourceSaver::save(p_file, sdata, flg);
@@ -970,7 +902,6 @@ void EditorNode::_save_scene(String p_file, int idx) {
editor_data.save_editor_external_data();
if (err == OK) {
scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_file));
- //EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type());
if (idx < 0 || idx == editor_data.get_edited_scene())
set_current_version(editor_data.get_undo_redo().get_version());
else
@@ -989,11 +920,7 @@ void EditorNode::_save_all_scenes() {
Node *scene = editor_data.get_edited_scene_root(i);
if (scene && scene->get_filename() != "") {
// save in background if in the script editor
- if (i != editor_data.get_edited_scene() || _get_current_main_editor() == EDITOR_SCRIPT) {
- _save_scene(scene->get_filename(), i);
- } else {
- _save_scene_with_preview(scene->get_filename());
- }
+ _save_scene_with_preview(scene->get_filename());
} // else: ignore new scenes
}
@@ -1023,106 +950,6 @@ void EditorNode::_mark_unsaved_scenes() {
_update_scene_tabs();
}
-void EditorNode::_import_action(const String &p_action) {
-#if 0
- import_confirmation->hide();
-
- if (p_action=="re-import") {
- _import(_tmp_import_path);
- }
- if (p_action=="update") {
-
- Node *src = EditorImport::import_scene(_tmp_import_path);
-
- if (!src) {
-
- current_option=-1;
- //accept->get_cancel()->hide();
- accept->get_ok()->set_text("Ugh");
- accept->set_text("Error importing scene.");
- accept->popup_centered(Size2(300,70));
- return;
- }
-
- //as soon as the scene is imported, version hashes must be generated for comparison against saved scene
- EditorImport::generate_version_hashes(src);
-
-
- Node *dst = SceneLoader::load(editor_data.get_imported_scene(ProjectSettings::get_singleton()->localize_path(_tmp_import_path)));
-
- if (!dst) {
-
- memdelete(src);
- //accept->get_cancel()->hide();
- accept->get_ok()->set_text("Ugh");
- accept->set_text("Error load scene to update.");
- accept->popup_centered(Size2(300,70));
- return;
- }
-
- List<EditorImport::Conflict> conflicts;
- EditorImport::check_conflicts(src,dst,&conflicts);
-
- bool conflicted=false;
- for (List<EditorImport::Conflict>::Element *E=conflicts.front();E;E=E->next()) {
-
-
- if (E->get().status==EditorImport::Conflict::STATUS_CONFLICT) {
-
- conflicted=true;
- break;
- }
- }
-
- if (conflicted) {
- import_conflicts_dialog->popup(src,dst,conflicts);
- return;
- }
-
- _import_with_conflicts(src,dst,conflicts);
- //not conflicted, just reimport!
-
- }
-#endif
-}
-
-void EditorNode::_import(const String &p_file) {
-
-#if 0
- Node *new_scene = EditorImport::import_scene(p_file);
-
- if (!new_scene) {
-
- current_option=-1;
- //accept->get_cancel()->hide();
- accept->get_ok()->set_text("Ugh");
- accept->set_text("Error importing scene.");
- accept->popup_centered(Size2(300,70));
- return;
- }
-
- //as soon as the scene is imported, version hashes must be generated for comparison against saved scene
- EditorImport::generate_version_hashes(new_scene);
-
- Node *old_scene = edited_scene;
- _hide_top_editors();
- set_edited_scene(NULL);
- editor_data.clear_editor_states();
- if (old_scene) {
- memdelete(old_scene);
- }
-
- set_edited_scene(new_scene);
- scene_tree_dock->set_selected(new_scene);
- //_get_scene_metadata();
-
- editor_data.get_undo_redo().clear_history();
- saved_version=editor_data.get_undo_redo().get_version();
- _update_title();
-
-#endif
-}
-
void EditorNode::_dialog_action(String p_file) {
switch (current_option) {
@@ -1133,7 +960,6 @@ void EditorNode::_dialog_action(String p_file) {
if (res.is_null()) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text("ok :(");
accept->set_text(TTR("Failed to load resource."));
return;
@@ -1156,9 +982,6 @@ void EditorNode::_dialog_action(String p_file) {
//would be nice to show the project manager opened with the highlighted field..
_run(false, ""); // automatically run the project
} break;
- case FILE_SAVE_OPTIMIZED: {
-
- } break;
case FILE_RUN_SCRIPT: {
Ref<Script> scr = ResourceLoader::load(p_file, "Script", true);
@@ -1190,12 +1013,8 @@ void EditorNode::_dialog_action(String p_file) {
if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
- //_save_scene(p_file);
_save_default_environment();
- if (scene_idx != editor_data.get_edited_scene() || _get_current_main_editor() == EDITOR_SCRIPT)
- _save_scene(p_file, scene_idx);
- else
- _save_scene_with_preview(p_file);
+ _save_scene_with_preview(p_file);
if (scene_idx != -1)
_discard_changes();
@@ -1206,7 +1025,6 @@ void EditorNode::_dialog_action(String p_file) {
case FILE_SAVE_AND_RUN: {
if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
- //_save_scene(p_file);
_save_default_environment();
_save_scene_with_preview(p_file);
_call_build();
@@ -1222,7 +1040,6 @@ void EditorNode::_dialog_action(String p_file) {
if (ml.is_null()) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Can't load MeshLibrary for merging!"));
accept->popup_centered_minsize();
@@ -1255,7 +1072,6 @@ void EditorNode::_dialog_action(String p_file) {
if (ml.is_null()) {
if (file_export_lib_merge->is_pressed()) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Can't load TileSet for merging!"));
accept->popup_centered_minsize();
@@ -1281,10 +1097,6 @@ void EditorNode::_dialog_action(String p_file) {
}
} break;
- // case SETTINGS_LOAD_EXPORT_TEMPLATES: {
-
- // } break;
-
case RESOURCE_SAVE:
case RESOURCE_SAVE_AS: {
@@ -1360,8 +1172,6 @@ void EditorNode::_dialog_action(String p_file) {
default: { //save scene?
if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
-
- //_save_scene(p_file);
_save_scene_with_preview(p_file);
}
@@ -1472,20 +1282,6 @@ void EditorNode::_save_default_environment() {
}
}
-void EditorNode::_imported(Node *p_node) {
-
- /*
- Node *scene = editor_data.get_edited_scene_root();
- add_edited_scene(p_node);
-
- if (scene) {
- String path = scene->get_filename();
- p_node->set_filename(path);
- memdelete(scene);
- }
-*/
-}
-
void EditorNode::_hide_top_editors() {
_display_top_editors(false);
@@ -1543,14 +1339,10 @@ void EditorNode::_edit_current() {
node_dock->set_node(NULL);
object_menu->set_disabled(false);
EditorNode::get_singleton()->get_import_dock()->set_edit_path(current_res->get_path());
- //resources_dock->add_resource(Ref<Resource>(current_res));
-
- //top_pallete->set_current_tab(1);
} else if (is_node) {
Node *current_node = Object::cast_to<Node>(current_obj);
ERR_FAIL_COND(!current_node);
- // ERR_FAIL_COND(!current_node->is_inside_tree());
property_editor->edit(current_node);
if (current_node->is_inside_tree()) {
@@ -1562,14 +1354,10 @@ void EditorNode::_edit_current() {
}
object_menu->get_popup()->clear();
- //top_pallete->set_current_tab(0);
-
} else {
property_editor->edit(current_obj);
node_dock->set_node(NULL);
- //scene_tree_dock->set_selected(current_node);
- //object_menu->get_popup()->clear();
}
/* Take care of PLUGIN EDITOR */
@@ -1624,15 +1412,6 @@ void EditorNode::_edit_current() {
_hide_top_editors();
}
- /*
- if (!plugin || plugin->has_main_screen()) {
- // remove the OVER plugin if exists
- if (editor_plugin_over)
- editor_plugin_over->make_visible(false);
- editor_plugin_over=NULL;
- }
-*/
- /* Take care of OBJECT MENU */
object_menu->set_disabled(false);
@@ -1677,9 +1456,6 @@ void EditorNode::_edit_current() {
}
}
- //p->add_separator();
- //p->add_item("All Methods",OBJECT_CALL_METHOD);
-
update_keying();
}
@@ -1716,7 +1492,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
play_button->set_pressed(false);
play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons"));
- //pause_button->set_pressed(false);
play_scene_button->set_pressed(false);
play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
play_custom_scene_button->set_pressed(false);
@@ -1732,7 +1507,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (!scene) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("There is no defined scene to run."));
accept->popup_centered_minsize();
@@ -1741,8 +1515,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (scene->get_filename() == "") {
current_option = -1;
- //accept->get_cancel()->hide();
- /**/
_menu_option_confirm(FILE_SAVE_BEFORE_RUN, false);
return;
}
@@ -1759,7 +1531,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (main_scene == "") {
current_option = -1;
- //accept->get_cancel()->hide();
pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category."));
pick_main_scene->popup_centered_minsize();
return;
@@ -1768,7 +1539,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (!FileAccess::exists(main_scene)) {
current_option = -1;
- //accept->get_cancel()->hide();
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
pick_main_scene->popup_centered_minsize();
return;
@@ -1777,7 +1547,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (ResourceLoader::get_resource_type(main_scene) != "PackedScene") {
current_option = -1;
- //accept->get_cancel()->hide();
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
pick_main_scene->popup_centered_minsize();
return;
@@ -1795,14 +1564,12 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (scene->get_filename() == "") {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Current scene was never saved, please save it prior to running."));
accept->popup_centered_minsize();
return;
}
- //_save_scene(scene->get_filename());
_save_scene_with_preview(scene->get_filename());
}
}
@@ -1828,7 +1595,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (error != OK) {
current_option = -1;
- //confirmation->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Could not start subprocess!"));
accept->popup_centered_minsize();
@@ -1853,23 +1619,12 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
- //print_line("option "+itos(p_option)+" confirm "+itos(p_confirmed));
if (!p_confirmed) //this may be a hack..
current_option = (MenuOptions)p_option;
switch (p_option) {
case FILE_NEW_SCENE: {
- // TODO: Drop such obsolete commented code
- /*
- if (!p_confirmed) {
- confirmation->get_ok()->set_text("Yes");
- //confirmation->get_cancel()->show();
- confirmation->set_text("Start a New Scene? (Current will be lost)");
- confirmation->popup_centered_minsize();
- break;
- }*/
-
int idx = editor_data.add_edited_scene(-1);
_scene_tab_changed(idx);
editor_data.clear_editor_states();
@@ -1878,9 +1633,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case FILE_NEW_INHERITED_SCENE:
case FILE_OPEN_SCENE: {
- //print_tree();
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- //not for now?
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
file->clear_filters();
@@ -1889,7 +1642,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
- //file->set_current_path(current_path);
Node *scene = editor_data.get_edited_scene_root();
if (scene) {
file->set_current_path(scene->get_filename());
@@ -1944,11 +1696,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (scene && scene->get_filename() != "") {
// save in background if in the script editor
- if (scene_idx != editor_data.get_edited_scene() || _get_current_main_editor() == EDITOR_SCRIPT) {
- _save_scene(scene->get_filename(), scene_idx);
- } else {
- _save_scene_with_preview(scene->get_filename());
- }
+ _save_scene_with_preview(scene->get_filename());
if (scene_idx != -1)
_discard_changes();
@@ -2023,44 +1771,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
_menu_option_confirm(FILE_SAVE_AND_RUN, false);
} break;
- case FILE_SAVE_OPTIMIZED: {
-#if 0
- Node *scene = editor_data.get_edited_scene_root();
- if (!scene) {
-
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("This operation can't be done without a tree root.");
- accept->popup_centered(Size2(300,70));
- break;
- }
-
-
-
- //file->set_current_path(current_path);
-
- String cpath;
- if (scene->get_filename()!="") {
- cpath = scene->get_filename();
-
- String fn = cpath.substr(0,cpath.length() - cpath.extension().size());
- String ext=cpath.extension();
- cpath=fn+".optimized.scn";
- optimized_save->set_optimized_scene(cpath);
- optimized_save->popup_centered(Size2(500,143));
- } else {
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("Please save the scene first.");
- accept->popup_centered(Size2(300,70));
- break;
-
- }
-#endif
- } break;
-
case FILE_EXPORT_PROJECT: {
project_export->popup_export();
@@ -2116,7 +1826,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (!editor_data.get_edited_scene_root()) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation can't be done without a selected node."));
accept->popup_centered_minsize();
@@ -2205,61 +1914,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
scene_tabs->set_current_tab(cur_idx);
} break;
-
-#if 0
- case NODE_EXTERNAL_INSTANCE: {
-
-
- if (!edited_scene) {
-
- current_option=-1;
- //accept->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("This operation can't be done without a selected node.");
- accept->popup_centered(Size2(300,70));
- break;
- }
-
- Node *parent = scene_tree_editor->get_selected();
-
- if (!parent) {
-
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("This operation can't be done without a selected node.");
- accept->popup_centered(Size2(300,70));
- break;
- }
-
- Node*instanced_scene=SceneLoader::load(external_file,true);
-
- if (!instanced_scene) {
-
- current_option=-1;
- //accept->get_cancel()->hide();
- accept->get_ok()->set_text("Ugh");
- accept->set_text("Error loading scene from "+external_file);
- accept->popup_centered(Size2(300,70));
- return;
- }
-
- instanced_scene->generate_instance_state();
- instanced_scene->set_filename( ProjectSettings::get_singleton()->localize_path(external_file) );
-
- editor_data.get_undo_redo().create_action("Instance Scene");
- editor_data.get_undo_redo().add_do_method(parent,"add_child",instanced_scene);
- editor_data.get_undo_redo().add_do_method(instanced_scene,"set_owner",edited_scene);
- editor_data.get_undo_redo().add_do_reference(instanced_scene);
- editor_data.get_undo_redo().add_undo_method(parent,"remove_child",instanced_scene);
- editor_data.get_undo_redo().commit_action();
-
- //parent->add_child(instanced_scene);
- //instanced_scene->set_owner(edited_scene);
- _last_instanced_scene=instanced_scene;
-
- } break;
-#endif
case RESOURCE_NEW: {
create_dialog->popup_create(true);
@@ -2414,7 +2068,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
play_custom_scene_button->set_pressed(false);
play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
- //pause_button->set_pressed(false);
if (bool(EDITOR_DEF("run/output/always_close_output_on_stop", true))) {
for (int i = 0; i < bottom_panel_items.size(); i++) {
if (bottom_panel_items[i].control == log) {
@@ -2503,19 +2156,14 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case RUN_FILE_SERVER: {
- //file_server
bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER));
if (ischecked) {
file_server->stop();
run_native->set_deploy_dumb(false);
- //debug_menu->set_icon(gui_base->get_icon("FileServer","EditorIcons"));
- //debug_menu->get_popup()->set_item_text( debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER),"Enable File Server");
} else {
file_server->start();
run_native->set_deploy_dumb(true);
- //debug_menu->set_icon(gui_base->get_icon("FileServerActive","EditorIcons"));
- //debug_menu->get_popup()->set_item_text( debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER),"Disable File Server");
}
debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER), !ischecked);
@@ -2530,14 +2178,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_live_debug", !ischecked);
} break;
-
- /*case RUN_DEPLOY_DUMB_CLIENTS: {
-
- bool ischecked = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(RUN_DEPLOY_DUMB_CLIENTS));
- debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(RUN_DEPLOY_DUMB_CLIENTS),!ischecked);
- run_native->set_deploy_dumb(!ischecked);
-
- } break;*/
case RUN_DEPLOY_REMOTE_DEBUG: {
bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG));
@@ -2578,25 +2218,26 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
update_menu->get_popup()->set_item_checked(0, true);
update_menu->get_popup()->set_item_checked(1, false);
OS::get_singleton()->set_low_processor_usage_mode(false);
+ EditorSettings::get_singleton()->set_project_metadata("editor_options", "update_mode", SETTINGS_UPDATE_ALWAYS);
} break;
case SETTINGS_UPDATE_CHANGES: {
update_menu->get_popup()->set_item_checked(0, false);
update_menu->get_popup()->set_item_checked(1, true);
OS::get_singleton()->set_low_processor_usage_mode(true);
+ EditorSettings::get_singleton()->set_project_metadata("editor_options", "update_mode", SETTINGS_UPDATE_CHANGES);
} break;
case SETTINGS_UPDATE_SPINNER_HIDE: {
+
update_menu->set_icon(gui_base->get_icon("Collapse", "EditorIcons"));
update_menu->get_popup()->toggle_item_checked(3);
+ bool checked = update_menu->get_popup()->is_item_checked(3);
+ EditorSettings::get_singleton()->set_project_metadata("editor_options", "update_spinner_hide", checked);
} break;
case SETTINGS_PREFERENCES: {
settings_config_dialog->popup_edit_settings();
} break;
- case SETTINGS_OPTIMIZED_PRESETS: {
-
- //optimized_presets->popup_centered_ratio();
- } break;
case SETTINGS_MANAGE_EXPORT_TEMPLATES: {
export_template_manager->popup_manager();
@@ -2609,9 +2250,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case SETTINGS_PICK_MAIN_SCENE: {
- //print_tree();
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- //not for now?
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
file->clear_filters();
@@ -2620,7 +2259,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
- //file->set_current_path(current_path);
Node *scene = editor_data.get_edited_scene_root();
if (scene) {
file->set_current_path(scene->get_filename());
@@ -2650,56 +2288,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case HELP_ABOUT: {
about->popup_centered_minsize(Size2(780, 500) * EDSCALE);
} break;
- case SOURCES_REIMPORT: {
-
- //reimport_dialog->popup_reimport();
- } break;
- case DEPENDENCY_LOAD_CHANGED_IMAGES: {
-
- } break;
- case DEPENDENCY_UPDATE_IMPORTED: {
-
- /*
- bool editing_changed = _find_editing_changed_scene(get_edited_scene());
-
- import_reload_fn="";
-
- if (editing_changed) {
- if (unsaved_cache && !bool(EDITOR_DEF("import/ask_save_before_reimport",false))) {
- if (!p_confirmed) {
-
-
- confirmation->get_ok()->set_text("Open");
- //confirmation->get_cancel()->show();
- confirmation->set_text("Current scene changed, save and re-import ?");
- confirmation->popup_centered(Size2(300,70));
- break;
-
- }
- }
-
- Node *scene = get_edited_scene();
-
- if (scene->get_filename()=="") {
-
- current_option=-1;
- //accept->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("Can't import if edited scene was not saved."); //i don't think this code will ever run
- accept->popup_centered(Size2(300,70));
- break;
-
- }
-
-
- import_reload_fn = scene->get_filename();
- _save_scene(import_reload_fn);
-
- }
-
-*/
-
- } break;
default: {
@@ -2864,7 +2452,7 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor) {
tb->set_toggle_mode(true);
tb->connect("pressed", singleton, "_editor_select", varray(singleton->main_editor_buttons.size()));
tb->set_text(p_editor->get_name());
- tb->set_icon(p_editor->get_base_control()->get_icon(p_editor->get_name(), "EditorIcons"));
+ tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons"));
tb->set_name(p_editor->get_name());
singleton->main_editor_buttons.push_back(tb);
singleton->main_editor_button_vb->add_child(tb);
@@ -3008,18 +2596,9 @@ void EditorNode::_remove_edited_scene() {
editor_data.get_undo_redo().clear_history();
_update_title();
_update_scene_tabs();
-
- /*
- if (editor_data.get_edited_scene_count()==1) {
- //make new scene appear saved
- set_current_version(editor_data.get_undo_redo().get_version());
- unsaved_cache=false;
- }
- */
}
void EditorNode::_remove_scene(int index) {
- //printf("Attempting to remove scene %d (current is %d)\n", index, editor_data.get_edited_scene());
if (editor_data.get_edited_scene() == index) {
//Scene to remove is current scene
@@ -3068,7 +2647,6 @@ Dictionary EditorNode::_get_main_scene_state() {
state["property_edit_offset"] = get_property_editor()->get_scene_tree()->get_vscroll_bar()->get_value();
state["saved_version"] = saved_version;
state["node_filter"] = scene_tree_dock->get_filter();
- //print_line(" getting main tab: "+itos(state["main_tab"]));
return state;
}
@@ -3077,32 +2655,8 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
if (get_edited_scene() != p_for_scene && p_for_scene != NULL)
return; //not for this scene
- //print_line("set current 7 ");
changing_scene = false;
-#if 0
- if (p_state.has("main_tab")) {
- int idx = p_state["main_tab"];
-
-
- print_line("comes with tab: "+itos(idx));
- int current=-1;
- for(int i=0;i<editor_table.size();i++) {
- if (editor_plugin_screen==editor_table[i]) {
- current=i;
- break;
- }
- }
-
-
- if (idx<2 && current<2) {
- //only set tab for 2D and 3D
- _editor_select(idx);
- //print_line(" setting main tab: "+itos(p_state["main_tab"]));
- }
- }
-#else
-
if (get_edited_scene()) {
int current = -1;
@@ -3125,7 +2679,6 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
}
}
}
-#endif
if (p_state.has("scene_tree_offset"))
scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->set_value(p_state["scene_tree_offset"]);
@@ -3134,16 +2687,12 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
if (p_state.has("node_filter"))
scene_tree_dock->set_filter(p_state["node_filter"]);
- //print_line("set current 8 ");
//this should only happen at the very end
- //changing_scene=true; //avoid script change from opening editor
ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root();
ScriptEditor::get_singleton()->set_scene_root_script(editor_data.get_scene_root_script(editor_data.get_edited_scene()));
editor_data.notify_edited_scene_changed();
-
- //changing_scene=false;
}
void EditorNode::set_current_version(uint64_t p_version) {
@@ -3175,8 +2724,6 @@ void EditorNode::set_current_scene(int p_idx) {
scene_root->remove_child(get_editor_data().get_edited_scene_root());
}
- //print_line("set current 2 ");
-
editor_selection->clear();
editor_data.set_edited_scene(p_idx);
@@ -3185,8 +2732,6 @@ void EditorNode::set_current_scene(int p_idx) {
if (Object::cast_to<Popup>(new_scene))
Object::cast_to<Popup>(new_scene)->show(); //show popups
- //print_line("set current 3 ");
-
scene_tree_dock->set_edited_scene(new_scene);
if (get_tree())
get_tree()->set_edited_scene_root(new_scene);
@@ -3195,25 +2740,11 @@ void EditorNode::set_current_scene(int p_idx) {
if (new_scene->get_parent() != scene_root)
scene_root->add_child(new_scene);
}
- //print_line("set current 4 ");
Dictionary state = editor_data.restore_edited_scene_state(editor_selection, &editor_history);
_edit_current();
- /*if (!unsaved) {
- saved_version=editor_data.get_undo_redo().get_version();
- if (p_backwards)
- saved_version--;
- else
- saved_version++;
- print_line("was saved, updating version");
- } else {
- saved_version=state["saved_version"];
- }*/
- //_set_main_scene_state(state);
-
call_deferred("_set_main_scene_state", state, get_edited_scene()); //do after everything else is done setting up
- //print_line("set current 6 ");
}
bool EditorNode::is_scene_open(const String &p_path) {
@@ -3264,7 +2795,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
if (!lpath.begins_with("res://")) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
accept->set_text(TTR("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path."));
accept->popup_centered_minsize();
@@ -3274,8 +2804,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
int prev = editor_data.get_edited_scene();
int idx = editor_data.add_edited_scene(-1);
- //print_line("load scene callback");
- //set_current_scene(idx);
if (!editor_data.get_edited_scene_root() && editor_data.get_edited_scene_count() == 2) {
_remove_edited_scene();
@@ -3289,7 +2817,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
if (!sdata.is_valid()) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
accept->set_text(TTR("Error loading scene."));
accept->popup_centered_minsize();
@@ -3350,7 +2877,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
sdata.unref();
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
accept->set_text(TTR("Error loading scene."));
accept->popup_centered_minsize();
@@ -3362,46 +2888,18 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
return ERR_FILE_NOT_FOUND;
}
- //guess not needed in the end?
- //new_scene->clear_internal_tree_resource_paths(); //make sure no internal tree paths to internal resources exist
-
- /*
- Node *old_scene = edited_scene;
- _hide_top_editors();
- set_edited_scene(NULL);
- editor_data.clear_editor_states();
- if (old_scene) {
- if (!opening_prev && old_scene->get_filename()!="") {
- previous_scenes.push_back(old_scene->get_filename());
- }
- memdelete(old_scene);
- }
-*/
-
if (p_set_inherited) {
Ref<SceneState> state = sdata->get_state();
state->set_path(lpath);
new_scene->set_scene_inherited_state(state);
new_scene->set_filename(String());
- /*
- if (new_scene->get_scene_instance_state().is_valid())
- new_scene->get_scene_instance_state()->set_path(String());
- */
}
new_scene->set_scene_instance_state(Ref<SceneState>());
set_edited_scene(new_scene);
_get_scene_metadata(p_scene);
- /*
- editor_data.set_edited_scene_root(new_scene);
- scene_tree_dock->set_selected(new_scene, true);
- property_editor->edit(new_scene);
- editor_data.set_edited_scene_root(new_scene);
-*/
-
- //editor_data.get_undo_redo().clear_history();
saved_version = editor_data.get_undo_redo().get_version();
_update_title();
_update_scene_tabs();
@@ -3412,8 +2910,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root();
- //top_pallete->set_current_tab(0); //always go to scene
-
push_item(new_scene);
return OK;
@@ -3422,8 +2918,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
void EditorNode::open_request(const String &p_path) {
load_scene(p_path); // as it will be opened in separate tab
- //external_file=p_path;
- //_menu_option_confirm(FILE_EXTERNAL_OPEN_SCENE,false);
}
void EditorNode::request_instance_scene(const String &p_path) {
@@ -3469,8 +2963,6 @@ void EditorNode::_transform_keyed(Object *sp, const String &p_sub, const Transfo
void EditorNode::update_keying() {
- //print_line("KR: "+itos(p_enabled));
-
bool valid = false;
if (AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) {
@@ -3492,57 +2984,15 @@ void EditorNode::update_keying() {
void EditorNode::_close_messages() {
- //left_split->set_dragger_visible(false);
old_split_ofs = center_split->get_split_offset();
center_split->set_split_offset(0);
- //scene_root_parent->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,0);
}
void EditorNode::_show_messages() {
- //left_split->set_dragger_visible(true);
center_split->set_split_offset(old_split_ofs);
- //scene_root_parent->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,log->get_margin(MARGIN_TOP));
}
-#if 0
-void EditorNode::animation_panel_make_visible(bool p_visible) {
-
- if (!p_visible) {
- animation_panel->hide();
- } else {
- animation_panel->show();
- }
-
- int idx = settings_menu->get_popup()->get_item_index(SETTINGS_SHOW_ANIMATION);
- settings_menu->get_popup()->set_item_checked(idx,p_visible);
-}
-
-
-void EditorNode::animation_editor_make_visible(bool p_visible) {
-
- if (p_visible) {
-
- animation_editor->show();
- animation_vb->get_parent_control()->minimum_size_changed();
- //pd_anim->show();
- top_split->set_collapsed(false);
-
- //scene_root_parent->set_margin(MARGIN_TOP,animation_editor->get_margin(MARGIN_BOTTOM));
- } else {
- //pd_anim->hide();
- animation_editor->hide();
- //scene_root_parent->set_margin(MARGIN_TOP,0);
- if (!animation_vb->get_parent_control())
- return;
- animation_vb->get_parent_control()->minimum_size_changed();
- top_split->set_collapsed(true);
- }
-
- animation_editor->set_keying(p_visible);
-
-}
-#endif
void EditorNode::_add_to_recent_scenes(const String &p_scene) {
String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
@@ -3571,44 +3021,6 @@ void EditorNode::_open_recent_scene(int p_idx) {
load_scene(path);
}
-void EditorNode::_save_optimized() {
-
-//save_optimized_copy(optimized_save->get_optimized_scene(),optimized_save->get_preset());
-#if 0
- String path = optimized_save->get_optimized_scene();
-
- uint32_t flags=0;
-
- String platform="all";
- Ref<EditorOptimizedSaver> saver=editor_data.get_optimized_saver(optimized_save->get_preset());
-
- if (saver->is_bundle_scenes_enabled())
- flags|=SceneSaver::FLAG_BUNDLE_INSTANCED_SCENES;
- if (saver->is_bundle_resources_enabled())
- flags|=SceneSaver::FLAG_BUNDLE_RESOURCES;
- if (saver->is_remove_editor_data_enabled())
- flags|=SceneSaver::FLAG_OMIT_EDITOR_PROPERTIES;
- if (saver->is_big_endian_data_enabled())
- flags|=SceneSaver::FLAG_SAVE_BIG_ENDIAN;
-
- platform=saver->get_target_platform();
-
- Error err = SceneSaver::save(path,get_edited_scene(),flags,saver);
-
- if (err) {
-
- //accept->"()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("Error saving optimized scene: "+path);
- accept->popup_centered(Size2(300,70));
- return;
-
- }
-
- project_settings->add_remapped_path(ProjectSettings::get_singleton()->localize_path(get_edited_scene()->get_filename()),ProjectSettings::get_singleton()->localize_path(path),platform);
-#endif
-}
-
void EditorNode::_update_recent_scenes() {
String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
@@ -3648,33 +3060,7 @@ void EditorNode::notify_child_process_exited() {
editor_run.stop();
}
-bool EditorNode::_find_editing_changed_scene(Node *p_from) {
- /*
- if (!p_from)
- return false;
-
- if (p_from->get_filename()!="") {
-
- StringName fn = p_from->get_filename();
- for(int i=0;i<import_monitor->get_changes().size();i++) {
-
- if (fn==import_monitor->get_changes()[i])
- return true;
- }
- }
-
- for(int i=0;i<p_from->get_child_count();i++) {
-
- if (_find_editing_changed_scene(p_from->get_child(i)))
- return true;
- }
-*/
- return false;
-}
-
void EditorNode::add_io_error(const String &p_error) {
- //CharString err_ut = p_error.utf8();
- //ERR_PRINT(!err_ut.get_data());
_load_error_notify(singleton, p_error);
}
@@ -3714,12 +3100,9 @@ void EditorNode::register_editor_types() {
ClassDB::register_class<EditorPlugin>();
ClassDB::register_class<EditorImportPlugin>();
- // ClassDB::register_class<EditorExportPlugin>();
- // ClassDB::register_class<EditorScenePostImport>();
ClassDB::register_class<EditorScript>();
ClassDB::register_class<EditorSelection>();
ClassDB::register_class<EditorFileDialog>();
- //ClassDB::register_type<EditorImportExport>();
ClassDB::register_class<EditorSettings>();
ClassDB::register_class<EditorSpatialGizmo>();
ClassDB::register_class<EditorResourcePreview>();
@@ -3727,9 +3110,12 @@ void EditorNode::register_editor_types() {
ClassDB::register_class<EditorFileSystem>();
ClassDB::register_class<EditorFileSystemDirectory>();
ClassDB::register_virtual_class<ScriptEditor>();
+ ClassDB::register_virtual_class<EditorInterface>();
- //ClassDB::register_type<EditorImporter>();
- //ClassDB::register_type<EditorPostImport>();
+ // FIXME: Is this stuff obsolete, or should it be ported to new APIs?
+ //ClassDB::register_class<EditorExportPlugin>();
+ //ClassDB::register_class<EditorScenePostImport>();
+ //ClassDB::register_type<EditorImportExport>();
}
void EditorNode::unregister_editor_types() {
@@ -4167,21 +3553,6 @@ void EditorNode::_update_dock_slots_visibility() {
}
}
-void EditorNode::_update_top_menu_visibility() {
-
- return; // I think removing top menu is too much
- /*
- if (distraction_free->is_pressed()) {
- play_cc->hide();
- menu_hb->hide();
- scene_tabs->hide();
- } else {
- play_cc->show();
- menu_hb->show();
- scene_tabs->show();
- }*/
-}
-
void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section) {
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
@@ -4429,27 +3800,20 @@ void EditorNode::_thumbnail_done(const String &p_path, const Ref<Texture> &p_pre
void EditorNode::_scene_tab_changed(int p_tab) {
tab_preview_panel->hide();
- //print_line("set current 1 ");
bool unsaved = (saved_version != editor_data.get_undo_redo().get_version());
- //print_line("version: "+itos(editor_data.get_undo_redo().get_version())+", saved "+itos(saved_version));
if (p_tab == editor_data.get_edited_scene())
return; //pointless
uint64_t next_scene_version = editor_data.get_scene_version(p_tab);
- //print_line("scene tab changed???");
editor_data.get_undo_redo().create_action(TTR("Switch Scene Tab"));
editor_data.get_undo_redo().add_do_method(this, "set_current_version", unsaved ? saved_version : 0);
editor_data.get_undo_redo().add_do_method(this, "set_current_scene", p_tab);
- //editor_data.get_undo_redo().add_do_method(scene_tabs,"set_current_tab",p_tab);
- //editor_data.get_undo_redo().add_do_method(scene_tabs,"ensure_tab_visible",p_tab);
editor_data.get_undo_redo().add_do_method(this, "set_current_version", next_scene_version == 0 ? editor_data.get_undo_redo().get_version() + 1 : next_scene_version);
editor_data.get_undo_redo().add_undo_method(this, "set_current_version", next_scene_version);
editor_data.get_undo_redo().add_undo_method(this, "set_current_scene", editor_data.get_edited_scene());
- //editor_data.get_undo_redo().add_undo_method(scene_tabs,"set_current_tab",editor_data.get_edited_scene());
- //editor_data.get_undo_redo().add_undo_method(scene_tabs,"ensure_tab_visible",p_tab,editor_data.get_edited_scene());
editor_data.get_undo_redo().add_undo_method(this, "set_current_version", saved_version);
editor_data.get_undo_redo().commit_action();
}
@@ -4630,7 +3994,6 @@ void EditorNode::set_distraction_free_mode(bool p_enter) {
} else {
set_docks_visible(true);
}
- _update_top_menu_visibility();
}
bool EditorNode::get_distraction_free_mode() const {
@@ -4763,11 +4126,14 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_files, Control *
void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
+ /*
String cur_path = filesystem_dock->get_current_path();
- // for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) {
- // EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path);
- // }
+ for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) {
+ EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path);
+ }
+ */
}
+
void EditorNode::_file_access_close_error_notify(const String &p_str) {
add_io_error("Unable to write to file '" + p_str + "', file in use, locked or lacking permissions.");
@@ -4955,7 +4321,6 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("_editor_select", &EditorNode::_editor_select);
ClassDB::bind_method("_node_renamed", &EditorNode::_node_renamed);
ClassDB::bind_method("edit_node", &EditorNode::edit_node);
- ClassDB::bind_method("_imported", &EditorNode::_imported);
ClassDB::bind_method("_unhandled_input", &EditorNode::_unhandled_input);
ClassDB::bind_method("_get_scene_metadata", &EditorNode::_get_scene_metadata);
@@ -4972,14 +4337,7 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("_quick_run", &EditorNode::_quick_run);
ClassDB::bind_method("_resource_created", &EditorNode::_resource_created);
-
- ClassDB::bind_method("_import_action", &EditorNode::_import_action);
- //ClassDB::bind_method("_import",&EditorNode::_import);
- //ClassDB::bind_method("_import_conflicts_solved",&EditorNode::_import_conflicts_solved);
ClassDB::bind_method("_open_recent_scene", &EditorNode::_open_recent_scene);
- //ClassDB::bind_method("_open_recent_scene_confirm",&EditorNode::_open_recent_scene_confirm);
-
- ClassDB::bind_method("_save_optimized", &EditorNode::_save_optimized);
ClassDB::bind_method("stop_child_process", &EditorNode::stop_child_process);
@@ -5019,8 +4377,6 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("_dropped_files", &EditorNode::_dropped_files);
ClassDB::bind_method("_toggle_distraction_free_mode", &EditorNode::_toggle_distraction_free_mode);
- // ClassDB::bind_method(D_METHOD("add_editor_import_plugin", "plugin"), &EditorNode::add_editor_import_plugin);
- //ClassDB::bind_method(D_METHOD("remove_editor_import_plugin", "plugin"), &EditorNode::remove_editor_import_plugin);
ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base);
ClassDB::bind_method(D_METHOD("_bottom_panel_switch"), &EditorNode::_bottom_panel_switch);
@@ -5200,7 +4556,6 @@ EditorNode::EditorNode() {
menu_hb = memnew(HBoxContainer);
main_vbox->add_child(menu_hb);
- //left
left_l_hsplit = memnew(HSplitContainer);
main_vbox->add_child(left_l_hsplit);
@@ -5224,19 +4579,14 @@ EditorNode::EditorNode() {
left_r_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_UR]);
dock_slot[DOCK_SLOT_LEFT_BR] = memnew(TabContainer);
left_r_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_BR]);
- //left_r_vsplit->hide();
- //dock_slot[DOCK_SLOT_LEFT_UR]->hide();
- //dock_slot[DOCK_SLOT_LEFT_BR]->hide();
main_hsplit = memnew(HSplitContainer);
left_r_hsplit->add_child(main_hsplit);
- //main_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
VBoxContainer *center_vb = memnew(VBoxContainer);
main_hsplit->add_child(center_vb);
center_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
center_split = memnew(VSplitContainer);
- //main_hsplit->add_child(center_split);
center_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
center_split->set_collapsed(false);
center_vb->add_child(center_split);
@@ -5250,9 +4600,6 @@ EditorNode::EditorNode() {
right_l_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_UL]);
dock_slot[DOCK_SLOT_RIGHT_BL] = memnew(TabContainer);
right_l_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_BL]);
- //right_l_vsplit->hide();
- //dock_slot[DOCK_SLOT_RIGHT_UL]->hide();
- //dock_slot[DOCK_SLOT_RIGHT_BL]->hide();
right_r_vsplit = memnew(VSplitContainer);
right_hsplit->add_child(right_r_vsplit);
@@ -5284,7 +4631,6 @@ EditorNode::EditorNode() {
dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons"));
dock_tab_move_left->set_focus_mode(Control::FOCUS_NONE);
dock_tab_move_left->connect("pressed", this, "_dock_move_left");
- //dock_tab_move_left->set_h_size_flags(Control::SIZE_EXPAND_FILL);
dock_hb->add_child(dock_tab_move_left);
dock_hb->add_spacer();
dock_tab_move_right = memnew(ToolButton);
@@ -5292,7 +4638,6 @@ EditorNode::EditorNode() {
dock_tab_move_right->set_focus_mode(Control::FOCUS_NONE);
dock_tab_move_right->connect("pressed", this, "_dock_move_right");
- //dock_tab_move_right->set_h_size_flags(Control::SIZE_EXPAND_FILL);
dock_hb->add_child(dock_tab_move_right);
dock_vb->add_child(dock_hb);
@@ -5374,36 +4719,20 @@ EditorNode::EditorNode() {
scene_root_parent = memnew(PanelContainer);
scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE);
scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
- // sc->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles"));
-
- //Ref<StyleBox> sp = scene_root_parent->get_stylebox("panel","TabContainer");
- //scene_root_parent->add_style_override("panel",sp);
- /*scene_root_parent->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
- scene_root_parent->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END );
- scene_root_parent->set_begin( Point2( 0, 0) );
- scene_root_parent->set_end( Point2( 0,80 ) );*/
srt->add_child(scene_root_parent);
scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL);
scene_root = memnew(Viewport);
scene_root->set_disable_3d(true);
- //scene_root_base->add_child(scene_root);
- //scene_root->set_meta("_editor_disable_input",true);
VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true);
scene_root->set_disable_input(true);
scene_root->set_as_audio_listener_2d(true);
- //scene_root->set_size_override(true,Size2(ProjectSettings::get_singleton()->get("display/width"),ProjectSettings::get_singleton()->get("display/height")));
-
- //scene_root->set_world_2d( Ref<World2D>( memnew( World2D )) );
viewport = memnew(VBoxContainer);
viewport->set_v_size_flags(Control::SIZE_EXPAND_FILL);
viewport->add_constant_override("separation", 0);
- /*for(int i=0;i<4;i++) {
- viewport->set_margin(Margin(i),sp->get_margin(Margin(i)));
- }*/
scene_root_parent->add_child(viewport);
PanelContainer *top_region = memnew(PanelContainer);
@@ -5412,9 +4741,14 @@ EditorNode::EditorNode() {
top_region->add_child(left_menu_hb);
menu_hb->add_child(top_region);
+ {
+ Control *sp = memnew(Control);
+ sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
+ menu_hb->add_child(sp);
+ }
+
file_menu = memnew(MenuButton);
file_menu->set_text(TTR("Scene"));
- //file_menu->set_icon(gui_base->get_icon("Save","EditorIcons"));
left_menu_hb->add_child(file_menu);
file_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
@@ -5422,7 +4756,6 @@ EditorNode::EditorNode() {
prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons"));
prev_scene->set_tooltip(TTR("Go to previously opened scene."));
prev_scene->set_disabled(true);
- //left_menu_hb->add_child( prev_scene );
prev_scene->connect("pressed", this, "_menu_option", make_binds(FILE_OPEN_PREV));
gui_base->add_child(prev_scene);
prev_scene->set_position(Point2(3, 24));
@@ -5470,11 +4803,6 @@ EditorNode::EditorNode() {
p->add_child(recent_scenes);
recent_scenes->connect("id_pressed", this, "_open_recent_scene");
- {
- Control *sp = memnew(Control);
- sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
- menu_hb->add_child(sp);
- }
p->add_separator();
p->add_item(TTR("Quit"), FILE_QUIT, KEY_MASK_CMD + KEY_Q);
@@ -5508,7 +4836,6 @@ EditorNode::EditorNode() {
PanelContainer *editor_region = memnew(PanelContainer);
main_editor_button_vb = memnew(HBoxContainer);
editor_region->add_child(main_editor_button_vb);
-
menu_hb->add_spacer();
menu_hb->add_child(editor_region);
@@ -5540,12 +4867,9 @@ EditorNode::EditorNode() {
left_menu_hb->add_child(settings_menu);
settings_menu->set_text(TTR("Editor"));
settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
- //settings_menu->set_anchor(MARGIN_RIGHT,ANCHOR_END);
p = settings_menu->get_popup();
- //p->add_item("Export Settings",SETTINGS_EXPORT_PREFERENCES);
p->add_item(TTR("Editor Settings"), SETTINGS_PREFERENCES);
- //p->add_item("Optimization Presets",SETTINGS_OPTIMIZED_PRESETS);
p->add_separator();
editor_layouts = memnew(PopupMenu);
editor_layouts->set_name("Layouts");
@@ -5600,7 +4924,6 @@ EditorNode::EditorNode() {
pause_button->set_toggle_mode(true);
pause_button->set_icon(gui_base->get_icon("Pause", "EditorIcons"));
pause_button->set_focus_mode(Control::FOCUS_NONE);
- //pause_button->connect("pressed", this,"_menu_option",make_binds(RUN_PAUSE));
pause_button->set_tooltip(TTR("Pause the scene"));
pause_button->set_disabled(true);
play_hb->add_child(pause_button);
@@ -5608,7 +4931,6 @@ EditorNode::EditorNode() {
stop_button = memnew(ToolButton);
play_hb->add_child(stop_button);
- //stop_button->set_toggle_mode(true);
stop_button->set_focus_mode(Control::FOCUS_NONE);
stop_button->set_icon(gui_base->get_icon("Stop", "EditorIcons"));
stop_button->connect("pressed", this, "_menu_option", make_binds(RUN_STOP));
@@ -5643,23 +4965,8 @@ EditorNode::EditorNode() {
play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5));
progress_hb = memnew(BackgroundProgress);
- //menu_hb->add_child(progress_hb);
- {
- Control *sp = memnew(Control);
- sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
- //menu_hb->add_child(sp);
- }
-
- {
- Control *sp = memnew(Control);
- sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
- //menu_hb->add_child(sp);
- }
-
- top_region = memnew(PanelContainer);
HBoxContainer *right_menu_hb = memnew(HBoxContainer);
- //top_region->add_child(right_menu_hb);
menu_hb->add_child(right_menu_hb);
layout_dialog = memnew(EditorNameDialog);
@@ -5678,16 +4985,16 @@ EditorNode::EditorNode() {
p->add_check_item(TTR("Update Changes"), SETTINGS_UPDATE_CHANGES);
p->add_separator();
p->add_check_item(TTR("Disable Update Spinner"), SETTINGS_UPDATE_SPINNER_HIDE);
- p->set_item_checked(1, true);
+ int update_mode = EditorSettings::get_singleton()->get_project_metadata("editor_options", "update_mode", SETTINGS_UPDATE_CHANGES);
+ int hide_spinner = EditorSettings::get_singleton()->get_project_metadata("editor_options", "update_spinner_hide", false);
+ _menu_option(update_mode);
+ if (hide_spinner) {
+ _menu_option(SETTINGS_UPDATE_SPINNER_HIDE);
+ }
scene_tree_dock = memnew(SceneTreeDock(this, scene_root, editor_selection, editor_data));
scene_tree_dock->set_name(TTR("Scene"));
dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(scene_tree_dock);
-#if 0
- resources_dock = memnew( ResourcesDock(this) );
- resources_dock->set_name("Resources");
- dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(resources_dock);
-#endif
dock_slot[DOCK_SLOT_LEFT_BR]->hide();
VBoxContainer *prop_editor_base = memnew(VBoxContainer);
@@ -5749,8 +5056,8 @@ EditorNode::EditorNode() {
editor_history_menu->get_popup()->connect("id_pressed", this, "_select_history");
prop_editor_hb = memnew(HBoxContainer); //again...
-
prop_editor_base->add_child(prop_editor_hb);
+
editor_path = memnew(EditorPath(&editor_history));
editor_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
prop_editor_hb->add_child(editor_path);
@@ -5811,7 +5118,6 @@ EditorNode::EditorNode() {
bool use_single_dock_column = (OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x < 1200);
node_dock = memnew(NodeDock);
- //node_dock->set_undoredo(&editor_data.get_undo_redo());
if (use_single_dock_column) {
dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(node_dock);
} else {
@@ -5855,31 +5161,17 @@ EditorNode::EditorNode() {
bottom_panel_vb = memnew(VBoxContainer);
bottom_panel->add_child(bottom_panel_vb);
- //bottom_panel_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
bottom_panel_hb = memnew(HBoxContainer);
bottom_panel_vb->add_child(bottom_panel_hb);
log = memnew(EditorLog);
-
add_bottom_panel_item(TTR("Output"), log);
- //left_split->set_dragger_visible(false);
-
old_split_ofs = 0;
center_split->connect("resized", this, "_vp_resized");
- /*PanelContainer *bottom_pc = memnew( PanelContainer );
- srt->add_child(bottom_pc);
- bottom_hb = memnew( HBoxContainer );
- bottom_pc->add_child(bottom_hb);*/
-
- //center_vb->add_child( log->get_button() );
- //log->get_button()->set_h_size_flags(Control::SIZE_EXPAND_FILL);
-
- //progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
-
orphan_resources = memnew(OrphanResourcesDialog);
gui_base->add_child(orphan_resources);
@@ -5897,23 +5189,9 @@ EditorNode::EditorNode() {
gui_base->add_child(accept);
accept->connect("confirmed", this, "_menu_confirm_current");
- //optimized_save = memnew( OptimizedSaveDialog(&editor_data) );
- //gui_base->add_child(optimized_save);
- //optimized_save->connect("confirmed",this,"_save_optimized");
-
project_export = memnew(ProjectExportDialog);
gui_base->add_child(project_export);
- //project_export_settings = memnew( ProjectExportDialog(this) );
- //gui_base->add_child(project_export_settings);
-
- //optimized_presets = memnew( OptimizedPresetsDialog(&editor_data) );
- //gui_base->add_child(optimized_presets);
- //optimized_presets->connect("confirmed",this,"_presets_optimized");
-
- //import_subscene = memnew( EditorSubScene );
- //gui_base->add_child(import_subscene);
-
dependency_error = memnew(DependencyErrorDialog);
gui_base->add_child(dependency_error);
@@ -5926,14 +5204,6 @@ EditorNode::EditorNode() {
project_settings = memnew(ProjectSettingsEditor(&editor_data));
gui_base->add_child(project_settings);
- import_confirmation = memnew(ConfirmationDialog);
- import_confirmation->get_ok()->set_text(TTR("Re-Import"));
- import_confirmation->add_button(TTR("Update"), !OS::get_singleton()->get_swap_ok_cancel(), "update");
- import_confirmation->get_label()->set_align(Label::ALIGN_CENTER);
- import_confirmation->connect("confirmed", this, "_import_action", make_binds("re-import"));
- import_confirmation->connect("custom_action", this, "_import_action");
- gui_base->add_child(import_confirmation);
-
run_settings_dialog = memnew(RunSettingsDialog);
gui_base->add_child(run_settings_dialog);
@@ -5993,9 +5263,6 @@ EditorNode::EditorNode() {
gui_base->add_child(file_script);
file_script->connect("file_selected", this, "_dialog_action");
- //reimport_dialog = memnew( EditorReImportDialog );
- //gui_base->add_child(reimport_dialog);
-
property_forward->connect("pressed", this, "_property_editor_forward");
property_back->connect("pressed", this, "_property_editor_back");
@@ -6027,14 +5294,19 @@ EditorNode::EditorNode() {
} else {
WARN_PRINT("Asset Library not available, as it requires SSL to work.");
}
+
+ //add interface before adding plugins
+
+ editor_interface = memnew(EditorInterface);
+ add_child(editor_interface);
+
//more visually meaningful to have this later
raise_bottom_panel_item(AnimationPlayerEditor::singleton);
add_editor_plugin(memnew(ShaderEditorPlugin(this)));
- /* add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,true) ) );
- add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,false) ) );
+ // FIXME: Disabled for Godot 3.0 as made incompatible, it needs to be ported to the new API.
+ //add_editor_plugin(memnew(ShaderGraphEditorPlugin(this)));
- add_editor_plugin( memnew( ShaderEditorPlugin(this,false) ) );*/
add_editor_plugin(memnew(CameraEditorPlugin(this)));
add_editor_plugin(memnew(ThemeEditorPlugin(this)));
add_editor_plugin(memnew(MultiMeshEditorPlugin(this)));
@@ -6045,7 +5317,6 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(ParticlesEditorPlugin(this)));
add_editor_plugin(memnew(ResourcePreloaderEditorPlugin(this)));
add_editor_plugin(memnew(ItemListEditorPlugin(this)));
- //add_editor_plugin( memnew( RichTextEditorPlugin(this) ) );
add_editor_plugin(memnew(CollisionPolygonEditorPlugin(this)));
add_editor_plugin(memnew(CollisionPolygon2DEditorPlugin(this)));
add_editor_plugin(memnew(TileSetEditorPlugin(this)));
@@ -6064,9 +5335,12 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(CollisionShape2DEditorPlugin(this)));
add_editor_plugin(memnew(CurveEditorPlugin(this)));
add_editor_plugin(memnew(TextureEditorPlugin(this)));
- add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor)));
- //add_editor_plugin( memnew( MaterialEditorPlugin(this) ) );
add_editor_plugin(memnew(MeshEditorPlugin(this)));
+ add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor)));
+
+ // FIXME: Disabled as (according to reduz) users were complaining that it gets in the way
+ // Waiting for PropertyEditor rewrite (planned for 3.1) to be refactored.
+ //add_editor_plugin(memnew(MaterialEditorPlugin(this)));
for (int i = 0; i < EditorPlugins::get_plugin_count(); i++)
add_editor_plugin(EditorPlugins::create(i, this));
@@ -6079,6 +5353,7 @@ EditorNode::EditorNode() {
resource_preview->add_preview_generator(Ref<EditorPackedScenePreviewPlugin>(memnew(EditorPackedScenePreviewPlugin)));
resource_preview->add_preview_generator(Ref<EditorMaterialPreviewPlugin>(memnew(EditorMaterialPreviewPlugin)));
resource_preview->add_preview_generator(Ref<EditorScriptPreviewPlugin>(memnew(EditorScriptPreviewPlugin)));
+ // FIXME: Needs to be rewritten for AudioStream in Godot 3.0+
//resource_preview->add_preview_generator( Ref<EditorSamplePreviewPlugin>( memnew(EditorSamplePreviewPlugin )));
resource_preview->add_preview_generator(Ref<EditorMeshPreviewPlugin>(memnew(EditorMeshPreviewPlugin)));
resource_preview->add_preview_generator(Ref<EditorBitmapPreviewPlugin>(memnew(EditorBitmapPreviewPlugin)));
@@ -6091,7 +5366,6 @@ EditorNode::EditorNode() {
editor_plugins_over = memnew(EditorPluginList);
editor_plugins_force_input_forwarding = memnew(EditorPluginList);
- //force_top_viewport(true);
_edit_current();
current = NULL;
@@ -6099,32 +5373,10 @@ EditorNode::EditorNode() {
Physics2DServer::get_singleton()->set_active(false); // no physics by default if editor
ScriptServer::set_scripting_enabled(false); // no scripting by default if editor
- //ProjectSettings::get_singleton()->set("render/room_cull_enabled",false);
-
reference_resource_mem = true;
save_external_resources_mem = true;
set_process(true);
- OS::get_singleton()->set_low_processor_usage_mode(true);
-
- if (0) { //not sure if i want this to happen after all
-
- //store project name in ssettings
- String project_name;
- //figure it out from path
- project_name = ProjectSettings::get_singleton()->get_resource_path().replace("\\", "/");
- print_line("path: " + project_name);
- if (project_name.length() && project_name[project_name.length() - 1] == '/')
- project_name = project_name.substr(0, project_name.length() - 1);
-
- project_name = project_name.replace("/", "::");
-
- if (project_name != "") {
- EditorSettings::get_singleton()->set("projects/" + project_name, ProjectSettings::get_singleton()->get_resource_path());
- EditorSettings::get_singleton()->raise_order("projects/" + project_name);
- EditorSettings::get_singleton()->save();
- }
- }
open_imported = memnew(ConfirmationDialog);
open_imported->get_ok()->set_text(TTR("Open Anyway"));
@@ -6133,7 +5385,6 @@ EditorNode::EditorNode() {
open_imported->connect("custom_action", this, "_inherit_imported");
gui_base->add_child(open_imported);
- //edited_scene=NULL;
saved_version = 1;
unsaved_cache = true;
_last_instanced_scene = NULL;
@@ -6154,17 +5405,12 @@ EditorNode::EditorNode() {
set_process_unhandled_input(true);
_playing_edited = false;
- //Panel *errors = memnew( Panel );
load_errors = memnew(RichTextLabel);
- //load_errors->set_readonly(true);
load_error_dialog = memnew(AcceptDialog);
load_error_dialog->add_child(load_errors);
load_error_dialog->set_title(TTR("Load Errors"));
- //load_error_dialog->set_child_rect(load_errors);
gui_base->add_child(load_error_dialog);
- //EditorImport::add_importer( Ref<EditorImporterCollada>( memnew(EditorImporterCollada )));
-
EditorFileSystem::get_singleton()->connect("sources_changed", this, "_sources_changed");
EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_fs_changed");
@@ -6187,9 +5433,6 @@ EditorNode::EditorNode() {
pick_main_scene->get_ok()->set_text(TTR("Select"));
pick_main_scene->connect("confirmed", this, "_menu_option", varray(SETTINGS_PICK_MAIN_SCENE));
- //Ref<ImageTexture> it = gui_base->get_icon("logo","Icons");
- //OS::get_singleton()->set_icon( it->get_data() );
-
for (int i = 0; i < _init_callbacks.size(); i++)
_init_callbacks[i]();
@@ -6200,7 +5443,6 @@ EditorNode::EditorNode() {
import_dock->initialize_import_options();
{
-
_initializing_addons = true;
Vector<String> addons;
if (ProjectSettings::get_singleton()->has("editor_plugins/enabled")) {
@@ -6242,6 +5484,7 @@ EditorNode::~EditorNode() {
memdelete(editor_plugins_over);
memdelete(editor_plugins_force_input_forwarding);
memdelete(file_server);
+ memdelete(progress_hb);
EditorSettings::destroy();
}
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 385d97ecc3..8a02b16ca2 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -35,16 +35,35 @@
#include "editor/create_dialog.h"
#include "editor/editor_about.h"
#include "editor/editor_data.h"
+#include "editor/editor_export.h"
+#include "editor/editor_log.h"
+#include "editor/editor_name_dialog.h"
#include "editor/editor_path.h"
+#include "editor/editor_plugin.h"
+#include "editor/editor_reimport_dialog.h"
+#include "editor/editor_resource_preview.h"
#include "editor/editor_run.h"
+#include "editor/editor_run_native.h"
+#include "editor/editor_run_script.h"
+#include "editor/editor_scale.h"
+#include "editor/editor_sub_scene.h"
#include "editor/export_template_manager.h"
+#include "editor/fileserver/editor_file_server.h"
#include "editor/filesystem_dock.h"
#include "editor/groups_editor.h"
#include "editor/import_dock.h"
#include "editor/node_dock.h"
+#include "editor/pane_drag.h"
+#include "editor/progress_dialog.h"
+#include "editor/project_export.h"
+#include "editor/project_settings_editor.h"
#include "editor/property_editor.h"
+#include "editor/quick_open.h"
#include "editor/reparent_dialog.h"
+#include "editor/run_settings_dialog.h"
+#include "editor/scene_tree_dock.h"
#include "editor/scene_tree_editor.h"
+#include "editor/script_create_dialog.h"
#include "editor/settings_config_dialog.h"
#include "scene/gui/center_container.h"
#include "scene/gui/control.h"
@@ -56,38 +75,12 @@
#include "scene/gui/separator.h"
#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
+#include "scene/gui/tabs.h"
#include "scene/gui/texture_progress.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
-
-#include "editor/pane_drag.h"
-
-#include "editor/editor_log.h"
-#include "editor/editor_run_script.h"
-#include "editor/project_export.h"
-#include "editor/project_settings_editor.h"
-#include "editor/resources_dock.h"
-#include "editor/run_settings_dialog.h"
-#include "editor/scene_tree_dock.h"
-#include "editor/script_create_dialog.h"
-
-#include "editor/editor_name_dialog.h"
-#include "editor/editor_plugin.h"
-#include "editor/editor_run_native.h"
-#include "editor/editor_sub_scene.h"
-#include "editor/project_export.h"
-#include "editor/quick_open.h"
-#include "editor_export.h"
-#include "editor_reimport_dialog.h"
-#include "scene/gui/tabs.h"
-
-#include "editor_resource_preview.h"
-#include "fileserver/editor_file_server.h"
#include "scene/gui/viewport_container.h"
-#include "progress_dialog.h"
-
-#include "editor_scale.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -170,7 +163,6 @@ private:
RUN_SETTINGS,
RUN_PROJECT_MANAGER,
RUN_FILE_SERVER,
- //RUN_DEPLOY_DUMB_CLIENTS,
RUN_LIVE_DEBUG,
RUN_DEBUG_COLLISONS,
RUN_DEBUG_NAVIGATION,
@@ -181,7 +173,6 @@ private:
SETTINGS_UPDATE_SPINNER_HIDE,
SETTINGS_EXPORT_PREFERENCES,
SETTINGS_PREFERENCES,
- SETTINGS_OPTIMIZED_PRESETS,
SETTINGS_LAYOUT_SAVE,
SETTINGS_LAYOUT_DELETE,
SETTINGS_LAYOUT_DEFAULT,
@@ -189,9 +180,6 @@ private:
SETTINGS_PICK_MAIN_SCENE,
SETTINGS_TOGGLE_FULLSCREN,
SETTINGS_HELP,
- SOURCES_REIMPORT,
- DEPENDENCY_LOAD_CHANGED_IMAGES,
- DEPENDENCY_UPDATE_IMPORTED,
SCENE_TAB_CLOSE,
HELP_CLASSES,
@@ -209,11 +197,8 @@ private:
TOOL_MENU_BASE = 1000
};
- //Node *edited_scene; //scene being edited
Viewport *scene_root; //root of the scene being edited
- //Ref<ResourceImportMetadata> scene_import_metadata;
-
PanelContainer *scene_root_parent;
Control *theme_base;
Control *gui_base;
@@ -247,7 +232,6 @@ private:
HBoxContainer *bottom_hb;
Control *vp_base;
PaneDrag *pd;
- //PaneDrag *pd_anim;
CenterContainer *play_cc;
HBoxContainer *menu_hb;
@@ -269,19 +253,16 @@ private:
ToolButton *play_custom_scene_button;
ToolButton *search_button;
TextureProgress *audio_vu;
- //MenuButton *fileserver_menu;
RichTextLabel *load_errors;
AcceptDialog *load_error_dialog;
- //Control *scene_root_base;
Ref<Theme> theme;
PopupMenu *recent_scenes;
Button *property_back;
Button *property_forward;
SceneTreeDock *scene_tree_dock;
- //ResourcesDock *resources_dock;
PropertyEditor *property_editor;
NodeDock *node_dock;
ImportDock *import_dock;
@@ -294,7 +275,6 @@ private:
CreateDialog *create_dialog;
- //CallDialog *call_dialog;
ConfirmationDialog *confirmation;
ConfirmationDialog *save_confirmation;
ConfirmationDialog *import_confirmation;
@@ -308,7 +288,6 @@ private:
PopupMenu *editor_layouts;
EditorNameDialog *layout_dialog;
- //OptimizedPresetsDialog *optimized_presets;
EditorSettingsDialog *settings_config_dialog;
RunSettingsDialog *run_settings_dialog;
ProjectSettingsEditor *project_settings;
@@ -343,8 +322,6 @@ private:
Vector<ToolButton *> main_editor_buttons;
Vector<EditorPlugin *> editor_table;
- // EditorReImportDialog *reimport_dialog;
-
ProgressDialog *progress_dialog;
BackgroundProgress *progress_hb;
@@ -402,7 +379,6 @@ private:
EditorData editor_data;
EditorRun editor_run;
EditorSelection *editor_selection;
- // ProjectExport *project_export;
ProjectExportDialog *project_export;
EditorResourcePreview *resource_preview;
@@ -420,6 +396,8 @@ private:
HBoxContainer *bottom_panel_hb;
VBoxContainer *bottom_panel_vb;
+ EditorInterface *editor_interface;
+
void _bottom_panel_switch(bool p_enable, int p_idx);
String external_file;
@@ -432,7 +410,6 @@ private:
void _dialog_display_file_error(String p_file, Error p_error);
int current_option;
- //void _animation_visibility_toggle();
void _resource_created();
void _resource_selected(const RES &p_res, const String &p_property = "");
void _menu_option(int p_option);
@@ -448,7 +425,6 @@ private:
void _fs_changed();
void _sources_changed(bool p_exist);
- void _imported(Node *p_node);
void _node_renamed();
void _editor_select_next();
@@ -489,7 +465,6 @@ private:
void _update_recent_scenes();
void _open_recent_scene(int p_idx);
void _dropped_files(const Vector<String> &p_files, int p_screen);
- //void _open_recent_scene_confirm();
String _recent_scene;
bool convert_old;
@@ -500,8 +475,6 @@ private:
bool has_main_screen() const { return true; }
- bool _find_editing_changed_scene(Node *p_from);
-
String import_reload_fn;
Set<FileDialog *> file_dialogs;
@@ -578,7 +551,6 @@ private:
void _save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section);
void _load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section);
void _update_dock_slots_visibility();
- void _update_top_menu_visibility();
void _update_layouts_menu();
void _layout_menu_option(int p_id);
@@ -699,10 +671,6 @@ public:
static EditorLog *get_log() { return singleton->log; }
Control *get_viewport();
- //void animation_editor_make_visible(bool p_visible);
- //void hide_animation_player_editors();
- //void animation_panel_make_visible(bool p_visible);
-
void set_edited_scene(Node *p_scene);
Node *get_edited_scene() { return editor_data.get_edited_scene_root(); }
@@ -762,7 +730,12 @@ public:
static void progress_task_step_bg(const String &p_task, int p_step = -1);
static void progress_end_task_bg(const String &p_task);
- void save_scene(String p_file) { _save_scene(p_file); }
+ void save_scene_to_path(String p_file, bool p_with_preview = true) {
+ if (p_with_preview)
+ _save_scene_with_preview(p_file);
+ else
+ _save_scene(p_file);
+ }
bool is_scene_in_use(const String &p_path);
@@ -853,4 +826,4 @@ struct EditorProgressBG {
~EditorProgressBG() { EditorNode::progress_end_task_bg(task); }
};
-#endif
+#endif // EDITOR_NODE_H
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 220b5fb2d6..a6e28e045e 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -37,6 +37,124 @@
#include "scene/3d/camera.h"
#include "scene/gui/popup_menu.h"
+Control *EditorInterface::get_editor_viewport() {
+
+ return EditorNode::get_singleton()->get_viewport();
+}
+
+void EditorInterface::edit_resource(const Ref<Resource> &p_resource) {
+
+ EditorNode::get_singleton()->edit_resource(p_resource);
+}
+
+void EditorInterface::open_scene_from_path(const String &scene_path) {
+
+ if (EditorNode::get_singleton()->is_changing_scene()) {
+ return;
+ }
+
+ EditorNode::get_singleton()->open_request(scene_path);
+}
+
+void EditorInterface::reload_scene_from_path(const String &scene_path) {
+
+ if (EditorNode::get_singleton()->is_changing_scene()) {
+ return;
+ }
+
+ EditorNode::get_singleton()->reload_scene(scene_path);
+}
+
+Node *EditorInterface::get_edited_scene_root() {
+ return EditorNode::get_singleton()->get_edited_scene();
+}
+
+Array EditorInterface::get_open_scenes() const {
+
+ Array ret;
+ Vector<EditorData::EditedScene> scenes = EditorNode::get_singleton()->get_editor_data().get_edited_scenes();
+
+ int scns_amount = scenes.size();
+ for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) {
+ if (scenes[idx_scn].root == NULL)
+ continue;
+ ret.push_back(scenes[idx_scn].root->get_filename());
+ }
+ return ret;
+}
+
+ScriptEditor *EditorInterface::get_script_editor() {
+ return ScriptEditor::get_singleton();
+}
+
+void EditorInterface::inspect_object(Object *p_obj, const String &p_for_property) {
+
+ EditorNode::get_singleton()->push_item(p_obj, p_for_property);
+}
+
+EditorFileSystem *EditorInterface::get_resource_file_system() {
+ return EditorFileSystem::get_singleton();
+}
+
+EditorSelection *EditorInterface::get_selection() {
+ return EditorNode::get_singleton()->get_editor_selection();
+}
+
+EditorSettings *EditorInterface::get_editor_settings() {
+ return EditorSettings::get_singleton();
+}
+
+EditorResourcePreview *EditorInterface::get_resource_previewer() {
+ return EditorResourcePreview::get_singleton();
+}
+
+Control *EditorInterface::get_base_control() {
+
+ return EditorNode::get_singleton()->get_gui_base();
+}
+
+Error EditorInterface::save_scene() {
+ if (!get_edited_scene_root())
+ return ERR_CANT_CREATE;
+ if (get_edited_scene_root()->get_filename() == String())
+ return ERR_CANT_CREATE;
+
+ save_scene_as(get_edited_scene_root()->get_filename());
+ return OK;
+}
+
+void EditorInterface::save_scene_as(const String &p_scene, bool p_with_preview) {
+
+ EditorNode::get_singleton()->save_scene_to_path(p_scene, p_with_preview);
+}
+
+EditorInterface *EditorInterface::singleton = NULL;
+
+void EditorInterface::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("inspect_object", "object", "for_property"), &EditorInterface::inspect_object, DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("get_selection"), &EditorInterface::get_selection);
+ ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorInterface::get_editor_settings);
+ ClassDB::bind_method(D_METHOD("get_script_editor"), &EditorInterface::get_script_editor);
+ ClassDB::bind_method(D_METHOD("get_base_control"), &EditorInterface::get_base_control);
+ ClassDB::bind_method(D_METHOD("edit_resource", "resource"), &EditorInterface::edit_resource);
+ ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorInterface::open_scene_from_path);
+ ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorInterface::reload_scene_from_path);
+ ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorInterface::get_open_scenes);
+ ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &EditorInterface::get_edited_scene_root);
+ ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorInterface::get_resource_previewer);
+ ClassDB::bind_method(D_METHOD("get_resource_filesystem"), &EditorInterface::get_resource_file_system);
+ ClassDB::bind_method(D_METHOD("get_editor_viewport"), &EditorInterface::get_editor_viewport);
+
+ ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene);
+ ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true));
+}
+
+EditorInterface::EditorInterface() {
+ singleton = this;
+}
+
+///////////////////////////////////////////
void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon) {
EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon);
@@ -70,34 +188,6 @@ void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
EditorNode::get_singleton()->remove_bottom_panel_item(p_control);
}
-Control *EditorPlugin::get_editor_viewport() {
-
- return EditorNode::get_singleton()->get_viewport();
-}
-
-void EditorPlugin::edit_resource(const Ref<Resource> &p_resource) {
-
- EditorNode::get_singleton()->edit_resource(p_resource);
-}
-
-void EditorPlugin::open_scene_from_path(const String &scene_path) {
-
- if (EditorNode::get_singleton()->is_changing_scene()) {
- return;
- }
-
- EditorNode::get_singleton()->open_request(scene_path);
-}
-
-void EditorPlugin::reload_scene_from_path(const String &scene_path) {
-
- if (EditorNode::get_singleton()->is_changing_scene()) {
- return;
- }
-
- EditorNode::get_singleton()->reload_scene(scene_path);
-}
-
void EditorPlugin::add_control_to_container(CustomControlContainer p_location, Control *p_control) {
switch (p_location) {
@@ -171,28 +261,6 @@ void EditorPlugin::set_input_event_forwarding_always_enabled() {
always_input_forwarding_list->add_plugin(this);
}
-Node *EditorPlugin::get_edited_scene_root() {
- return EditorNode::get_singleton()->get_edited_scene();
-}
-
-Array EditorPlugin::get_open_scenes() const {
-
- Array ret;
- Vector<EditorData::EditedScene> scenes = EditorNode::get_singleton()->get_editor_data().get_edited_scenes();
-
- int scns_amount = scenes.size();
- for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) {
- if (scenes[idx_scn].root == NULL)
- continue;
- ret.push_back(scenes[idx_scn].root->get_filename());
- }
- return ret;
-}
-
-ScriptEditor *EditorPlugin::get_script_editor() {
- return ScriptEditor::get_singleton();
-}
-
void EditorPlugin::notify_scene_changed(const Node *scn_root) {
if (scn_root == NULL) return;
emit_signal("scene_changed", scn_root);
@@ -369,23 +437,6 @@ void EditorPlugin::queue_save_layout() const {
EditorNode::get_singleton()->save_layout();
}
-EditorSelection *EditorPlugin::get_selection() {
- return EditorNode::get_singleton()->get_editor_selection();
-}
-
-EditorSettings *EditorPlugin::get_editor_settings() {
- return EditorSettings::get_singleton();
-}
-
-EditorResourcePreview *EditorPlugin::get_resource_previewer() {
- return EditorResourcePreview::get_singleton();
-}
-
-Control *EditorPlugin::get_base_control() {
-
- return EditorNode::get_singleton()->get_gui_base();
-}
-
void EditorPlugin::make_bottom_panel_item_visible(Control *p_item) {
EditorNode::get_singleton()->make_bottom_panel_item_visible(p_item);
@@ -396,13 +447,8 @@ void EditorPlugin::hide_bottom_panel() {
EditorNode::get_singleton()->hide_bottom_panel();
}
-void EditorPlugin::inspect_object(Object *p_obj, const String &p_for_property) {
-
- EditorNode::get_singleton()->push_item(p_obj, p_for_property);
-}
-
-EditorFileSystem *EditorPlugin::get_resource_file_system() {
- return EditorFileSystem::get_singleton();
+EditorInterface *EditorPlugin::get_editor_interface() {
+ return EditorInterface::get_singleton();
}
void EditorPlugin::_bind_methods() {
@@ -417,31 +463,19 @@ void EditorPlugin::_bind_methods() {
//ClassDB::bind_method(D_METHOD("remove_tool_menu_item", "name"),&EditorPlugin::remove_tool_menu_item);
ClassDB::bind_method(D_METHOD("add_custom_type", "type", "base", "script", "icon"), &EditorPlugin::add_custom_type);
ClassDB::bind_method(D_METHOD("remove_custom_type", "type"), &EditorPlugin::remove_custom_type);
- ClassDB::bind_method(D_METHOD("get_editor_viewport"), &EditorPlugin::get_editor_viewport);
- ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorPlugin::get_resource_previewer);
- ClassDB::bind_method(D_METHOD("get_resource_filesystem"), &EditorPlugin::get_resource_file_system);
-
- ClassDB::bind_method(D_METHOD("inspect_object", "object", "for_property"), &EditorPlugin::inspect_object, DEFVAL(String()));
ClassDB::bind_method(D_METHOD("update_canvas"), &EditorPlugin::update_canvas);
ClassDB::bind_method(D_METHOD("make_bottom_panel_item_visible", "item"), &EditorPlugin::make_bottom_panel_item_visible);
ClassDB::bind_method(D_METHOD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
- ClassDB::bind_method(D_METHOD("get_base_control"), &EditorPlugin::get_base_control);
ClassDB::bind_method(D_METHOD("get_undo_redo"), &EditorPlugin::_get_undo_redo);
- ClassDB::bind_method(D_METHOD("get_selection"), &EditorPlugin::get_selection);
- ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorPlugin::get_editor_settings);
- ClassDB::bind_method(D_METHOD("get_script_editor"), &EditorPlugin::get_script_editor);
ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout);
- ClassDB::bind_method(D_METHOD("edit_resource", "resource"), &EditorPlugin::edit_resource);
- ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorPlugin::open_scene_from_path);
- ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorPlugin::reload_scene_from_path);
ClassDB::bind_method(D_METHOD("add_import_plugin", "importer"), &EditorPlugin::add_import_plugin);
ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin);
ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
- ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorPlugin::get_open_scenes);
- ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &EditorPlugin::get_edited_scene_root);
+
+ ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorPlugin::get_editor_interface);
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_canvas", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "canvas:Control")));
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index 77c5501b25..df094f4c50 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -55,6 +55,40 @@ class EditorFileSystem;
class EditorToolAddons;
class ScriptEditor;
+class EditorInterface : public Node {
+ GDCLASS(EditorInterface, Node)
+protected:
+ static void _bind_methods();
+ static EditorInterface *singleton;
+
+public:
+ static EditorInterface *get_singleton() { return singleton; }
+
+ Control *get_editor_viewport();
+ void edit_resource(const Ref<Resource> &p_resource);
+ void open_scene_from_path(const String &scene_path);
+ void reload_scene_from_path(const String &scene_path);
+
+ Node *get_edited_scene_root();
+ Array get_open_scenes() const;
+ ScriptEditor *get_script_editor();
+
+ void inspect_object(Object *p_obj, const String &p_for_property = String());
+
+ EditorSelection *get_selection();
+ //EditorImportExport *get_import_export();
+ EditorSettings *get_editor_settings();
+ EditorResourcePreview *get_resource_previewer();
+ EditorFileSystem *get_resource_file_system();
+
+ Control *get_base_control();
+
+ Error save_scene();
+ void save_scene_as(const String &p_scene, bool p_with_preview = true);
+
+ EditorInterface();
+};
+
class EditorPlugin : public Node {
GDCLASS(EditorPlugin, Node);
@@ -105,10 +139,6 @@ public:
void add_control_to_dock(DockSlot p_slot, Control *p_control);
void remove_control_from_docks(Control *p_control);
void remove_control_from_bottom_panel(Control *p_control);
- Control *get_editor_viewport();
- void edit_resource(const Ref<Resource> &p_resource);
- void open_scene_from_path(const String &scene_path);
- void reload_scene_from_path(const String &scene_path);
void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant());
void add_tool_submenu_item(const String &p_name, Object *p_submenu);
@@ -117,10 +147,6 @@ public:
void set_input_event_forwarding_always_enabled();
bool is_input_event_forwarding_always_enabled() { return input_event_forwarding_always_enabled; }
- Node *get_edited_scene_root();
- Array get_open_scenes() const;
- ScriptEditor *get_script_editor();
-
void notify_main_screen_changed(const String &screen_name);
void notify_scene_changed(const Node *scn_root);
void notify_scene_closed(const String &scene_filepath);
@@ -146,23 +172,15 @@ public:
virtual void get_window_layout(Ref<ConfigFile> p_layout);
virtual void edited_scene_changed() {} // if changes are pending in editor, apply them
- void update_canvas();
+ EditorInterface *get_editor_interface();
- virtual void inspect_object(Object *p_obj, const String &p_for_property = String());
+ void update_canvas();
void queue_save_layout() const;
- Control *get_base_control();
-
void make_bottom_panel_item_visible(Control *p_item);
void hide_bottom_panel();
- EditorSelection *get_selection();
- //EditorImportExport *get_import_export();
- EditorSettings *get_editor_settings();
- EditorResourcePreview *get_resource_previewer();
- EditorFileSystem *get_resource_file_system();
-
virtual void restore_global_state();
virtual void save_global_state();
diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp
index 8bd1b8f4fd..990c0cfbe9 100644
--- a/editor/editor_run_script.cpp
+++ b/editor/editor_run_script.cpp
@@ -46,6 +46,11 @@ void EditorScript::add_root_node(Node *p_node) {
//editor->set_edited_scene(p_node);
}
+EditorInterface *EditorScript::get_editor_interface() {
+
+ return EditorInterface::get_singleton();
+}
+
Node *EditorScript::get_scene() {
if (!editor) {
@@ -83,6 +88,7 @@ void EditorScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node);
ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene);
+ ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorScript::get_editor_interface);
BIND_VMETHOD(MethodInfo("_run"));
}
diff --git a/editor/editor_run_script.h b/editor/editor_run_script.h
index 2c3b4b85ce..9bb9917c1c 100644
--- a/editor/editor_run_script.h
+++ b/editor/editor_run_script.h
@@ -30,8 +30,8 @@
#ifndef EDITOR_RUN_SCRIPT_H
#define EDITOR_RUN_SCRIPT_H
+#include "editor_plugin.h"
#include "reference.h"
-
class EditorNode;
class EditorScript : public Reference {
@@ -45,7 +45,7 @@ protected:
public:
void add_root_node(Node *p_node);
Node *get_scene();
-
+ EditorInterface *get_editor_interface();
virtual void _run();
void set_editor(EditorNode *p_editor);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 88c8c368d4..fe41e83bcb 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -29,23 +29,23 @@
/*************************************************************************/
#include "editor_settings.h"
-#include "editor_node.h"
-#include "io/compression.h"
-#include "io/config_file.h"
-#include "io/file_access_memory.h"
-#include "io/resource_loader.h"
-#include "io/resource_saver.h"
-#include "io/translation_loader_po.h"
-#include "os/dir_access.h"
-#include "os/file_access.h"
-#include "os/keyboard.h"
-#include "os/os.h"
-#include "project_settings.h"
+#include "core/io/compression.h"
+#include "core/io/config_file.h"
+#include "core/io/file_access_memory.h"
+#include "core/io/resource_loader.h"
+#include "core/io/resource_saver.h"
+#include "core/io/translation_loader_po.h"
+#include "core/os/dir_access.h"
+#include "core/os/file_access.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
+#include "core/version.h"
+#include "editor/editor_node.h"
+#include "editor/translations.gen.h"
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "scene/main/viewport.h"
-#include "translations.gen.h"
-#include "version.h"
Ref<EditorSettings> EditorSettings::singleton = NULL;
@@ -93,6 +93,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) {
emit_signal("settings_changed");
return true;
}
+
bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
_THREAD_SAFE_METHOD_
@@ -216,6 +217,12 @@ Variant _EDITOR_DEF(const String &p_var, const Variant &p_default) {
return p_default;
}
+Variant _EDITOR_GET(const String &p_var) {
+
+ ERR_FAIL_COND_V(!EditorSettings::get_singleton()->has(p_var), Variant())
+ return EditorSettings::get_singleton()->get(p_var);
+}
+
static Dictionary _get_builtin_script_templates() {
Dictionary templates;
@@ -253,6 +260,7 @@ static void _create_script_templates(const String &p_path) {
}
}
+ memdelete(dir);
memdelete(file);
}
@@ -266,7 +274,6 @@ void EditorSettings::create() {
String config_path;
String config_dir;
- //String config_file="editor_settings.xml";
Ref<ConfigFile> extra_config = memnew(ConfigFile);
String exe_path = OS::get_singleton()->get_executable_path().get_base_dir();
@@ -280,6 +287,7 @@ void EditorSettings::create() {
self_contained = true;
extra_config->load(exe_path + "/_sc_");
}
+ memdelete(d);
if (self_contained) {
// editor is self contained
@@ -638,7 +646,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/files/maximum_recent_files", 20);
hints["text_editor/files/maximum_recent_files"] = PropertyInfo(Variant::INT, "text_editor/files/maximum_recent_files", PROPERTY_HINT_RANGE, "1, 200, 0");
- //set("docks/scene_tree/display_old_action_buttons",false);
set("docks/scene_tree/start_create_dialog_fully_expanded", false);
set("docks/scene_tree/draw_relationship_lines", false);
set("docks/scene_tree/relationship_line_color", Color::html("464646"));
@@ -699,8 +706,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("filesystem/on_save/compress_binary_resources", true);
set("filesystem/on_save/save_modified_external_resources", true);
- //set("filesystem/on_save/save_paths_as_relative",false);
- //set("filesystem/on_save/save_paths_without_extension",false);
set("text_editor/tools/create_signal_callbacks", true);
@@ -1145,7 +1150,6 @@ void EditorSettings::_bind_methods() {
EditorSettings::EditorSettings() {
- //singleton=this;
last_order = 0;
optimize_save = true;
save_changed_setting = true;
@@ -1175,8 +1179,6 @@ EditorSettings::EditorSettings() {
}
EditorSettings::~EditorSettings() {
-
- //singleton=NULL;
}
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) {
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index a99d7e0ad5..b479d21dfb 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -180,6 +180,9 @@ public:
#define EDITOR_DEF(m_var, m_val) _EDITOR_DEF(m_var, Variant(m_val))
Variant _EDITOR_DEF(const String &p_var, const Variant &p_default);
+#define EDITOR_GET(m_var) _EDITOR_GET(m_var)
+Variant _EDITOR_GET(const String &p_var);
+
#define ED_IS_SHORTCUT(p_name, p_ev) (EditorSettings::get_singleton()->is_shortcut(p_name, p_ev))
Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode = 0);
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path);
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 5bba289492..59cd16c0b8 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -537,7 +537,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
s->set_transform(Transform());
p_node = bv;
-
+#if 0
} else if (_teststr(name, "room") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot)
@@ -657,7 +657,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
p_node->replace_by(portal);
memdelete(p_node);
p_node = portal;
-
+#endif
} else if (Object::cast_to<MeshInstance>(p_node)) {
//last attempt, maybe collision insde the mesh data
diff --git a/editor/io_plugins/editor_scene_import_plugin.cpp b/editor/io_plugins/editor_scene_import_plugin.cpp
index 06d12917fd..a0a52621a0 100644
--- a/editor/io_plugins/editor_scene_import_plugin.cpp
+++ b/editor/io_plugins/editor_scene_import_plugin.cpp
@@ -2095,14 +2095,6 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
return p_node;
}
-#if 0
-
-Error EditorImport::import_scene(const String& p_path,const String& p_dest_path,const String& p_resource_path,uint32_t p_flags,ImageFormat p_image_format,ImageCompression p_image_compression,uint32_t p_image_flags,float p_quality,uint32_t animation_flags,Node **r_scene,Ref<EditorPostImport> p_post_import) {
-
-
-}
-#endif
-
void EditorSceneImportPlugin::_tag_import_paths(Node *p_scene,Node *p_node) {
if (p_scene!=p_node && p_node->get_owner()!=p_scene)
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 43d6c22bcc..5b71f51b0f 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -367,10 +367,6 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou
int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
flg |= ResourceSaver::FLAG_COMPRESS;
- /*
- if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
- flg |= ResourceSaver::FLAG_RELATIVE_PATHS;
- */
String path = ProjectSettings::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
@@ -380,7 +376,6 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou
accept->popup_centered_minsize();
return;
}
- //EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
((Resource *)p_resource.ptr())->set_path(path);
editor->emit_signal("resource_saved", p_resource);
diff --git a/editor/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index c01c2de6b7..c01c2de6b7 100644
--- a/editor/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
diff --git a/editor/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index fa768ec96a..fa768ec96a 100644
--- a/editor/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 0dcabb1776..34c0a0595e 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -4102,3 +4102,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
label_desc->hide();
editor->get_gui_base()->add_child(label_desc);
}
+
+CanvasItemEditorViewport::~CanvasItemEditorViewport() {
+ memdelete(preview);
+}
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 9b027fda60..0291660d42 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -512,6 +512,7 @@ public:
virtual void drop_data(const Point2 &p_point, const Variant &p_data);
CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor *p_canvas);
+ ~CanvasItemEditorViewport();
};
#endif
diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp
index 5520d196e0..c6fa796226 100644
--- a/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -48,6 +48,9 @@ void CollisionPolygonEditor::_notification(int p_what) {
} break;
case NOTIFICATION_PROCESS: {
+ if (!node) {
+ return;
+ }
if (node->get_depth() != prev_depth) {
_polygon_draw();
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 5f50978693..da14c77fa9 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -775,7 +775,7 @@ CurveEditorPlugin::CurveEditorPlugin(EditorNode *p_node) {
_toggle_button = _editor_node->add_bottom_panel_item(get_name(), _view);
_toggle_button->hide();
- get_resource_previewer()->add_preview_generator(memnew(CurvePreviewGenerator));
+ get_editor_interface()->get_resource_previewer()->add_preview_generator(memnew(CurvePreviewGenerator));
}
CurveEditorPlugin::~CurveEditorPlugin() {
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index ce6eefd694..1842717cc0 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -29,14 +29,13 @@
/*************************************************************************/
#include "editor_preview_plugins.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "io/file_access_memory.h"
#include "io/resource_loader.h"
#include "os/os.h"
-#include "scene/resources/material.h"
-//#include "scene/resources/sample.h"
-#include "editor/editor_scale.h"
#include "scene/resources/bit_mask.h"
+#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
bool EditorTexturePreviewPlugin::handles(const String &p_type) const {
@@ -239,7 +238,6 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from) {
VS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid());
VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture
- //print_line("queue capture!");
preview_done = false;
VS::get_singleton()->request_frame_drawn_callback(this, "_preview_done", Variant());
@@ -454,9 +452,7 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from) {
while (_is_text_char(code[pos])) {
pos++;
}
- ///print_line("from "+itos(i)+" to "+itos(pos));
String word = code.substr(i, pos - i);
- //print_line("found word: "+word);
if (keywords.has(word))
in_keyword = true;
@@ -502,6 +498,8 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from) {
EditorScriptPreviewPlugin::EditorScriptPreviewPlugin() {
}
///////////////////////////////////////////////////////////////////
+
+// FIXME: Needs to be rewritten for AudioStream in Godot 3.0+
#if 0
bool EditorSamplePreviewPlugin::handles(const String& p_type) const {
@@ -766,10 +764,9 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) {
}
EditorSamplePreviewPlugin::EditorSamplePreviewPlugin() {
-
-
}
#endif
+
///////////////////////////////////////////////////////////////////////////
void EditorMeshPreviewPlugin::_preview_done(const Variant &p_udata) {
@@ -788,14 +785,12 @@ bool EditorMeshPreviewPlugin::handles(const String &p_type) const {
Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) {
- print_line("**Generating for mesh finally??");
Ref<Mesh> mesh = p_from;
ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture>());
VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid());
Rect3 aabb = mesh->get_aabb();
- print_line("mesh aabb: " + aabb);
Vector3 ofs = aabb.position + aabb.size * 0.5;
aabb.position -= ofs;
Transform xform;
@@ -807,14 +802,12 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) {
return Ref<Texture>();
m = 1.0 / m;
m *= 0.5;
- //print_line("scale: "+rtos(m));
xform.basis.scale(Vector3(m, m, m));
xform.origin = -xform.basis.xform(ofs); //-ofs*m;
xform.origin.z -= rot_aabb.size.z * 2;
VS::get_singleton()->instance_set_transform(mesh_instance, xform);
VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture
- //print_line("queue capture!");
preview_done = false;
VS::get_singleton()->request_frame_drawn_callback(this, "_preview_done", Variant());
@@ -826,7 +819,6 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) {
Ref<Image> img = VS::get_singleton()->VS::get_singleton()->texture_get_data(viewport_texture);
ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>());
- print_line("captured! " + itos(img->get_width()) + "x" + itos(img->get_height()));
VS::get_singleton()->instance_set_base(mesh_instance, RID());
int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h
index 7e7d36eb1e..2ce35390a5 100644
--- a/editor/plugins/editor_preview_plugins.h
+++ b/editor/plugins/editor_preview_plugins.h
@@ -97,6 +97,7 @@ public:
EditorScriptPreviewPlugin();
};
+// FIXME: Needs to be rewritten for AudioStream in Godot 3.0+
#if 0
class EditorSamplePreviewPlugin : public EditorResourcePreviewGenerator {
public:
@@ -106,8 +107,8 @@ public:
EditorSamplePreviewPlugin();
};
-
#endif
+
class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {
GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator)
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index 751f39e55d..2afcf6a341 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -27,12 +27,14 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
+// FIXME: Disabled as (according to reduz) users were complaining that it gets in the way
+// Waiting for PropertyEditor rewrite (planned for 3.1) to be refactored.
+#if 0
#include "material_editor_plugin.h"
#include "scene/main/viewport.h"
-#if 0
-
void MaterialEditor::_gui_input(InputEvent p_event) {
diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h
index a0a91f53a6..218354a918 100644
--- a/editor/plugins/material_editor_plugin.h
+++ b/editor/plugins/material_editor_plugin.h
@@ -30,6 +30,10 @@
#ifndef MATERIAL_EDITOR_PLUGIN_H
#define MATERIAL_EDITOR_PLUGIN_H
+// FIXME: Disabled as (according to reduz) users were complaining that it gets in the way
+// Waiting for PropertyEditor rewrite (planned for 3.1) to be refactored.
+#if 0
+
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/3d/camera.h"
@@ -37,7 +41,6 @@
#include "scene/3d/mesh_instance.h"
#include "scene/resources/material.h"
-#if 0
class MaterialEditor : public Control {
GDCLASS(MaterialEditor, Control);
@@ -97,5 +100,5 @@ public:
};
-#endif // MATERIAL_EDITOR_PLUGIN_H
#endif
+#endif // MATERIAL_EDITOR_PLUGIN_H
diff --git a/editor/plugins/rich_text_editor_plugin.cpp b/editor/plugins/rich_text_editor_plugin.cpp
deleted file mode 100644
index 2a6474023c..0000000000
--- a/editor/plugins/rich_text_editor_plugin.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*************************************************************************/
-/* rich_text_editor_plugin.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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 "rich_text_editor_plugin.h"
-
-#include "canvas_item_editor_plugin.h"
-#include "os/file_access.h"
-
-void RichTextEditor::_notification(int p_what) {
-
- switch (p_what) {
-
- case NOTIFICATION_FIXED_PROCESS: {
-
- } break;
- }
-}
-void RichTextEditor::_node_removed(Node *p_node) {
-
- if (p_node == node) {
- node = NULL;
- hide();
- }
-}
-
-void RichTextEditor::_file_selected(const String &p_path) {
-
- CharString cs;
- FileAccess *fa = FileAccess::open(p_path, FileAccess::READ);
- if (!fa) {
- ERR_FAIL();
- }
-
- while (!fa->eof_reached())
- cs.push_back(fa->get_8());
- cs.push_back(0);
- memdelete(fa);
-
- String bbcode;
- bbcode.parse_utf8(&cs[0]);
- node->parse_bbcode(bbcode);
-}
-
-void RichTextEditor::_menu_option(int p_option) {
-
- switch (p_option) {
-
- case PARSE_BBCODE: {
-
- file_dialog->popup_centered_ratio();
- } break;
- case CLEAR: {
-
- node->clear();
-
- } break;
- }
-}
-
-void RichTextEditor::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_menu_option"), &RichTextEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_file_selected"), &RichTextEditor::_file_selected);
-}
-
-void RichTextEditor::edit(Node *p_rich_text) {
-
- node = Object::cast_to<RichTextLabel>(p_rich_text);
-}
-RichTextEditor::RichTextEditor() {
-
- options = memnew(MenuButton);
- //add_child(options);
- CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options);
- options->set_area_as_parent_rect();
-
- options->set_text("RichText");
- options->get_popup()->add_item(TTR("Parse BBCode"), PARSE_BBCODE);
- options->get_popup()->add_item(TTR("Clear"), CLEAR);
-
- options->get_popup()->connect("id_pressed", this, "_menu_option");
- file_dialog = memnew(EditorFileDialog);
- add_child(file_dialog);
- file_dialog->add_filter("*.txt");
- file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- file_dialog->connect("file_selected", this, "_file_selected");
-}
-
-void RichTextEditorPlugin::edit(Object *p_object) {
-
- rich_text_editor->edit(Object::cast_to<Node>(p_object));
-}
-
-bool RichTextEditorPlugin::handles(Object *p_object) const {
-
- return p_object->is_class("RichTextLabel");
-}
-
-void RichTextEditorPlugin::make_visible(bool p_visible) {
-
- if (p_visible) {
- rich_text_editor->options->show();
- } else {
-
- rich_text_editor->options->hide();
- rich_text_editor->edit(NULL);
- }
-}
-
-RichTextEditorPlugin::RichTextEditorPlugin(EditorNode *p_node) {
-
- editor = p_node;
- rich_text_editor = memnew(RichTextEditor);
- editor->get_viewport()->add_child(rich_text_editor);
-
- rich_text_editor->set_margin(MARGIN_LEFT, 184);
- rich_text_editor->set_margin(MARGIN_RIGHT, 230);
- rich_text_editor->set_margin(MARGIN_TOP, 0);
- rich_text_editor->set_margin(MARGIN_BOTTOM, 10);
-
- rich_text_editor->options->hide();
-}
-
-RichTextEditorPlugin::~RichTextEditorPlugin() {
-}
diff --git a/editor/plugins/rich_text_editor_plugin.h b/editor/plugins/rich_text_editor_plugin.h
deleted file mode 100644
index 2665db2993..0000000000
--- a/editor/plugins/rich_text_editor_plugin.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*************************************************************************/
-/* rich_text_editor_plugin.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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 RICH_TEXT_EDITOR_PLUGIN_H
-#define RICH_TEXT_EDITOR_PLUGIN_H
-
-#include "editor/editor_node.h"
-#include "editor/editor_plugin.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/rich_text_label.h"
-
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-
-class RichTextEditor : public Control {
-
- GDCLASS(RichTextEditor, Control);
-
- friend class RichTextEditorPlugin;
-
- enum {
-
- PARSE_BBCODE,
- CLEAR
- };
-
- Panel *panel;
- MenuButton *options;
- RichTextLabel *node;
- EditorFileDialog *file_dialog;
-
- void _file_selected(const String &p_path);
- void _menu_option(int p_option);
-
-protected:
- void _notification(int p_what);
- void _node_removed(Node *p_node);
- static void _bind_methods();
-
-public:
- void edit(Node *p_rich_text);
- RichTextEditor();
-};
-
-class RichTextEditorPlugin : public EditorPlugin {
-
- GDCLASS(RichTextEditorPlugin, EditorPlugin);
-
- RichTextEditor *rich_text_editor;
- EditorNode *editor;
-
-public:
- virtual String get_name() const { return "RichText"; }
- bool has_main_screen() const { return false; }
- virtual void edit(Object *p_object);
- virtual bool handles(Object *p_object) const;
- virtual void make_visible(bool p_visible);
-
- RichTextEditorPlugin(EditorNode *p_node);
- ~RichTextEditorPlugin();
-};
-
-#endif // RICH_TEXT_EDITOR_PLUGIN_H
diff --git a/editor/plugins/sample_editor_plugin.cpp b/editor/plugins/sample_editor_plugin.cpp
deleted file mode 100644
index f6f776f670..0000000000
--- a/editor/plugins/sample_editor_plugin.cpp
+++ /dev/null
@@ -1,452 +0,0 @@
-/*************************************************************************/
-/* sample_editor_plugin.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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 "sample_editor_plugin.h"
-
-#if 0
-#include "editor/editor_settings.h"
-#include "io/resource_loader.h"
-#include "project_settings.h"
-
-
-
-
-void SampleEditor::_gui_input(InputEvent p_event) {
-
-
-}
-
-void SampleEditor::_notification(int p_what) {
-
- if (p_what==NOTIFICATION_FIXED_PROCESS) {
-
- }
-
- if (p_what==NOTIFICATION_ENTER_TREE) {
- play->set_icon( get_icon("Play","EditorIcons") );
- stop->set_icon( get_icon("Stop","EditorIcons") );
- }
-
- if (p_what==NOTIFICATION_READY) {
-
- //get_scene()->connect("node_removed",this,"_node_removed");
-
- }
-
- if (p_what==NOTIFICATION_DRAW) {
-
- }
-}
-
-void SampleEditor::_play_pressed() {
-
- player->play("default",true);
- stop->set_pressed(false);
- play->set_pressed(true);
-}
-void SampleEditor::_stop_pressed() {
-
- player->stop_all();
- play->set_pressed(false);
-}
-
-void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<ImageTexture> &p_texture) {
-
-
- PoolVector<uint8_t> data = p_sample->get_data();
-
- PoolVector<uint8_t> img;
- int w = p_texture->get_width();
- int h = p_texture->get_height();
- img.resize(w*h*3);
- PoolVector<uint8_t>::Write imgdata = img.write();
- uint8_t * imgw = imgdata.ptr();
- PoolVector<uint8_t>::Read sampledata = data.read();
- const uint8_t *sdata=sampledata.ptr();
-
- bool stereo = p_sample->is_stereo();
- bool _16=p_sample->get_format()==Sample::FORMAT_PCM16;
- int len = p_sample->get_length();
-
- if (len<1)
- return;
-
- if (p_sample->get_format()==Sample::FORMAT_IMA_ADPCM) {
-
-
- struct IMA_ADPCM_State {
-
- int16_t step_index;
- int32_t predictor;
- /* values at loop point */
- int16_t loop_step_index;
- int32_t loop_predictor;
- int32_t last_nibble;
- int32_t loop_pos;
- int32_t window_ofs;
- const uint8_t *ptr;
- } ima_adpcm;
-
- ima_adpcm.step_index=0;
- ima_adpcm.predictor=0;
- ima_adpcm.loop_step_index=0;
- ima_adpcm.loop_predictor=0;
- ima_adpcm.last_nibble=-1;
- ima_adpcm.loop_pos=0x7FFFFFFF;
- ima_adpcm.window_ofs=0;
- ima_adpcm.ptr=NULL;
-
-
- for(int i=0;i<w;i++) {
-
- float max[2]={-1e10,-1e10};
- float min[2]={1e10,1e10};
- int from = i*len/w;
- int to = (i+1)*len/w;
- if (to>=len)
- to=len-1;
-
- for(int j=from;j<to;j++) {
-
- while(j>ima_adpcm.last_nibble) {
-
- static const int16_t _ima_adpcm_step_table[89] = {
- 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
- 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
- 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
- 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
- 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
- 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
- 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
- 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
- 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
- };
-
- static const int8_t _ima_adpcm_index_table[16] = {
- -1, -1, -1, -1, 2, 4, 6, 8,
- -1, -1, -1, -1, 2, 4, 6, 8
- };
-
- int16_t nibble,diff,step;
-
- ima_adpcm.last_nibble++;
- const uint8_t *src_ptr=sdata;
-
- int ofs = ima_adpcm.last_nibble>>1;
-
- if (stereo)
- ofs*=2;
-
- nibble = (ima_adpcm.last_nibble&1)?
- (src_ptr[ofs]>>4):(src_ptr[ofs]&0xF);
-
- step=_ima_adpcm_step_table[ima_adpcm.step_index];
-
- ima_adpcm.step_index += _ima_adpcm_index_table[nibble];
- if (ima_adpcm.step_index<0)
- ima_adpcm.step_index=0;
- if (ima_adpcm.step_index>88)
- ima_adpcm.step_index=88;
-
- diff = step >> 3 ;
- if (nibble & 1)
- diff += step >> 2 ;
- if (nibble & 2)
- diff += step >> 1 ;
- if (nibble & 4)
- diff += step ;
- if (nibble & 8)
- diff = -diff ;
-
- ima_adpcm.predictor+=diff;
- if (ima_adpcm.predictor<-0x8000)
- ima_adpcm.predictor=-0x8000;
- else if (ima_adpcm.predictor>0x7FFF)
- ima_adpcm.predictor=0x7FFF;
-
-
- /* store loop if there */
- if (ima_adpcm.last_nibble==ima_adpcm.loop_pos) {
-
- ima_adpcm.loop_step_index = ima_adpcm.step_index;
- ima_adpcm.loop_predictor = ima_adpcm.predictor;
- }
-
- }
-
- float v=ima_adpcm.predictor/32767.0;
- if (v>max[0])
- max[0]=v;
- if (v<min[0])
- min[0]=v;
- }
-
- for(int j=0;j<h;j++) {
- float v = (j/(float)h) * 2.0 - 1.0;
- uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3];
- if (v>min[0] && v<max[0]) {
- imgofs[0]=255;
- imgofs[1]=150;
- imgofs[2]=80;
- } else {
- imgofs[0]=0;
- imgofs[1]=0;
- imgofs[2]=0;
- }
- }
- }
- } else {
- for(int i=0;i<w;i++) {
- // i trust gcc will optimize this loop
- float max[2]={-1e10,-1e10};
- float min[2]={1e10,1e10};
- int c=stereo?2:1;
- int from = uint64_t(i)*len/w;
- int to = (uint64_t(i)+1)*len/w;
- if (to>=len)
- to=len-1;
-
- if (_16) {
- const int16_t*src =(const int16_t*)sdata;
-
- for(int j=0;j<c;j++) {
-
- for(int k=from;k<=to;k++) {
-
- float v = src[uint64_t(k)*c+j]/32768.0;
- if (v>max[j])
- max[j]=v;
- if (v<min[j])
- min[j]=v;
- }
-
- }
- } else {
-
- const int8_t*src =(const int8_t*)sdata;
-
- for(int j=0;j<c;j++) {
-
- for(int k=from;k<=to;k++) {
-
- float v = src[uint64_t(k)*c+j]/128.0;
- if (v>max[j])
- max[j]=v;
- if (v<min[j])
- min[j]=v;
- }
-
- }
- }
-
- if (!stereo) {
- for(int j=0;j<h;j++) {
- float v = (j/(float)h) * 2.0 - 1.0;
- uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3];
- if (v>min[0] && v<max[0]) {
- imgofs[0]=255;
- imgofs[1]=150;
- imgofs[2]=80;
- } else {
- imgofs[0]=0;
- imgofs[1]=0;
- imgofs[2]=0;
- }
- }
- } else {
-
- for(int j=0;j<h;j++) {
-
- int half;
- float v;
- if (j<(h/2)) {
- half=0;
- v = (j/(float)(h/2)) * 2.0 - 1.0;
- } else {
- half=1;
- v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0;
- }
-
- uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3];
- if (v>min[half] && v<max[half]) {
- imgofs[0]=255;
- imgofs[1]=150;
- imgofs[2]=80;
- } else {
- imgofs[0]=0;
- imgofs[1]=0;
- imgofs[2]=0;
- }
- }
-
- }
-
- }
- }
-
- imgdata = PoolVector<uint8_t>::Write();
-
-
- p_texture->set_data(Image(w,h,0,Image::FORMAT_RGB8,img));
-
-}
-
-void SampleEditor::_update_sample() {
-
- player->stop_all();
-
- generate_preview_texture(sample,peakdisplay);
- info_label->set_text(TTR("Length:")+" "+String::num(sample->get_length()/(float)sample->get_mix_rate(),2)+"s");
-
- if (library->has_sample("default"))
- library->remove_sample("default");
-
- library->add_sample("default",sample);
-}
-
-
-
-void SampleEditor::edit(Ref<Sample> p_sample) {
-
- sample=p_sample;
-
- if (!sample.is_null())
- _update_sample();
- else {
-
- hide();
- set_fixed_process(false);
- }
-
-}
-
-
-
-void SampleEditor::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_gui_input"),&SampleEditor::_gui_input);
- ClassDB::bind_method(D_METHOD("_play_pressed"),&SampleEditor::_play_pressed);
- ClassDB::bind_method(D_METHOD("_stop_pressed"),&SampleEditor::_stop_pressed);
-
-}
-
-SampleEditor::SampleEditor() {
-
- player = memnew(SamplePlayer);
- add_child(player);
- add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel"));
- library = Ref<SampleLibrary>(memnew(SampleLibrary));
- player->set_sample_library(library);
- sample_texframe = memnew( TextureRect );
- add_child(sample_texframe);
- sample_texframe->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
- sample_texframe->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,-5);
- sample_texframe->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,30);
- sample_texframe->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,-5);
-
- info_label = memnew( Label );
- sample_texframe->add_child(info_label);
- info_label->set_area_as_parent_rect();
- info_label->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,-15);
- info_label->set_margin(MARGIN_BOTTOM,-4);
- info_label->set_margin(MARGIN_RIGHT,-4);
- info_label->set_align(Label::ALIGN_RIGHT);
-
-
- play = memnew( Button );
-
- play->set_position(Point2( 5, 5 ));
- play->set_size( Size2(1,1 ) );
- play->set_toggle_mode(true);
- add_child(play);
-
- stop = memnew( Button );
-
- stop->set_position(Point2( 35, 5 ));
- stop->set_size( Size2(1,1 ) );
- stop->set_toggle_mode(true);
- add_child(stop);
-
- peakdisplay=Ref<ImageTexture>( memnew( ImageTexture) );
- peakdisplay->create( EDITOR_DEF("editors/sample_editor/preview_width",512),EDITOR_DEF("editors/sample_editor/preview_height",128),Image::FORMAT_RGB8);
- sample_texframe->set_expand(true);
- sample_texframe->set_texture(peakdisplay);
-
- play->connect("pressed", this,"_play_pressed");
- stop->connect("pressed", this,"_stop_pressed");
-
- set_custom_minimum_size(Size2(1,150)*EDSCALE);
-
-}
-
-
-void SampleEditorPlugin::edit(Object *p_object) {
-
- Sample * s = Object::cast_to<Sample>(p_object);
- if (!s)
- return;
-
- sample_editor->edit(Ref<Sample>(s));
-}
-
-bool SampleEditorPlugin::handles(Object *p_object) const {
-
- return p_object->is_class("Sample");
-}
-
-void SampleEditorPlugin::make_visible(bool p_visible) {
-
- if (p_visible) {
- sample_editor->show();
- //sample_editor->set_process(true);
- } else {
-
- sample_editor->hide();
- //sample_editor->set_process(false);
- }
-
-}
-
-SampleEditorPlugin::SampleEditorPlugin(EditorNode *p_node) {
-
- editor=p_node;
- sample_editor = memnew( SampleEditor );
- add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM,sample_editor);
- sample_editor->hide();
-
-
-
-}
-
-
-SampleEditorPlugin::~SampleEditorPlugin()
-{
-}
-
-#endif
diff --git a/editor/plugins/sample_editor_plugin.h b/editor/plugins/sample_editor_plugin.h
deleted file mode 100644
index 8f93026c92..0000000000
--- a/editor/plugins/sample_editor_plugin.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*************************************************************************/
-/* sample_editor_plugin.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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 SAMPLE_EDITOR_PLUGIN_H
-#define SAMPLE_EDITOR_PLUGIN_H
-
-#if 0
-#include "editor/editor_node.h"
-#include "editor/editor_plugin.h"
-#include "scene/audio/sample_player.h"
-#include "scene/resources/sample.h"
-#include "scene/resources/sample_library.h"
-
-
-class SampleEditor : public Panel {
-
- GDCLASS(SampleEditor, Panel );
-
-
- SamplePlayer *player;
- Label *info_label;
- Ref<ImageTexture> peakdisplay;
- Ref<Sample> sample;
- Ref<SampleLibrary> library;
- TextureRect *sample_texframe;
- Button *stop;
- Button *play;
-
- void _play_pressed();
- void _stop_pressed();
- void _update_sample();
-
-protected:
- void _notification(int p_what);
- void _gui_input(InputEvent p_event);
- static void _bind_methods();
-public:
-
- static void generate_preview_texture(const Ref<Sample>& p_sample,Ref<ImageTexture> &p_texture);
- void edit(Ref<Sample> p_sample);
- SampleEditor();
-};
-
-
-class SampleEditorPlugin : public EditorPlugin {
-
- GDCLASS( SampleEditorPlugin, EditorPlugin );
-
- SampleEditor *sample_editor;
- EditorNode *editor;
-
-public:
-
- virtual String get_name() const { return "Sample"; }
- bool has_main_screen() const { return false; }
- virtual void edit(Object *p_node);
- virtual bool handles(Object *p_node) const;
- virtual void make_visible(bool p_visible);
-
- SampleEditorPlugin(EditorNode *p_node);
- ~SampleEditorPlugin();
-
-};
-
-#endif
-
-#endif // SAMPLE_EDITOR_PLUGIN_H
diff --git a/editor/plugins/sample_library_editor_plugin.cpp b/editor/plugins/sample_library_editor_plugin.cpp
deleted file mode 100644
index 761301610e..0000000000
--- a/editor/plugins/sample_library_editor_plugin.cpp
+++ /dev/null
@@ -1,547 +0,0 @@
-/*************************************************************************/
-/* sample_library_editor_plugin.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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. */
-/*************************************************************************/
-
-#if 0
-#include "sample_library_editor_plugin.h"
-
-#include "editor/editor_settings.h"
-#include "io/resource_loader.h"
-#include "project_settings.h"
-#include "sample_editor_plugin.h"
-#include "scene/main/viewport.h"
-
-
-void SampleLibraryEditor::_gui_input(InputEvent p_event) {
-
-
-}
-
-void SampleLibraryEditor::_notification(int p_what) {
-
- if (p_what==NOTIFICATION_PROCESS) {
- if (is_playing && !player->is_active()) {
- TreeItem *tl=Object::cast_to<TreeItem>(last_sample_playing);
- tl->set_button(0,0,get_icon("Play","EditorIcons"));
- is_playing = false;
- set_process(false);
- }
- }
-
- if (p_what==NOTIFICATION_ENTER_TREE) {
- load->set_icon( get_icon("Folder","EditorIcons") );
- load->set_tooltip(TTR("Open Sample File(s)"));
- }
-
- if (p_what==NOTIFICATION_READY) {
-
- //NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
- }
-
- if (p_what==NOTIFICATION_DRAW) {
-
- }
-}
-
-void SampleLibraryEditor::_file_load_request(const PoolVector<String>& p_path) {
-
-
- for(int i=0;i<p_path.size();i++) {
-
- String path = p_path[i];
- Ref<Sample> sample = ResourceLoader::load(path,"Sample");
- if (sample.is_null()) {
- dialog->set_text(TTR("ERROR: Couldn't load sample!"));
- dialog->set_title(TTR("Error!"));
- //dialog->get_cancel()->set_text("Close");
- dialog->get_ok()->set_text(TTR("Close"));
- dialog->popup_centered_minsize();
- return; ///beh should show an error i guess
- }
- String basename = path.get_file().get_basename();
- String name=basename;
- int counter=0;
- while(sample_library->has_sample(name)) {
- counter++;
- name=basename+"_"+itos(counter);
- }
-
- undo_redo->create_action(TTR("Add Sample"));
- undo_redo->add_do_method(sample_library.operator->(),"add_sample",name,sample);
- undo_redo->add_undo_method(sample_library.operator->(),"remove_sample",name);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
- undo_redo->commit_action();
- }
-}
-
-void SampleLibraryEditor::_load_pressed() {
-
- file->popup_centered_ratio();
-
-}
-
-void SampleLibraryEditor::_button_pressed(Object *p_item,int p_column, int p_id) {
-
- TreeItem *ti=Object::cast_to<TreeItem>(p_item);
- String name = ti->get_text(0);
-
- if (p_column==0) { // Play/Stop
-
- String btn_type;
- if(!is_playing) {
- is_playing = true;
- btn_type = TTR("Stop");
- player->play(name,true);
- last_sample_playing = p_item;
- set_process(true);
- } else {
- player->stop_all();
- if(last_sample_playing != p_item){
- TreeItem *tl=Object::cast_to<TreeItem>(last_sample_playing);
- tl->set_button(p_column,0,get_icon("Play","EditorIcons"));
- btn_type = TTR("Stop");
- player->play(name,true);
- last_sample_playing = p_item;
- } else {
- btn_type = TTR("Play");
- is_playing = false;
- }
- }
- ti->set_button(p_column,0,get_icon(btn_type,"EditorIcons"));
- } else if (p_column==1) { // Edit
-
- get_tree()->get_root()->get_child(0)->call("_resource_selected",sample_library->get_sample(name));
- } else if (p_column==5) { // Delete
-
- ti->select(0);
- _delete_pressed();
- }
-
-
-}
-
-
-
-
-
-void SampleLibraryEditor::_item_edited() {
-
- if (!tree->get_selected())
- return;
-
- TreeItem *s = tree->get_selected();
-
- if (tree->get_selected_column()==0) { // Name
- // renamed
- String old_name=s->get_metadata(0);
- String new_name=s->get_text(0);
- if (old_name==new_name)
- return;
-
- if (new_name=="" || new_name.find("\\")!=-1 || new_name.find("/")!=-1 || sample_library->has_sample(new_name)) {
-
- s->set_text(0,old_name);
- return;
- }
-
- Ref<Sample> samp = sample_library->get_sample(old_name);
- undo_redo->create_action(TTR("Rename Sample"));
- undo_redo->add_do_method(sample_library.operator->(),"remove_sample",old_name);
- undo_redo->add_do_method(sample_library.operator->(),"add_sample",new_name,samp);
- undo_redo->add_undo_method(sample_library.operator->(),"remove_sample",new_name);
- undo_redo->add_undo_method(sample_library.operator->(),"add_sample",old_name,samp);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
- undo_redo->commit_action();
-
- } else if (tree->get_selected_column()==3) { // Volume dB
-
- StringName n = s->get_text(0);
- sample_library->sample_set_volume_db(n,s->get_range(3));
-
- } else if (tree->get_selected_column()==4) { // Pitch scale
-
- StringName n = s->get_text(0);
- sample_library->sample_set_pitch_scale(n,s->get_range(4));
-
- }
-
-
-}
-
-void SampleLibraryEditor::_delete_pressed() {
-
- if (!tree->get_selected())
- return;
-
- String to_remove = tree->get_selected()->get_text(0);
- undo_redo->create_action(TTR("Delete Sample"));
- undo_redo->add_do_method(sample_library.operator->(),"remove_sample",to_remove);
- undo_redo->add_undo_method(sample_library.operator->(),"add_sample",to_remove,sample_library->get_sample(to_remove));
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
- undo_redo->commit_action();
-}
-
-
-void SampleLibraryEditor::_update_library() {
-
- player->stop_all();
-
- tree->clear();
- tree->set_hide_root(true);
- TreeItem *root = tree->create_item(NULL);
-
- List<StringName> names;
- sample_library->get_sample_list(&names);
- names.sort_custom<StringName::AlphCompare>();
-
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
-
- TreeItem *ti = tree->create_item(root);
-
- // Name + Play/Stop
- ti->set_cell_mode(0,TreeItem::CELL_MODE_STRING);
- ti->set_editable(0,true);
- ti->set_selectable(0,true);
- ti->set_text(0,E->get());
- ti->set_metadata(0,E->get());
- ti->add_button(0,get_icon("Play","EditorIcons"));
-
- Ref<Sample> smp = sample_library->get_sample(E->get());
-
- // Preview/edit
- Ref<ImageTexture> preview( memnew( ImageTexture ));
- preview->create(128,16,Image::FORMAT_RGB8);
- SampleEditor::generate_preview_texture(smp,preview);
- ti->set_cell_mode(1,TreeItem::CELL_MODE_ICON);
- ti->set_selectable(1,false);
- ti->set_editable(1,false);
- ti->set_icon(1,preview);
- ti->add_button(1,get_icon("Edit","EditorIcons"));
-
- // Format
- ti->set_cell_mode(2,TreeItem::CELL_MODE_STRING);
- ti->set_editable(2,false);
- ti->set_selectable(2,false);
- ti->set_text(2,String()+(smp->get_format()==Sample::FORMAT_PCM16?TTR("16 Bits")+", ":(smp->get_format()==Sample::FORMAT_PCM8?TTR("8 Bits")+", ":"IMA-ADPCM,"))+(smp->is_stereo()?TTR("Stereo"):TTR("Mono")));
-
- // Volume dB
- ti->set_cell_mode(3,TreeItem::CELL_MODE_RANGE);
- ti->set_range_config(3,-60,24,0.01);
- ti->set_selectable(3,true);
- ti->set_editable(3,true);
- ti->set_range(3,sample_library->sample_get_volume_db(E->get()));
-
- // Pitch scale
- ti->set_cell_mode(4,TreeItem::CELL_MODE_RANGE);
- ti->set_range_config(4,0.01,100,0.01);
- ti->set_selectable(4,true);
- ti->set_editable(4,true);
- ti->set_range(4,sample_library->sample_get_pitch_scale(E->get()));
-
- // Delete
- ti->set_cell_mode(5,TreeItem::CELL_MODE_STRING);
- ti->add_button(5,get_icon("Remove","EditorIcons"));
-
- }
-
- //player->add_sample("default",sample);
-}
-
-
-
-void SampleLibraryEditor::edit(Ref<SampleLibrary> p_sample_library) {
-
- sample_library=p_sample_library;
-
-
- if (!sample_library.is_null()) {
- player->set_sample_library(sample_library);
- _update_library();
- } else {
-
- hide();
- }
-
-}
-
-Variant SampleLibraryEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) {
-
- TreeItem*ti =tree->get_item_at_pos(p_point);
- if (!ti)
- return Variant();
-
- String name = ti->get_metadata(0);
-
- RES res = sample_library->get_sample(name);
- if (!res.is_valid())
- return Variant();
-
- return EditorNode::get_singleton()->drag_resource(res,p_from);
-
-
-}
-
-bool SampleLibraryEditor::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;
-
- if (d.has("from") && (Object*)(d["from"])==tree)
- return false;
-
- if (String(d["type"])=="resource" && d.has("resource")) {
- RES r=d["resource"];
-
- Ref<Sample> sample = r;
-
- if (sample.is_valid()) {
-
- return true;
- }
- }
-
-
- if (String(d["type"])=="files") {
-
- Vector<String> files = d["files"];
-
- if (files.size()==0)
- return false;
-
- for(int i=0;i<files.size();i++) {
- String file = files[0];
- String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
-
- if (ftype!="Sample") {
- return false;
- }
-
- }
-
- return true;
-
- }
- return false;
-}
-
-void SampleLibraryEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) {
-
- if (!can_drop_data_fw(p_point,p_data,p_from))
- return;
-
- Dictionary d = p_data;
-
- if (!d.has("type"))
- return;
-
-
- if (String(d["type"])=="resource" && d.has("resource")) {
- RES r=d["resource"];
-
- Ref<Sample> sample = r;
-
- if (sample.is_valid()) {
-
- String basename;
- if (sample->get_name()!="") {
- basename=sample->get_name();
- } else if (sample->get_path().is_resource_file()) {
- basename = sample->get_path().get_basename();
- } else {
- basename="Sample";
- }
-
- String name=basename;
- int counter=0;
- while(sample_library->has_sample(name)) {
- counter++;
- name=basename+"_"+itos(counter);
- }
-
- undo_redo->create_action(TTR("Add Sample"));
- undo_redo->add_do_method(sample_library.operator->(),"add_sample",name,sample);
- undo_redo->add_undo_method(sample_library.operator->(),"remove_sample",name);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
- undo_redo->commit_action();
- }
- }
-
-
- if (String(d["type"])=="files") {
-
- PoolVector<String> files = d["files"];
-
- _file_load_request(files);
-
- }
-
-}
-
-
-void SampleLibraryEditor::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_gui_input"),&SampleLibraryEditor::_gui_input);
- ClassDB::bind_method(D_METHOD("_load_pressed"),&SampleLibraryEditor::_load_pressed);
- ClassDB::bind_method(D_METHOD("_item_edited"),&SampleLibraryEditor::_item_edited);
- ClassDB::bind_method(D_METHOD("_delete_pressed"),&SampleLibraryEditor::_delete_pressed);
- ClassDB::bind_method(D_METHOD("_file_load_request"),&SampleLibraryEditor::_file_load_request);
- ClassDB::bind_method(D_METHOD("_update_library"),&SampleLibraryEditor::_update_library);
- ClassDB::bind_method(D_METHOD("_button_pressed"),&SampleLibraryEditor::_button_pressed);
-
- ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SampleLibraryEditor::get_drag_data_fw);
- ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SampleLibraryEditor::can_drop_data_fw);
- ClassDB::bind_method(D_METHOD("drop_data_fw"), &SampleLibraryEditor::drop_data_fw);
-
-}
-
-SampleLibraryEditor::SampleLibraryEditor() {
-
- player = memnew(SamplePlayer);
- add_child(player);
- add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel"));
-
-
- load = memnew( Button );
- load->set_position(Point2( 5, 5 ));
- load->set_size( Size2(1,1 ) );
- add_child(load);
-
- file = memnew( EditorFileDialog );
- add_child(file);
- List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("Sample",&extensions);
- for(int i=0;i<extensions.size();i++)
- file->add_filter("*."+extensions[i]);
- file->set_mode(EditorFileDialog::MODE_OPEN_FILES);
-
- tree = memnew( Tree );
- tree->set_columns(6);
- add_child(tree);
- tree->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
- tree->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,-5);
- tree->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,30);
- tree->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,-5);
- tree->set_column_titles_visible(true);
- tree->set_column_title(0,TTR("Name"));
- tree->set_column_title(1,TTR("Preview"));
- tree->set_column_title(2,TTR("Format"));
- tree->set_column_title(3,"dB");
- tree->set_column_title(4,TTR("Pitch"));
- tree->set_column_title(5,"");
-
- tree->set_column_min_width(1,150);
- tree->set_column_min_width(2,100);
- tree->set_column_min_width(3,50);
- tree->set_column_min_width(4,50);
- tree->set_column_min_width(5,32);
- tree->set_column_expand(1,false);
- tree->set_column_expand(2,false);
- tree->set_column_expand(3,false);
- tree->set_column_expand(4,false);
- tree->set_column_expand(5,false);
-
- tree->set_drag_forwarding(this);
-
- dialog = memnew( ConfirmationDialog );
- add_child( dialog );
-
- tree->connect("button_pressed",this,"_button_pressed");
- load->connect("pressed", this,"_load_pressed");
- file->connect("files_selected", this,"_file_load_request");
- tree->connect("item_edited", this,"_item_edited");
-
- is_playing = false;
-}
-
-
-void SampleLibraryEditorPlugin::edit(Object *p_object) {
-
- sample_library_editor->set_undo_redo(&get_undo_redo());
- SampleLibrary * s = Object::cast_to<SampleLibrary>(p_object);
- if (!s)
- return;
-
- sample_library_editor->edit(Ref<SampleLibrary>(s));
-}
-
-bool SampleLibraryEditorPlugin::handles(Object *p_object) const {
-
- return p_object->is_class("SampleLibrary");
-}
-
-void SampleLibraryEditorPlugin::make_visible(bool p_visible) {
-
- if (p_visible) {
- //sample_library_editor->show();
- button->show();
- editor->make_bottom_panel_item_visible(sample_library_editor);
- //sample_library_editor->set_process(true);
- } else {
-
- if (sample_library_editor->is_visible_in_tree())
- editor->hide_bottom_panel();
- button->hide();
-
- //sample_library_editor->set_process(false);
- }
-
-}
-
-SampleLibraryEditorPlugin::SampleLibraryEditorPlugin(EditorNode *p_node) {
-
- editor=p_node;
- sample_library_editor = memnew( SampleLibraryEditor );
-
- //editor->get_viewport()->add_child(sample_library_editor);
- sample_library_editor->set_custom_minimum_size(Size2(0,250));
- button=p_node->add_bottom_panel_item("SampleLibrary",sample_library_editor);
- button->hide();
-
- //sample_library_editor->set_area_as_parent_rect();
- //sample_library_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END);
- //sample_library_editor->set_margin( MARGIN_TOP, 120 );
- //sample_library_editor->hide();
-
-
-
-}
-
-
-SampleLibraryEditorPlugin::~SampleLibraryEditorPlugin()
-{
-}
-#endif
diff --git a/editor/plugins/sample_library_editor_plugin.h b/editor/plugins/sample_library_editor_plugin.h
deleted file mode 100644
index 0244fa66ed..0000000000
--- a/editor/plugins/sample_library_editor_plugin.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*************************************************************************/
-/* sample_library_editor_plugin.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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 SAMPLE_LIBRARY_EDITOR_PLUGIN_H
-#define SAMPLE_LIBRARY_EDITOR_PLUGIN_H
-
-#if 0
-#include "editor/editor_node.h"
-#include "editor/editor_plugin.h"
-#include "scene/audio/sample_player.h"
-#include "scene/gui/dialogs.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/tree.h"
-#include "scene/resources/sample.h"
-
-
-class SampleLibraryEditor : public Panel {
-
- GDCLASS(SampleLibraryEditor, Panel );
-
-
-
- SamplePlayer *player;
- Ref<SampleLibrary> sample_library;
- Button *load;
- Tree *tree;
- bool is_playing;
- Object *last_sample_playing;
-
- EditorFileDialog *file;
-
- ConfirmationDialog *dialog;
-
-
- void _load_pressed();
- void _file_load_request(const PoolVector<String>& p_path);
- void _delete_pressed();
- void _update_library();
- void _item_edited();
-
- UndoRedo *undo_redo;
-
- void _button_pressed(Object *p_item,int p_column, int p_id);
-
- Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
- 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);
-
-protected:
- void _notification(int p_what);
- void _gui_input(InputEvent p_event);
- static void _bind_methods();
-public:
-
- void set_undo_redo(UndoRedo *p_undo_redo) {undo_redo=p_undo_redo; }
- void edit(Ref<SampleLibrary> p_sample);
- SampleLibraryEditor();
-};
-
-class SampleLibraryEditorPlugin : public EditorPlugin {
-
- GDCLASS( SampleLibraryEditorPlugin, EditorPlugin );
-
- SampleLibraryEditor *sample_library_editor;
- EditorNode *editor;
- Button *button;
-
-public:
-
- virtual String get_name() const { return "SampleLibrary"; }
- bool has_main_screen() const { return false; }
- virtual void edit(Object *p_node);
- virtual bool handles(Object *p_node) const;
- virtual void make_visible(bool p_visible);
-
- SampleLibraryEditorPlugin(EditorNode *p_node);
- ~SampleLibraryEditorPlugin();
-
-};
-
-#endif
-#endif // SAMPLE_LIBRARY_EDITOR_PLUGIN_H
diff --git a/editor/plugins/sample_player_editor_plugin.cpp b/editor/plugins/sample_player_editor_plugin.cpp
deleted file mode 100644
index 821c7ecc01..0000000000
--- a/editor/plugins/sample_player_editor_plugin.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/*************************************************************************/
-/* sample_player_editor_plugin.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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. */
-/*************************************************************************/
-
-#if 0
-#include "sample_player_editor_plugin.h"
-
-#include "scene/resources/sample_library.h"
-
-
-void SamplePlayerEditor::_notification(int p_what) {
-
- if (p_what==NOTIFICATION_ENTER_TREE) {
- play->set_icon( get_icon("Play","EditorIcons") );
- stop->set_icon( get_icon("Stop","EditorIcons") );
- }
-
-}
-
-void SamplePlayerEditor::_node_removed(Node *p_node) {
-
- if(p_node==node) {
- node=NULL;
- hide();
- }
-
-}
-
-void SamplePlayerEditor::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_play"),&SamplePlayerEditor::_play);
- ClassDB::bind_method(D_METHOD("_stop"),&SamplePlayerEditor::_stop);
-
-}
-
-
-void SamplePlayerEditor::_play() {
-
- if (!node)
- return;
- if (samples->get_item_count()<=0)
- return;
-
- node->call("play",samples->get_item_text( samples->get_selected() ));
- stop->set_pressed(false);
- play->set_pressed(true);
-}
-
-void SamplePlayerEditor::_stop() {
-
- if (!node)
- return;
- if (samples->get_item_count()<=0)
- return;
-
- node->call("stop_all");
- print_line("STOP ALL!!");
- stop->set_pressed(true);
- play->set_pressed(false);
-
-}
-
-
-void SamplePlayerEditor::_update_sample_library() {
-
- samples->clear();
- Ref<SampleLibrary> sl = node->call("get_sample_library");
- if (sl.is_null()) {
- samples->add_item("<NO SAMPLE LIBRARY>");
- return; //no sample library;
- }
-
- List<StringName> samplenames;
- sl->get_sample_list(&samplenames);
- samplenames.sort_custom<StringName::AlphCompare>();
- for(List<StringName>::Element *E=samplenames.front();E;E=E->next()) {
- samples->add_item(E->get());
- }
-
-}
-
-void SamplePlayerEditor::edit(Node *p_sample_player) {
-
- node=p_sample_player;
- if (node) {
- _update_sample_library();
- }
-
-}
-SamplePlayerEditor::SamplePlayerEditor() {
-
-
- play = memnew( Button );
-
- play->set_position(Point2( 5, 5 ));
- play->set_toggle_mode(true);
- play->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,-250);
- play->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,-230);
- play->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0);
- play->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,0);
-
- add_child(play);
-
- stop = memnew( Button );
-
- stop->set_position(Point2( 35, 5 ));
- stop->set_toggle_mode(true);
- stop->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,-220);
- stop->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,-200);
- stop->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0);
- stop->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,0);
- add_child(stop);
-
- samples = memnew( OptionButton );
- samples->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,-190);
- samples->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,-5);
- samples->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0);
- samples->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,0);
- add_child(samples);
-
- play->connect("pressed", this,"_play");
- stop->connect("pressed", this,"_stop");
-
-}
-
-
-void SamplePlayerEditorPlugin::edit(Object *p_object) {
-
- sample_player_editor->edit(Object::cast_to<Node>(p_object));
-}
-
-bool SamplePlayerEditorPlugin::handles(Object *p_object) const {
-
- return p_object->is_class("SamplePlayer2D") || p_object->is_class("SamplePlayer") || p_object->is_class("SpatialSamplePlayer");
-}
-
-void SamplePlayerEditorPlugin::make_visible(bool p_visible) {
-
- if (p_visible) {
- sample_player_editor->show();
- sample_player_editor->set_fixed_process(true);
- } else {
-
- sample_player_editor->hide();
- sample_player_editor->set_fixed_process(false);
- sample_player_editor->edit(NULL);
- }
-
-}
-
-SamplePlayerEditorPlugin::SamplePlayerEditorPlugin(EditorNode *p_node) {
-
- editor=p_node;
- sample_player_editor = memnew( SamplePlayerEditor );
- editor->get_viewport()->add_child(sample_player_editor);
-
- sample_player_editor->set_anchor(MARGIN_LEFT,Control::ANCHOR_END);
- sample_player_editor->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END);
- sample_player_editor->set_margin(MARGIN_LEFT,-250);
- sample_player_editor->set_margin(MARGIN_RIGHT,0);
- sample_player_editor->set_margin(MARGIN_TOP,0);
- sample_player_editor->set_margin(MARGIN_BOTTOM,10);
-
-
- sample_player_editor->hide();
-
-
-
-}
-
-
-SamplePlayerEditorPlugin::~SamplePlayerEditorPlugin()
-{
-}
-
-#endif
diff --git a/editor/plugins/sample_player_editor_plugin.h b/editor/plugins/sample_player_editor_plugin.h
deleted file mode 100644
index 5c1b25aaa2..0000000000
--- a/editor/plugins/sample_player_editor_plugin.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*************************************************************************/
-/* sample_player_editor_plugin.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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 SAMPLE_PLAYER_EDITOR_PLUGIN_H
-#define SAMPLE_PLAYER_EDITOR_PLUGIN_H
-
-#if 0
-
-#include "editor/editor_node.h"
-#include "editor/editor_plugin.h"
-#include "scene/3d/spatial_sample_player.h"
-#include "scene/audio/sample_player.h"
-#include "scene/gui/option_button.h"
-
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-
-class SamplePlayerEditor : public Control {
-
- GDCLASS(SamplePlayerEditor, Control );
-
- Panel *panel;
- Button * play;
- Button * stop;
- OptionButton *samples;
- Node *node;
-
-
- void _update_sample_library();
- void _play();
- void _stop();
-
-protected:
- void _notification(int p_what);
- void _node_removed(Node *p_node);
- static void _bind_methods();
-public:
-
- void edit(Node *p_sample_player);
- SamplePlayerEditor();
-};
-
-class SamplePlayerEditorPlugin : public EditorPlugin {
-
- GDCLASS( SamplePlayerEditorPlugin, EditorPlugin );
-
- SamplePlayerEditor *sample_player_editor;
- EditorNode *editor;
-
-public:
-
- virtual String get_name() const { return "SamplePlayer"; }
- bool has_main_screen() const { return false; }
- virtual void edit(Object *p_node);
- virtual bool handles(Object *p_node) const;
- virtual void make_visible(bool p_visible);
-
- SamplePlayerEditorPlugin(EditorNode *p_node);
- ~SamplePlayerEditorPlugin();
-
-};
-
-#endif
-#endif // SAMPLE_PLAYER_EDITOR_PLUGIN_H
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index a6db0f6e59..9b83d4e483 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -29,18 +29,19 @@
/*************************************************************************/
#include "script_editor_plugin.h"
+#include "core/io/resource_loader.h"
+#include "core/io/resource_saver.h"
+#include "core/os/file_access.h"
+#include "core/os/input.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
+#include "editor/node_dock.h"
#include "editor/script_editor_debugger.h"
-#include "io/resource_loader.h"
-#include "io/resource_saver.h"
-#include "node_dock.h"
-#include "os/file_access.h"
-#include "os/input.h"
-#include "os/keyboard.h"
-#include "os/os.h"
-#include "project_settings.h"
#include "scene/main/viewport.h"
+
/*** SCRIPT EDITOR ****/
void ScriptEditorBase::_bind_methods() {
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 251416f853..5a57efd941 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -29,20 +29,17 @@
/*************************************************************************/
#include "shader_editor_plugin.h"
+#include "core/io/resource_loader.h"
+#include "core/io/resource_saver.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/property_editor.h"
-#include "io/resource_loader.h"
-#include "io/resource_saver.h"
-#include "os/keyboard.h"
-#include "os/os.h"
#include "scene/resources/shader_graph.h"
#include "servers/visual/shader_types.h"
-#include "spatial_editor_plugin.h"
-/*** SETTINGS EDITOR ****/
-
-/*** SCRIPT EDITOR ****/
+/*** SHADER SCRIPT EDITOR ****/
Ref<Shader> ShaderTextEditor::get_edited_shader() const {
diff --git a/editor/plugins/shader_graph_editor_plugin.cpp b/editor/plugins/shader_graph_editor_plugin.cpp
index 7ad32464af..3f8f2488dc 100644
--- a/editor/plugins/shader_graph_editor_plugin.cpp
+++ b/editor/plugins/shader_graph_editor_plugin.cpp
@@ -27,9 +27,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "shader_graph_editor_plugin.h"
+// FIXME: Godot 3.0 broke compatibility with ShaderGraphEditorPlugin,
+// it needs to be ported to the new shader language.
#if 0
+#include "shader_graph_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "os/keyboard.h"
diff --git a/editor/plugins/shader_graph_editor_plugin.h b/editor/plugins/shader_graph_editor_plugin.h
index e7cab50d8d..159c752ee6 100644
--- a/editor/plugins/shader_graph_editor_plugin.h
+++ b/editor/plugins/shader_graph_editor_plugin.h
@@ -30,6 +30,10 @@
#ifndef SHADER_GRAPH_EDITOR_PLUGIN_H
#define SHADER_GRAPH_EDITOR_PLUGIN_H
+// FIXME: Godot 3.0 broke compatibility with ShaderGraphEditorPlugin,
+// it needs to be ported to the new shader language.
+#if 0
+
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "editor/property_editor.h"
@@ -39,11 +43,11 @@
#include "scene/gui/tree.h"
#include "scene/resources/shader.h"
#include "scene/resources/shader_graph.h"
+
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-#if 0
class GraphColorRampEdit : public Control {
GDCLASS(GraphColorRampEdit,Control);
@@ -238,5 +242,6 @@ public:
~ShaderGraphEditorPlugin();
};
+
#endif
-#endif
+#endif // SHADER_GRAPH_EDITOR_PLUGIN_H
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index b269f29036..607052231a 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -63,17 +63,47 @@
#define MIN_FOV 0.01
#define MAX_FOV 179
-void SpatialEditorViewport::_update_camera() {
+void SpatialEditorViewport::_update_camera(float p_interp_delta) {
if (orthogonal) {
//camera->set_orthogonal(size.width*cursor.distance,get_znear(),get_zfar());
camera->set_orthogonal(2 * cursor.distance, 0.1, 8192);
} else
camera->set_perspective(get_fov(), get_znear(), get_zfar());
- Transform camera_transform = to_camera_transform(cursor);
+ Transform new_transform = to_camera_transform(cursor);
+ Transform old_transform = camera->get_global_transform();
+ Transform transform;
- if (camera->get_global_transform() != camera_transform) {
- camera->set_global_transform(camera_transform);
+ bool disable_interp = (Input::get_singleton()->get_mouse_button_mask() & (2 | 4)) || Input::get_singleton()->is_key_pressed(KEY_SHIFT) || Input::get_singleton()->is_key_pressed(KEY_ALT) || Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+
+ if (p_interp_delta && !disable_interp) {
+ //interpolate
+ float interp_speed = 14; //maybe should be made configuration
+ transform = old_transform.interpolate_with(new_transform, MIN(1.0, p_interp_delta * interp_speed));
+ } else {
+ transform = new_transform;
+ }
+
+ float tolerance = 0.0001;
+ bool equal = true;
+ for (int i = 0; i < 3; i++) {
+ if (transform.basis[i].distance_to(old_transform.basis[i]) > tolerance) {
+ equal = false;
+ break;
+ }
+ }
+
+ if (equal && transform.origin.distance_to(old_transform.origin) > tolerance) {
+ equal = false;
+ }
+
+ if (equal) {
+ transform = new_transform;
+ }
+
+ if (!equal || p_interp_delta == 0) {
+ //print_line(transform);
+ camera->set_global_transform(transform);
update_transform_gizmo_view();
}
}
@@ -257,14 +287,12 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario());
Set<Ref<SpatialEditorGizmo> > found_gizmos;
+ Node *edited_scene = get_tree()->get_edited_scene_root();
ObjectID closest = 0;
Spatial *item = NULL;
float closest_dist = 1e20;
int selected_handle = -1;
- Vector<Spatial *> subscenes = Vector<Spatial *>();
- Vector<Vector3> subscenes_positions = Vector<Vector3>();
-
for (int i = 0; i < instances.size(); i++) {
Spatial *spat = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i]));
@@ -275,19 +303,6 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
Ref<SpatialEditorGizmo> seg = spat->get_gizmo();
if ((!seg.is_valid()) || found_gizmos.has(seg)) {
-
- Node *subscene_candidate = spat;
- Vector3 source_click_spatial_pos = spat->get_global_transform().origin;
-
- while ((subscene_candidate->get_owner() != NULL) && (subscene_candidate->get_owner() != editor->get_edited_scene()))
- subscene_candidate = subscene_candidate->get_owner();
-
- spat = Object::cast_to<Spatial>(subscene_candidate);
- if (spat && (spat->get_filename() != "") && (subscene_candidate->get_owner() != NULL)) {
- subscenes.push_back(spat);
- subscenes_positions.push_back(source_click_spatial_pos);
- }
-
continue;
}
@@ -307,32 +322,26 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
continue;
if (dist < closest_dist) {
- closest = instances[i];
- closest_dist = dist;
- selected_handle = handle;
- item = spat;
+ //make sure that whathever is selected is editable
+ while (spat && spat != edited_scene && spat->get_owner() != edited_scene && !edited_scene->is_editable_instance(spat->get_owner())) {
+
+ spat = Object::cast_to<Spatial>(spat->get_owner());
+ }
+
+ if (spat) {
+ item = spat;
+ closest = spat->get_instance_id();
+ closest_dist = dist;
+ selected_handle = handle;
+ } else {
+ ERR_PRINT("Bug?");
+ }
}
// if (editor_selection->is_selected(spat))
// r_includes_current=true;
}
- for (int idx_subscene = 0; idx_subscene < subscenes.size(); idx_subscene++) {
-
- Spatial *subscene = subscenes.get(idx_subscene);
- float dist = ray.cross(subscenes_positions.get(idx_subscene) - pos).length();
-
- if ((dist < 0) || (dist > 1.2))
- continue;
-
- if (dist < closest_dist) {
- closest = subscene->get_instance_id();
- closest_dist = dist;
- item = subscene;
- selected_handle = -1;
- }
- }
-
if (!item)
return 0;
@@ -1678,7 +1687,7 @@ void SpatialEditorViewport::_notification(int p_what) {
set_process(visible);
if (visible)
- _update_camera();
+ _update_camera(0);
call_deferred("update_transform_gizmo_view");
}
@@ -1710,7 +1719,7 @@ void SpatialEditorViewport::_notification(int p_what) {
_update_freelook(delta);
- _update_camera();
+ _update_camera(get_process_delta_time());
Map<Node *, Object *> &selection = editor_selection->get_selection();
@@ -3677,7 +3686,7 @@ void SpatialEditor::_request_gizmo(Object *p_obj) {
Spatial *sp = Object::cast_to<Spatial>(p_obj);
if (!sp)
return;
- if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || sp->get_owner() == editor->get_edited_scene() || editor->get_edited_scene()->is_editable_instance(sp->get_owner()))) {
+ if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || (sp->get_owner() && editor->get_edited_scene()->is_a_parent_of(sp)))) {
Ref<SpatialEditorGizmo> seg;
@@ -3691,7 +3700,6 @@ void SpatialEditor::_request_gizmo(Object *p_obj) {
if (!seg.is_valid()) {
seg = gizmos->get_gizmo(sp);
}
-
if (seg.is_valid()) {
sp->set_gizmo(seg);
}
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 2fd72739df..7797a657c0 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -49,6 +49,7 @@ class SpatialEditorGizmo : public SpatialGizmo {
GDCLASS(SpatialEditorGizmo, SpatialGizmo);
bool selected;
+ bool instanced;
public:
void set_selected(bool p_selected) { selected = p_selected; }
@@ -240,7 +241,7 @@ private:
void set_message(String p_message, float p_time = 5);
//
- void _update_camera();
+ void _update_camera(float p_interp_delta);
Transform to_camera_transform(const Cursor &p_cursor) const;
void _draw();
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 0d57fe05b9..9cb110a2ca 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -805,7 +805,8 @@ void ProjectManager::_load_recent_projects() {
Error err = img->load(appicon.replace_first("res://", path + "/"));
if (err == OK) {
- img->resize(64, 64);
+ Ref<Texture> default_icon = get_icon("DefaultProjectIcon", "EditorIcons");
+ img->resize(default_icon->get_width(), default_icon->get_height());
Ref<ImageTexture> it = memnew(ImageTexture);
it->create_from_image(img);
icon = it;
diff --git a/editor/project_manager.h b/editor/project_manager.h
index 181d3cc5d9..11fd3b2e01 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -30,7 +30,7 @@
#ifndef PROJECT_MANAGER_H
#define PROJECT_MANAGER_H
-#include "editor/asset_library_editor_plugin.h"
+#include "editor/plugins/asset_library_editor_plugin.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/scroll_container.h"
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 5a30522d7c..3352ea22de 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -29,13 +29,13 @@
/*************************************************************************/
#include "project_settings_editor.h"
-#include "editor_node.h"
-#include "global_constants.h"
-#include "os/keyboard.h"
-#include "project_settings.h"
+#include "core/global_constants.h"
+#include "core/os/keyboard.h"
+#include "core/project_settings.h"
+#include "core/translation.h"
+#include "editor/editor_node.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/tab_container.h"
-#include "translation.h"
ProjectSettingsEditor *ProjectSettingsEditor::singleton = NULL;
@@ -184,8 +184,6 @@ void ProjectSettingsEditor::_device_input_add() {
int idx = edit_idx;
Variant old_val = ProjectSettings::get_singleton()->get(name);
Array arr = old_val;
- // ie.device = device_id->get_value();
- // ie.type = add_type;
switch (add_type) {
@@ -619,7 +617,6 @@ void ProjectSettingsEditor::_update_actions() {
continue;
TreeItem *item = input_editor->create_item(root);
- //item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
item->set_text(0, name);
item->add_button(0, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event"));
if (!ProjectSettings::get_singleton()->get_input_presets().find(pi.name)) {
@@ -627,7 +624,6 @@ void ProjectSettingsEditor::_update_actions() {
item->set_editable(0, true);
}
item->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
- //item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED);
Array actions = ProjectSettings::get_singleton()->get(pi.name);
@@ -748,19 +744,7 @@ void ProjectSettingsEditor::_item_add() {
}
String catname = category->get_text().strip_edges();
- /*if (!catname.is_valid_identifier()) {
- message->set_text("Invalid Category.\nValid characters: a-z,A-Z,0-9 or _");
- message->popup_centered(Size2(300,100));
- return;
- }*/
-
String propname = property->get_text().strip_edges();
- /*if (!propname.is_valid_identifier()) {
- message->set_text("Invalid Property.\nValid characters: a-z,A-Z,0-9 or _");
- message->popup_centered(Size2(300,100));
- return;
- }*/
-
String name = catname != "" ? catname + "/" + propname : propname;
undo_redo->create_action(TTR("Add Global Property"));
@@ -790,7 +774,7 @@ void ProjectSettingsEditor::_item_del() {
String path = globals_editor->get_property_editor()->get_selected_path();
if (path == String()) {
- EditorNode::get_singleton()->show_warning(TTR("Select an setting item first!"));
+ EditorNode::get_singleton()->show_warning(TTR("Select a setting item first!"));
return;
}
@@ -882,13 +866,6 @@ void ProjectSettingsEditor::_save() {
message->popup_centered(Size2(300, 100) * EDSCALE);
}
-void ProjectSettingsEditor::_settings_prop_edited(const String &p_name) {
-
- String full_item = globals_editor->get_full_item_path(p_name);
-
- _settings_changed();
-}
-
void ProjectSettingsEditor::_settings_changed() {
timer->start();
@@ -1357,7 +1334,6 @@ void ProjectSettingsEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_add_item"), &ProjectSettingsEditor::_add_item, DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("_device_input_add"), &ProjectSettingsEditor::_device_input_add);
ClassDB::bind_method(D_METHOD("_press_a_key_confirm"), &ProjectSettingsEditor::_press_a_key_confirm);
- ClassDB::bind_method(D_METHOD("_settings_prop_edited"), &ProjectSettingsEditor::_settings_prop_edited);
ClassDB::bind_method(D_METHOD("_copy_to_platform"), &ProjectSettingsEditor::_copy_to_platform);
ClassDB::bind_method(D_METHOD("_update_translations"), &ProjectSettingsEditor::_update_translations);
ClassDB::bind_method(D_METHOD("_translation_delete"), &ProjectSettingsEditor::_translation_delete);
@@ -1391,12 +1367,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
tab_container = memnew(TabContainer);
tab_container->set_tab_align(TabContainer::ALIGN_LEFT);
add_child(tab_container);
- //set_child_rect(tab_container);
-
- //tab_container->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 15 );
- //tab_container->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 15 );
- //tab_container->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 15 );
- //tab_container->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );
VBoxContainer *props_base = memnew(VBoxContainer);
props_base->set_alignment(BoxContainer::ALIGN_BEGIN);
@@ -1478,21 +1448,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
globals_editor->register_search_box(search_box);
globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected", this, "_item_selected");
globals_editor->get_property_editor()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED);
- globals_editor->get_property_editor()->connect("property_edited", this, "_settings_prop_edited");
-
- /*
- Button *save = memnew( Button );
- props_base->add_child(save);
-
- save->set_anchor(MARGIN_LEFT,ANCHOR_END);
- save->set_anchor(MARGIN_RIGHT,ANCHOR_END);
- save->set_anchor(MARGIN_TOP,ANCHOR_END);
- save->set_anchor(MARGIN_BOTTOM,ANCHOR_END);
- save->set_begin( Point2(80,28) );
- save->set_end( Point2(10,20) );
- save->set_text("Save");
- save->connect("pressed",this,"_save");
-*/
+ globals_editor->get_property_editor()->connect("property_edited", this, "_settings_changed");
Button *del = memnew(Button);
hbc->add_child(del);
@@ -1506,16 +1462,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
popup_copy_to_feature->set_disabled(true);
add_prop_bar->add_child(popup_copy_to_feature);
- /*List<StringName> ep;
- EditorImportExport::get_singleton()->get_export_platforms(&ep);
- ep.sort_custom<StringName::AlphCompare>();
-
- for(List<StringName>::Element *E=ep.front();E;E=E->next()) {
-
- popup_copy_to_feature->get_popup()->add_item( E->get() );
-
- }*/
-
popup_copy_to_feature->get_popup()->connect("id_pressed", this, "_copy_to_platform");
popup_copy_to_feature->get_popup()->connect("about_to_show", this, "_copy_to_platform_about_to_show");
@@ -1524,7 +1470,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
message = memnew(ConfirmationDialog);
add_child(message);
- //message->get_cancel()->hide();
message->set_hide_on_ok(true);
Control *input_base = memnew(Control);
@@ -1591,7 +1536,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
hbc = memnew(HBoxContainer);
device_input->add_child(hbc);
- //device_input->set_child_rect(hbc);
VBoxContainer *vbc_left = memnew(VBoxContainer);
hbc->add_child(vbc_left);
@@ -1616,18 +1560,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
device_index = memnew(OptionButton);
vbc_right->add_child(device_index);
- /*
- save = memnew( Button );
- input_base->add_child(save);
- save->set_anchor(MARGIN_LEFT,ANCHOR_END);
- save->set_anchor(MARGIN_RIGHT,ANCHOR_END);
- save->set_anchor(MARGIN_TOP,ANCHOR_END);
- save->set_anchor(MARGIN_BOTTOM,ANCHOR_END);
- save->set_begin( Point2(80,28) );
- save->set_end( Point2(10,20) );
- save->set_text("Save");
- save->connect("pressed",this,"_save");
-*/
setting = false;
//translations
@@ -1739,14 +1671,4 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
add_child(timer);
updating_translations = false;
-
- /*
- Control * es = memnew( Control );
- es->set_name("Export");
- tab_container->add_child(es);
- export_settings = memnew( ProjectExportSettings );
- es->add_child(export_settings);
- export_settings->set_area_as_parent_rect();
- export_settings->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );
-*/
}
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index 4390a23d60..6deb9e1d46 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -30,17 +30,16 @@
#ifndef PROJECT_SETTINGS_H
#define PROJECT_SETTINGS_H
-#include "editor_autoload_settings.h"
-#include "editor_data.h"
-#include "editor_plugin_settings.h"
-#include "property_editor.h"
+#include "core/undo_redo.h"
+#include "editor/editor_autoload_settings.h"
+#include "editor/editor_data.h"
+#include "editor/editor_plugin_settings.h"
+#include "editor/property_editor.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/tab_container.h"
-#include "undo_redo.h"
-
-//#include "project_export_settings.h"
class ProjectSettingsEditor : public AcceptDialog {
+
GDCLASS(ProjectSettingsEditor, AcceptDialog);
enum InputType {
@@ -122,10 +121,8 @@ class ProjectSettingsEditor : public AcceptDialog {
void _press_a_key_confirm();
void _show_last_added(const Ref<InputEvent> &p_event, const String &p_name);
- void _settings_prop_edited(const String &p_name);
void _settings_changed();
- //ProjectExportSettings *export_settings;
void _copy_to_platform(int p_which);
void _translation_file_open();
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index f175e4c8e4..a6a29bb66c 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -29,24 +29,24 @@
/*************************************************************************/
#include "property_editor.h"
-#include "array_property_edit.h"
-#include "class_db.h"
-#include "create_dialog.h"
-#include "editor_export.h"
-#include "editor_file_system.h"
-#include "editor_help.h"
-#include "editor_node.h"
-#include "editor_settings.h"
-#include "io/image_loader.h"
-#include "io/marshalls.h"
-#include "io/resource_loader.h"
-#include "multi_node_edit.h"
-#include "os/input.h"
-#include "os/keyboard.h"
-#include "pair.h"
-#include "print_string.h"
-#include "project_settings.h"
-#include "property_selector.h"
+#include "core/class_db.h"
+#include "core/io/image_loader.h"
+#include "core/io/marshalls.h"
+#include "core/io/resource_loader.h"
+#include "core/os/input.h"
+#include "core/os/keyboard.h"
+#include "core/pair.h"
+#include "core/print_string.h"
+#include "core/project_settings.h"
+#include "editor/array_property_edit.h"
+#include "editor/create_dialog.h"
+#include "editor/editor_export.h"
+#include "editor/editor_file_system.h"
+#include "editor/editor_help.h"
+#include "editor/editor_node.h"
+#include "editor/editor_settings.h"
+#include "editor/multi_node_edit.h"
+#include "editor/property_selector.h"
#include "scene/gui/label.h"
#include "scene/main/viewport.h"
#include "scene/resources/font.h"
@@ -59,11 +59,6 @@ void CustomPropertyEditor::_notification(int p_what) {
RID ci = get_canvas_item();
get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size()));
- /*
- if (v.get_type()==Variant::COLOR) {
-
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2( 10,10,60, get_size().height-20 ), v );
- }*/
}
if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) {
hide();
@@ -202,17 +197,6 @@ void CustomPropertyEditor::_menu_option(int p_which) {
emit_signal("variant_changed");
} break;
- case OBJ_MENU_REIMPORT: {
-
- RES r = v;
- /* if (r.is_valid() && r->get_import_metadata().is_valid()) {
- Ref<ResourceImportMetadata> rimd = r->get_import_metadata();
- Ref<EditorImportPlugin> eip = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor());
- if (eip.is_valid()) {
- eip->import_dialog(r->get_path());
- }
- }*/
- } break;
case OBJ_MENU_NEW_SCRIPT: {
if (Object::cast_to<Node>(owner))
@@ -515,8 +499,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
text_edit->show();
text_edit->set_text(v);
- //action_buttons[0];
-
int button_margin = get_constant("button_margin", "Dialogs");
int margin = get_constant("margin", "Dialogs");
@@ -531,7 +513,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_TYPE_STRING) {
- /* FIXME: This is repeated twice, with slightly different behavior! Which one? Check line 644 */
if (!create_dialog) {
create_dialog = memnew(CreateDialog);
create_dialog->connect("create", this, "_create_dialog_callback");
@@ -648,14 +629,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
updating = false;
return false;
- } else if (hint == PROPERTY_HINT_TYPE_STRING) {
- if (!create_dialog) {
- /* FIXME: ... and here. See line 529 */
- create_dialog = memnew(CreateDialog);
- create_dialog->connect("create", this, "_create_dialog_callback");
- add_child(create_dialog);
- }
-
} else {
List<String> names;
names.push_back("string:");
@@ -822,39 +795,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
color_picker->set_edit_alpha(hint != PROPERTY_HINT_COLOR_NO_ALPHA);
color_picker->set_pick_color(v);
color_picker->set_focus_on_line_edit();
- /*
- int ofs=80;
- int m=10;
- int h=20;
- Color c=v;
- float values[4]={c.r,c.g,c.b,c.a};
- for (int i=0;i<4;i++) {
- int y=m+i*h;
-
- value_editor[i]->show();
- value_label[i]->show();
- value_label[i]->set_position(Point2(ofs,y));
- scroll[i]->set_min(0);
- scroll[i]->set_max(1.0);
- scroll[i]->set_page(0);
- scroll[i]->set_position(Point2(ofs+15,y+Math::floor((h-scroll[i]->get_minimum_size().height)/2.0)));
- scroll[i]->set_val(values[i]);
- scroll[i]->set_size(Size2(120,1));
- scroll[i]->show();
- value_editor[i]->set_position(Point2(ofs+140,y));
- value_editor[i]->set_size(Size2(40,h));
- value_editor[i]->set_text( String::num(values[i],2 ));
-
- }
-
- value_label[0]->set_text("R");
- value_label[1]->set_text("G");
- value_label[2]->set_text("B");
- value_label[3]->set_text("A");
-
- Size2 new_size = value_editor[3]->get_position() + value_editor[3]->get_size() + Point2(10,10);
- set_size( new_size );
- */
} break;
@@ -930,18 +870,9 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), "Make Unique", OBJ_MENU_MAKE_UNIQUE);
RES r = v;
if (r.is_valid() && r->get_path().is_resource_file()) {
- /*if (r->get_import_metadata().is_valid()) {
- menu->add_separator();
- menu->add_icon_item(get_icon("ReloadSmall","EditorIcons"),"Re-Import",OBJ_MENU_REIMPORT);
- }*/
menu->add_separator();
menu->add_item(TTR("Show in File System"), OBJ_MENU_SHOW_IN_FILE_SYSTEM);
}
- /*if (r.is_valid() && r->get_path().is_resource_file()) {
- menu->set_item_tooltip(1,r->get_path());
- } else if (r.is_valid()) {
- menu->set_item_tooltip(1,r->get_name()+" ("+r->get_type()+")");
- }*/
} else {
}
@@ -1007,14 +938,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
return true;
}
-////void CustomPropertyEditor::_save_properties_values(List<String> p_names) {
-////
-//// field_names=p_names;
-//// for (int i=0;i<p_names.size();i++) {
-//// field_values.push_back(v.get(p_names[i]));
-//// }
-////}
-
void CustomPropertyEditor::_file_selected(String p_file) {
switch (type) {
@@ -1093,11 +1016,6 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
ERR_FAIL_INDEX(p_idx, inheritors_array.size());
- //List<String> inheritors;
- //ClassDB::get_inheriters_from(hint_text,&inheritors);
- //inheritors.push_front(hint_text);
-
- //ERR_FAIL_INDEX( p_idx, inheritors.size() );
String intype = inheritors_array[p_idx];
Object *obj = ClassDB::instance(intype);
@@ -1382,33 +1300,6 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
}
}
-void CustomPropertyEditor::_scroll_modified(double p_value) {
-
- if (updating)
- return;
- /*
- switch(type) {
-
- case Variant::COLOR: {
-
- for (int i=0;i<4;i++) {
-
- value_editor[i]->set_text( String::num(scroll[i]->get_val(),2) );
- }
- Color c;
- c.r=scroll[0]->get_val();
- c.g=scroll[1]->get_val();
- c.b=scroll[2]->get_val();
- c.a=scroll[3]->get_val();
- v=c;
- update();
- emit_signal("variant_changed");
- } break;
- default: {}
- }
- */
-}
-
void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) {
Ref<InputEventMouseMotion> mm = p_ev;
@@ -1433,7 +1324,6 @@ void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) {
val = Math::log(val) / Math::log((float)2.0);
//logspace
val += rel * 0.05;
- //
val = Math::pow(2.0f, val);
if (sg)
@@ -1441,11 +1331,8 @@ void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) {
v = val;
easing_draw->update();
- //emit_signal("variant_changed");
emit_signal("variant_changed");
}
- // if (p_ev.type == Ref<InputEvent>::MOUSE_BUTTON && p_ev->get_button_index() == BUTTON_LEFT) {
- // }
}
void CustomPropertyEditor::_draw_easing() {
@@ -1456,7 +1343,6 @@ void CustomPropertyEditor::_draw_easing() {
Rect2 r(Point2(), s);
r = r.grow(3);
get_stylebox("normal", "LineEdit")->draw(ci, r);
- //VisualServer::get_singleton()->canvas_item_add
int points = 48;
@@ -1508,6 +1394,7 @@ void CustomPropertyEditor::_modified(String p_string) {
if (updating)
return;
+
updating = true;
switch (type) {
case Variant::INT: {
@@ -1704,20 +1591,7 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::COLOR: {
- /*
- for (int i=0;i<4;i++) {
- scroll[i]->set_val( value_editor[i]->get_text().to_double() );
- }
- Color c;
- c.r=value_editor[0]->get_text().to_double();
- c.g=value_editor[1]->get_text().to_double();
- c.b=value_editor[2]->get_text().to_double();
- c.a=value_editor[3]->get_text().to_double();
- v=c;
- update();
- emit_signal("variant_changed");
- */
} break;
case Variant::NODE_PATH: {
@@ -1870,7 +1744,6 @@ void CustomPropertyEditor::_bind_methods() {
ClassDB::bind_method("_focus_exit", &CustomPropertyEditor::_focus_exit);
ClassDB::bind_method("_modified", &CustomPropertyEditor::_modified);
ClassDB::bind_method("_range_modified", &CustomPropertyEditor::_range_modified);
- ClassDB::bind_method("_scroll_modified", &CustomPropertyEditor::_scroll_modified);
ClassDB::bind_method("_action_pressed", &CustomPropertyEditor::_action_pressed);
ClassDB::bind_method("_file_selected", &CustomPropertyEditor::_file_selected);
ClassDB::bind_method("_type_create_selected", &CustomPropertyEditor::_type_create_selected);
@@ -1914,7 +1787,6 @@ CustomPropertyEditor::CustomPropertyEditor() {
scroll[i]->set_max(1.0);
scroll[i]->set_step(0.01);
add_child(scroll[i]);
- scroll[i]->connect("value_changed", this, "_scroll_modified");
}
checks20gc = memnew(GridContainer);
@@ -1968,7 +1840,6 @@ CustomPropertyEditor::CustomPropertyEditor() {
error = memnew(ConfirmationDialog);
error->set_title(TTR("Error!"));
add_child(error);
- //error->get_cancel()->hide();
scene_tree = memnew(SceneTreeDialog);
add_child(scene_tree);
@@ -1984,7 +1855,6 @@ CustomPropertyEditor::CustomPropertyEditor() {
easing_draw->hide();
easing_draw->connect("draw", this, "_draw_easing");
easing_draw->connect("gui_input", this, "_drag_easing");
- //easing_draw->emit_signal(SceneStringNames::get_singleton()->input_event,InputEvent());
easing_draw->set_default_cursor_shape(Control::CURSOR_MOVE);
type_button = memnew(MenuButton);
@@ -2056,8 +1926,6 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_p
bool found = false;
- //print_line("for prop - "+String(p_prop));
-
while (node) {
Ref<SceneState> ss;
@@ -2068,13 +1936,11 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_p
} else {
ss = node->get_scene_instance_state();
}
- //print_line("at - "+String(edited_scene->get_path_to(node)));
if (ss.is_valid()) {
NodePath np = node->get_path_to(orig);
int node_idx = ss->find_node_by_path(np);
- //print_line("\t valid, nodeidx "+itos(node_idx));
if (node_idx >= 0) {
bool lfound = false;
Variant lvar;
@@ -2083,7 +1949,6 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_p
found = true;
value = lvar;
- //print_line("\t found value "+String(value));
}
}
}
@@ -2107,8 +1972,6 @@ bool PropertyEditor::_is_property_different(const Variant &p_current, const Vari
Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
bool found_state = false;
- //print_line("for prop - "+String(p_prop));
-
while (node) {
Ref<SceneState> ss;
@@ -2247,8 +2110,6 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p
break;
}
- //p_item->set_cell_mode( 1, TreeItem::CELL_MODE_RANGE );
-
if (p_type == Variant::REAL) {
p_item->set_range(1, obj->get(p_name));
@@ -2310,7 +2171,6 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p
case Variant::COLOR: {
tree->update();
- //p_item->set_text(1,obj->get(p_name));
} break;
case Variant::NODE_PATH: {
@@ -2424,17 +2284,7 @@ void PropertyEditor::_check_reload_status(const String &p_name, TreeItem *item)
if (_get_instanced_node_original_property(p_name, vorig) || usage) {
Variant v = obj->get(p_name);
- bool changed = _is_property_different(v, vorig, usage);
-
- //if ((found!=-1 && !is_disabled)!=changed) {
-
- if (changed) {
-
- has_reload = true;
- } else {
- }
-
- //}
+ bool has_reload = _is_property_different(v, vorig, usage);
}
}
@@ -2453,7 +2303,6 @@ void PropertyEditor::_check_reload_status(const String &p_name, TreeItem *item)
}
}
- //print_line("found: "+itos(found)+" has reload: "+itos(has_reload)+" is_disabled "+itos(is_disabled));
if (found != -1 && !has_reload) {
if (!is_disabled) {
@@ -2481,14 +2330,11 @@ bool PropertyEditor::_is_drop_valid(const Dictionary &p_drag_data, const Diction
String allowed_type = d["hint_text"];
- print_line("allowed type " + allowed_type);
-
Dictionary drag_data = p_drag_data;
if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
Ref<Resource> res = drag_data["resource"];
for (int i = 0; i < allowed_type.get_slice_count(","); i++) {
String at = allowed_type.get_slice(",", i).strip_edges();
- print_line("RES vs " + at);
if (res.is_valid() && ClassDB::is_parent_class(res->get_class(), at)) {
return true;
}
@@ -2499,18 +2345,14 @@ bool PropertyEditor::_is_drop_valid(const Dictionary &p_drag_data, const Diction
Vector<String> files = drag_data["files"];
- print_line("fileS: " + String(Variant(files)));
if (files.size() == 1) {
String file = files[0];
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
- print_line("file: " + file);
- print_line("type: " + ftype);
if (ftype != "") {
for (int i = 0; i < allowed_type.get_slice_count(","); i++) {
String at = allowed_type.get_slice(",", i).strip_edges();
- print_line("FILE vs " + at);
if (ClassDB::is_parent_class(ftype, at)) {
return true;
}
@@ -2733,7 +2575,6 @@ TreeItem *PropertyEditor::get_parent_node(String p_path, HashMap<String, TreeIte
item = item_paths.get(p_path);
} else {
- //printf("path %s parent path %s - item name %s\n",p_path.ascii().get_data(),p_path.left( p_path.find_last("/") ).ascii().get_data(),p_path.right( p_path.find_last("/") ).ascii().get_data() );
TreeItem *parent = get_parent_node(p_path.left(p_path.find_last("/")), item_paths, root, NULL);
item = tree->create_item(parent);
@@ -2783,64 +2624,6 @@ void PropertyEditor::_refresh_item(TreeItem *p_item) {
if (name != String()) {
_check_reload_status(name, p_item);
-#if 0
- bool has_reload=false;
-
- int found=-1;
- for(int i=0;i<p_item->get_button_count(1);i++) {
-
- if (p_item->get_button_id(1,i)==3) {
- found=i;
- break;
- }
- }
-
- if (_might_be_in_instance()) {
-
- Variant vorig;
- Dictionary d=p_item->get_metadata(0);
- int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0;
-
-
- if (_get_instanced_node_original_property(name,vorig) || usage) {
- Variant v = obj->get(name);
-
-
- bool changed = _is_property_different(v,vorig,usage);
-
- if ((found!=-1)!=changed) {
-
- if (changed) {
-
- has_reload=true;
-
- } else {
-
- //p_item->erase_button(1,found);
- }
-
- }
-
- }
-
- }
-
- if (!has_reload && !obj->get_script().is_null()) {
- Ref<Script> scr = obj->get_script();
- Variant orig_value;
- if (scr->get_property_default_value(name,orig_value)) {
- if (orig_value!=obj->get(name)) {
- has_reload=true;
- }
- }
- }
-
- if (!has_reload && found!=-1) {
- p_item->erase_button(1,found);
- } else if (has_reload && found==-1) {
- p_item->add_button(1,get_icon("ReloadSmall","EditorIcons"),3);
- }
-#endif
Dictionary d = p_item->get_metadata(0);
set_item_text(p_item, d["type"], d["name"], d["hint"], d["hint_text"]);
}
@@ -2874,45 +2657,6 @@ void PropertyEditor::update_tree() {
TreeItem *root = tree->create_item(NULL);
tree->set_hide_root(true);
- /*
- TreeItem *title = tree->create_item(root);
-
- title->set_custom_bg_color(0,get_color("prop_section","Editor"));
- title->set_text(0,"Property"); // todo, fetch name if ID exists in database
- title->set_editable(0,false);
- title->set_selectable(0,false);
- title->set_custom_bg_color(1,get_color("prop_section","Editor"));
- title->set_text(1,"Value"); // todo, fetch name if ID exists in database
- title->set_editable(1,false);
- title->set_selectable(1,false);
-*/
-
- /*
- if (Object::cast_to<Node>() || Object::cast_to<Resource>(obj)) {
- TreeItem *type = tree->create_item(root);
-
- type->set_text(0,"Type"); // todo, fetch name if ID exists in database
- type->set_text(1,obj->get_type()); // todo, fetch name if ID exists in database
- if (has_icon(obj->get_type(),"EditorIcons"))
- type->set_icon(1,get_icon(obj->get_type(),"EditorIcons") );
- else
- type->set_icon(1,get_icon("Object","EditorIcons") );
-
- type->set_selectable(0,false);
- type->set_selectable(1,false);
-
-
- TreeItem *name = tree->create_item(root);
-
- name->set_text(0,"Name"); // todo, fetch name if ID exists in database
- if (obj->is_type("Resource"))
- name->set_text(1,Object::cast_to<Resource>(obj)->get_name());
- else if (obj->is_type("Node"))
- name->set_text(1,Object::cast_to<Node>(obj)->get_name());
- name->set_selectable(0,false);
- name->set_selectable(1,false);
- }
-*/
List<PropertyInfo> plist;
obj->get_property_list(&plist, true);
@@ -3003,9 +2747,8 @@ void PropertyEditor::update_tree() {
sep->set_tooltip(0, TTR("Class:") + " " + p.name + ":\n\n" + class_descr_cache[type]);
}
- //sep->set_custom_color(0,Color(1,1,1));
-
continue;
+
} else if (!(p.usage & PROPERTY_USAGE_EDITOR))
continue;
@@ -3057,12 +2800,7 @@ void PropertyEditor::update_tree() {
continue;
}
- //printf("property %s\n",basename.ascii().get_data());
TreeItem *parent = get_parent_node(path, item_path, root, current_category);
- /*
- if (parent->get_parent()==root)
- parent=root;
- */
int level = 0;
if (parent != root) {
level++;
@@ -3082,7 +2820,6 @@ void PropertyEditor::update_tree() {
if (level > 0) {
item->set_custom_bg_color(0, col);
- //item->set_custom_bg_color(1,col);
}
item->set_editable(0, false);
item->set_selectable(0, property_selectable);
@@ -3144,7 +2881,6 @@ void PropertyEditor::update_tree() {
item->set_tooltip(0, TTR("Property:") + " " + p.name + "\n\n" + descr);
}
}
- //EditorHelp::get_doc_data();
Dictionary d;
d["name"] = p.name;
@@ -3164,7 +2900,6 @@ void PropertyEditor::update_tree() {
item->select(1);
}
- //printf("property %s type %i\n",p.name.ascii().get_data(),p.type);
switch (p.type) {
case Variant::BOOL: {
@@ -3204,7 +2939,6 @@ void PropertyEditor::update_tree() {
item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
item->set_editable(1, !read_only);
- //item->set_icon( 0, get_icon("Curve","EditorIcons"));
Vector<String> values = p.hint_string.split(",");
String flags;
@@ -3251,7 +2985,6 @@ void PropertyEditor::update_tree() {
item->set_range_config(1, min, max, step, p.hint == PROPERTY_HINT_EXP_RANGE);
} else if (p.hint == PROPERTY_HINT_ENUM) {
- //int c = p.hint_string.get_slice_count(",");
item->set_text(1, p.hint_string);
if (show_type_icons)
item->set_icon(0, get_icon("Enum", "EditorIcons"));
@@ -3260,7 +2993,6 @@ void PropertyEditor::update_tree() {
break;
} else if (p.hint == PROPERTY_HINT_OBJECT_ID) {
- //int c = p.hint_string.get_slice_count(",");
item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
String type = p.hint_string;
@@ -3591,7 +3323,6 @@ void PropertyEditor::update_tree() {
item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
item->set_editable(1, !read_only);
- //item->set_text(1,obj->get(p.name));
item->set_custom_draw(1, this, "_draw_transparency");
if (show_type_icons)
item->set_icon(0, get_icon("Color", "EditorIcons"));
@@ -3610,7 +3341,6 @@ void PropertyEditor::update_tree() {
item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
item->set_editable(1, !read_only);
- //item->add_button(1, get_icon("EditResource", "EditorIcons"));
String type;
if (p.hint == PROPERTY_HINT_RESOURCE_TYPE)
type = p.hint_string;
@@ -3675,15 +3405,12 @@ void PropertyEditor::update_tree() {
if (type != String()) {
if (type.find(",") != -1)
type = type.get_slice(",", 0);
- //printf("prop %s , type %s\n",p.name.ascii().get_data(),p.hint_string.ascii().get_data());
if (has_icon(type, "EditorIcons"))
item->set_icon(0, get_icon(type, "EditorIcons"));
else
item->set_icon(0, get_icon("Object", "EditorIcons"));
}
- //item->double_click_signal.connect( Method1<int>( Method2<int,String>( this, &Editoritem_obj_edited ), p.name ) );
-
} break;
default: {};
}
@@ -3710,7 +3437,6 @@ void PropertyEditor::update_tree() {
Variant v = obj->get(p.name);
if (_is_property_different(v, vorig, usage)) {
- //print_line("FOR "+String(p.name)+" RELOAD WITH: "+String(v)+"("+Variant::get_type_name(v.get_type())+")=="+String(vorig)+"("+Variant::get_type_name(vorig.get_type())+")");
item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3);
has_reload = true;
}
@@ -3942,9 +3668,8 @@ void PropertyEditor::_item_edited() {
case Variant::TRANSFORM: {
} break;
-
case Variant::COLOR: {
- //_edit_set(name,item->get_custom_bg_color(0));
+
} break;
case Variant::NODE_PATH: {
@@ -4030,7 +3755,6 @@ void PropertyEditor::_custom_editor_request(bool p_arrow) {
ERR_FAIL_COND(!item);
Dictionary d = item->get_metadata(0);
- //int type=d["type"];
String name = d["name"];
Variant::Type type = Variant::NIL;
if (d.has("type"))
@@ -4078,6 +3802,7 @@ void PropertyEditor::_set_range_def(Object *p_item, String prop, float p_frame)
}
void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
+
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
@@ -4095,7 +3820,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
return;
String prop = d["name"];
emit_signal("property_keyed", prop, obj->get(prop), true);
- //set_range(p_column, ti->get_range(p_column)+1.0 );
call_deferred("_set_range_def", ti, prop, ti->get_range(p_column) + 1.0);
} else if (p_button == 3) {
@@ -4156,7 +3880,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
Variant v = obj->get(n);
custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht);
- //Rect2 where=tree->get_custom_popup_rect();
if (h == PROPERTY_HINT_FILE || h == PROPERTY_HINT_DIR || h == PROPERTY_HINT_GLOBAL_DIR || h == PROPERTY_HINT_GLOBAL_FILE) {
Rect2 where = tree->get_item_rect(ti, 1);
@@ -4178,7 +3901,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
} else if (t == Variant::INT && h == PROPERTY_HINT_OBJECT_ID) {
emit_signal("object_id_selected", obj->get(n));
- print_line("OBJ ID SELECTED");
} else if (t == Variant::ARRAY || t == Variant::POOL_INT_ARRAY || t == Variant::POOL_REAL_ARRAY || t == Variant::POOL_STRING_ARRAY || t == Variant::POOL_VECTOR2_ARRAY || t == Variant::POOL_VECTOR3_ARRAY || t == Variant::POOL_COLOR_ARRAY || t == Variant::POOL_BYTE_ARRAY) {
@@ -4200,7 +3922,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
void PropertyEditor::_node_removed(Node *p_node) {
if (p_node == obj) {
-
edit(NULL);
}
}
@@ -4432,8 +4153,6 @@ PropertyEditor::PropertyEditor() {
tree->set_column_min_width(0, 30);
tree->set_column_expand(1, true);
tree->set_column_min_width(1, 18);
-
- //tree->set_hide_root(true);
add_child(tree);
tree->connect("item_edited", this, "_item_edited", varray(), CONNECT_DEFERRED);
@@ -4502,7 +4221,6 @@ class SectionedPropertyEditorFilter : public Object {
bool valid;
edited->set(name, p_value, &valid);
- //_change_notify(p_name.operator String().utf8().get_data());
return valid;
}
@@ -4819,8 +4537,7 @@ void PropertyValueEvaluator::edit(Object *p_obj) {
}
String PropertyValueEvaluator::_build_script(const String &p_text) {
- String script_text =
- "tool\nextends Object\nfunc eval(s):\n\tself = s\n\treturn " + p_text.strip_edges() + "\n";
+ String script_text = "tool\nextends Object\nfunc eval(s):\n\tself = s\n\treturn " + p_text.strip_edges() + "\n";
return script_text;
}
diff --git a/editor/property_editor.h b/editor/property_editor.h
index 3dd09268ec..2ba6058bdf 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -31,6 +31,7 @@
#define PROPERTY_EDITOR_H
#include "editor/editor_file_dialog.h"
+#include "editor/scene_tree_editor.h"
#include "scene/gui/button.h"
#include "scene/gui/check_box.h"
#include "scene/gui/check_button.h"
@@ -43,7 +44,6 @@
#include "scene/gui/text_edit.h"
#include "scene/gui/texture_rect.h"
#include "scene/gui/tree.h"
-#include "scene_tree_editor.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -66,9 +66,8 @@ class CustomPropertyEditor : public Popup {
OBJ_MENU_MAKE_UNIQUE = 3,
OBJ_MENU_COPY = 4,
OBJ_MENU_PASTE = 5,
- OBJ_MENU_REIMPORT = 6,
- OBJ_MENU_NEW_SCRIPT = 7,
- OBJ_MENU_SHOW_IN_FILE_SYSTEM = 8,
+ OBJ_MENU_NEW_SCRIPT = 6,
+ OBJ_MENU_SHOW_IN_FILE_SYSTEM = 7,
TYPE_BASE_ID = 100
};
@@ -120,7 +119,6 @@ class CustomPropertyEditor : public Popup {
void _text_edit_changed();
void _file_selected(String p_file);
- void _scroll_modified(double p_value);
void _modified(String p_string);
void _range_modified(double p_value);
void _focus_enter();
@@ -168,7 +166,6 @@ class PropertyEditor : public Control {
Tree *tree;
Label *top_label;
- //Object *object;
LineEdit *search_box;
PropertyValueEvaluator *evaluator;
diff --git a/editor/resources_dock.cpp b/editor/resources_dock.cpp
deleted file mode 100644
index dcff3bcd73..0000000000
--- a/editor/resources_dock.cpp
+++ /dev/null
@@ -1,378 +0,0 @@
-/*************************************************************************/
-/* resources_dock.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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 "resources_dock.h"
-
-#include "editor_file_system.h"
-#include "editor_node.h"
-#include "editor_settings.h"
-#include "io/resource_loader.h"
-#include "io/resource_saver.h"
-#include "project_settings.h"
-#include "project_settings_editor.h"
-
-void ResourcesDock::_tool_selected(int p_tool) {
-
- current_action = p_tool;
-
- switch (p_tool) {
-
- case TOOL_NEW: {
-
- create_dialog->popup_centered_ratio();
- } break;
- case TOOL_OPEN: {
- editor->open_resource();
-
- } break;
- case TOOL_SAVE: {
-
- TreeItem *ti = resources->get_selected();
- if (!ti)
- break;
- Ref<Resource> current_res = ti->get_metadata(0);
-
- if (current_res->get_path() != "" && current_res->get_path().find("::") == -1) {
- _file_action(current_res->get_path());
- break;
- };
-
- }; /* fallthrough */
- case TOOL_SAVE_AS: {
-
- TreeItem *ti = resources->get_selected();
- if (!ti)
- break;
-
- save_resource_as(ti->get_metadata(0));
-
- } break;
- case TOOL_MAKE_LOCAL: {
-
- TreeItem *ti = resources->get_selected();
- if (!ti)
- break;
- Ref<Resource> current_res = ti->get_metadata(0);
- current_res->set_path("");
- _update_name(ti);
- } break;
- case TOOL_COPY: {
-
- TreeItem *ti = resources->get_selected();
- if (!ti)
- break;
- Ref<Resource> current_res = ti->get_metadata(0);
- EditorSettings::get_singleton()->set_resource_clipboard(current_res);
-
- } break;
- case TOOL_PASTE: {
-
- add_resource(EditorSettings::get_singleton()->get_resource_clipboard());
- } break;
- }
-}
-
-void ResourcesDock::_notification(int p_what) {
-
- switch (p_what) {
-
- case NOTIFICATION_ENTER_TREE: {
-
- button_new->set_icon(get_icon("New", "EditorIcons"));
- button_open->set_icon(get_icon("Folder", "EditorIcons"));
- button_save->set_icon(get_icon("Save", "EditorIcons"));
- button_tools->set_icon(get_icon("Tools", "EditorIcons"));
-
- } break;
- }
-}
-
-void ResourcesDock::save_resource(const String &p_path, const Ref<Resource> &p_resource) {
-
- editor->get_editor_data().apply_changes_in_editors();
- int flg = 0;
- if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources"))
- flg |= ResourceSaver::FLAG_COMPRESS;
- /*
- if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative"))
- flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
- */
-
- String path = ProjectSettings::get_singleton()->localize_path(p_path);
- Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
-
- if (err != OK) {
- accept->set_text(TTR("Error saving resource!"));
- accept->popup_centered_minsize();
- return;
- }
- //EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
-
- ((Resource *)p_resource.ptr())->set_path(path);
- editor->emit_signal("resource_saved", p_resource);
-}
-
-void ResourcesDock::save_resource_as(const Ref<Resource> &p_resource) {
-
- current_action = TOOL_SAVE_AS;
-
- RES res(p_resource);
-
- List<String> extensions;
- ResourceSaver::get_recognized_extensions(res, &extensions);
- file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
-
- if (p_resource->get_path() != "" && p_resource->get_path().find("::") == -1) {
-
- file->set_current_path(p_resource->get_path());
- } else {
-
- String existing;
- if (extensions.size()) {
- existing = "new_" + res->get_class().to_lower() + "." + extensions.front()->get().to_lower();
- }
-
- file->set_current_file(existing);
- }
-
- file->clear_filters();
- for (int i = 0; i < extensions.size(); i++) {
-
- file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
- }
-
- file->popup_centered_ratio();
-}
-
-void ResourcesDock::_file_action(const String &p_path) {
-
- switch (current_action) {
-
- case TOOL_OPEN: {
-
- } break;
- case TOOL_SAVE:
- case TOOL_SAVE_AS: {
-
- TreeItem *ti = resources->get_selected();
- if (!ti)
- break;
- Ref<Resource> current_res = ti->get_metadata(0);
-
- RES res(current_res);
-
- save_resource(p_path, res);
-
- _update_name(ti);
-
- } break;
- }
-}
-
-void ResourcesDock::_update_name(TreeItem *item) {
-
- Ref<Resource> res = item->get_metadata(0);
-
- if (res->get_name() != "")
- item->set_text(0, res->get_name());
- else if (res->get_path() != "" && res->get_path().find("::") == -1)
- item->set_text(0, res->get_path().get_file());
- else
- item->set_text(0, res->get_class() + " (" + itos(res->get_instance_id()) + ")");
-}
-
-void ResourcesDock::remove_resource(const Ref<Resource> &p_resource) {
-
- TreeItem *root = resources->get_root();
- ERR_FAIL_COND(!root);
-
- TreeItem *existing = root->get_children();
-
- while (existing) {
-
- Ref<Resource> r = existing->get_metadata(0);
- if (r == p_resource) {
- //existing->move_to_top();
- memdelete(existing);
- return;
- }
- existing = existing->get_next();
- }
-}
-
-void ResourcesDock::add_resource(const Ref<Resource> &p_resource) {
-
- if (block_add)
- return;
- if (!p_resource.is_valid())
- return;
-
- TreeItem *root = resources->get_root();
- ERR_FAIL_COND(!root);
-
- TreeItem *existing = root->get_children();
-
- while (existing) {
-
- Ref<Resource> r = existing->get_metadata(0);
- if (r == p_resource) {
- //existing->move_to_top();
- existing->select(0);
- resources->ensure_cursor_is_visible();
- return; // existing
- }
- existing = existing->get_next();
- }
-
- TreeItem *res = resources->create_item(root);
- res->set_metadata(0, p_resource);
-
- if (has_icon(p_resource->get_class(), "EditorIcons")) {
- res->set_icon(0, get_icon(p_resource->get_class(), "EditorIcons"));
- }
-
- _update_name(res);
- res->add_button(0, get_icon("Del", "EditorIcons"));
- res->move_to_top();
- res->select(0);
- resources->ensure_cursor_is_visible();
-}
-
-void ResourcesDock::_resource_selected() {
-
- TreeItem *sel = resources->get_selected();
- ERR_FAIL_COND(!sel);
-
- Ref<Resource> r = sel->get_metadata(0);
- if (r.is_null())
- return;
- block_add = true;
- editor->push_item(r.ptr());
- block_add = false;
-}
-
-void ResourcesDock::_delete(Object *p_item, int p_column, int p_id) {
-
- TreeItem *ti = Object::cast_to<TreeItem>(p_item);
- ERR_FAIL_COND(!ti);
-
- call_deferred("remove_resource", ti->get_metadata(0));
-}
-
-void ResourcesDock::_create() {
-
- Object *c = create_dialog->instance_selected();
-
- ERR_FAIL_COND(!c);
- Resource *r = Object::cast_to<Resource>(c);
- ERR_FAIL_COND(!r);
-
- REF res(r);
-
- editor->push_item(c);
-}
-
-void ResourcesDock::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_tool_selected"), &ResourcesDock::_tool_selected);
- ClassDB::bind_method(D_METHOD("_create"), &ResourcesDock::_create);
- ClassDB::bind_method(D_METHOD("_resource_selected"), &ResourcesDock::_resource_selected);
- ClassDB::bind_method(D_METHOD("_delete"), &ResourcesDock::_delete);
- ClassDB::bind_method(D_METHOD("remove_resource"), &ResourcesDock::remove_resource);
- ClassDB::bind_method(D_METHOD("_file_action"), &ResourcesDock::_file_action);
-}
-
-void ResourcesDock::cleanup() {
-
- resources->clear();
- resources->create_item(); //root
-}
-
-ResourcesDock::ResourcesDock(EditorNode *p_editor) {
-
- editor = p_editor;
-
- VBoxContainer *vbc = this;
-
- HBoxContainer *hbc = memnew(HBoxContainer);
- vbc->add_child(hbc);
-
- Button *b;
- b = memnew(ToolButton);
- b->set_tooltip(TTR("Create New Resource"));
- b->connect("pressed", this, "_tool_selected", make_binds(TOOL_NEW));
- hbc->add_child(b);
- button_new = b;
-
- b = memnew(ToolButton);
- b->set_tooltip(TTR("Open Resource"));
- b->connect("pressed", this, "_tool_selected", make_binds(TOOL_OPEN));
- hbc->add_child(b);
- button_open = b;
-
- MenuButton *mb = memnew(MenuButton);
- mb->set_tooltip(TTR("Save Resource"));
- mb->get_popup()->add_item(TTR("Save Resource"), TOOL_SAVE);
- mb->get_popup()->add_item(TTR("Save Resource As.."), TOOL_SAVE_AS);
- mb->get_popup()->connect("id_pressed", this, "_tool_selected");
- hbc->add_child(mb);
- button_save = mb;
-
- hbc->add_spacer();
-
- mb = memnew(MenuButton);
- mb->set_tooltip(TTR("Resource Tools"));
- mb->get_popup()->add_item(TTR("Make Local"), TOOL_MAKE_LOCAL);
- mb->get_popup()->add_item(TTR("Copy"), TOOL_COPY);
- mb->get_popup()->add_item(TTR("Paste"), TOOL_PASTE);
- mb->get_popup()->connect("id_pressed", this, "_tool_selected");
- hbc->add_child(mb);
- button_tools = mb;
-
- resources = memnew(Tree);
- vbc->add_child(resources);
- resources->set_v_size_flags(SIZE_EXPAND_FILL);
- resources->create_item(); //root
- resources->set_hide_root(true);
- resources->connect("cell_selected", this, "_resource_selected");
- resources->connect("button_pressed", this, "_delete");
-
- create_dialog = memnew(CreateDialog);
- add_child(create_dialog);
- create_dialog->set_base_type("Resource");
- create_dialog->connect("create", this, "_create");
- accept = memnew(AcceptDialog);
- add_child(accept);
-
- file = memnew(EditorFileDialog);
- add_child(file);
- file->connect("file_selected", this, "_file_action");
-
- block_add = false;
-}
diff --git a/editor/resources_dock.h b/editor/resources_dock.h
deleted file mode 100644
index e5470b1a3c..0000000000
--- a/editor/resources_dock.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*************************************************************************/
-/* resources_dock.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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 RESOURCES_DOCK_H
-#define RESOURCES_DOCK_H
-
-#include "create_dialog.h"
-#include "editor_file_dialog.h"
-#include "scene/gui/box_container.h"
-#include "scene/gui/button.h"
-#include "scene/gui/control.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/label.h"
-#include "scene/gui/menu_button.h"
-#include "scene/gui/tool_button.h"
-#include "scene/gui/tree.h"
-
-class EditorNode;
-
-class ResourcesDock : public VBoxContainer {
-
- GDCLASS(ResourcesDock, VBoxContainer);
-
- enum {
- TOOL_NEW,
- TOOL_OPEN,
- TOOL_SAVE,
- TOOL_SAVE_AS,
- TOOL_MAKE_LOCAL,
- TOOL_COPY,
- TOOL_PASTE,
- TOOL_MAX
- };
-
- EditorNode *editor;
-
- Button *button_new;
- Button *button_open;
- Button *button_save;
- Button *button_tools;
-
- CreateDialog *create_dialog;
-
- AcceptDialog *accept;
- EditorFileDialog *file;
- Tree *resources;
- bool block_add;
- int current_action;
-
- void _file_action(const String &p_path);
-
- void _delete(Object *p_item, int p_column, int p_id);
- void _resource_selected();
- void _update_name(TreeItem *item);
- void _tool_selected(int p_tool);
- void _create();
-
-protected:
- void _notification(int p_what);
- static void _bind_methods();
-
-public:
- void add_resource(const Ref<Resource> &p_resource);
- void remove_resource(const Ref<Resource> &p_resource);
- void save_resource(const String &p_path, const Ref<Resource> &p_resource);
- void save_resource_as(const Ref<Resource> &p_resource);
-
- void cleanup();
-
- ResourcesDock(EditorNode *p_editor);
-};
-
-#endif // RESOURCES_DOCK_H
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index c3eb7240d4..859c41f0d0 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -29,20 +29,20 @@
/*************************************************************************/
#include "scene_tree_dock.h"
-#include "animation_editor.h"
#include "core/io/resource_saver.h"
+#include "core/os/keyboard.h"
+#include "core/project_settings.h"
+#include "editor/animation_editor.h"
+#include "editor/editor_node.h"
+#include "editor/editor_settings.h"
+#include "editor/multi_node_edit.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
#include "editor/plugins/spatial_editor_plugin.h"
-#include "editor_node.h"
-#include "editor_settings.h"
-#include "multi_node_edit.h"
-#include "os/keyboard.h"
-#include "project_settings.h"
+#include "editor/script_editor_debugger.h"
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
-#include "script_editor_debugger.h"
void SceneTreeDock::_nodes_drag_begin() {
@@ -106,7 +106,6 @@ void SceneTreeDock::instance(const String &p_file) {
if (!parent || !edited_scene) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("OK :("));
accept->set_text(TTR("No parent to instance a child at."));
accept->popup_centered_minsize();
@@ -152,7 +151,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
Ref<PackedScene> sdata = ResourceLoader::load(p_files[i]);
if (!sdata.is_valid()) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
accept->set_text(vformat(TTR("Error loading scene from %s"), p_files[i]));
accept->popup_centered_minsize();
@@ -163,7 +161,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!instanced_scene) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
accept->set_text(vformat(TTR("Error instancing scene from %s"), p_files[i]));
accept->popup_centered_minsize();
@@ -195,8 +192,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
return;
}
- //instanced_scene->generate_instance_state();
-
editor_data->get_undo_redo().create_action(TTR("Instance Scene(s)"));
for (int i = 0; i < instances.size(); i++) {
@@ -275,10 +270,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
switch (p_tool) {
case TOOL_NEW: {
- /*
- if (!_validate_no_foreign())
- break;
- */
create_dialog->popup_create(true);
} break;
case TOOL_INSTANCE: {
@@ -286,24 +277,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *scene = edited_scene;
if (!scene) {
-
EditorNode::get_singleton()->new_inherited_scene();
-
- /* should be legal now
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("This operation can't be done without a tree root.");
- accept->popup_centered_minsize();
- */
- break;
}
- /*
- if (!_validate_no_foreign())
- break;
- */
-
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
@@ -313,7 +289,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
- //file->set_current_path(current_path);
file->popup_centered_ratio();
} break;
@@ -321,43 +296,12 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
create_dialog->popup_create(false);
} break;
- case TOOL_CONNECT: {
-
- Node *current = scene_tree->get_selected();
- if (!current)
- break;
-
- /*
- if (!_validate_no_foreign())
- break;
- connect_dialog->popup_centered_ratio();
- connect_dialog->set_node(current);
- */
-
- } break;
- case TOOL_GROUP: {
-
- Node *current = scene_tree->get_selected();
- if (!current)
- break;
- /*
- if (!_validate_no_foreign())
- break;
- groups_editor->set_current(current);
- groups_editor->popup_centered_ratio();
- */
- } break;
case TOOL_ATTACH_SCRIPT: {
Node *selected = scene_tree->get_selected();
if (!selected)
break;
- /*
- if (!_validate_no_foreign())
- break;
- */
-
Ref<Script> existing = selected->get_script();
if (existing.is_valid())
editor->push_item(existing.ptr());
@@ -391,7 +335,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (scene_tree->get_selected() == edited_scene) {
current_option = -1;
- //accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation can't be done on the tree root."));
accept->popup_centered_minsize();
@@ -467,8 +410,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (selection.size() == 0)
break;
- List<Node *> reselect;
-
editor_data->get_undo_redo().create_action(TTR("Duplicate Node(s)"));
editor_data->get_undo_redo().add_do_method(editor_selection, "clear");
@@ -510,9 +451,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().add_do_method(sed, "live_debug_duplicate_node", edited_scene->get_path_to(node), dup->get_name());
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + dup->get_name()));
-
- //parent->add_child(dup);
- //reselect.push_back(dup);
}
editor_data->get_undo_redo().commit_action();
@@ -529,7 +467,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (editor_selection->is_selected(edited_scene)) {
current_option = -1;
- //confirmation->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation can't be done on the tree root."));
accept->popup_centered_minsize();
@@ -860,7 +797,6 @@ Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node *, Node *> &duplimap) {
node = sd->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
ERR_FAIL_COND_V(!node, NULL);
node->set_scene_instance_load_placeholder(p_node->get_scene_instance_load_placeholder());
- //node->generate_instance_state();
} else {
Object *obj = ClassDB::instance(p_node->get_class());
ERR_FAIL_COND_V(!obj, NULL);
@@ -1149,8 +1085,6 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) {
Node *new_parent = scene_root->get_node(p_path);
ERR_FAIL_COND(!new_parent);
- //ok all valid
-
List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.empty())
@@ -1180,11 +1114,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
}
validate = validate->get_parent();
}
-
//ok all valid
- List<Node *> selection = editor_selection->get_selected_node_list();
-
if (p_nodes.size() == 0)
return; //nothing to reparent
@@ -1285,7 +1216,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
perform_node_renames(NULL, &path_renames);
editor_data->get_undo_redo().commit_action();
- //node->set_owner(owner);
}
void SceneTreeDock::_script_created(Ref<Script> p_script) {
@@ -1361,7 +1291,6 @@ void SceneTreeDock::_delete_confirm() {
if (AnimationPlayerEditor::singleton->get_key_editor()->get_root() == n)
editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_key_editor(), "set_root", n);
editor_data->get_undo_redo().add_undo_method(this, "_set_owners", edited_scene, owners);
- //editor_data->get_undo_redo().add_undo_method(n,"set_owner",n->get_owner());
editor_data->get_undo_redo().add_undo_reference(n);
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
@@ -1392,8 +1321,6 @@ void SceneTreeDock::_selection_changed() {
button_create_script->hide();
button_clear_script->hide();
}
-
- //tool_buttons[TOOL_MULTI_EDIT]->set_disabled(EditorNode::get_singleton()->get_editor_selection()->get_selection().size()<2);
}
void SceneTreeDock::_create() {
@@ -1557,16 +1484,6 @@ void SceneTreeDock::_import_subscene() {
import_subscene_dialog->move(parent, edited_scene);
editor_data->get_undo_redo().clear_history(); //no undo for now..
-
- /*
- editor_data->get_undo_redo().create_action("Import Subscene");
- editor_data->get_undo_redo().add_do_method(parent,"add_child",ss);
- //editor_data->get_undo_redo().add_do_method(editor_selection,"clear");
- //editor_data->get_undo_redo().add_do_method(editor_selection,"add_node",child);
- editor_data->get_undo_redo().add_do_reference(ss);
- editor_data->get_undo_redo().add_undo_method(parent,"remove_child",ss);
- editor_data->get_undo_redo().commit_action();
-*/
}
void SceneTreeDock::_new_scene_from(String p_file) {
@@ -1601,10 +1518,6 @@ void SceneTreeDock::_new_scene_from(String p_file) {
int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
flg |= ResourceSaver::FLAG_COMPRESS;
- /*
- if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
- flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
- */
err = ResourceSaver::save(p_file, sdata, flg);
if (err != OK) {
@@ -1704,7 +1617,6 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) {
if (_has_visible_children(to_node)) {
to_pos = 0;
} else {
-
for (int i = to_node->get_index() + 1; i < to_node->get_parent()->get_child_count(); i++) {
Node *c = to_node->get_parent()->get_child(i);
if (_is_node_visible(c)) {
@@ -1718,26 +1630,6 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) {
to_node = to_node->get_parent();
}
-#if 0
- //quite complicated, look for next visible in tree
- upper_sibling=_find_last_visible(upper_sibling);
-
- if (upper_sibling->get_parent()==to_node->get_parent()) {
- //just insert over this node because nothing is above at an upper level
- to_pos=to_node->get_index();
- to_node=to_node->get_parent();
- } else {
- to_pos=-1; //insert last in whathever is up
- to_node=upper_sibling->get_parent(); //insert at a parent of whathever is up
- }
-
-
- } else {
- //just insert over this node because nothing is above at the same level
- to_pos=to_node->get_index();
- to_node=to_node->get_parent();
- }
-#endif
}
}
@@ -1857,9 +1749,6 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
menu->add_separator();
menu->add_icon_shortcut(get_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE);
- //menu->add_separator(); moved to their own dock
- //menu->add_icon_item(get_icon("Groups","EditorIcons"),TTR("Edit Groups"),TOOL_GROUP);
- //menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT);
menu->add_separator();
menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
@@ -1945,7 +1834,6 @@ void SceneTreeDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_tool_selected"), &SceneTreeDock::_tool_selected, DEFVAL(false));
ClassDB::bind_method(D_METHOD("_create"), &SceneTreeDock::_create);
- //ClassDB::bind_method(D_METHOD("_script_created"),&SceneTreeDock::_script_created);
ClassDB::bind_method(D_METHOD("_node_reparent"), &SceneTreeDock::_node_reparent);
ClassDB::bind_method(D_METHOD("_set_owners"), &SceneTreeDock::_set_owners);
ClassDB::bind_method(D_METHOD("_node_selected"), &SceneTreeDock::_node_selected);
@@ -2062,14 +1950,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
add_child(create_dialog);
create_dialog->connect("create", this, "_create");
- //groups_editor = memnew( GroupsEditor );
- //add_child(groups_editor);
- //groups_editor->set_undo_redo(&editor_data->get_undo_redo());
-
- //connect_dialog = memnew( ConnectionsDialog(p_editor) );
- //add_child(connect_dialog);
- //connect_dialog->set_undoredo(&editor_data->get_undo_redo());
-
script_create_dialog = memnew(ScriptCreateDialog);
add_child(script_create_dialog);
script_create_dialog->connect("script_created", this, "_script_created");
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index 5a6bc94125..618159f5c9 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -30,12 +30,13 @@
#ifndef SCENE_TREE_DOCK_H
#define SCENE_TREE_DOCK_H
-#include "connections_dialog.h"
-#include "create_dialog.h"
-#include "editor_data.h"
-#include "editor_sub_scene.h"
-#include "groups_editor.h"
-#include "reparent_dialog.h"
+#include "editor/connections_dialog.h"
+#include "editor/create_dialog.h"
+#include "editor/editor_data.h"
+#include "editor/editor_sub_scene.h"
+#include "editor/groups_editor.h"
+#include "editor/reparent_dialog.h"
+#include "editor/script_create_dialog.h"
#include "scene/animation/animation_player.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
@@ -45,7 +46,7 @@
#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
#include "scene_tree_editor.h"
-#include "script_create_dialog.h"
+
class EditorNode;
class SceneTreeDock : public VBoxContainer {
@@ -57,8 +58,6 @@ class SceneTreeDock : public VBoxContainer {
TOOL_NEW,
TOOL_INSTANCE,
TOOL_REPLACE,
- TOOL_CONNECT,
- TOOL_GROUP,
TOOL_ATTACH_SCRIPT,
TOOL_CLEAR_SCRIPT,
TOOL_MOVE_UP,
@@ -104,8 +103,6 @@ class SceneTreeDock : public VBoxContainer {
EditorData *editor_data;
EditorSelection *editor_selection;
- //GroupsEditor *groups_editor;
- //ConnectionsDialog *connect_dialog;
ScriptCreateDialog *script_create_dialog;
AcceptDialog *accept;
ConfirmationDialog *delete_dialog;
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index 299538a2b3..b70c63c97c 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -591,6 +591,9 @@ ScriptCreateDialog::ScriptCreateDialog() {
hb->add_child(vb);
hb->add_child(empty_v->duplicate());
+ memdelete(empty_h);
+ memdelete(empty_v);
+
add_child(hb);
/* Language */
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 689bea2749..d1d9f86b66 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -789,14 +789,17 @@ void ScriptEditorDebugger::_performance_draw() {
which.push_back(i);
}
- if (which.empty())
+ Ref<Font> graph_font = get_font("font", "TextEdit");
+
+ if (which.empty()) {
+ perf_draw->draw_string(graph_font, Point2(0, graph_font->get_ascent()), TTR("Pick one or more items from the list to display the graph."), get_color("font_color", "Label"), perf_draw->get_size().x);
return;
+ }
Ref<StyleBox> graph_sb = get_stylebox("normal", "TextEdit");
- Ref<Font> graph_font = get_font("font", "TextEdit");
int cols = Math::ceil(Math::sqrt((float)which.size()));
- int rows = (which.size() + 1) / cols;
+ int rows = Math::ceil((float)which.size() / cols);
if (which.size() == 1)
rows = 1;
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index e80fa603ce..2de63054b3 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -45,6 +45,24 @@
#define HANDLE_HALF_SIZE 0.05
+bool EditorSpatialGizmo::can_draw() const {
+ return is_editable();
+}
+bool EditorSpatialGizmo::is_editable() const {
+
+ ERR_FAIL_COND_V(!spatial_node, false);
+ Node *edited_root = spatial_node->get_tree()->get_edited_scene_root();
+ if (spatial_node == edited_root)
+ return true;
+ if (spatial_node->get_owner() == edited_root)
+ return true;
+
+ if (edited_root->is_editable_instance(spatial_node->get_owner()))
+ return true;
+
+ return false;
+}
+
void EditorSpatialGizmo::clear() {
for (int i = 0; i < instances.size(); i++) {
@@ -211,7 +229,7 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi
billboard_handle = p_billboard;
- if (!is_selected())
+ if (!is_selected() || !is_editable())
return;
ERR_FAIL_COND(!spatial_node);
@@ -560,6 +578,94 @@ void EditorSpatialGizmo::free() {
valid = false;
}
+Ref<SpatialMaterial> EditorSpatialGizmo::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) {
+
+ String name = p_name;
+
+ if (!is_editable()) {
+ name += "@readonly";
+ } else if (is_selected()) {
+ name += "@selected";
+ }
+
+ if (SpatialEditorGizmos::singleton->material_cache.has(name)) {
+ return SpatialEditorGizmos::singleton->material_cache[name];
+ }
+
+ Color color = p_color;
+
+ if (!is_editable()) {
+ color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/instanced");
+ } else if (!is_selected()) {
+ color.a *= 0.5;
+ }
+
+ Ref<SpatialMaterial> line_material;
+ line_material.instance();
+ line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ if (p_use_vertex_color) {
+ line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ }
+
+ if (p_billboard) {
+ line_material->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+ }
+
+ if (p_on_top && is_selected()) {
+ line_material->set_flag(SpatialMaterial::FLAG_ONTOP, true);
+ }
+
+ line_material->set_albedo(color);
+
+ SpatialEditorGizmos::singleton->material_cache[name] = line_material;
+
+ return line_material;
+}
+
+Ref<SpatialMaterial> EditorSpatialGizmo::create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top, const Color &p_albedo) {
+
+ String name = p_name;
+
+ if (!is_editable()) {
+ name += "@readonly";
+ } else if (is_selected()) {
+ name += "@selected";
+ }
+
+ if (SpatialEditorGizmos::singleton->material_cache.has(name)) {
+ return SpatialEditorGizmos::singleton->material_cache[name];
+ }
+
+ Color color = p_albedo;
+
+ if (!is_editable()) {
+ color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/instanced");
+ } else if (!is_selected()) {
+ color.a *= 0.5;
+ }
+
+ Ref<SpatialMaterial> icon;
+ icon.instance();
+ icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ icon->set_cull_mode(SpatialMaterial::CULL_DISABLED);
+ icon->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_DISABLED);
+ icon->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ icon->set_albedo(color);
+ icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, p_texture);
+ icon->set_flag(SpatialMaterial::FLAG_FIXED_SIZE, true);
+ icon->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+
+ if (p_on_top && is_selected()) {
+ icon->set_flag(SpatialMaterial::FLAG_ONTOP, true);
+ }
+
+ SpatialEditorGizmos::singleton->material_cache[name] = icon;
+
+ return icon;
+}
+
void EditorSpatialGizmo::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard"), &EditorSpatialGizmo::add_lines, DEFVAL(false));
@@ -713,8 +819,13 @@ void LightSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool
void LightSpatialGizmo::redraw() {
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/light");
+
if (Object::cast_to<DirectionalLight>(light)) {
+ Ref<Material> material = create_material("light_directional_material", gizmo_color);
+ Ref<Material> icon = create_icon_material("light_directional_icon", SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight", "EditorIcons"));
+
const int arrow_points = 5;
Vector3 arrow[arrow_points] = {
Vector3(0, 0, 2),
@@ -746,13 +857,15 @@ void LightSpatialGizmo::redraw() {
}
}
- add_lines(lines, SpatialEditorGizmos::singleton->light_material);
+ add_lines(lines, material);
add_collision_segments(lines);
- add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_directional_icon, 0.05);
+ add_unscaled_billboard(icon, 0.05);
}
if (Object::cast_to<OmniLight>(light)) {
+ Ref<Material> material = create_material("light_omni_material", gizmo_color, true);
+ Ref<Material> icon = create_icon_material("light_omni_icon", SpatialEditor::get_singleton()->get_icon("GizmoLight", "EditorIcons"));
clear();
OmniLight *on = Object::cast_to<OmniLight>(light);
@@ -776,10 +889,10 @@ void LightSpatialGizmo::redraw() {
points.push_back(Vector3(b.x, b.y, 0));
}
- add_lines(points, SpatialEditorGizmos::singleton->light_material_omni, true);
+ add_lines(points, material, true);
add_collision_segments(points);
- add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_omni_icon, 0.05);
+ add_unscaled_billboard(icon, 0.05);
Vector<Vector3> handles;
handles.push_back(Vector3(r, 0, 0));
@@ -788,6 +901,9 @@ void LightSpatialGizmo::redraw() {
if (Object::cast_to<SpotLight>(light)) {
+ Ref<Material> material = create_material("light_spot_material", gizmo_color, true);
+ Ref<Material> icon = create_icon_material("light_spot_icon", SpatialEditor::get_singleton()->get_icon("GizmoLight", "EditorIcons"));
+
clear();
Vector<Vector3> points;
@@ -821,7 +937,7 @@ void LightSpatialGizmo::redraw() {
points.push_back(Vector3(0, 0, -r));
points.push_back(Vector3());
- add_lines(points, SpatialEditorGizmos::singleton->light_material);
+ add_lines(points, material);
Vector<Vector3> handles;
handles.push_back(Vector3(0, 0, -r));
@@ -855,7 +971,7 @@ void LightSpatialGizmo::redraw() {
add_handles(handles);
add_collision_segments(collision_segments);
- add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_omni_icon, 0.05);
+ add_unscaled_billboard(icon, 0.05);
}
}
@@ -937,7 +1053,13 @@ void AudioStreamPlayer3DSpatialGizmo::redraw() {
clear();
+ Ref<Material> icon = create_icon_material("stream_player_3d_material", SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer", "EditorIcons"));
+
if (player->is_emission_angle_enabled()) {
+
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/stream_player_3d");
+ Ref<Material> material = create_material("stream_player_3d_material", gizmo_color);
+
float pc = player->get_emission_angle();
Vector<Vector3> points;
@@ -968,7 +1090,7 @@ void AudioStreamPlayer3DSpatialGizmo::redraw() {
points[200 + i * 2 + 1] = Vector3();
}
- add_lines(points, SpatialEditorGizmos::singleton->car_wheel_material);
+ add_lines(points, material);
add_collision_segments(points);
Vector<Vector3> handles;
@@ -977,7 +1099,7 @@ void AudioStreamPlayer3DSpatialGizmo::redraw() {
add_handles(handles);
}
- add_unscaled_billboard(SpatialEditorGizmos::singleton->sample_player_icon, 0.05);
+ add_unscaled_billboard(icon, 0.05);
}
AudioStreamPlayer3DSpatialGizmo::AudioStreamPlayer3DSpatialGizmo(AudioStreamPlayer3D *p_player) {
@@ -1068,6 +1190,9 @@ void CameraSpatialGizmo::redraw() {
Vector<Vector3> lines;
Vector<Vector3> handles;
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/camera");
+ Ref<Material> material = create_material("camera_material", gizmo_color);
+
switch (camera->get_projection()) {
case Camera::PROJECTION_PERSPECTIVE: {
@@ -1135,7 +1260,7 @@ void CameraSpatialGizmo::redraw() {
} break;
}
- add_lines(lines, SpatialEditorGizmos::singleton->camera_material);
+ add_lines(lines, material);
add_collision_segments(lines);
add_handles(handles);
}
@@ -1148,6 +1273,9 @@ CameraSpatialGizmo::CameraSpatialGizmo(Camera *p_camera) {
//////
+bool MeshInstanceSpatialGizmo::can_draw() const {
+ return true; //mesh can always draw (even though nothing is displayed)
+}
void MeshInstanceSpatialGizmo::redraw() {
Ref<Mesh> m = mesh->get_mesh();
@@ -1194,10 +1322,13 @@ void SkeletonSpatialGizmo::redraw() {
clear();
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/skeleton");
+ Ref<Material> material = create_material("skeleton_material", gizmo_color);
+
Ref<SurfaceTool> surface_tool(memnew(SurfaceTool));
surface_tool->begin(Mesh::PRIMITIVE_LINES);
- surface_tool->set_material(SpatialEditorGizmos::singleton->skeleton_material);
+ surface_tool->set_material(material);
Vector<Transform> grests;
grests.resize(skel->get_bone_count());
@@ -1378,7 +1509,7 @@ SkeletonSpatialGizmo::SkeletonSpatialGizmo(Skeleton *p_skel) {
skel = p_skel;
set_spatial_node(p_skel);
}
-
+#if 0
void RoomSpatialGizmo::redraw() {
clear();
@@ -1481,6 +1612,7 @@ PortalSpatialGizmo::PortalSpatialGizmo(Portal *p_portal) {
portal = p_portal;
}
+#endif
/////
void RayCastSpatialGizmo::redraw() {
@@ -1492,7 +1624,10 @@ void RayCastSpatialGizmo::redraw() {
lines.push_back(Vector3());
lines.push_back(raycast->get_cast_to());
- add_lines(lines, SpatialEditorGizmos::singleton->raycast_material);
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape");
+ Ref<Material> material = create_material("shape_material", gizmo_color);
+
+ add_lines(lines, material);
add_collision_segments(lines);
}
@@ -1550,7 +1685,10 @@ void VehicleWheelSpatialGizmo::redraw() {
points.push_back(Vector3(0, -r, r * 2));
points.push_back(Vector3(-r * 2 * 0.2, -r, r * 2 * 0.8));
- add_lines(points, SpatialEditorGizmos::singleton->car_wheel_material);
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape");
+ Ref<Material> material = create_material("shape_material", gizmo_color);
+
+ add_lines(points, material);
add_collision_segments(points);
}
@@ -1778,6 +1916,9 @@ void CollisionShapeSpatialGizmo::redraw() {
if (s.is_null())
return;
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape");
+ Ref<Material> material = create_material("shape_material", gizmo_color);
+
if (Object::cast_to<SphereShape>(*s)) {
Ref<SphereShape> sp = s;
@@ -1817,7 +1958,7 @@ void CollisionShapeSpatialGizmo::redraw() {
collision_segments.push_back(Vector3(b.x, b.y, 0));
}
- add_lines(points, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, material);
add_collision_segments(collision_segments);
Vector<Vector3> handles;
handles.push_back(Vector3(r, 0, 0));
@@ -1848,7 +1989,7 @@ void CollisionShapeSpatialGizmo::redraw() {
handles.push_back(ax);
}
- add_lines(lines, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(lines, material);
add_collision_segments(lines);
add_handles(handles);
}
@@ -1889,7 +2030,7 @@ void CollisionShapeSpatialGizmo::redraw() {
points.push_back(Vector3(b.y, 0, b.x) + dud);
}
- add_lines(points, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, material);
Vector<Vector3> collision_segments;
@@ -1955,7 +2096,7 @@ void CollisionShapeSpatialGizmo::redraw() {
points.push_back(p.normal * p.d);
points.push_back(p.normal * p.d + p.normal * 3);
- add_lines(points, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, material);
add_collision_segments(points);
}
@@ -1977,7 +2118,7 @@ void CollisionShapeSpatialGizmo::redraw() {
points[i * 2 + 1] = md.vertices[md.edges[i].b];
}
- add_lines(points, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, material);
add_collision_segments(points);
}
}
@@ -1990,7 +2131,7 @@ void CollisionShapeSpatialGizmo::redraw() {
Vector<Vector3> points;
points.push_back(Vector3());
points.push_back(Vector3(0, 0, rs->get_length()));
- add_lines(points, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, material);
add_collision_segments(points);
Vector<Vector3> handles;
handles.push_back(Vector3(0, 0, rs->get_length()));
@@ -2024,7 +2165,10 @@ void CollisionPolygonSpatialGizmo::redraw() {
lines.push_back(Vector3(points[i].x, points[i].y, -depth));
}
- add_lines(lines, SpatialEditorGizmos::singleton->shape_material);
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape");
+ Ref<Material> material = create_material("shape_material", gizmo_color);
+
+ add_lines(lines, material);
add_collision_segments(lines);
}
@@ -2092,6 +2236,9 @@ void VisibilityNotifierGizmo::commit_handle(int p_idx, const Variant &p_restore,
void VisibilityNotifierGizmo::redraw() {
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/visibility_notifier");
+ Ref<Material> material = create_material("visibility_notifier_material", gizmo_color);
+
clear();
Vector<Vector3> lines;
@@ -2113,7 +2260,7 @@ void VisibilityNotifierGizmo::redraw() {
handles.push_back(ax);
}
- add_lines(lines, SpatialEditorGizmos::singleton->visibility_notifier_material);
+ add_lines(lines, material);
//add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05);
add_collision_segments(lines);
add_handles(handles);
@@ -2238,7 +2385,10 @@ void ParticlesGizmo::redraw() {
lines.push_back(center + ax);
}
- add_lines(lines, SpatialEditorGizmos::singleton->particles_material);
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/particles");
+ Ref<Material> material = create_material("particles_material", gizmo_color);
+
+ add_lines(lines, material);
add_collision_segments(lines);
//add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05);
add_handles(handles);
@@ -2384,8 +2534,15 @@ void ReflectionProbeGizmo::redraw() {
lines.push_back(orig_handle);
}
- add_lines(lines, SpatialEditorGizmos::singleton->reflection_probe_material);
- add_lines(internal_lines, SpatialEditorGizmos::singleton->reflection_probe_material_internal);
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/reflection_probe");
+ Ref<Material> material = create_material("reflection_probe_material", gizmo_color);
+
+ Color gizmo_color_internal = gizmo_color;
+ gizmo_color_internal.a = 0.5;
+ Ref<Material> material_internal = create_material("reflection_internal_material", gizmo_color_internal);
+
+ add_lines(lines, material);
+ add_lines(internal_lines, material_internal);
//add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05);
add_collision_segments(lines);
add_handles(handles);
@@ -2458,6 +2615,12 @@ void GIProbeGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_can
void GIProbeGizmo::redraw() {
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/gi_probe");
+ Ref<Material> material = create_material("gi_probe_material", gizmo_color);
+ Color gizmo_color_internal = gizmo_color;
+ gizmo_color_internal.a = 0.1;
+ Ref<Material> material_internal = create_material("gi_probe_internal_material", gizmo_color_internal);
+
clear();
Vector<Vector3> lines;
@@ -2476,7 +2639,7 @@ void GIProbeGizmo::redraw() {
lines.push_back(b);
}
- add_lines(lines, SpatialEditorGizmos::singleton->gi_probe_material);
+ add_lines(lines, material);
add_collision_segments(lines);
lines.clear();
@@ -2521,7 +2684,7 @@ void GIProbeGizmo::redraw() {
}
}
- add_lines(lines, SpatialEditorGizmos::singleton->gi_probe_material_internal);
+ add_lines(lines, material_internal);
Vector<Vector3> handles;
@@ -2544,6 +2707,11 @@ GIProbeGizmo::GIProbeGizmo(GIProbe *p_probe) {
void NavigationMeshSpatialGizmo::redraw() {
+ Ref<Material> edge_material = create_material("navigation_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/navigation_edge"));
+ Ref<Material> edge_material_disabled = create_material("navigation_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/navigation_edge_disabled"));
+ Ref<Material> solid_material = create_material("navigation_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/navigation_solid"));
+ Ref<Material> solid_material_disabled = create_material("navigation_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/navigation_solid_disabled"));
+
clear();
Ref<NavigationMesh> navmeshie = navmesh->get_navigation_mesh();
if (navmeshie.is_null())
@@ -2616,14 +2784,14 @@ void NavigationMeshSpatialGizmo::redraw() {
tmesh->create(tmeshfaces);
if (lines.size())
- add_lines(lines, navmesh->is_enabled() ? SpatialEditorGizmos::singleton->navmesh_edge_material : SpatialEditorGizmos::singleton->navmesh_edge_material_disabled);
+ add_lines(lines, navmesh->is_enabled() ? edge_material : edge_material_disabled);
add_collision_triangles(tmesh);
Ref<ArrayMesh> m = memnew(ArrayMesh);
Array a;
a.resize(Mesh::ARRAY_MAX);
a[0] = tmeshfaces;
m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a);
- m->surface_set_material(0, navmesh->is_enabled() ? SpatialEditorGizmos::singleton->navmesh_solid_material : SpatialEditorGizmos::singleton->navmesh_solid_material_disabled);
+ m->surface_set_material(0, navmesh->is_enabled() ? solid_material : solid_material_disabled);
add_mesh(m);
add_collision_segments(lines);
}
@@ -2650,7 +2818,10 @@ void PinJointSpatialGizmo::redraw() {
cursor_points.push_back(Vector3(0, 0, +cs));
cursor_points.push_back(Vector3(0, 0, -cs));
add_collision_segments(cursor_points);
- add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
+
+ Ref<Material> material = create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint"));
+
+ add_lines(cursor_points, material);
}
PinJointSpatialGizmo::PinJointSpatialGizmo(PinJoint *p_p3d) {
@@ -2720,8 +2891,11 @@ void HingeJointSpatialGizmo::redraw() {
cursor_points.push_back(to);
}
}
+
+ Ref<Material> material = create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint"));
+
add_collision_segments(cursor_points);
- add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
+ add_lines(cursor_points, material);
}
HingeJointSpatialGizmo::HingeJointSpatialGizmo(HingeJoint *p_p3d) {
@@ -2824,8 +2998,11 @@ void SliderJointSpatialGizmo::redraw() {
cursor_points.push_back(to);
}
}
+
+ Ref<Material> material = create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint"));
+
add_collision_segments(cursor_points);
- add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
+ add_lines(cursor_points, material);
}
SliderJointSpatialGizmo::SliderJointSpatialGizmo(SliderJoint *p_p3d) {
@@ -2896,8 +3073,9 @@ void ConeTwistJointSpatialGizmo::redraw() {
points.push_back(Vector3(cn, b.x, b.y));
}
+ Ref<Material> material = create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint"));
add_collision_segments(points);
- add_lines(points, SpatialEditorGizmos::singleton->joint_material);
+ add_lines(points, material);
}
ConeTwistJointSpatialGizmo::ConeTwistJointSpatialGizmo(ConeTwistJoint *p_p3d) {
@@ -3080,8 +3258,9 @@ void Generic6DOFJointSpatialGizmo::redraw() {
#undef ADD_VTX
#undef SET_VTX
+ Ref<Material> material = create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint"));
add_collision_segments(cursor_points);
- add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
+ add_lines(cursor_points, material);
}
Generic6DOFJointSpatialGizmo::Generic6DOFJointSpatialGizmo(Generic6DOFJoint *p_p3d) {
@@ -3128,11 +3307,11 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
return misg;
}
- if (Object::cast_to<Room>(p_spatial)) {
+ /*if (Object::cast_to<Room>(p_spatial)) {
Ref<RoomSpatialGizmo> misg = memnew(RoomSpatialGizmo(Object::cast_to<Room>(p_spatial)));
return misg;
- }
+ }*/
if (Object::cast_to<NavigationMeshInstance>(p_spatial)) {
@@ -3145,13 +3324,13 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
Ref<RayCastSpatialGizmo> misg = memnew(RayCastSpatialGizmo(Object::cast_to<RayCast>(p_spatial)));
return misg;
}
-
+ /*
if (Object::cast_to<Portal>(p_spatial)) {
Ref<PortalSpatialGizmo> misg = memnew(PortalSpatialGizmo(Object::cast_to<Portal>(p_spatial)));
return misg;
}
-
+*/
if (Object::cast_to<CollisionShape>(p_spatial)) {
Ref<CollisionShapeSpatialGizmo> misg = memnew(CollisionShapeSpatialGizmo(Object::cast_to<CollisionShape>(p_spatial)));
@@ -3231,35 +3410,13 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
return Ref<SpatialEditorGizmo>();
}
-Ref<SpatialMaterial> SpatialEditorGizmos::create_line_material(const Color &p_base_color) {
-
- Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- line_material->set_line_width(3.0);
- line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- //line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- //->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- line_material->set_albedo(p_base_color);
-
- return line_material;
-}
-
-Ref<SpatialMaterial> SpatialEditorGizmos::create_solid_material(const Color &p_base_color) {
-
- Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- line_material->set_albedo(p_base_color);
-
- return line_material;
-}
-
SpatialEditorGizmos::SpatialEditorGizmos() {
singleton = this;
handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ handle_material->set_flag(SpatialMaterial::FLAG_ONTOP, true);
handle_material->set_albedo(Color(0.8, 0.8, 0.8));
handle_material_billboard = handle_material->duplicate();
handle_material_billboard->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
@@ -3274,9 +3431,29 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
handle2_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
handle2_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
handle2_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ handle2_material->set_flag(SpatialMaterial::FLAG_ONTOP, true);
handle2_material_billboard = handle2_material->duplicate();
handle2_material_billboard->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
-
+ handle2_material_billboard->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+ handle2_material_billboard->set_flag(SpatialMaterial::FLAG_ONTOP, true);
+
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/light", Color(1, 1, 0.2));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/camera", Color(0.8, 0.4, 0.8));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/skeleton", Color(1, 0.8, 0.4));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/visibility_notifier", Color(0.8, 0.5, 0.7));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/particles", Color(0.8, 0.7, 0.4));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/reflection_probe", Color(0.6, 1, 0.5));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/gi_probe", Color(0.5, 1, 0.6));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_edge", Color(0.5, 1, 1));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_edge_disabled", Color(0.7, 0.7, 0.7));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_solid", Color(0.5, 1, 1, 0.4));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_solid_disabled", Color(0.7, 0.7, 0.7, 0.4));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.5));
+
+#if 0
light_material = create_line_material(Color(1, 1, 0.2));
light_material_omni = create_line_material(Color(1, 1, 0.2));
light_material_omni->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
@@ -3289,6 +3466,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
light_material_omni_icon->set_albedo(Color(1, 1, 1, 0.9));
light_material_omni_icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoLight", "EditorIcons"));
light_material_omni_icon->set_flag(SpatialMaterial::FLAG_FIXED_SIZE, true);
+ light_material_omni_icon->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
light_material_directional_icon = Ref<SpatialMaterial>(memnew(SpatialMaterial));
light_material_directional_icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
@@ -3297,6 +3475,8 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
light_material_directional_icon->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
light_material_directional_icon->set_albedo(Color(1, 1, 1, 0.9));
light_material_directional_icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight", "EditorIcons"));
+ light_material_directional_icon->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+ light_material_directional_icon->set_depth_scale(1);
camera_material = create_line_material(Color(1.0, 0.5, 1.0));
@@ -3377,14 +3557,6 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
listener_line_mesh->surface_set_material(0, mat);
}
- sample_player_icon = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- sample_player_icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- sample_player_icon->set_cull_mode(SpatialMaterial::CULL_DISABLED);
- sample_player_icon->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_DISABLED);
- sample_player_icon->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- sample_player_icon->set_albedo(Color(1, 1, 1, 0.9));
- sample_player_icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer", "EditorIcons"));
-
room_material = create_line_material(Color(1.0, 0.6, 0.9));
portal_material = create_line_material(Color(1.0, 0.8, 0.6));
raycast_material = create_line_material(Color(1.0, 0.8, 0.6));
@@ -3463,4 +3635,62 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
}
shape_material = create_line_material(Color(0.2, 1, 1.0));
+#endif
+
+ pos3d_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ {
+
+ PoolVector<Vector3> cursor_points;
+ PoolVector<Color> cursor_colors;
+ float cs = 0.25;
+ cursor_points.push_back(Vector3(+cs, 0, 0));
+ cursor_points.push_back(Vector3(-cs, 0, 0));
+ cursor_points.push_back(Vector3(0, +cs, 0));
+ cursor_points.push_back(Vector3(0, -cs, 0));
+ cursor_points.push_back(Vector3(0, 0, +cs));
+ cursor_points.push_back(Vector3(0, 0, -cs));
+ cursor_colors.push_back(Color(1, 0.5, 0.5, 0.7));
+ cursor_colors.push_back(Color(1, 0.5, 0.5, 0.7));
+ cursor_colors.push_back(Color(0.5, 1, 0.5, 0.7));
+ cursor_colors.push_back(Color(0.5, 1, 0.5, 0.7));
+ cursor_colors.push_back(Color(0.5, 0.5, 1, 0.7));
+ cursor_colors.push_back(Color(0.5, 0.5, 1, 0.7));
+
+ Ref<SpatialMaterial> mat = memnew(SpatialMaterial);
+ mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ mat->set_line_width(3);
+ Array d;
+ d.resize(VS::ARRAY_MAX);
+ d[Mesh::ARRAY_VERTEX] = cursor_points;
+ d[Mesh::ARRAY_COLOR] = cursor_colors;
+ pos3d_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, d);
+ pos3d_mesh->surface_set_material(0, mat);
+ }
+
+ listener_line_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ {
+
+ PoolVector<Vector3> cursor_points;
+ PoolVector<Color> cursor_colors;
+ cursor_points.push_back(Vector3(0, 0, 0));
+ cursor_points.push_back(Vector3(0, 0, -1.0));
+ cursor_colors.push_back(Color(0.5, 0.5, 0.5, 0.7));
+ cursor_colors.push_back(Color(0.5, 0.5, 0.5, 0.7));
+
+ Ref<SpatialMaterial> mat = memnew(SpatialMaterial);
+ mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ mat->set_line_width(3);
+ Array d;
+ d.resize(VS::ARRAY_MAX);
+ d[Mesh::ARRAY_VERTEX] = cursor_points;
+ d[Mesh::ARRAY_COLOR] = cursor_colors;
+ listener_line_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, d);
+ listener_line_mesh->surface_set_material(0, mat);
+ }
}
diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h
index 4769e5d765..fa5484c3d9 100644
--- a/editor/spatial_editor_gizmos.h
+++ b/editor/spatial_editor_gizmos.h
@@ -107,6 +107,9 @@ protected:
static void _bind_methods();
+ Ref<SpatialMaterial> create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false);
+ Ref<SpatialMaterial> create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1));
+
public:
virtual Vector3 get_handle_pos(int p_idx) const;
virtual bool intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum);
@@ -117,6 +120,8 @@ public:
void transform();
virtual void redraw();
void free();
+ virtual bool is_editable() const;
+ virtual bool can_draw() const;
EditorSpatialGizmo();
~EditorSpatialGizmo();
@@ -177,6 +182,7 @@ class MeshInstanceSpatialGizmo : public EditorSpatialGizmo {
MeshInstance *mesh;
public:
+ virtual bool can_draw() const;
void redraw();
MeshInstanceSpatialGizmo(MeshInstance *p_mesh = NULL);
};
@@ -203,25 +209,7 @@ public:
SkeletonSpatialGizmo(Skeleton *p_skel = NULL);
};
-class RoomSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(RoomSpatialGizmo, EditorSpatialGizmo);
-
- struct _EdgeKey {
-
- Vector3 from;
- Vector3 to;
-
- bool operator<(const _EdgeKey &p_with) const { return from == p_with.from ? to < p_with.to : from < p_with.from; }
- };
-
- Room *room;
-
-public:
- void redraw();
- RoomSpatialGizmo(Room *p_room = NULL);
-};
-
+#if 0
class PortalSpatialGizmo : public EditorSpatialGizmo {
GDCLASS(PortalSpatialGizmo, EditorSpatialGizmo);
@@ -232,6 +220,7 @@ public:
void redraw();
PortalSpatialGizmo(Portal *p_portal = NULL);
};
+#endif
class VisibilityNotifierGizmo : public EditorSpatialGizmo {
@@ -420,51 +409,19 @@ public:
};
class SpatialEditorGizmos {
+
public:
- Ref<SpatialMaterial> create_line_material(const Color &p_base_color);
- Ref<SpatialMaterial> create_solid_material(const Color &p_base_color);
+ HashMap<String, Ref<SpatialMaterial> > material_cache;
+
Ref<SpatialMaterial> handle2_material;
Ref<SpatialMaterial> handle2_material_billboard;
Ref<SpatialMaterial> handle_material;
Ref<SpatialMaterial> handle_material_billboard;
- Ref<SpatialMaterial> light_material;
- Ref<SpatialMaterial> light_material_omni;
- Ref<SpatialMaterial> light_material_omni_icon;
- Ref<SpatialMaterial> light_material_directional_icon;
- Ref<SpatialMaterial> camera_material;
- Ref<SpatialMaterial> skeleton_material;
- Ref<SpatialMaterial> reflection_probe_material;
- Ref<SpatialMaterial> reflection_probe_material_internal;
- Ref<SpatialMaterial> gi_probe_material;
- Ref<SpatialMaterial> gi_probe_material_internal;
- Ref<SpatialMaterial> room_material;
- Ref<SpatialMaterial> portal_material;
- Ref<SpatialMaterial> raycast_material;
- Ref<SpatialMaterial> visibility_notifier_material;
- Ref<SpatialMaterial> particles_material;
- Ref<SpatialMaterial> car_wheel_material;
- Ref<SpatialMaterial> joint_material;
-
- Ref<SpatialMaterial> navmesh_edge_material;
- Ref<SpatialMaterial> navmesh_solid_material;
- Ref<SpatialMaterial> navmesh_edge_material_disabled;
- Ref<SpatialMaterial> navmesh_solid_material_disabled;
-
- Ref<SpatialMaterial> listener_icon;
-
- Ref<SpatialMaterial> sample_player_icon;
- Ref<SpatialMaterial> stream_player_icon;
- Ref<SpatialMaterial> visibility_notifier_icon;
-
- Ref<SpatialMaterial> shape_material;
Ref<Texture> handle_t;
-
Ref<ArrayMesh> pos3d_mesh;
Ref<ArrayMesh> listener_line_mesh;
static SpatialEditorGizmos *singleton;
- Ref<TriangleMesh> test_cube_tm;
-
Ref<SpatialEditorGizmo> get_gizmo(Spatial *p_spatial);
SpatialEditorGizmos();
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index d06da08551..905c784ab9 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -1546,7 +1546,9 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
scr = NULL;
}
} else {
- on_script = obj->get_script();
+ if (obj) {
+ on_script = obj->get_script();
+ }
}
}
@@ -2237,7 +2239,9 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
scr = NULL;
}
} else {
- on_script = obj->get_script();
+ if (obj) {
+ on_script = obj->get_script();
+ }
}
}
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index fe5936b715..b444664878 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -96,25 +96,6 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
}
_recreate_octant_data();
- } else if (name.begins_with("areas/")) {
- int which = name.get_slicec('/', 1).to_int();
- String what = name.get_slicec('/', 2);
- if (what == "bounds") {
- ERR_FAIL_COND_V(area_map.has(which), false);
- create_area(which, p_value);
- return true;
- }
-
- ERR_FAIL_COND_V(!area_map.has(which), false);
-
- if (what == "name")
- area_set_name(which, p_value);
- else if (what == "disable_distance")
- area_set_portal_disable_distance(which, p_value);
- else if (what == "exterior_portal")
- area_set_portal_disable_color(which, p_value);
- else
- return false;
} else
return false;
@@ -158,19 +139,6 @@ bool GridMap::_get(const StringName &p_name, Variant &r_ret) const {
d["cells"] = cells;
r_ret = d;
- } else if (name.begins_with("areas/")) {
- int which = name.get_slicec('/', 1).to_int();
- String what = name.get_slicec('/', 2);
- if (what == "bounds")
- r_ret = area_get_bounds(which);
- else if (what == "name")
- r_ret = area_get_name(which);
- else if (what == "disable_distance")
- r_ret = area_get_portal_disable_distance(which);
- else if (what == "exterior_portal")
- r_ret = area_is_exterior_portal(which);
- else
- return false;
} else
return false;
@@ -189,16 +157,6 @@ void GridMap::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::REAL, "cell_scale"));
p_list->push_back(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
-
- for (const Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
-
- String base = "areas/" + itos(E->key()) + "/";
- p_list->push_back(PropertyInfo(Variant::RECT3, base + "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::STRING, base + "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::REAL, base + "disable_distance", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::COLOR, base + "disable_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "exterior_portal", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- }
}
void GridMap::set_theme(const Ref<MeshLibrary> &p_theme) {
@@ -268,20 +226,6 @@ bool GridMap::get_center_z() const {
return center_z;
}
-int GridMap::_find_area(const IndexKey &p_pos) const {
-
- for (const Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- const Area &a = *E->get();
- if (p_pos.x >= a.from.x && p_pos.x < a.to.x &&
- p_pos.y >= a.from.y && p_pos.y < a.to.y &&
- p_pos.z >= a.from.z && p_pos.z < a.to.z) {
- return E->key();
- }
- }
-
- return 0;
-}
void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
ERR_FAIL_INDEX(ABS(p_x), 1 << 20);
@@ -297,7 +241,6 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
ok.x = p_x / octant_size;
ok.y = p_y / octant_size;
ok.z = p_z / octant_size;
- ok.area = _find_area(key);
if (cell_map.has(key)) {
@@ -485,19 +428,12 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
if (g.collision_debug_instance.is_valid()) {
VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario());
VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
- if (area_map.has(p_key.area)) {
- VS::get_singleton()->instance_set_room(g.collision_debug_instance, area_map[p_key.area]->instance);
- }
}
for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance, get_world()->get_scenario());
VS::get_singleton()->instance_set_transform(E->get().multimesh_instance, get_global_transform());
//print_line("INSTANCEPOS: "+get_global_transform());
-
- if (area_map.has(p_key.area)) {
- VS::get_singleton()->instance_set_room(E->get().multimesh_instance, area_map[p_key.area]->instance);
- }
}
}
@@ -655,7 +591,6 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_room(g.collision_debug_instance, RID());
VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID());
}
@@ -663,7 +598,6 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance, RID());
//VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
- VS::get_singleton()->instance_set_room(E->get().multimesh_instance, RID());
}
}
@@ -673,8 +607,6 @@ void GridMap::_notification(int p_what) {
case NOTIFICATION_ENTER_WORLD: {
- _update_area_instances();
-
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
//IndexKey ik;
//ik.key = E->key().indexkey;
@@ -761,14 +693,14 @@ void GridMap::_queue_dirty_map() {
void GridMap::_recreate_octant_data() {
Map<IndexKey, Cell> cell_copy = cell_map;
- _clear_internal(true);
+ _clear_internal();
for (Map<IndexKey, Cell>::Element *E = cell_copy.front(); E; E = E->next()) {
set_cell_item(E->key().x, E->key().y, E->key().z, E->get().item, E->get().rot);
}
}
-void GridMap::_clear_internal(bool p_keep_areas) {
+void GridMap::_clear_internal() {
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
if (is_inside_world())
@@ -790,20 +722,6 @@ void GridMap::_clear_internal(bool p_keep_areas) {
octant_map.clear();
cell_map.clear();
-
- if (p_keep_areas)
- return;
-
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
-
- VS::get_singleton()->free(E->get()->base_portal);
- VS::get_singleton()->free(E->get()->instance);
- for (int i = 0; i < E->get()->portals.size(); i++) {
- VS::get_singleton()->free(E->get()->portals[i].instance);
- }
-
- memdelete(E->get());
- }
}
void GridMap::clear() {
@@ -856,19 +774,6 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_clip", "enabled", "clipabove", "floor", "axis"), &GridMap::set_clip, DEFVAL(true), DEFVAL(0), DEFVAL(Vector3::AXIS_X));
- ClassDB::bind_method(D_METHOD("create_area", "id", "area"), &GridMap::create_area);
- ClassDB::bind_method(D_METHOD("area_get_bounds", "area"), &GridMap::area_get_bounds);
- ClassDB::bind_method(D_METHOD("area_set_exterior_portal", "area", "enable"), &GridMap::area_set_exterior_portal);
- ClassDB::bind_method(D_METHOD("area_set_name", "area", "name"), &GridMap::area_set_name);
- ClassDB::bind_method(D_METHOD("area_get_name", "area"), &GridMap::area_get_name);
- ClassDB::bind_method(D_METHOD("area_is_exterior_portal", "area"), &GridMap::area_is_exterior_portal);
- ClassDB::bind_method(D_METHOD("area_set_portal_disable_distance", "area", "distance"), &GridMap::area_set_portal_disable_distance);
- ClassDB::bind_method(D_METHOD("area_get_portal_disable_distance", "area"), &GridMap::area_get_portal_disable_distance);
- ClassDB::bind_method(D_METHOD("area_set_portal_disable_color", "area", "color"), &GridMap::area_set_portal_disable_color);
- ClassDB::bind_method(D_METHOD("area_get_portal_disable_color", "area"), &GridMap::area_get_portal_disable_color);
- ClassDB::bind_method(D_METHOD("erase_area", "area"), &GridMap::erase_area);
- ClassDB::bind_method(D_METHOD("get_unused_area_id"), &GridMap::get_unused_area_id);
-
ClassDB::bind_method(D_METHOD("clear"), &GridMap::clear);
ClassDB::bind_method(D_METHOD("get_meshes"), &GridMap::get_meshes);
@@ -898,334 +803,6 @@ void GridMap::set_clip(bool p_enabled, bool p_clip_above, int p_floor, Vector3::
_update_dirty_map_callback();
}
-void GridMap::_update_areas() {
-
- //clear the portals
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- Area &a = *E->get();
- a.portals.clear();
- if (a.instance.is_valid()) {
- VisualServer::get_singleton()->free(a.instance);
- a.instance = RID();
- }
- }
-
- //test all areas against all areas and create portals - this sucks (slow :( )
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- Area &a = *E->get();
- if (a.exterior_portal) //that's pretty much all it does... yes it is
- continue;
- Vector3 from_a(a.from.x, a.from.y, a.from.z);
- Vector3 to_a(a.to.x, a.to.y, a.to.z);
-
- for (Map<int, Area *>::Element *F = area_map.front(); F; F = F->next()) {
-
- Area &b = *F->get();
- Vector3 from_b(b.from.x, b.from.y, b.from.z);
- Vector3 to_b(b.to.x, b.to.y, b.to.z);
-
- // initially test intersection and discards
- int axis = -1;
- float sign = 0;
- bool valid = true;
- Vector3 axmin, axmax;
-
- for (int i = 0; i < 3; i++) {
-
- if (from_a[i] == to_b[i]) {
-
- if (axis != -1) {
- valid = false;
- break;
- }
-
- axis = i;
- sign = -1;
- } else if (from_b[i] == to_a[i]) {
-
- if (axis != -1) {
- valid = false;
- break;
- }
- axis = i;
- sign = +1;
- }
-
- if (from_a[i] > to_b[i] || to_a[i] < from_b[i]) {
- valid = false;
- break;
- } else {
-
- axmin[i] = (from_a[i] > from_b[i]) ? from_a[i] : from_b[i];
- axmax[i] = (to_a[i] < to_b[i]) ? to_a[i] : to_b[i];
- }
- }
-
- if (axis == -1 || !valid)
- continue;
-
- Transform xf;
-
- for (int i = 0; i < 3; i++) {
-
- int ax = (axis + i) % 3;
- Vector3 axis_vec;
- float scale = (i == 0) ? sign : ((axmax[ax] - axmin[ax]) * cell_size);
- axis_vec[ax] = scale;
- xf.basis.set_axis((2 + i) % 3, axis_vec);
- xf.origin[i] = axmin[i] * cell_size;
- }
-
- Area::Portal portal;
- portal.xform = xf;
- a.portals.push_back(portal);
- }
- }
-
- _update_area_instances();
-}
-
-void GridMap::_update_area_instances() {
-
- Transform base_xform;
- if (_in_tree)
- base_xform = get_global_transform();
-
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- Area &a = *E->get();
- if (a.instance.is_valid() != _in_tree) {
-
- if (!_in_tree) {
-
- for (int i = 0; i < a.portals.size(); i++) {
-
- Area::Portal &p = a.portals[i];
- ERR_CONTINUE(!p.instance.is_valid());
- VisualServer::get_singleton()->free(p.instance);
- p.instance = RID();
- }
-
- VisualServer::get_singleton()->free(a.instance);
- a.instance = RID();
-
- } else {
-
- //a.instance = VisualServer::get_singleton()->instance_create2(base_room,get_world()->get_scenario());
- for (int i = 0; i < a.portals.size(); i++) {
-
- Area::Portal &p = a.portals[i];
- ERR_CONTINUE(p.instance.is_valid());
- p.instance = VisualServer::get_singleton()->instance_create2(a.base_portal, get_world()->get_scenario());
- VisualServer::get_singleton()->instance_set_room(p.instance, a.instance);
- }
- }
- }
-
- if (a.instance.is_valid()) {
- Transform xform;
-
- Vector3 from_a(a.from.x, a.from.y, a.from.z);
- Vector3 to_a(a.to.x, a.to.y, a.to.z);
-
- for (int i = 0; i < 3; i++) {
- xform.origin[i] = from_a[i] * cell_size;
- Vector3 s;
- s[i] = (to_a[i] - from_a[i]) * cell_size;
- xform.basis.set_axis(i, s);
- }
-
- VisualServer::get_singleton()->instance_set_transform(a.instance, base_xform * xform);
-
- for (int i = 0; i < a.portals.size(); i++) {
-
- Area::Portal &p = a.portals[i];
- ERR_CONTINUE(!p.instance.is_valid());
-
- VisualServer::get_singleton()->instance_set_transform(p.instance, base_xform * xform);
- }
- }
- }
-}
-
-Error GridMap::create_area(int p_id, const Rect3 &p_area) {
-
- ERR_FAIL_COND_V(area_map.has(p_id), ERR_ALREADY_EXISTS);
- ERR_EXPLAIN("ID 0 is taken as global area, start from 1");
- ERR_FAIL_COND_V(p_id == 0, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_area.has_no_area(), ERR_INVALID_PARAMETER);
-
- // FIRST VALIDATE AREA
- IndexKey from, to;
- from.x = p_area.position.x;
- from.y = p_area.position.y;
- from.z = p_area.position.z;
- to.x = p_area.position.x + p_area.size.x;
- to.y = p_area.position.y + p_area.size.y;
- to.z = p_area.position.z + p_area.size.z;
-
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- Area &a = *E->get();
-
- //does it interset with anything else?
-
- if (from.x >= a.to.x ||
- to.x <= a.from.x ||
- from.y >= a.to.y ||
- to.y <= a.from.y ||
- from.z >= a.to.z ||
- to.z <= a.from.z) {
-
- // all good
- } else {
-
- return ERR_INVALID_PARAMETER;
- }
- }
-
- Area *area = memnew(Area);
- area->from = from;
- area->to = to;
- area->portal_disable_distance = 0;
- area->exterior_portal = false;
- area->name = "Area " + itos(p_id);
- area_map[p_id] = area;
- _recreate_octant_data();
- return OK;
-}
-
-Rect3 GridMap::area_get_bounds(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), Rect3());
-
- const Area *a = area_map[p_area];
- Rect3 aabb;
- aabb.position = Vector3(a->from.x, a->from.y, a->from.z);
- aabb.size = Vector3(a->to.x, a->to.y, a->to.z) - aabb.position;
-
- return aabb;
-}
-
-void GridMap::area_set_name(int p_area, const String &p_name) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- a->name = p_name;
-}
-
-String GridMap::area_get_name(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), "");
-
- const Area *a = area_map[p_area];
- return a->name;
-}
-
-void GridMap::area_set_exterior_portal(int p_area, bool p_enable) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- if (a->exterior_portal == p_enable)
- return;
- a->exterior_portal = p_enable;
-
- _recreate_octant_data();
-}
-
-bool GridMap::area_is_exterior_portal(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), false);
-
- const Area *a = area_map[p_area];
- return a->exterior_portal;
-}
-
-void GridMap::area_set_portal_disable_distance(int p_area, float p_distance) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- a->portal_disable_distance = p_distance;
-}
-
-float GridMap::area_get_portal_disable_distance(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), 0);
-
- const Area *a = area_map[p_area];
- return a->portal_disable_distance;
-}
-
-void GridMap::area_set_portal_disable_color(int p_area, Color p_color) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- a->portal_disable_color = p_color;
-}
-
-Color GridMap::area_get_portal_disable_color(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), Color());
-
- const Area *a = area_map[p_area];
- return a->portal_disable_color;
-}
-
-void GridMap::get_area_list(List<int> *p_areas) const {
-
- for (const Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
-
- p_areas->push_back(E->key());
- }
-}
-
-GridMap::Area::Portal::~Portal() {
-
- if (instance.is_valid())
- VisualServer::get_singleton()->free(instance);
-}
-
-GridMap::Area::Area() {
-
- base_portal = VisualServer::get_singleton()->portal_create();
- Vector<Point2> points;
- points.push_back(Point2(0, 1));
- points.push_back(Point2(1, 1));
- points.push_back(Point2(1, 0));
- points.push_back(Point2(0, 0));
- VisualServer::get_singleton()->portal_set_shape(base_portal, points);
-}
-
-GridMap::Area::~Area() {
-
- if (instance.is_valid())
- VisualServer::get_singleton()->free(instance);
- VisualServer::get_singleton()->free(base_portal);
-}
-
-void GridMap::erase_area(int p_area) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- memdelete(a);
- area_map.erase(p_area);
- _recreate_octant_data();
-}
-
-int GridMap::get_unused_area_id() const {
-
- if (area_map.empty())
- return 1;
- else
- return area_map.back()->key() + 1;
-}
-
void GridMap::set_cell_scale(float p_scale) {
cell_scale = p_scale;
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 106bf82dc2..7af1e08eb2 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -120,7 +120,7 @@ class GridMap : public Spatial {
int16_t x;
int16_t y;
int16_t z;
- int16_t area;
+ int16_t empty;
};
uint64_t key;
@@ -148,35 +148,10 @@ class GridMap : public Spatial {
int clip_floor;
Vector3::Axis clip_axis;
- /**
- * @brief An Area is something like a room: it has doors, and Octants can choose to belong to it.
- */
- struct Area {
-
- String name;
- RID base_portal;
- RID instance;
- IndexKey from;
- IndexKey to;
- struct Portal {
- Transform xform;
- RID instance;
- ~Portal();
- };
- Vector<Portal> portals;
- float portal_disable_distance;
- Color portal_disable_color;
- bool exterior_portal;
-
- Area();
- ~Area();
- };
-
Ref<MeshLibrary> theme;
Map<OctantKey, Octant *> octant_map;
Map<IndexKey, Cell> cell_map;
- Map<int, Area *> area_map;
void _recreate_octant_data();
@@ -188,8 +163,6 @@ class GridMap : public Spatial {
float param[VS::LIGHT_PARAM_MAX];
};
- _FORCE_INLINE_ int _find_area(const IndexKey &p_pos) const;
-
_FORCE_INLINE_ Vector3 _octant_get_offset(const OctantKey &p_key) const {
return Vector3(p_key.x, p_key.y, p_key.z) * cell_size * octant_size;
@@ -208,10 +181,7 @@ class GridMap : public Spatial {
void resource_changed(const RES &p_res);
- void _update_areas();
- void _update_area_instances();
-
- void _clear_internal(bool p_keep_areas = false);
+ void _clear_internal();
protected:
bool _set(const StringName &p_name, const Variant &p_value);
@@ -248,20 +218,6 @@ public:
void set_clip(bool p_enabled, bool p_clip_above = true, int p_floor = 0, Vector3::Axis p_axis = Vector3::AXIS_X);
- Error create_area(int p_id, const Rect3 &p_area);
- Rect3 area_get_bounds(int p_area) const;
- void area_set_exterior_portal(int p_area, bool p_enable);
- void area_set_name(int p_area, const String &p_name);
- String area_get_name(int p_area) const;
- bool area_is_exterior_portal(int p_area) const;
- void area_set_portal_disable_distance(int p_area, float p_distance);
- float area_get_portal_disable_distance(int p_area) const;
- void area_set_portal_disable_color(int p_area, Color p_color);
- Color area_get_portal_disable_color(int p_area) const;
- void get_area_list(List<int> *p_areas) const;
- void erase_area(int p_area);
- int get_unused_area_id() const;
-
void set_cell_scale(float p_scale);
float get_cell_scale() const;
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 5d98b0f7a7..3bab1bfbc1 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -178,30 +178,6 @@ void GridMapEditor::_menu_option(int p_option) {
int idx = options->get_popup()->get_item_index(MENU_OPTION_DUPLICATE_SELECTS);
options->get_popup()->set_item_checked(idx, !options->get_popup()->is_item_checked(idx));
} break;
- case MENU_OPTION_SELECTION_MAKE_AREA:
- case MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR: {
-
- if (!selection.active)
- break;
- int area = node->get_unused_area_id();
- Error err = node->create_area(area, Rect3(selection.begin, selection.end - selection.begin + Vector3(1, 1, 1)));
- if (err != OK) {
- }
- if (p_option == MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR) {
-
- node->area_set_exterior_portal(area, true);
- }
- _update_areas_display();
- update_areas();
-
- } break;
- case MENU_OPTION_REMOVE_AREA: {
- if (selected_area < 1)
- return;
- node->erase_area(selected_area);
- _update_areas_display();
- update_areas();
- } break;
case MENU_OPTION_SELECTION_DUPLICATE:
if (!(selection.active && input_action == INPUT_NONE))
return;
@@ -513,146 +489,96 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu
return false;
}
- if (edit_mode->get_selected() == 0) { // regular click
-
- Ref<InputEventMouseButton> mb = p_event;
-
- if (mb.is_valid()) {
-
- if (mb->get_button_index() == BUTTON_WHEEL_UP && (mb->get_command() || mb->get_shift())) {
- if (mb->is_pressed())
- floor->set_value(floor->get_value() + mb->get_factor());
-
- return true; //eaten
- } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && (mb->get_command() || mb->get_shift())) {
- if (mb->is_pressed())
- floor->set_value(floor->get_value() - mb->get_factor());
- return true;
- }
-
- if (mb->is_pressed()) {
-
- if (mb->get_button_index() == BUTTON_LEFT) {
+ Ref<InputEventMouseButton> mb = p_event;
- if (input_action == INPUT_DUPLICATE) {
-
- //paste
- _duplicate_paste();
- input_action = INPUT_NONE;
- _update_duplicate_indicator();
- } else if (mb->get_shift()) {
- input_action = INPUT_SELECT;
- } else if (mb->get_command())
- input_action = INPUT_COPY;
- else {
- input_action = INPUT_PAINT;
- set_items.clear();
- }
- } else if (mb->get_button_index() == BUTTON_RIGHT)
- if (input_action == INPUT_DUPLICATE) {
-
- input_action = INPUT_NONE;
- _update_duplicate_indicator();
- } else {
- input_action = INPUT_ERASE;
- set_items.clear();
- }
- else
- return false;
+ if (mb.is_valid()) {
- return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
- } else {
+ if (mb->get_button_index() == BUTTON_WHEEL_UP && (mb->get_command() || mb->get_shift())) {
+ if (mb->is_pressed())
+ floor->set_value(floor->get_value() + mb->get_factor());
- if (
- (mb->get_button_index() == BUTTON_RIGHT && input_action == INPUT_ERASE) ||
- (mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_PAINT)) {
+ return true; //eaten
+ } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && (mb->get_command() || mb->get_shift())) {
+ if (mb->is_pressed())
+ floor->set_value(floor->get_value() - mb->get_factor());
+ return true;
+ }
- if (set_items.size()) {
- undo_redo->create_action(TTR("GridMap Paint"));
- for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) {
+ if (mb->is_pressed()) {
- const SetItem &si = E->get();
- undo_redo->add_do_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.new_value, si.new_orientation);
- }
- for (List<SetItem>::Element *E = set_items.back(); E; E = E->prev()) {
+ if (mb->get_button_index() == BUTTON_LEFT) {
- const SetItem &si = E->get();
- undo_redo->add_undo_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.old_value, si.old_orientation);
- }
+ if (input_action == INPUT_DUPLICATE) {
- undo_redo->commit_action();
- }
- set_items.clear();
+ //paste
+ _duplicate_paste();
input_action = INPUT_NONE;
- return true;
- }
-
- if (mb->get_button_index() == BUTTON_LEFT && input_action != INPUT_NONE) {
-
+ _update_duplicate_indicator();
+ } else if (mb->get_shift()) {
+ input_action = INPUT_SELECT;
+ } else if (mb->get_command())
+ input_action = INPUT_COPY;
+ else {
+ input_action = INPUT_PAINT;
set_items.clear();
- input_action = INPUT_NONE;
- return true;
}
- if (mb->get_button_index() == BUTTON_RIGHT && (input_action == INPUT_ERASE || input_action == INPUT_DUPLICATE)) {
+ } else if (mb->get_button_index() == BUTTON_RIGHT)
+ if (input_action == INPUT_DUPLICATE) {
+
input_action = INPUT_NONE;
- return true;
+ _update_duplicate_indicator();
+ } else {
+ input_action = INPUT_ERASE;
+ set_items.clear();
}
- }
- }
-
- Ref<InputEventMouseMotion> mm = p_event;
-
- if (mm.is_valid()) {
-
- return do_input_action(p_camera, mm->get_position(), false);
- }
-
- } else if (edit_mode->get_selected() == 1) {
- //area mode, select an area
+ else
+ return false;
- Ref<InputEventMouseButton> mb = p_event;
+ return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
+ } else {
- if (mb.is_valid()) {
+ if (
+ (mb->get_button_index() == BUTTON_RIGHT && input_action == INPUT_ERASE) ||
+ (mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_PAINT)) {
- if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
+ if (set_items.size()) {
+ undo_redo->create_action("GridMap Paint");
+ for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) {
- Point2 point = mb->get_position();
-
- Camera *camera = p_camera;
- Vector3 from = camera->project_ray_origin(point);
- Vector3 normal = camera->project_ray_normal(point);
- Transform local_xform = node->get_global_transform().affine_inverse();
- from = local_xform.xform(from);
- normal = local_xform.basis.xform(normal).normalized();
+ const SetItem &si = E->get();
+ undo_redo->add_do_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.new_value, si.new_orientation);
+ }
+ for (List<SetItem>::Element *E = set_items.back(); E; E = E->prev()) {
- List<int> areas;
- node->get_area_list(&areas);
+ const SetItem &si = E->get();
+ undo_redo->add_undo_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.old_value, si.old_orientation);
+ }
- float min_d = 1e10;
- int min_area = -1;
+ undo_redo->commit_action();
+ }
+ set_items.clear();
+ input_action = INPUT_NONE;
+ return true;
+ }
- for (List<int>::Element *E = areas.front(); E; E = E->next()) {
+ if (mb->get_button_index() == BUTTON_LEFT && input_action != INPUT_NONE) {
- int area = E->get();
- Rect3 aabb = node->area_get_bounds(area);
- aabb.position *= node->get_cell_size();
- aabb.size *= node->get_cell_size();
+ set_items.clear();
+ input_action = INPUT_NONE;
+ return true;
+ }
+ if (mb->get_button_index() == BUTTON_RIGHT && (input_action == INPUT_ERASE || input_action == INPUT_DUPLICATE)) {
+ input_action = INPUT_NONE;
+ return true;
+ }
+ }
+ }
- Vector3 rclip, rnormal;
- if (!aabb.intersects_segment(from, from + normal * 10000, &rclip, &rnormal))
- continue;
+ Ref<InputEventMouseMotion> mm = p_event;
- float d = normal.dot(rclip);
- if (d < min_d) {
- min_d = d;
- min_area = area;
- }
- }
+ if (mm.is_valid()) {
- selected_area = min_area;
- update_areas();
- }
- }
+ return do_input_action(p_camera, mm->get_position(), false);
}
return false;
@@ -749,52 +675,6 @@ void GridMapEditor::update_pallete() {
last_theme = theme.operator->();
}
-void GridMapEditor::_area_renamed() {
-
- TreeItem *it = area_list->get_selected();
- int area = it->get_metadata(0);
- if (area < 1)
- return;
- node->area_set_name(area, it->get_text(0));
-}
-
-void GridMapEditor::_area_selected() {
-
- TreeItem *it = area_list->get_selected();
- int area = it->get_metadata(0);
- if (area < 1)
- return;
- selected_area = area;
-}
-
-void GridMapEditor::update_areas() {
-
- area_list->clear();
-
- List<int> areas;
- node->get_area_list(&areas);
-
- TreeItem *root = area_list->create_item(NULL);
- area_list->set_hide_root(true);
- TreeItem *selected = NULL;
-
- for (List<int>::Element *E = areas.front(); E; E = E->next()) {
-
- int area = E->get();
- TreeItem *ti = area_list->create_item(root);
- String name = node->area_get_name(area);
-
- ti->set_metadata(0, area);
- ti->set_text(0, name);
- ti->set_editable(0, true);
- if (area == selected_area)
- selected = ti;
- }
-
- if (selected)
- selected->select(0);
-}
-
void GridMapEditor::edit(GridMap *p_gridmap) {
node = p_gridmap;
@@ -816,13 +696,10 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
VisualServer::get_singleton()->instance_set_visible(cursor_instance, false);
- _clear_areas();
-
return;
}
update_pallete();
- update_areas();
set_process(true);
@@ -894,7 +771,6 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
update_grid();
_update_clip();
- _update_areas_display();
}
void GridMapEditor::_update_clip() {
@@ -931,9 +807,6 @@ void GridMapEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
theme_pallete->connect("item_selected", this, "_item_selected_cbk");
- edit_mode->connect("item_selected", this, "_edit_mode_changed");
- area_list->connect("item_edited", this, "_area_renamed");
- area_list->connect("item_selected", this, "_area_selected");
for (int i = 0; i < 3; i++) {
grid[i] = VS::get_singleton()->mesh_create();
@@ -962,6 +835,9 @@ void GridMapEditor::_notification(int p_what) {
duplicate_instance = RID();
} else if (p_what == NOTIFICATION_PROCESS) {
+ if (!node) {
+ return;
+ }
Transform xf = node->get_global_transform();
@@ -1021,85 +897,6 @@ void GridMapEditor::_item_selected_cbk(int idx) {
_update_cursor_instance();
}
-void GridMapEditor::_clear_areas() {
-
- for (int i = 0; i < areas.size(); i++) {
-
- VisualServer::get_singleton()->free(areas[i].instance);
- VisualServer::get_singleton()->free(areas[i].mesh);
- }
-
- areas.clear();
-}
-
-void GridMapEditor::_update_areas_display() {
- if (!node) {
- return;
- }
-#if 0
- _clear_areas();
- List<int> areas;
- node->get_area_list(&areas);
-
- Transform global_xf = node->get_global_transform();
-
- for(List<int>::Element *E=areas.front();E;E=E->next()) {
-
- int area = E->get();
- Color color;
- if (node->area_is_exterior_portal(area))
- color=Color(1,1,1,0.2);
- else
- color.set_hsv(Math::fmod(area*0.37,1),Math::fmod(area*0.75,1),1.0,0.2);
-
-
- RID material = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_DIFFUSE,color );
- VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_EMISSION,0.5 );
- VisualServer::get_singleton()->fixed_material_set_flag( material, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
-
-
- RID mesh = VisualServer::get_singleton()->mesh_create();
-
- PoolVector<Plane> planes;
- for(int i=0;i<3;i++) {
-
- Vector3 axis;
- axis[i]=1.0;
- planes.push_back(Plane(axis,1));
- planes.push_back(Plane(-axis,0));
- }
-
- VisualServer::get_singleton()->mesh_add_surface_from_planes(mesh,planes);
- VisualServer::get_singleton()->mesh_surface_set_material(mesh,0,material,true);
-
- AreaDisplay ad;
- ad.mesh=mesh;
- ad.instance = VisualServer::get_singleton()->instance_create2(mesh,node->get_world()->get_scenario());
- Transform xform;
- Rect3 aabb = node->area_get_bounds(area);
- xform.origin=aabb.pos * node->get_cell_size();
- xform.basis.scale(aabb.size * node->get_cell_size());
- VisualServer::get_singleton()->instance_set_transform(ad.instance,global_xf * xform);
- this->areas.push_back(ad);
-
- }
-#endif
-}
-
-void GridMapEditor::_edit_mode_changed(int p_what) {
-
- if (p_what == 0) {
-
- theme_pallete->show();
- area_list->hide();
- } else {
-
- theme_pallete->hide();
- area_list->show();
- }
-}
-
void GridMapEditor::_floor_changed(float p_value) {
if (updating)
@@ -1116,9 +913,6 @@ void GridMapEditor::_bind_methods() {
ClassDB::bind_method("_menu_option", &GridMapEditor::_menu_option);
ClassDB::bind_method("_configure", &GridMapEditor::_configure);
ClassDB::bind_method("_item_selected_cbk", &GridMapEditor::_item_selected_cbk);
- ClassDB::bind_method("_edit_mode_changed", &GridMapEditor::_edit_mode_changed);
- ClassDB::bind_method("_area_renamed", &GridMapEditor::_area_renamed);
- ClassDB::bind_method("_area_selected", &GridMapEditor::_area_selected);
ClassDB::bind_method("_floor_changed", &GridMapEditor::_floor_changed);
ClassDB::bind_method(D_METHOD("_set_display_mode", "mode"), &GridMapEditor::_set_display_mode);
@@ -1198,15 +992,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
add_child(hb);
hb->set_h_size_flags(SIZE_EXPAND_FILL);
- edit_mode = memnew(OptionButton);
- edit_mode->set_area_as_parent_rect();
- edit_mode->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 24);
- edit_mode->set_margin(MARGIN_RIGHT, -14);
- edit_mode->add_item(TTR("Tiles"));
- edit_mode->add_item(TTR("Areas"));
- hb->add_child(edit_mode);
- edit_mode->set_h_size_flags(SIZE_EXPAND_FILL);
-
mode_thumbnail = memnew(ToolButton);
mode_thumbnail->set_toggle_mode(true);
mode_thumbnail->set_pressed(true);
@@ -1224,17 +1009,11 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
EDITOR_DEF("editors/grid_map/preview_size", 64);
display_mode = DISPLAY_THUMBNAIL;
- selected_area = -1;
theme_pallete = memnew(ItemList);
add_child(theme_pallete);
theme_pallete->set_v_size_flags(SIZE_EXPAND_FILL);
- area_list = memnew(Tree);
- add_child(area_list);
- area_list->set_v_size_flags(SIZE_EXPAND_FILL);
- area_list->hide();
-
spatial_editor_hb->add_child(memnew(VSeparator));
Label *fl = memnew(Label);
fl->set_text(" Floor: ");
@@ -1363,8 +1142,6 @@ GridMapEditor::~GridMapEditor() {
VisualServer::get_singleton()->free(duplicate_mesh);
if (duplicate_instance.is_valid())
VisualServer::get_singleton()->free(duplicate_instance);
-
- _clear_areas();
}
void GridMapEditorPlugin::edit(Object *p_object) {
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index a1b2c96ccd..6c7c0ab331 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -75,7 +75,6 @@ class GridMapEditor : public VBoxContainer {
Panel *panel;
MenuButton *options;
SpinBox *floor;
- OptionButton *edit_mode;
ToolButton *mode_thumbnail;
ToolButton *mode_list;
HBoxContainer *spatial_editor_hb;
@@ -137,7 +136,6 @@ class GridMapEditor : public VBoxContainer {
int display_mode;
int selected_pallete;
- int selected_area;
int cursor_rot;
enum Menu {
@@ -177,18 +175,12 @@ class GridMapEditor : public VBoxContainer {
RID instance;
};
- Vector<AreaDisplay> areas;
-
- void _update_areas_display();
- void _clear_areas();
-
void update_grid();
void _configure();
void _menu_option(int);
void update_pallete();
void _set_display_mode(int p_mode);
ItemList *theme_pallete;
- Tree *area_list;
void _item_selected_cbk(int idx);
void _update_cursor_transform();
void _update_cursor_instance();
@@ -199,14 +191,9 @@ class GridMapEditor : public VBoxContainer {
void _update_selection_transform();
void _validate_selection();
- void _edit_mode_changed(int p_what);
- void _area_renamed();
- void _area_selected();
-
void _floor_changed(float p_value);
void _delete_selection();
- void update_areas();
EditorNode *editor;
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp
index 5693195bfa..ffd9150ba4 100644
--- a/platform/android/java_class_wrapper.cpp
+++ b/platform/android/java_class_wrapper.cpp
@@ -112,7 +112,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
Ref<Reference> ref = *p_args[i];
if (!ref.is_null()) {
- if (Object::cast_to<JavaObject>(ref)) {
+ if (Object::cast_to<JavaObject>(ref.ptr())) {
Ref<JavaObject> jo = ref;
//could be faster
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index dbc3914410..008b3ab615 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -538,6 +538,8 @@ void OS_X11::finalize() {
physics_2d_server->finish();
memdelete(physics_2d_server);
+ memdelete(power_manager);
+
if (xrandr_handle)
dlclose(xrandr_handle);
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index d77dde1dd8..f79f7f6949 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -32,6 +32,7 @@
#include "scene/resources/surface_tool.h"
#include "servers/visual_server.h"
+#if 0
bool Portal::_set(const StringName &p_name, const Variant &p_value) {
if (p_name == "shape") {
@@ -226,3 +227,4 @@ Portal::~Portal() {
VisualServer::get_singleton()->free(portal);
}
+#endif
diff --git a/scene/3d/portal.h b/scene/3d/portal.h
index 7c25e4904b..9cc5d280a1 100644
--- a/scene/3d/portal.h
+++ b/scene/3d/portal.h
@@ -39,7 +39,8 @@
If a portal is placed next (very close to) a similar, opposing portal, they automatically connect,
otherwise, a portal connects to the parent room
*/
-
+//this will be redone and replaced by area portals, left for reference since a new class with this name will have to exist and want to reuse the gizmos
+#if 0
class Portal : public VisualInstance {
GDCLASS(Portal, VisualInstance);
@@ -85,3 +86,4 @@ public:
};
#endif
+#endif
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index 3e6a8d3c38..81ddf4a667 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -31,6 +31,7 @@
#include "servers/visual_server.h"
+#if 0
#include "geometry.h"
#include "project_settings.h"
#include "scene/resources/surface_tool.h"
@@ -158,3 +159,4 @@ Room::Room() {
Room::~Room() {
}
+#endif
diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h
index 4176da92e8..5b9886671f 100644
--- a/scene/3d/room_instance.h
+++ b/scene/3d/room_instance.h
@@ -44,6 +44,9 @@
*/
+//this will be removed, left for reference
+#if 0
+
class Room : public VisualInstance {
GDCLASS(Room, VisualInstance);
@@ -77,5 +80,5 @@ public:
Room();
~Room();
};
-
+#endif
#endif // ROOM_INSTANCE_H
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index 9e85a8a5b1..2c1ef5c00b 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -185,8 +185,13 @@ void Spatial::_notification(int p_what) {
get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
if (!data.gizmo_disabled) {
- if (data.gizmo.is_valid())
+ if (data.gizmo.is_valid()) {
data.gizmo->create();
+ if (data.gizmo->can_draw()) {
+ data.gizmo->redraw();
+ }
+ data.gizmo->transform();
+ }
}
}
#endif
@@ -449,7 +454,9 @@ void Spatial::set_gizmo(const Ref<SpatialGizmo> &p_gizmo) {
if (data.gizmo.is_valid() && is_inside_world()) {
data.gizmo->create();
- data.gizmo->redraw();
+ if (data.gizmo->can_draw()) {
+ data.gizmo->redraw();
+ }
data.gizmo->transform();
}
@@ -471,12 +478,16 @@ Ref<SpatialGizmo> Spatial::get_gizmo() const {
void Spatial::_update_gizmo() {
+ if (!is_inside_world())
+ return;
data.gizmo_dirty = false;
if (data.gizmo.is_valid()) {
- if (is_visible_in_tree())
- data.gizmo->redraw();
- else
- data.gizmo->clear();
+ if (data.gizmo->can_draw()) {
+ if (is_visible_in_tree())
+ data.gizmo->redraw();
+ else
+ data.gizmo->clear();
+ }
}
}
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index f22b19d3cc..3e647927ae 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -47,6 +47,7 @@ public:
virtual void clear() = 0;
virtual void redraw() = 0;
virtual void free() = 0;
+ virtual bool can_draw() const = 0;
SpatialGizmo();
};
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index b9e4488998..1ca6ec42d9 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -29,7 +29,6 @@
/*************************************************************************/
#include "visual_instance.h"
-#include "room_instance.h"
#include "scene/scene_string_names.h"
#include "servers/visual_server.h"
#include "skeleton.h"
@@ -54,29 +53,6 @@ void VisualInstance::_notification(int p_what) {
case NOTIFICATION_ENTER_WORLD: {
- // CHECK ROOM
- Spatial *parent = get_parent_spatial();
- Room *room = NULL;
- bool is_geom = Object::cast_to<GeometryInstance>(this);
-
- /* while(parent) {
-
- room = Object::cast_to<Room>(parent);
- if (room)
- break;
-
- if (is_geom && Object::cast_to<BakedLightSampler>(parent)) {
- VS::get_singleton()->instance_geometry_set_baked_light_sampler(get_instance(),Object::cast_to<BakedLightSampler>(parent)->get_instance());
- break;
- }
-
- parent=parent->get_parent_spatial();
- }*/
-
- if (room) {
-
- VisualServer::get_singleton()->instance_set_room(instance, room->get_instance());
- }
// CHECK SKELETON => moving skeleton attaching logic to MeshInstance
/*
Skeleton *skeleton=Object::cast_to<Skeleton>(get_parent());
@@ -96,7 +72,6 @@ void VisualInstance::_notification(int p_what) {
case NOTIFICATION_EXIT_WORLD: {
VisualServer::get_singleton()->instance_set_scenario(instance, RID());
- VisualServer::get_singleton()->instance_set_room(instance, RID());
VisualServer::get_singleton()->instance_attach_skeleton(instance, RID());
//VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
@@ -303,7 +278,6 @@ void GeometryInstance::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_override", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial"), "set_material_override", "get_material_override");
ADD_PROPERTY(PropertyInfo(Variant::INT, "cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), "set_cast_shadows_setting", "get_cast_shadows_setting");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "extra_cull_margin", PROPERTY_HINT_RANGE, "0,16384,0"), "set_extra_cull_margin", "get_extra_cull_margin");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "visible_in_all_rooms"), "set_flag", "get_flag", FLAG_VISIBLE_IN_ALL_ROOMS);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "use_in_baked_light"), "set_flag", "get_flag", FLAG_USE_BAKED_LIGHT);
ADD_GROUP("LOD", "lod_");
@@ -314,7 +288,6 @@ void GeometryInstance::_bind_methods() {
//ADD_SIGNAL( MethodInfo("visibility_changed"));
- BIND_CONSTANT(FLAG_VISIBLE_IN_ALL_ROOMS);
BIND_CONSTANT(FLAG_MAX);
BIND_CONSTANT(SHADOW_CASTING_SETTING_OFF);
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index 694d0c2499..4751d109e6 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -84,7 +84,6 @@ class GeometryInstance : public VisualInstance {
public:
enum Flags {
- FLAG_VISIBLE_IN_ALL_ROOMS = VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS,
FLAG_USE_BAKED_LIGHT = VS::INSTANCE_FLAG_USE_BAKED_LIGHT,
FLAG_MAX = VS::INSTANCE_FLAG_MAX,
};
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 2c50b4e854..e506953d77 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2115,14 +2115,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
//keep indentation
int space_count = 0;
for (int i = 0; i < text[cursor.line].length(); i++) {
- if (text[cursor.line][i] == '\t') {
+ if (text[cursor.line][i] == '\t' && cursor.column > 0) {
if (indent_using_spaces) {
ins += space_indent;
} else {
ins += "\t";
}
space_count = 0;
- } else if (text[cursor.line][i] == ' ') {
+ } else if (text[cursor.line][i] == ' ' && cursor.column > 0) {
space_count++;
if (space_count == indent_size) {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 20bf818d44..38cd425a89 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2473,22 +2473,24 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
Point2 pos = b->get_position() - bg->get_offset();
cache.click_type = Cache::CLICK_NONE;
- if (show_column_titles && b->get_button_index() == BUTTON_LEFT) {
+ if (show_column_titles) {
pos.y -= _get_title_button_height();
if (pos.y < 0) {
- pos.x += cache.offset.x;
- int len = 0;
- for (int i = 0; i < columns.size(); i++) {
-
- len += get_column_width(i);
- if (pos.x < len) {
-
- cache.click_type = Cache::CLICK_TITLE;
- cache.click_index = i;
- //cache.click_id=;
- update();
- break;
+ if (b->get_button_index() == BUTTON_LEFT) {
+ pos.x += cache.offset.x;
+ int len = 0;
+ for (int i = 0; i < columns.size(); i++) {
+
+ len += get_column_width(i);
+ if (pos.x < len) {
+
+ cache.click_type = Cache::CLICK_TITLE;
+ cache.click_index = i;
+ //cache.click_id=;
+ update();
+ break;
+ }
}
}
break;
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 66d3ad22f1..adc52c501a 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -1353,20 +1353,24 @@ void Node::_add_child_nocheck(Node *p_child, const StringName &p_name) {
void Node::add_child(Node *p_child, bool p_legible_unique_name) {
ERR_FAIL_NULL(p_child);
- /* Fail if node has a parent */
+
if (p_child == this) {
- ERR_EXPLAIN("Can't add child " + p_child->get_name() + " to itself.")
+ ERR_EXPLAIN("Can't add child '" + p_child->get_name() + "' to itself.")
ERR_FAIL_COND(p_child == this); // adding to itself!
}
- ERR_EXPLAIN("Can't add child, already has a parent");
- ERR_FAIL_COND(p_child->data.parent);
+
+ /* Fail if node has a parent */
+ if (p_child->data.parent) {
+ ERR_EXPLAIN("Can't add child '" + p_child->get_name() + "' to '" + get_name() + "', already has a parent '" + p_child->data.parent->get_name() + "'.");
+ ERR_FAIL_COND(p_child->data.parent);
+ }
if (data.blocked > 0) {
- ERR_EXPLAIN("Parent node is busy setting up children, add_node() failed. Consider using call_deferred(\"add_child\",child) instead.");
+ ERR_EXPLAIN("Parent node is busy setting up children, add_node() failed. Consider using call_deferred(\"add_child\", child) instead.");
ERR_FAIL_COND(data.blocked > 0);
}
- ERR_EXPLAIN("Can't add child while a notification is happening");
+ ERR_EXPLAIN("Can't add child while a notification is happening.");
ERR_FAIL_COND(data.blocked > 0);
/* Validate name */
@@ -1381,7 +1385,7 @@ void Node::add_child_below_node(Node *p_node, Node *p_child, bool p_legible_uniq
if (is_a_parent_of(p_node)) {
move_child(p_child, p_node->get_position_in_parent() + 1);
} else {
- WARN_PRINTS("Cannot move under node " + p_node->get_name() + " as " + p_child->get_name() + " does not share a parent")
+ WARN_PRINTS("Cannot move under node " + p_node->get_name() + " as " + p_child->get_name() + " does not share a parent.")
}
}
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 03a604734e..33331a465f 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -1401,8 +1401,11 @@ void SceneTree::_live_edit_create_node_func(const NodePath &p_parent, const Stri
Node *n2 = n->get_node(p_parent);
Node *no = Object::cast_to<Node>(ClassDB::instance(p_type));
- no->set_name(p_name);
+ if (!no) {
+ continue;
+ }
+ no->set_name(p_name);
n2->add_child(no);
}
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 0661b10184..b4eabaa540 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -395,7 +395,7 @@ void Viewport::_notification(int p_what) {
contact_3d_debug_instance = VisualServer::get_singleton()->instance_create();
VisualServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh);
VisualServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world()->get_scenario());
- VisualServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true);
+ //VisualServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true);
}
VS::get_singleton()->viewport_set_active(viewport, true);
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 3e6d80d314..283514dd53 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -28,21 +28,44 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_scene_types.h"
-#include "os/os.h"
-#include "project_settings.h"
-#include "scene/io/resource_format_image.h"
-#include "scene/io/resource_format_wav.h"
-//#include "scene/io/scene_format_script.h"
-#include "class_db.h"
-#include "resources/default_theme/default_theme.h"
+#include "core/class_db.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
+#include "scene/2d/animated_sprite.h"
+#include "scene/2d/area_2d.h"
+#include "scene/2d/audio_stream_player_2d.h"
+#include "scene/2d/back_buffer_copy.h"
+#include "scene/2d/camera_2d.h"
+#include "scene/2d/canvas_item.h"
+#include "scene/2d/canvas_modulate.h"
+#include "scene/2d/collision_polygon_2d.h"
+#include "scene/2d/collision_shape_2d.h"
+#include "scene/2d/joints_2d.h"
#include "scene/2d/light_2d.h"
#include "scene/2d/light_occluder_2d.h"
+#include "scene/2d/line_2d.h"
+#include "scene/2d/navigation2d.h"
+#include "scene/2d/parallax_background.h"
+#include "scene/2d/parallax_layer.h"
#include "scene/2d/particles_2d.h"
#include "scene/2d/path_2d.h"
+#include "scene/2d/physics_body_2d.h"
+#include "scene/2d/polygon_2d.h"
+#include "scene/2d/position_2d.h"
+#include "scene/2d/ray_cast_2d.h"
+#include "scene/2d/remote_transform_2d.h"
+#include "scene/2d/screen_button.h"
+#include "scene/2d/sprite.h"
+#include "scene/2d/tile_map.h"
+#include "scene/2d/visibility_notifier_2d.h"
+#include "scene/2d/y_sort.h"
+#include "scene/animation/animation_player.h"
+#include "scene/animation/animation_tree_player.h"
+#include "scene/animation/tween.h"
+#include "scene/audio/audio_player.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
-
#include "scene/gui/button_group.h"
#include "scene/gui/center_container.h"
#include "scene/gui/check_box.h"
@@ -85,157 +108,90 @@
#include "scene/gui/tree.h"
#include "scene/gui/video_player.h"
#include "scene/gui/viewport_container.h"
+#include "scene/io/resource_format_image.h"
+#include "scene/io/resource_format_wav.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/http_request.h"
#include "scene/main/instance_placeholder.h"
-#include "scene/main/viewport.h"
-#include "scene/resources/audio_stream_sample.h"
-#include "scene/resources/video_stream.h"
-
-#include "scene/2d/animated_sprite.h"
-#include "scene/2d/back_buffer_copy.h"
-#include "scene/2d/canvas_item.h"
-#include "scene/2d/polygon_2d.h"
-#include "scene/2d/sprite.h"
-
-#include "scene/2d/visibility_notifier_2d.h"
-
-#include "scene/2d/area_2d.h"
-#include "scene/2d/camera_2d.h"
-#include "scene/2d/collision_polygon_2d.h"
-#include "scene/2d/collision_shape_2d.h"
-#include "scene/2d/joints_2d.h"
-#include "scene/2d/parallax_background.h"
-#include "scene/2d/parallax_layer.h"
-#include "scene/2d/physics_body_2d.h"
-#include "scene/2d/ray_cast_2d.h"
-//#include "scene/2d/sound_player_2d.h"
-//#include "scene/2d/sample_player_2d.h"
-#include "scene/2d/audio_stream_player_2d.h"
-#include "scene/2d/canvas_modulate.h"
-#include "scene/2d/navigation2d.h"
-#include "scene/2d/remote_transform_2d.h"
-#include "scene/2d/screen_button.h"
-#include "scene/2d/y_sort.h"
-
-#include "scene/2d/position_2d.h"
-#include "scene/2d/tile_map.h"
-//#include "scene/2d/tile_map.h"
-#include "scene/2d/line_2d.h"
-
-#include "scene/resources/tile_set.h"
-
-#include "scene/animation/animation_player.h"
-#include "scene/animation/animation_tree_player.h"
-#include "scene/animation/tween.h"
#include "scene/main/resource_preloader.h"
#include "scene/main/scene_tree.h"
-#include "scene/resources/packed_scene.h"
-
-#include "scene/resources/mesh_data_tool.h"
-#include "scene/resources/surface_tool.h"
-
-#include "scene/resources/dynamic_font.h"
-#include "scene/resources/dynamic_font_stb.h"
-
#include "scene/main/timer.h"
-
-#include "scene/audio/audio_player.h"
-//#include "scene/audio/event_player.h"
-//#include "scene/audio/sound_room_params.h"
+#include "scene/main/viewport.h"
+#include "scene/resources/audio_stream_sample.h"
+#include "scene/resources/bit_mask.h"
#include "scene/resources/box_shape.h"
#include "scene/resources/capsule_shape.h"
-#include "scene/resources/concave_polygon_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
-#include "scene/resources/plane_shape.h"
-#include "scene/resources/ray_shape.h"
-#include "scene/resources/sphere_shape.h"
-
#include "scene/resources/capsule_shape_2d.h"
#include "scene/resources/circle_shape_2d.h"
+#include "scene/resources/color_ramp.h"
+#include "scene/resources/concave_polygon_shape.h"
#include "scene/resources/concave_polygon_shape_2d.h"
+#include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/convex_polygon_shape_2d.h"
+#include "scene/resources/default_theme/default_theme.h"
+#include "scene/resources/dynamic_font.h"
+#include "scene/resources/dynamic_font_stb.h"
+#include "scene/resources/material.h"
+#include "scene/resources/mesh.h"
+#include "scene/resources/mesh_data_tool.h"
+#include "scene/resources/mesh_library.h"
+#include "scene/resources/packed_scene.h"
+#include "scene/resources/plane_shape.h"
+#include "scene/resources/polygon_path_finder.h"
+#include "scene/resources/primitive_meshes.h"
+#include "scene/resources/ray_shape.h"
#include "scene/resources/rectangle_shape_2d.h"
+#include "scene/resources/scene_format_text.h"
#include "scene/resources/segment_shape_2d.h"
+#include "scene/resources/shader_graph.h"
#include "scene/resources/shape_line_2d.h"
-
-#include "scene/resources/mesh_library.h"
-
-#include "scene/resources/polygon_path_finder.h"
-
-//#include "scene/resources/sample.h"
-#include "scene/3d/audio_stream_player_3d.h"
-#include "scene/resources/material.h"
-#include "scene/resources/mesh.h"
-#include "scene/resources/room.h"
#include "scene/resources/sky_box.h"
+#include "scene/resources/sphere_shape.h"
+#include "scene/resources/surface_tool.h"
#include "scene/resources/texture.h"
-
-#include "scene/resources/primitive_meshes.h"
-
-#include "scene/resources/shader_graph.h"
-
+#include "scene/resources/tile_set.h"
+#include "scene/resources/video_stream.h"
#include "scene/resources/world.h"
#include "scene/resources/world_2d.h"
-
-//#include "scene/resources/sample_library.h"
-//#include "scene/resources/audio_stream.h"
-#include "scene/resources/bit_mask.h"
-#include "scene/resources/color_ramp.h"
-#include "scene/resources/gibberish_stream.h"
#include "scene/scene_string_names.h"
-#include "scene/3d/bone_attachment.h"
-#include "scene/3d/path.h"
-#include "scene/3d/remote_transform.h"
-#include "scene/3d/room_instance.h"
-#include "scene/3d/scenario_fx.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/spatial.h"
-
-#include "scene/3d/visibility_notifier.h"
-
#ifndef _3D_DISABLED
-#include "scene/3d/camera.h"
-#include "scene/3d/listener.h"
-
+#include "scene/3d/area.h"
#include "scene/3d/arvr_nodes.h"
-
+#include "scene/3d/audio_stream_player_3d.h"
+#include "scene/3d/bone_attachment.h"
+#include "scene/3d/camera.h"
+#include "scene/3d/collision_polygon.h"
+#include "scene/3d/collision_shape.h"
#include "scene/3d/gi_probe.h"
+#include "scene/3d/immediate_geometry.h"
#include "scene/3d/interpolated_camera.h"
#include "scene/3d/light.h"
+#include "scene/3d/listener.h"
#include "scene/3d/mesh_instance.h"
+#include "scene/3d/multimesh_instance.h"
+#include "scene/3d/navigation.h"
+#include "scene/3d/navigation_mesh.h"
#include "scene/3d/particles.h"
+#include "scene/3d/path.h"
#include "scene/3d/physics_body.h"
+#include "scene/3d/physics_joint.h"
#include "scene/3d/portal.h"
#include "scene/3d/position_3d.h"
-#include "scene/3d/reflection_probe.h"
-#include "scene/resources/environment.h"
-
-#include "scene/3d/area.h"
-
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/immediate_geometry.h"
-#include "scene/3d/multimesh_instance.h"
-#include "scene/3d/physics_joint.h"
+#include "scene/3d/proximity_group.h"
#include "scene/3d/ray_cast.h"
+#include "scene/3d/reflection_probe.h"
+#include "scene/3d/remote_transform.h"
+#include "scene/3d/room_instance.h"
+#include "scene/3d/scenario_fx.h"
+#include "scene/3d/skeleton.h"
+#include "scene/3d/spatial.h"
#include "scene/3d/sprite_3d.h"
#include "scene/3d/vehicle_body.h"
-//#include "scene/3d/spatial_sample_player.h"
-//#include "scene/3d/spatial_stream_player.h"
-#include "scene/3d/collision_polygon.h"
-#include "scene/3d/navigation.h"
-#include "scene/3d/navigation_mesh.h"
-#include "scene/3d/proximity_group.h"
+#include "scene/3d/visibility_notifier.h"
+#include "scene/resources/environment.h"
#endif
-#include "scene/resources/scene_format_text.h"
-
-//static ResourceFormatLoaderWAV *resource_loader_wav=NULL;
-
-#ifdef TOOLS_ENABLED
-
-#endif
static ResourceFormatLoaderTheme *resource_loader_theme = NULL;
static ResourceFormatSaverText *resource_saver_text = NULL;
@@ -245,8 +201,6 @@ static ResourceFormatLoaderDynamicFont *resource_loader_dynamic_font = NULL;
static ResourceFormatLoaderStreamTexture *resource_loader_stream_texture = NULL;
-//static SceneStringNames *string_names;
-
void register_scene_types() {
SceneStringNames::create();
@@ -255,20 +209,12 @@ void register_scene_types() {
Node::init_node_hrcr();
- //resource_loader_wav = memnew( ResourceFormatLoaderWAV );
- //ResourceLoader::add_resource_format_loader( resource_loader_wav );
resource_loader_dynamic_font = memnew(ResourceFormatLoaderDynamicFont);
ResourceLoader::add_resource_format_loader(resource_loader_dynamic_font);
resource_loader_stream_texture = memnew(ResourceFormatLoaderStreamTexture);
ResourceLoader::add_resource_format_loader(resource_loader_stream_texture);
-#ifdef TOOLS_ENABLED
-
-//scene first!
-
-#endif
-
resource_loader_theme = memnew(ResourceFormatLoaderTheme);
ResourceLoader::add_resource_format_loader(resource_loader_theme);
@@ -316,7 +262,6 @@ void register_scene_types() {
ClassDB::register_class<ShortCut>();
ClassDB::register_class<Control>();
- //ClassDB::register_type<EmptyControl>();
ClassDB::register_class<Button>();
ClassDB::register_class<Label>();
ClassDB::register_class<HScrollBar>();
@@ -424,7 +369,6 @@ void register_scene_types() {
ClassDB::register_class<GIProbe>();
ClassDB::register_class<GIProbeData>();
ClassDB::register_class<AnimationTreePlayer>();
- ClassDB::register_class<Portal>();
ClassDB::register_class<Particles>();
ClassDB::register_class<Position3D>();
ClassDB::register_class<NavigationMeshInstance>();
@@ -446,14 +390,12 @@ void register_scene_types() {
ClassDB::register_class<CollisionPolygon>();
ClassDB::register_class<RayCast>();
ClassDB::register_class<MultiMeshInstance>();
- ClassDB::register_class<Room>();
+
ClassDB::register_class<Curve3D>();
ClassDB::register_class<Path>();
ClassDB::register_class<PathFollow>();
ClassDB::register_class<VisibilityNotifier>();
ClassDB::register_class<VisibilityEnabler>();
- // ClassDB::register_class<BakedLight>();
- //ClassDB::register_type<BakedLightSampler>();
ClassDB::register_class<WorldEnvironment>();
ClassDB::register_class<RemoteTransform>();
@@ -464,8 +406,6 @@ void register_scene_types() {
ClassDB::register_class<ConeTwistJoint>();
ClassDB::register_class<Generic6DOFJoint>();
- //scenariofx
-
OS::get_singleton()->yield(); //may take time to init
#endif
@@ -545,8 +485,6 @@ void register_scene_types() {
SceneTree::add_idle_callback(ParticlesMaterial::flush_changes);
ParticlesMaterial::init_shaders();
- //ClassDB::register_type<ShaderMaterial>();
- ClassDB::register_class<RoomBounds>();
ClassDB::register_class<MultiMesh>();
ClassDB::register_class<MeshLibrary>();
@@ -562,7 +500,6 @@ void register_scene_types() {
ClassDB::register_class<SurfaceTool>();
ClassDB::register_class<MeshDataTool>();
- //ClassDB::register_type<BakedLight>();
OS::get_singleton()->yield(); //may take time to init
@@ -661,14 +598,8 @@ void unregister_scene_types() {
clear_default_theme();
- // memdelete( resource_loader_wav );
memdelete(resource_loader_dynamic_font);
memdelete(resource_loader_stream_texture);
-
-#ifdef TOOLS_ENABLED
-
-#endif
-
memdelete(resource_loader_theme);
if (resource_saver_text) {
diff --git a/scene/resources/gibberish_stream.cpp b/scene/resources/gibberish_stream.cpp
deleted file mode 100644
index e2994f1419..0000000000
--- a/scene/resources/gibberish_stream.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-/*************************************************************************/
-/* gibberish_stream.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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 "gibberish_stream.h"
-#include "servers/audio_server.h"
-
-//TODO: This class needs to be adapted to the new AudioStream API,
-// or dropped if nobody cares about fixing it :) (GH-3307)
-
-#if 0
-
-int AudioStreamGibberish::get_channel_count() const {
-
- return 1;
-}
-
-
-static float _get_vol_at_pos(int p_pos, int p_len, int p_x_fade) {
-
- if (p_pos < p_x_fade)
- return float(p_pos)/p_x_fade;
- else if (p_pos>(p_len-p_x_fade))
- return float(p_len-p_pos)/p_x_fade;
- else
- return 1.0;
-
-}
- int AudioStreamGibberish::randomize() {
-
- if (rand_idx==_rand_pool.size()) {
-
- for(int i=0;i<_rand_pool.size();i++) {
-
- SWAP(_rand_pool[i],_rand_pool[Math::rand()%_rand_pool.size()]);
- }
- rand_idx=0;
- }
-
- return _rand_pool[rand_idx++];
-}
-
-bool AudioStreamGibberish::mix(int32_t *p_buffer, int p_frames) {
-
- if (!active)
- return false;
-
- zeromem(p_buffer,p_frames*sizeof(int32_t));
-
- if (!paused && active_voices==0) {
-
- active_voices=1;
- playback[0].idx=randomize();
- playback[0].fp_pos=0;
- playback[0].scale=Math::random(1,1+pitch_random_scale);
- }
-
- for(int i=0;i<active_voices;i++) {
-
- RID s = _samples[playback[i].idx]->get_rid();
-
- uint64_t fp_pos=playback[i].fp_pos;
- const void *data = AudioServer::get_singleton()->sample_get_data_ptr(s);
- bool is16 = AudioServer::get_singleton()->sample_get_format(s)==AudioServer::SAMPLE_FORMAT_PCM16;
- int skip = AudioServer::get_singleton()->sample_is_stereo(s) ? 1: 0;
- uint64_t max = AudioServer::get_singleton()->sample_get_length(s) * uint64_t(FP_LEN);
- int mrate = AudioServer::get_singleton()->sample_get_mix_rate(s) * pitch_scale * playback[i].scale;
- uint64_t increment = uint64_t(mrate) * uint64_t(FP_LEN) / get_mix_rate();
-
-
- float vol_begin = _get_vol_at_pos(fp_pos>>FP_BITS,max>>FP_BITS,xfade_time*mrate);
- float vol_end = _get_vol_at_pos((fp_pos+p_frames*increment)>>FP_BITS,max>>FP_BITS,xfade_time*mrate);
-
- int32_t vol = CLAMP(int32_t(vol_begin * 65535),0,65535);
- int32_t vol_to = CLAMP(int32_t(vol_end * 65535),0,65535);
- int32_t vol_inc = (vol_to-vol)/p_frames;
-
- bool done=false;
-
- if (is16) {
-
- const int16_t *smp = (int16_t*)data;
- for(int i=0;i<p_frames;i++) {
-
- if (fp_pos >= max) {
- done=true;
- break;
- }
-
- int idx = (fp_pos>>FP_BITS)<<skip;
- p_buffer[i]+=int32_t(smp[idx])*vol;
- vol+=vol_inc;
-
- fp_pos+=increment;
- }
- } else {
-
- const int8_t *smp = (int8_t*)data;
- for(int i=0;i<p_frames;i++) {
-
- if (fp_pos >= max) {
- done=true;
- break;
- }
-
- int idx = (fp_pos>>FP_BITS)<<skip;
- p_buffer[i]+=(int32_t(smp[idx])<<8)*vol;
- vol+=vol_inc;
- fp_pos+=increment;
- }
-
- }
-
- playback[i].fp_pos=fp_pos;
- if (!paused && active_voices==1 && (vol_end < vol_begin || done)) {
- //xfade to something else i gues
- active_voices=2;
- playback[1].idx=randomize();
- playback[1].fp_pos=0;
- playback[1].scale=Math::random(1,1+pitch_random_scale);
- }
-
- if (done) {
-
- if (i==0 && active_voices==2) {
- playback[0]=playback[1];
- i--;
- }
- active_voices--;
-
- }
- }
-
- return true;
-}
-
-
-void AudioStreamGibberish::play() {
- if (active)
- stop();
-
-
- if (!phonemes.is_valid())
- return;
-
-
- List<StringName> slist;
- phonemes->get_sample_list(&slist);
- if (slist.size()==0)
- return;
-
- _samples.resize(slist.size());
- _rand_pool.resize(slist.size());
-
- int i=0;
- for(List<StringName>::Element *E=slist.front();E;E=E->next()) {
-
- _rand_pool[i]=i;
- _samples[i++]=phonemes->get_sample(E->get());
- }
-
- rand_idx=0;
- active_voices=0;
- active=true;
-}
-
-void AudioStreamGibberish::stop(){
-
- active=false;
-
-
-}
-
-bool AudioStreamGibberish::is_playing() const {
-
- return active;
-}
-
-
-void AudioStreamGibberish::set_paused(bool p_paused){
-
- paused=p_paused;
-}
-
-bool AudioStreamGibberish::is_paused(bool p_paused) const{
-
- return paused;
-}
-
-void AudioStreamGibberish::set_loop(bool p_enable){
-
-
-}
-
-bool AudioStreamGibberish::has_loop() const{
-
- return false;
-}
-
-
-float AudioStreamGibberish::get_length() const{
-
- return 0;
-}
-
-
-String AudioStreamGibberish::get_stream_name() const{
-
- return "Gibberish";
-}
-
-
-int AudioStreamGibberish::get_loop_count() const{
-
- return 0;
-}
-
-
-float AudioStreamGibberish::get_pos() const{
-
- return 0;
-}
-
-void AudioStreamGibberish::seek_pos(float p_time){
-
-
-}
-
-
-AudioStream::UpdateMode AudioStreamGibberish::get_update_mode() const{
-
- return AudioStream::UPDATE_NONE;
-}
-
-void AudioStreamGibberish::update(){
-
-
-}
-
-
-void AudioStreamGibberish::set_phonemes(const Ref<SampleLibrary>& p_phonemes) {
-
- phonemes=p_phonemes;
-
-}
-
-Ref<SampleLibrary> AudioStreamGibberish::get_phonemes() const {
-
- return phonemes;
-}
-
-void AudioStreamGibberish::set_xfade_time(float p_xfade) {
-
- xfade_time=p_xfade;
-}
-
-float AudioStreamGibberish::get_xfade_time() const {
-
- return xfade_time;
-}
-
-void AudioStreamGibberish::set_pitch_scale(float p_scale) {
-
- pitch_scale=p_scale;
-}
-
-float AudioStreamGibberish::get_pitch_scale() const {
-
- return pitch_scale;
-}
-
-void AudioStreamGibberish::set_pitch_random_scale(float p_random_scale) {
-
- pitch_random_scale=p_random_scale;
-}
-
-float AudioStreamGibberish::get_pitch_random_scale() const {
-
- return pitch_random_scale;
-}
-
-void AudioStreamGibberish::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_phonemes","phonemes"),&AudioStreamGibberish::set_phonemes);
- ClassDB::bind_method(D_METHOD("get_phonemes"),&AudioStreamGibberish::get_phonemes);
-
- ClassDB::bind_method(D_METHOD("set_pitch_scale","pitch_scale"),&AudioStreamGibberish::set_pitch_scale);
- ClassDB::bind_method(D_METHOD("get_pitch_scale"),&AudioStreamGibberish::get_pitch_scale);
-
- ClassDB::bind_method(D_METHOD("set_pitch_random_scale","pitch_random_scale"),&AudioStreamGibberish::set_pitch_random_scale);
- ClassDB::bind_method(D_METHOD("get_pitch_random_scale"),&AudioStreamGibberish::get_pitch_random_scale);
-
- ClassDB::bind_method(D_METHOD("set_xfade_time","sec"),&AudioStreamGibberish::set_xfade_time);
- ClassDB::bind_method(D_METHOD("get_xfade_time"),&AudioStreamGibberish::get_xfade_time);
-
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"phonemes",PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),"set_phonemes","get_phonemes");
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"pitch_scale",PROPERTY_HINT_RANGE,"0.01,64,0.01"),"set_pitch_scale","get_pitch_scale");
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"pitch_random_scale",PROPERTY_HINT_RANGE,"0,64,0.01"),"set_pitch_random_scale","get_pitch_random_scale");
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"xfade_sec",PROPERTY_HINT_RANGE,"0.001,0.5,0.001"),"set_xfade_time","get_xfade_time");
-
-}
-
-AudioStreamGibberish::AudioStreamGibberish() {
-
- xfade_time=0.1;
- pitch_scale=1;
- pitch_random_scale=0;
- active=false;
- paused=false;
- active_voices=0;
-}
-#endif
diff --git a/scene/resources/gibberish_stream.h b/scene/resources/gibberish_stream.h
deleted file mode 100644
index ebe61382eb..0000000000
--- a/scene/resources/gibberish_stream.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*************************************************************************/
-/* gibberish_stream.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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 GIBBERISH_STREAM_H
-#define GIBBERISH_STREAM_H
-
-//TODO: This class needs to be adapted to the new AudioStream API,
-// or dropped if nobody cares about fixing it :) (GH-3307)
-
-#if 0
-#include "scene/resources/audio_stream.h"
-#include "scene/resources/sample_library.h"
-class AudioStreamGibberish : public AudioStream {
-
- GDCLASS( AudioStreamGibberish, AudioStream );
-
- enum {
-
- FP_BITS = 12,
- FP_LEN = (1<<12),
- };
- bool active;
- bool paused;
-
- float xfade_time;
- float pitch_scale;
- float pitch_random_scale;
- Vector<Ref<Sample> > _samples;
- Vector<int> _rand_pool;
- int rand_idx;
- _FORCE_INLINE_ int randomize();
-
- struct Playback {
-
- int idx;
- uint64_t fp_pos;
- float scale;
- };
-
- Playback playback[2];
- int active_voices;
-
- Ref<SampleLibrary> phonemes;
-protected:
-
- virtual int get_channel_count() const;
- virtual bool mix(int32_t *p_buffer, int p_frames);
-
- static void _bind_methods();
-
-public:
-
- void set_phonemes(const Ref<SampleLibrary>& p_phonemes);
- Ref<SampleLibrary> get_phonemes() const;
-
- virtual void play();
- virtual void stop();
- virtual bool is_playing() const;
-
- virtual void set_paused(bool p_paused);
- virtual bool is_paused(bool p_paused) const;
-
- virtual void set_loop(bool p_enable);
- virtual bool has_loop() const;
-
- virtual float get_length() const;
-
- virtual String get_stream_name() const;
-
- virtual int get_loop_count() const;
-
- virtual float get_pos() const;
- virtual void seek_pos(float p_time);
-
- virtual UpdateMode get_update_mode() const;
- virtual void update();
-
- void set_xfade_time(float p_xfade);
- float get_xfade_time() const;
-
- void set_pitch_scale(float p_scale);
- float get_pitch_scale() const;
-
- void set_pitch_random_scale(float p_random_scale);
- float get_pitch_random_scale() const;
-
- AudioStreamGibberish();
-};
-
-#endif
-
-#endif // GIBBERISH_STREAM_H
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 555c94a512..f01d9f841b 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "material.h"
+
#include "scene/scene_string_names.h"
void Material::set_next_pass(const Ref<Material> &p_pass) {
diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp
index c89b7c72c7..de238ebcc0 100644
--- a/scene/resources/room.cpp
+++ b/scene/resources/room.cpp
@@ -30,7 +30,7 @@
#include "room.h"
#include "servers/visual_server.h"
-
+#if 0
RID RoomBounds::get_rid() const {
return area;
@@ -64,3 +64,4 @@ RoomBounds::~RoomBounds() {
VisualServer::get_singleton()->free(area);
}
+#endif
diff --git a/scene/resources/room.h b/scene/resources/room.h
index ba5c0eee1c..4b8c837458 100644
--- a/scene/resources/room.h
+++ b/scene/resources/room.h
@@ -36,6 +36,9 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
+//left for reference but will be removed when portals are reimplemented using Area
+#if 0
+
class RoomBounds : public Resource {
GDCLASS(RoomBounds, Resource);
@@ -57,4 +60,5 @@ public:
~RoomBounds();
};
+#endif
#endif // ROOM_H
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 3b4ba313e6..a75ce1cf35 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -376,23 +376,6 @@ public:
virtual float reflection_probe_get_origin_max_distance(RID p_probe) const = 0;
virtual bool reflection_probe_renders_shadows(RID p_probe) const = 0;
- /* ROOM API */
-
- virtual RID room_create() = 0;
- virtual void room_add_bounds(RID p_room, const PoolVector<Vector2> &p_convex_polygon, float p_height, const Transform &p_transform) = 0;
- virtual void room_clear_bounds(RID p_room) = 0;
-
- /* PORTAL API */
-
- // portals are only (x/y) points, forming a convex shape, which its clockwise
- // order points outside. (z is 0)=0;
-
- virtual RID portal_create() = 0;
- virtual void portal_set_shape(RID p_portal, const Vector<Point2> &p_shape) = 0;
- virtual void portal_set_enabled(RID p_portal, bool p_enabled) = 0;
- virtual void portal_set_disable_distance(RID p_portal, float p_distance) = 0;
- virtual void portal_set_disabled_color(RID p_portal, const Color &p_color) = 0;
-
virtual void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) = 0;
virtual void instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) = 0;
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index fff37a71b3..70492afe83 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -811,23 +811,6 @@ public:
BIND2(reflection_probe_set_enable_shadows, RID, bool)
BIND2(reflection_probe_set_cull_mask, RID, uint32_t)
- /* ROOM API */
-
- BIND0R(RID, room_create)
- BIND4(room_add_bounds, RID, const PoolVector<Vector2> &, float, const Transform &)
- BIND1(room_clear_bounds, RID)
-
- /* PORTAL API */
-
- // portals are only (x/y) points, forming a convex shape, which its clockwise
- // order points outside. (z is 0);
-
- BIND0R(RID, portal_create)
- BIND2(portal_set_shape, RID, const Vector<Point2> &)
- BIND2(portal_set_enabled, RID, bool)
- BIND2(portal_set_disable_distance, RID, float)
- BIND2(portal_set_disabled_color, RID, const Color &)
-
/* BAKED LIGHT API */
BIND0R(RID, gi_probe_create)
@@ -1011,7 +994,6 @@ public:
BIND2(instance_attach_skeleton, RID, RID)
BIND2(instance_set_exterior, RID, bool)
- BIND2(instance_set_room, RID, RID)
BIND2(instance_set_extra_visibility_margin, RID, real_t)
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index fb298e3ed7..fc9583d793 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -156,58 +156,6 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
return gi_probe->lights.insert(A);
}
-#if 0
- if (A->base_type==INSTANCE_PORTAL) {
-
- ERR_FAIL_COND_V( B->base_type!=INSTANCE_PORTAL,NULL );
-
- A->portal_info->candidate_set.insert(B);
- B->portal_info->candidate_set.insert(A);
-
- self->_portal_attempt_connect(A);
- //attempt to conncet portal A (will go through B anyway)
- //this is a little hackish, but works fine in practice
-
- } else if (A->base_type==INSTANCE_GI_PROBE || B->base_type==INSTANCE_GI_PROBE) {
-
- if (B->base_type==INSTANCE_GI_PROBE) {
- SWAP(A,B);
- }
-
- ERR_FAIL_COND_V(B->base_type!=INSTANCE_GI_PROBE_SAMPLER,NULL);
- B->gi_probe_sampler_info->gi_probes.insert(A);
-
- } else if (A->base_type==INSTANCE_ROOM || B->base_type==INSTANCE_ROOM) {
-
- if (B->base_type==INSTANCE_ROOM)
- SWAP(A,B);
-
- ERR_FAIL_COND_V(! ((1<<B->base_type)&INSTANCE_GEOMETRY_MASK ),NULL);
-
- B->auto_rooms.insert(A);
- A->room_info->owned_autoroom_geometry.insert(B);
-
- self->_instance_validate_autorooms(B);
-
-
- } else {
-
- if (B->base_type==INSTANCE_LIGHT) {
-
- SWAP(A,B);
- } else if (A->base_type!=INSTANCE_LIGHT) {
- return NULL;
- }
-
-
- A->light_info->affected.insert(B);
- B->lights.insert(A);
- B->light_cache_dirty=true;
-
-
- }
-#endif
-
return NULL;
}
void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *udata) {
@@ -269,57 +217,6 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
gi_probe->lights.erase(E);
}
-#if 0
- if (A->base_type==INSTANCE_PORTAL) {
-
- ERR_FAIL_COND( B->base_type!=INSTANCE_PORTAL );
-
-
- A->portal_info->candidate_set.erase(B);
- B->portal_info->candidate_set.erase(A);
-
- //after disconnecting them, see if they can connect again
- self->_portal_attempt_connect(A);
- self->_portal_attempt_connect(B);
-
- } else if (A->base_type==INSTANCE_GI_PROBE || B->base_type==INSTANCE_GI_PROBE) {
-
- if (B->base_type==INSTANCE_GI_PROBE) {
- SWAP(A,B);
- }
-
- ERR_FAIL_COND(B->base_type!=INSTANCE_GI_PROBE_SAMPLER);
- B->gi_probe_sampler_info->gi_probes.erase(A);
-
- } else if (A->base_type==INSTANCE_ROOM || B->base_type==INSTANCE_ROOM) {
-
- if (B->base_type==INSTANCE_ROOM)
- SWAP(A,B);
-
- ERR_FAIL_COND(! ((1<<B->base_type)&INSTANCE_GEOMETRY_MASK ));
-
- B->auto_rooms.erase(A);
- B->valid_auto_rooms.erase(A);
- A->room_info->owned_autoroom_geometry.erase(B);
-
- }else {
-
-
-
- if (B->base_type==INSTANCE_LIGHT) {
-
- SWAP(A,B);
- } else if (A->base_type!=INSTANCE_LIGHT) {
- return;
- }
-
-
- A->light_info->affected.erase(B);
- B->lights.erase(A);
- B->light_cache_dirty=true;
-
- }
-#endif
}
RID VisualServerScene::scenario_create() {
@@ -467,125 +364,6 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
}
}
instance->materials.clear();
-
-#if 0
- if (instance->light_info) {
-
- if (instance->scenario && instance->light_info->D)
- instance->scenario->directional_lights.erase( instance->light_info->D );
- rasterizer->free(instance->light_info->instance);
- memdelete(instance->light_info);
- instance->light_info=NULL;
- }
-
-
-
- if ( instance->room ) {
-
- instance_set_room(p_instance,RID());
- /*
- if((1<<instance->base_type)&INSTANCE_GEOMETRY_MASK)
- instance->room->room_info->owned_geometry_instances.erase(instance->RE);
- else if (instance->base_type==INSTANCE_PORTAL) {
- print_line("freeing portal, is it there? "+itos(instance->room->room_info->owned_portal_instances.(instance->RE)));
- instance->room->room_info->owned_portal_instances.erase(instance->RE);
- } else if (instance->base_type==INSTANCE_ROOM)
- instance->room->room_info->owned_room_instances.erase(instance->RE);
- else if (instance->base_type==INSTANCE_LIGHT)
- instance->room->room_info->owned_light_instances.erase(instance->RE);
-
- instance->RE=NULL;*/
- }
-
-
-
-
-
-
- if (instance->portal_info) {
-
- _portal_disconnect(instance,true);
- memdelete(instance->portal_info);
- instance->portal_info=NULL;
-
- }
-
- if (instance->gi_probe_info) {
-
- while(instance->gi_probe_info->owned_instances.size()) {
-
- Instance *owned=instance->gi_probe_info->owned_instances.front()->get();
- owned->gi_probe=NULL;
- owned->data.gi_probe=NULL;
- owned->data.gi_probe_octree_xform=NULL;
- owned->BLE=NULL;
- instance->gi_probe_info->owned_instances.pop_front();
- }
-
- memdelete(instance->gi_probe_info);
- instance->gi_probe_info=NULL;
-
- }
-
- if (instance->scenario && instance->octree_id) {
- instance->scenario->octree.erase( instance->octree_id );
- instance->octree_id=0;
- }
-
-
- if (instance->room_info) {
-
- for(List<Instance*>::Element *E=instance->room_info->owned_geometry_instances.front();E;E=E->next()) {
-
- Instance *owned = E->get();
- owned->room=NULL;
- owned->RE=NULL;
- }
- for(List<Instance*>::Element *E=instance->room_info->owned_portal_instances.front();E;E=E->next()) {
-
- _portal_disconnect(E->get(),true);
- Instance *owned = E->get();
- owned->room=NULL;
- owned->RE=NULL;
- }
-
- for(List<Instance*>::Element *E=instance->room_info->owned_room_instances.front();E;E=E->next()) {
-
- Instance *owned = E->get();
- owned->room=NULL;
- owned->RE=NULL;
- }
-
- if (instance->room_info->disconnected_child_portals.size()) {
- ERR_PRINT("BUG: Disconnected portals remain!");
- }
- memdelete(instance->room_info);
- instance->room_info=NULL;
-
- }
-
- if (instance->particles_info) {
-
- rasterizer->free( instance->particles_info->instance );
- memdelete(instance->particles_info);
- instance->particles_info=NULL;
-
- }
-
- if (instance->gi_probe_sampler_info) {
-
- while (instance->gi_probe_sampler_info->owned_instances.size()) {
-
- instance_geometry_set_gi_probe_sampler(instance->gi_probe_sampler_info->owned_instances.front()->get()->self,RID());
- }
-
- if (instance->gi_probe_sampler_info->sampled_light.is_valid()) {
- rasterizer->free(instance->gi_probe_sampler_info->sampled_light);
- }
- memdelete( instance->gi_probe_sampler_info );
- instance->gi_probe_sampler_info=NULL;
- }
-#endif
}
instance->base_type = VS::INSTANCE_NONE;
@@ -646,64 +424,6 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
if (scenario)
_instance_queue_update(instance, true, true);
-
-#if 0
- if (rasterizer->is_mesh(p_base)) {
- instance->base_type=INSTANCE_MESH;
- instance->data.morph_values.resize( rasterizer->mesh_get_morph_target_count(p_base));
- instance->data.materials.resize( rasterizer->mesh_get_surface_count(p_base));
- } else if (rasterizer->is_multimesh(p_base)) {
- instance->base_type=INSTANCE_MULTIMESH;
- } else if (rasterizer->is_immediate(p_base)) {
- instance->base_type=INSTANCE_IMMEDIATE;
- } else if (rasterizer->is_particles(p_base)) {
- instance->base_type=INSTANCE_PARTICLES;
- instance->particles_info=memnew( Instance::ParticlesInfo );
- instance->particles_info->instance = rasterizer->particles_instance_create( p_base );
- } else if (rasterizer->is_light(p_base)) {
-
- instance->base_type=INSTANCE_LIGHT;
- instance->light_info = memnew( Instance::LightInfo );
- instance->light_info->instance = rasterizer->light_instance_create(p_base);
- if (instance->scenario && rasterizer->light_get_type(p_base)==LIGHT_DIRECTIONAL) {
-
- instance->light_info->D = instance->scenario->directional_lights.push_back(instance->self);
- }
-
- } else if (room_owner.owns(p_base)) {
- instance->base_type=INSTANCE_ROOM;
- instance->room_info = memnew( Instance::RoomInfo );
- instance->room_info->room=room_owner.get(p_base);
- } else if (portal_owner.owns(p_base)) {
-
- instance->base_type=INSTANCE_PORTAL;
- instance->portal_info = memnew(Instance::PortalInfo);
- instance->portal_info->portal=portal_owner.get(p_base);
- } else if (gi_probe_owner.owns(p_base)) {
-
- instance->base_type=INSTANCE_GI_PROBE;
- instance->gi_probe_info=memnew(Instance::BakedLightInfo);
- instance->gi_probe_info->gi_probe=gi_probe_owner.get(p_base);
-
- //instance->portal_info = memnew(Instance::PortalInfo);
- //instance->portal_info->portal=portal_owner.get(p_base);
- } else if (gi_probe_sampler_owner.owns(p_base)) {
-
-
- instance->base_type=INSTANCE_GI_PROBE_SAMPLER;
- instance->gi_probe_sampler_info=memnew( Instance::BakedLightSamplerInfo);
- instance->gi_probe_sampler_info->sampler=gi_probe_sampler_owner.get(p_base);
-
- //instance->portal_info = memnew(Instance::PortalInfo);
- //instance->portal_info->portal=portal_owner.get(p_base);
-
- } else {
- ERR_EXPLAIN("Invalid base RID for instance!")
- ERR_FAIL();
- }
-
- instance_dependency_map[ p_base ].insert( instance->self );
-#endif
}
}
void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
@@ -894,8 +614,6 @@ void VisualServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton)
void VisualServerScene::instance_set_exterior(RID p_instance, bool p_enabled) {
}
-void VisualServerScene::instance_set_room(RID p_instance, RID p_room) {
-}
void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) {
}
@@ -978,11 +696,6 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF
switch (p_flags) {
- case VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS: {
-
- instance->visible_in_all_rooms = p_enabled;
-
- } break;
case VS::INSTANCE_FLAG_USE_BAKED_LIGHT: {
instance->baked_light = p_enabled;
@@ -1067,58 +780,12 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
}
}
}
-#if 0
- else if (p_instance->base_type == INSTANCE_ROOM) {
-
- p_instance->room_info->affine_inverse=p_instance->data.transform.affine_inverse();
- } else if (p_instance->base_type == INSTANCE_GI_PROBE) {
-
- Transform scale;
- scale.basis.scale(p_instance->gi_probe_info->gi_probe->octree_aabb.size);
- scale.origin=p_instance->gi_probe_info->gi_probe->octree_aabb.pos;
- //print_line("scale: "+scale);
- p_instance->gi_probe_info->affine_inverse=(p_instance->data.transform*scale).affine_inverse();
- }
-
-#endif
p_instance->mirror = p_instance->transform.basis.determinant() < 0.0;
Rect3 new_aabb;
-#if 0
- if (p_instance->base_type==INSTANCE_PORTAL) {
-
- //portals need to be transformed in a special way, so they don't become too wide if they have scale..
- Transform portal_xform = p_instance->data.transform;
- portal_xform.basis.set_axis(2,portal_xform.basis.get_axis(2).normalized());
- p_instance->portal_info->plane_cache=Plane( p_instance->data.transform.origin, portal_xform.basis.get_axis(2));
- int point_count=p_instance->portal_info->portal->shape.size();
- p_instance->portal_info->transformed_point_cache.resize(point_count);
-
- AABB portal_aabb;
-
- for(int i=0;i<point_count;i++) {
-
- Point2 src = p_instance->portal_info->portal->shape[i];
- Vector3 point = portal_xform.xform(Vector3(src.x,src.y,0));
- p_instance->portal_info->transformed_point_cache[i]=point;
- if (i==0)
- portal_aabb.pos=point;
- else
- portal_aabb.expand_to(point);
- }
-
- portal_aabb.grow_by(p_instance->portal_info->portal->connect_range);
-
- new_aabb = portal_aabb;
-
- } else {
-#endif
new_aabb = p_instance->transform.xform(p_instance->aabb);
-#if 0
- }
-#endif
p_instance->transformed_aabb = new_aabb;
@@ -1145,33 +812,6 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
pairable = true;
}
-#if 0
-
- if (p_instance->base_type == VS::INSTANCE_PORTAL) {
-
- pairable_mask=(1<<INSTANCE_PORTAL);
- pairable=true;
- }
-
- if (p_instance->base_type == VS::INSTANCE_GI_PROBE_SAMPLER) {
-
- pairable_mask=(1<<INSTANCE_GI_PROBE);
- pairable=true;
- }
-
-
- if (!p_instance->room && (1<<p_instance->base_type)&VS::INSTANCE_GEOMETRY_MASK) {
-
- base_type|=VS::INSTANCE_ROOMLESS_MASK;
- }
-
- if (p_instance->base_type == VS::INSTANCE_ROOM) {
-
- pairable_mask=INSTANCE_ROOMLESS_MASK;
- pairable=true;
- }
-#endif
-
// not inside octree
p_instance->octree_id = p_instance->scenario->octree.create(p_instance, new_aabb, 0, pairable, base_type, pairable_mask);
@@ -1184,23 +824,6 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
p_instance->scenario->octree.move(p_instance->octree_id, new_aabb);
}
-#if 0
- if (p_instance->base_type==INSTANCE_PORTAL) {
-
- _portal_attempt_connect(p_instance);
- }
-
- if (!p_instance->room && (1<<p_instance->base_type)&INSTANCE_GEOMETRY_MASK) {
-
- _instance_validate_autorooms(p_instance);
- }
-
- if (p_instance->base_type == INSTANCE_ROOM) {
-
- for(Set<Instance*>::Element *E=p_instance->room_info->owned_autoroom_geometry.front();E;E=E->next())
- _instance_validate_autorooms(E->get());
- }
-#endif
}
void VisualServerScene::_update_instance_aabb(Instance *p_instance) {
@@ -1235,15 +858,6 @@ void VisualServerScene::_update_instance_aabb(Instance *p_instance) {
new_aabb = VSG::storage->particles_get_aabb(p_instance->base);
} break;
-#if 0
-
- case VisualServer::INSTANCE_PARTICLES: {
-
- new_aabb = rasterizer->particles_get_aabb(p_instance->base);
-
-
- } break;
-#endif
case VisualServer::INSTANCE_LIGHT: {
new_aabb = VSG::storage->light_get_aabb(p_instance->base);
@@ -1260,49 +874,6 @@ void VisualServerScene::_update_instance_aabb(Instance *p_instance) {
} break;
-#if 0
- case VisualServer::INSTANCE_ROOM: {
-
- Room *room = room_owner.get( p_instance->base );
- ERR_FAIL_COND(!room);
- new_aabb=room->bounds.get_aabb();
-
- } break;
- case VisualServer::INSTANCE_PORTAL: {
-
- Portal *portal = portal_owner.get( p_instance->base );
- ERR_FAIL_COND(!portal);
- for (int i=0;i<portal->shape.size();i++) {
-
- Vector3 point( portal->shape[i].x, portal->shape[i].y, 0 );
- if (i==0) {
-
- new_aabb.pos=point;
- new_aabb.size.z=0.01; // make it not flat for octree
- } else {
-
- new_aabb.expand_to(point);
- }
- }
-
- } break;
- case VisualServer::INSTANCE_GI_PROBE: {
-
- BakedLight *gi_probe = gi_probe_owner.get( p_instance->base );
- ERR_FAIL_COND(!gi_probe);
- new_aabb=gi_probe->octree_aabb;
-
- } break;
- case VisualServer::INSTANCE_GI_PROBE_SAMPLER: {
-
- BakedLightSampler *gi_probe_sampler = gi_probe_sampler_owner.get( p_instance->base );
- ERR_FAIL_COND(!gi_probe_sampler);
- float radius = gi_probe_sampler->params[VS::BAKED_LIGHT_SAMPLER_RADIUS];
-
- new_aabb=AABB(Vector3(-radius,-radius,-radius),Vector3(radius*2,radius*2,radius*2));
-
- } break;
-#endif
default: {}
}
@@ -1736,98 +1307,17 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam
reflection_probe_cull_count = 0;
-//light_samplers_culled=0;
+ //light_samplers_culled=0;
-/* print_line("OT: "+rtos( (OS::get_singleton()->get_ticks_usec()-t)/1000.0));
+ /* print_line("OT: "+rtos( (OS::get_singleton()->get_ticks_usec()-t)/1000.0));
print_line("OTO: "+itos(p_scenario->octree.get_octant_count()));
//print_line("OTE: "+itos(p_scenario->octree.get_elem_count()));
print_line("OTP: "+itos(p_scenario->octree.get_pair_count()));
*/
-/* STEP 3 - PROCESS PORTALS, VALIDATE ROOMS */
-
-// compute portals
-#if 0
- exterior_visited=false;
- exterior_portal_cull_count=0;
-
- if (room_cull_enabled) {
- for(int i=0;i<cull_count;i++) {
-
- Instance *ins = instance_cull_result[i];
- ins->last_render_pass=render_pass;
+ /* STEP 3 - PROCESS PORTALS, VALIDATE ROOMS */
+ //removed, will replace with culling
- if (ins->base_type!=INSTANCE_PORTAL)
- continue;
-
- if (ins->room)
- continue;
-
- ERR_CONTINUE(exterior_portal_cull_count>=MAX_EXTERIOR_PORTALS);
- exterior_portal_cull_result[exterior_portal_cull_count++]=ins;
-
- }
-
- room_cull_count = p_scenario->octree.cull_point(camera->transform.origin,room_cull_result,MAX_ROOM_CULL,NULL,(1<<INSTANCE_ROOM)|(1<<INSTANCE_PORTAL));
-
-
- Set<Instance*> current_rooms;
- Set<Instance*> portal_rooms;
- //add to set
- for(int i=0;i<room_cull_count;i++) {
-
- if (room_cull_result[i]->base_type==INSTANCE_ROOM) {
- current_rooms.insert(room_cull_result[i]);
- }
- if (room_cull_result[i]->base_type==INSTANCE_PORTAL) {
- //assume inside that room if also inside the portal..
- if (room_cull_result[i]->room) {
- portal_rooms.insert(room_cull_result[i]->room);
- }
-
- SWAP(room_cull_result[i],room_cull_result[room_cull_count-1]);
- room_cull_count--;
- i--;
- }
- }
-
- //remove from set if it has a parent room or BSP doesn't contain
- for(int i=0;i<room_cull_count;i++) {
- Instance *r = room_cull_result[i];
-
- //check inside BSP
- Vector3 room_local_point = r->room_info->affine_inverse.xform( camera->transform.origin );
-
- if (!portal_rooms.has(r) && !r->room_info->room->bounds.point_is_inside(room_local_point)) {
-
- current_rooms.erase(r);
- continue;
- }
-
- //check parent
- while (r->room) {// has parent room
-
- current_rooms.erase(r);
- r=r->room;
- }
-
- }
-
- if (current_rooms.size()) {
- //camera is inside a room
- // go through rooms
- for(Set<Instance*>::Element *E=current_rooms.front();E;E=E->next()) {
- _cull_room(camera,E->get());
- }
-
- } else {
- //start from exterior
- _cull_room(camera,NULL);
-
- }
- }
-
-#endif
/* STEP 4 - REMOVE FURTHER CULLED OBJECTS, ADD LIGHTS */
for (int i = 0; i < cull_count; i++) {
@@ -1895,71 +1385,6 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam
} else if ((1 << ins->base_type) & VS::INSTANCE_GEOMETRY_MASK && ins->visible && ins->cast_shadows != VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
keep = true;
-#if 0
- bool discarded=false;
-
- if (ins->draw_range_end>0) {
-
- float d = cull_range.nearp.distance_to(ins->data.transform.origin);
- if (d<0)
- d=0;
- discarded=(d<ins->draw_range_begin || d>=ins->draw_range_end);
-
-
- }
-
- if (!discarded) {
-
- // test if this geometry should be visible
-
- if (room_cull_enabled) {
-
-
- if (ins->visible_in_all_rooms) {
- keep=true;
- } else if (ins->room) {
-
- if (ins->room->room_info->last_visited_pass==render_pass)
- keep=true;
- } else if (ins->auto_rooms.size()) {
-
-
- for(Set<Instance*>::Element *E=ins->auto_rooms.front();E;E=E->next()) {
-
- if (E->get()->room_info->last_visited_pass==render_pass) {
- keep=true;
- break;
- }
- }
- } else if(exterior_visited)
- keep=true;
- } else {
-
- keep=true;
- }
-
-
- }
-
-
- if (keep) {
- // update cull range
- float min,max;
- ins->transformed_aabb.project_range_in_plane(cull_range.nearp,min,max);
-
- if (min<cull_range.min)
- cull_range.min=min;
- if (max>cull_range.max)
- cull_range.max=max;
-
- if (ins->sampled_light && ins->sampled_light->gi_probe_sampler_info->last_pass!=render_pass) {
- if (light_samplers_culled<MAX_LIGHT_SAMPLERS) {
- light_sampler_cull_result[light_samplers_culled++]=ins->sampled_light;
- ins->sampled_light->gi_probe_sampler_info->last_pass=render_pass;
- }
- }
- }
-#endif
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(ins->base_data);
@@ -3467,7 +2892,6 @@ bool VisualServerScene::free(RID p_rid) {
Instance *instance = instance_owner.get(p_rid);
- instance_set_room(p_rid, RID());
instance_set_scenario(p_rid, RID());
instance_set_base(p_rid, RID());
instance_geometry_set_material_override(p_rid, RID());
diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h
index 910e75c3e3..177521e267 100644
--- a/servers/visual/visual_server_scene.h
+++ b/servers/visual/visual_server_scene.h
@@ -137,38 +137,6 @@ public:
virtual void camera_set_environment(RID p_camera, RID p_env);
virtual void camera_set_use_vertical_aspect(RID p_camera, bool p_enable);
- /*
-
- struct RoomInfo {
-
- Transform affine_inverse;
- Room *room;
- List<Instance*> owned_geometry_instances;
- List<Instance*> owned_portal_instances;
- List<Instance*> owned_room_instances;
- List<Instance*> owned_light_instances; //not used, but just for the sake of it
- Set<Instance*> disconnected_child_portals;
- Set<Instance*> owned_autoroom_geometry;
- uint64_t last_visited_pass;
- RoomInfo() { last_visited_pass=0; }
-
- };
-
- struct InstancePortal {
-
- Portal *portal;
- Set<Instance*> candidate_set;
- Instance *connected;
- uint64_t last_visited_pass;
-
- Plane plane_cache;
- Vector<Vector3> transformed_point_cache;
-
-
- PortalInfo() { connected=NULL; last_visited_pass=0;}
- };
-*/
-
/* SCENARIO API */
struct Instance;
@@ -236,10 +204,6 @@ public:
float lod_end_hysteresis;
RID lod_instance;
- Instance *room;
- SelfList<Instance> room_item;
- bool visible_in_all_rooms;
-
uint64_t last_render_pass;
uint64_t last_frame_pass;
@@ -263,7 +227,7 @@ public:
}
Instance()
- : scenario_item(this), update_item(this), room_item(this) {
+ : scenario_item(this), update_item(this) {
octree_id = 0;
scenario = NULL;
@@ -281,9 +245,6 @@ public:
lod_begin_hysteresis = 0;
lod_end_hysteresis = 0;
- room = NULL;
- visible_in_all_rooms = false;
-
last_render_pass = 0;
last_frame_pass = 0;
version = 1;
@@ -496,7 +457,6 @@ public:
virtual void instance_attach_skeleton(RID p_instance, RID p_skeleton);
virtual void instance_set_exterior(RID p_instance, bool p_enabled);
- virtual void instance_set_room(RID p_instance, RID p_room);
virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin);
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index ca040e9355..476412a4f1 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -250,23 +250,6 @@ public:
FUNC2(reflection_probe_set_enable_shadows, RID, bool)
FUNC2(reflection_probe_set_cull_mask, RID, uint32_t)
- /* ROOM API */
-
- FUNC0R(RID, room_create)
- FUNC4(room_add_bounds, RID, const PoolVector<Vector2> &, float, const Transform &)
- FUNC1(room_clear_bounds, RID)
-
- /* PORTAL API */
-
- // portals are only (x/y) points, forming a convex shape, which its clockwise
- // order points outside. (z is 0);
-
- FUNC0R(RID, portal_create)
- FUNC2(portal_set_shape, RID, const Vector<Point2> &)
- FUNC2(portal_set_enabled, RID, bool)
- FUNC2(portal_set_disable_distance, RID, float)
- FUNC2(portal_set_disabled_color, RID, const Color &)
-
/* BAKED LIGHT API */
FUNC0R(RID, gi_probe_create)
@@ -438,7 +421,6 @@ public:
FUNC2(instance_attach_skeleton, RID, RID)
FUNC2(instance_set_exterior, RID, bool)
- FUNC2(instance_set_room, RID, RID)
FUNC2(instance_set_extra_visibility_margin, RID, real_t)
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 5e0a390a21..cf32dcd1d5 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -421,23 +421,6 @@ public:
virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) = 0;
virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0;
- /* ROOM API */
-
- virtual RID room_create() = 0;
- virtual void room_add_bounds(RID p_room, const PoolVector<Vector2> &p_convex_polygon, float p_height, const Transform &p_transform) = 0;
- virtual void room_clear_bounds(RID p_room) = 0;
-
- /* PORTAL API */
-
- // portals are only (x/y) points, forming a convex shape, which its clockwise
- // order points outside. (z is 0);
-
- virtual RID portal_create() = 0;
- virtual void portal_set_shape(RID p_portal, const Vector<Point2> &p_shape) = 0;
- virtual void portal_set_enabled(RID p_portal, bool p_enabled) = 0;
- virtual void portal_set_disable_distance(RID p_portal, float p_distance) = 0;
- virtual void portal_set_disabled_color(RID p_portal, const Color &p_color) = 0;
-
/* GI PROBE API */
virtual RID gi_probe_create() = 0;
@@ -709,8 +692,6 @@ public:
INSTANCE_PARTICLES,
INSTANCE_LIGHT,
INSTANCE_REFLECTION_PROBE,
- INSTANCE_ROOM,
- INSTANCE_PORTAL,
INSTANCE_GI_PROBE,
INSTANCE_MAX,
/*INSTANCE_BAKED_LIGHT_SAMPLER,*/
@@ -734,7 +715,6 @@ public:
virtual void instance_attach_skeleton(RID p_instance, RID p_skeleton) = 0;
virtual void instance_set_exterior(RID p_instance, bool p_enabled) = 0;
- virtual void instance_set_room(RID p_instance, RID p_room) = 0;
virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) = 0;
@@ -744,7 +724,6 @@ public:
virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const = 0;
enum InstanceFlags {
- INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS,
INSTANCE_FLAG_USE_BAKED_LIGHT,
INSTANCE_FLAG_MAX
};