diff options
45 files changed, 425 insertions, 310 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 9e301ccac5..8d85e78226 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -248,6 +248,7 @@ void HTTPClient::close() { body_size = 0; body_left = 0; chunk_left = 0; + read_until_eof = false; response_num = 0; } @@ -352,10 +353,17 @@ Error HTTPClient::poll() { chunked = false; body_left = 0; chunk_left = 0; + read_until_eof = false; response_str.clear(); response_headers.clear(); response_num = RESPONSE_OK; + // Per the HTTP 1.1 spec, keep-alive is the default, but in practice + // it's safe to assume it only if the explicit header is found, allowing + // to handle body-up-to-EOF responses on naive servers; that's what Curl + // and browsers do + bool keep_alive = false; + for (int i = 0; i < responses.size(); i++) { String header = responses[i].strip_edges(); @@ -365,13 +373,14 @@ Error HTTPClient::poll() { if (s.begins_with("content-length:")) { body_size = s.substr(s.find(":") + 1, s.length()).strip_edges().to_int(); body_left = body_size; - } - if (s.begins_with("transfer-encoding:")) { + } else if (s.begins_with("transfer-encoding:")) { String encoding = header.substr(header.find(":") + 1, header.length()).strip_edges(); if (encoding == "chunked") { chunked = true; } + } else if (s.begins_with("connection: keep-alive")) { + keep_alive = true; } if (i == 0 && responses[i].begins_with("HTTP")) { @@ -384,11 +393,16 @@ Error HTTPClient::poll() { } } - if (body_size == 0 && !chunked) { + if (body_size || chunked) { - status = STATUS_CONNECTED; // Ready for new requests - } else { status = STATUS_BODY; + } else if (!keep_alive) { + + read_until_eof = true; + status = STATUS_BODY; + } else { + + status = STATUS_CONNECTED; } return OK; } @@ -515,34 +529,53 @@ PoolByteArray HTTPClient::read_response_body_chunk() { } else { - int to_read = MIN(body_left, read_chunk_size); + int to_read = !read_until_eof ? MIN(body_left, read_chunk_size) : read_chunk_size; PoolByteArray ret; ret.resize(to_read); int _offset = 0; - while (to_read > 0) { + while (read_until_eof || to_read > 0) { int rec = 0; { PoolByteArray::Write w = ret.write(); err = _get_http_data(w.ptr() + _offset, to_read, rec); } - if (rec > 0) { - body_left -= rec; - to_read -= rec; - _offset += rec; - } else { + if (rec < 0) { if (to_read > 0) // Ended up reading less ret.resize(_offset); break; + } else { + _offset += rec; + if (!read_until_eof) { + body_left -= rec; + to_read -= rec; + } else { + if (rec < to_read) { + ret.resize(_offset); + err = ERR_FILE_EOF; + break; + } + ret.resize(_offset + to_read); + } } } - if (body_left == 0) { - status = STATUS_CONNECTED; + if (!read_until_eof) { + if (body_left == 0) { + status = STATUS_CONNECTED; + } + return ret; + } else { + if (err == ERR_FILE_EOF) { + err = OK; // EOF is expected here + close(); + return ret; + } } - return ret; } if (err != OK) { + close(); + if (err == ERR_FILE_EOF) { status = STATUS_DISCONNECTED; // Server disconnected @@ -602,6 +635,7 @@ HTTPClient::HTTPClient() { body_size = 0; chunked = false; body_left = 0; + read_until_eof = false; chunk_left = 0; response_num = 0; ssl = false; diff --git a/core/io/http_client.h b/core/io/http_client.h index 839012e701..38ec82ce8c 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -173,6 +173,7 @@ private: int chunk_left; int body_size; int body_left; + bool read_until_eof; Ref<StreamPeerTCP> tcp_connection; Ref<StreamPeer> connection; diff --git a/core/project_settings.cpp b/core/project_settings.cpp index ac4a4b7d15..ef485cb3b2 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -1071,6 +1071,7 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_mode", 2); GLOBAL_DEF("debug/settings/profiler/max_functions", 16384); + GLOBAL_DEF("debug/settings/performance/update_frequency_msec", 250); //assigning here, because using GLOBAL_GET on every block for compressing can be slow Compression::zstd_long_distance_matching = GLOBAL_DEF("compression/formats/zstd/long_distance_matching", false); diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 75bcedbbc8..7a30a33c67 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -854,7 +854,7 @@ void ScriptDebuggerRemote::idle_poll() { if (performance) { uint64_t pt = OS::get_singleton()->get_ticks_msec(); - if (pt - last_perf_time > 1000) { + if (pt - last_perf_time > update_frequency) { last_perf_time = pt; int max = performance->get("MONITOR_MAX"); @@ -1081,7 +1081,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() : eh.userdata = this; add_error_handler(&eh); - profile_info.resize(CLAMP(int(ProjectSettings::get_singleton()->get("debug/settings/profiler/max_functions")), 128, 65535)); + profile_info.resize(CLAMP(int(GLOBAL_GET("debug/settings/profiler/max_functions")), 128, 65535)); profile_info_ptrs.resize(profile_info.size()); } diff --git a/core/script_language.cpp b/core/script_language.cpp index 1dab58e29e..ce9b138bb2 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "script_language.h" +#include "project_settings.h" ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES]; int ScriptServer::_language_count = 0; @@ -283,6 +284,7 @@ ScriptDebugger::ScriptDebugger() { lines_left = -1; depth = -1; break_lang = NULL; + update_frequency = GLOBAL_GET("debug/settings/performance/update_frequency_msec"); } bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_value) { diff --git a/core/script_language.h b/core/script_language.h index b4c55cac9e..64c6f2eb81 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -352,6 +352,8 @@ class ScriptDebugger { public: typedef void (*RequestSceneTreeMessageFunc)(void *); + int update_frequency; + struct LiveEditFuncs { void *udata; diff --git a/doc/classes/AudioStreamSample.xml b/doc/classes/AudioStreamSample.xml index 8b6651abe7..b6abda1a6f 100644 --- a/doc/classes/AudioStreamSample.xml +++ b/doc/classes/AudioStreamSample.xml @@ -13,6 +13,9 @@ <methods> </methods> <members> + <member name="data" type="PoolByteArray" setter="set_data" getter="get_data"> + Contains the audio data in bytes. + </member> <member name="format" type="int" setter="set_format" getter="get_format" enum="AudioStreamSample.Format"> Audio format. See FORMAT_* constants for values. </member> diff --git a/doc/classes/Plane.xml b/doc/classes/Plane.xml index 157bf42239..ca035ad383 100644 --- a/doc/classes/Plane.xml +++ b/doc/classes/Plane.xml @@ -24,7 +24,7 @@ <argument index="3" name="d" type="float"> </argument> <description> - Creates a plane from the three parameters "a", "b", "c" and "d". + Creates a plane from the four parameters "a", "b", "c" and "d". </description> </method> <method name="Plane"> diff --git a/doc/classes/Shader.xml b/doc/classes/Shader.xml index 732881c777..7c07778a05 100644 --- a/doc/classes/Shader.xml +++ b/doc/classes/Shader.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="Shader" inherits="Resource" category="Core" version="3.1"> <brief_description> - To be changed, ignore. + A custom shader program. </brief_description> <description> - To be changed, ignore. + This class allows you to define a custom shader program that can be used for various materials to render objects. </description> <tutorials> http://docs.godotengine.org/en/3.0/tutorials/shading/index.html @@ -24,6 +24,7 @@ <return type="int" enum="Shader.Mode"> </return> <description> + Returns the shader mode for the shader, eiter [code]MODE_CANVAS_ITEM[/code], [code]MODE_SPATIAL[/code] or [code]MODE_PARTICLES[/code] </description> </method> <method name="has_param" qualifiers="const"> diff --git a/doc/classes/ShaderMaterial.xml b/doc/classes/ShaderMaterial.xml index 4767686a8f..058e00e46c 100644 --- a/doc/classes/ShaderMaterial.xml +++ b/doc/classes/ShaderMaterial.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="ShaderMaterial" inherits="Material" category="Core" version="3.1"> <brief_description> + A material that uses a custom [Shader] program </brief_description> <description> + A material that uses a custom [Shader] program to render either items to screen or process particles. You can create multiple materials for the same shader but configure different values for the uniforms defined in the shader. </description> <tutorials> </tutorials> @@ -15,6 +17,7 @@ <argument index="0" name="param" type="String"> </argument> <description> + Returns the current value set for this material of a uniform in the shader </description> </method> <method name="set_shader_param"> @@ -25,11 +28,13 @@ <argument index="1" name="value" type="Variant"> </argument> <description> + Changes the value set for this material of a uniform in the shader </description> </method> </methods> <members> <member name="shader" type="Shader" setter="set_shader" getter="get_shader"> + The [Shader] program used to render this material </member> </members> <constants> diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index ff423bf0d0..bb4c8ab4d7 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -193,11 +193,11 @@ void RasterizerCanvasGLES3::canvas_end() { state.using_ninepatch = false; } -RasterizerStorageGLES3::Texture *RasterizerCanvasGLES3::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) { +RasterizerStorageGLES3::Texture *RasterizerCanvasGLES3::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map, bool p_force) { RasterizerStorageGLES3::Texture *tex_return = NULL; - if (p_texture == state.current_tex) { + if (p_texture == state.current_tex && !p_force) { tex_return = state.current_tex_ptr; } else if (p_texture.is_valid()) { @@ -232,7 +232,7 @@ RasterizerStorageGLES3::Texture *RasterizerCanvasGLES3::_bind_canvas_texture(con state.current_tex_ptr = NULL; } - if (p_normal_map == state.current_normal) { + if (p_normal_map == state.current_normal && !p_force) { //do none state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, state.current_normal.is_valid()); @@ -1086,7 +1086,7 @@ void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) { state.using_texture_rect = true; _set_texture_rect_mode(false); - _bind_canvas_texture(state.current_tex, state.current_normal); + _bind_canvas_texture(state.current_tex, state.current_normal, true); glEnable(GL_BLEND); } diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h index bfaf1fdb4b..c7f2e54efb 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.h +++ b/drivers/gles3/rasterizer_canvas_gles3.h @@ -123,7 +123,7 @@ public: virtual void canvas_end(); _FORCE_INLINE_ void _set_texture_rect_mode(bool p_enable, bool p_ninepatch = false); - _FORCE_INLINE_ RasterizerStorageGLES3::Texture *_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map); + _FORCE_INLINE_ RasterizerStorageGLES3::Texture *_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map, bool p_force = false); _FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs); _FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const int *p_bones, const float *p_weights); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 8da2c2f9c2..03ff84c093 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -2363,10 +2363,9 @@ void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const C ERR_FAIL_COND(!tex); glActiveTexture(GL_TEXTURE0); - if (tex->proxy && tex->proxy->tex_id) - glBindTexture(tex->target, tex->proxy->tex_id); - else - glBindTexture(tex->target, tex->tex_id); + tex = tex->get_ptr(); //resolve for proxies + + glBindTexture(tex->target, tex->tex_id); if (storage->config.srgb_decode_supported && tex->srgb && !tex->using_srgb) { diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 85ae69f8b8..11ab957458 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -1356,6 +1356,8 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra ERR_FAIL_COND(!texture); } + texture = texture->get_ptr(); //resolve for proxies + glBindVertexArray(0); glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); @@ -5895,12 +5897,9 @@ void RasterizerStorageGLES3::update_particles() { tex = resources.white_tex; } break; } - } else if (t->proxy && t->proxy->tex_id) { - - target = t->proxy->target; - tex = t->proxy->tex_id; } else { + t = t->get_ptr(); //resolve for proxies target = t->target; tex = t->tex_id; } diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index 6d798f32f9..44b9ef1d7c 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -297,6 +297,7 @@ Error StreamPeerTCPPosix::read(uint8_t *p_buffer, int p_bytes, int &r_received, status = STATUS_NONE; peer_port = 0; peer_host = IP_Address(); + r_received = total_read; return ERR_FILE_EOF; } else { diff --git a/drivers/windows/stream_peer_tcp_winsock.cpp b/drivers/windows/stream_peer_tcp_winsock.cpp index cb501ce35d..19c937170b 100644 --- a/drivers/windows/stream_peer_tcp_winsock.cpp +++ b/drivers/windows/stream_peer_tcp_winsock.cpp @@ -212,6 +212,7 @@ Error StreamPeerTCPWinsock::read(uint8_t *p_buffer, int p_bytes, int &r_received _block(sockfd, true, false); } else if (read == 0) { disconnect_from_host(); + r_received = total_read; return ERR_FILE_EOF; } else { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 4ac3e33cb9..d41d5c929a 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -420,6 +420,18 @@ void EditorData::paste_object_params(Object *p_object) { } } +bool EditorData::call_build() { + + bool result = true; + + for (int i = 0; i < editor_plugins.size() && result; i++) { + + result &= editor_plugins[i]->build(); + } + + return result; +} + UndoRedo &EditorData::get_undo_redo() { return undo_redo; diff --git a/editor/editor_data.h b/editor/editor_data.h index f020d07ea7..0452867bf4 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -197,6 +197,7 @@ public: NodePath get_edited_scene_live_edit_root(); bool check_and_update_scene(int p_idx); void move_edited_scene_to_index(int p_idx); + bool call_build(); void set_plugin_window_layout(Ref<ConfigFile> p_layout); void get_plugin_window_layout(Ref<ConfigFile> p_layout); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index dd3b6c2c4c..4b068f1000 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4271,12 +4271,21 @@ EditorBuildCallback EditorNode::build_callbacks[EditorNode::MAX_BUILD_CALLBACKS] bool EditorNode::call_build() { - for (int i = 0; i < build_callback_count; i++) { - if (!build_callbacks[i]()) - return false; + bool builds_successful = true; + + for (int i = 0; i < build_callback_count && builds_successful; i++) { + if (!build_callbacks[i]()) { + ERR_PRINT("A Godot Engine build callback failed."); + builds_successful = false; + } } - return true; + if (builds_successful && !editor_data.call_build()) { + ERR_PRINT("An EditorPlugin build callback failed."); + builds_successful = false; + } + + return builds_successful; } void EditorNode::_inherit_imported(const String &p_action) { @@ -5379,6 +5388,7 @@ EditorNode::EditorNode() { //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))); + resource_preview->add_preview_generator(Ref<EditorFontPreviewPlugin>(memnew(EditorFontPreviewPlugin))); { Ref<SpatialMaterialConversionPlugin> spatial_mat_convert; diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 24d0592ee7..cc44938c25 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -689,6 +689,15 @@ void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) { } } +bool EditorPlugin::build() { + + if (get_script_instance() && get_script_instance()->has_method("build")) { + return get_script_instance()->call("build"); + } + + return true; +} + void EditorPlugin::queue_save_layout() const { EditorNode::get_singleton()->save_layout(); @@ -767,6 +776,7 @@ void EditorPlugin::_bind_methods() { ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::POOL_STRING_ARRAY, "get_breakpoints")); ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "build")); ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node"))); ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath"))); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 8af7f83771..fcc74cb1e9 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -192,6 +192,7 @@ public: virtual void set_window_layout(Ref<ConfigFile> p_layout); virtual void get_window_layout(Ref<ConfigFile> p_layout); virtual void edited_scene_changed() {} // if changes are pending in editor, apply them + virtual bool build(); // builds with external tools. Returns true if safe to continue running scene. EditorInterface *get_editor_interface(); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index d0b842f231..8d29e0d40b 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1050,7 +1050,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color function_definition_color = Color::html(dark_theme ? "#01e1ff" : "#00a5ba"); const Color node_path_color = Color::html(dark_theme ? "64c15a" : "#518b4b"); - const Color te_background_color = Color(0, 0, 0, 0); + const Color te_background_color = dark_theme ? background_color : Color::html("#ffffff"); const Color completion_background_color = base_color; const Color completion_selected_color = alpha1; const Color completion_existing_color = alpha2; @@ -1084,7 +1084,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true); setting->set_initial_value("text_editor/highlighting/comment_color", comment_color, true); setting->set_initial_value("text_editor/highlighting/string_color", string_color, true); - setting->set_initial_value("text_editor/highlighting/background_color", background_color, true); + setting->set_initial_value("text_editor/highlighting/background_color", te_background_color, true); setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color, true); setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color, true); setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color, true); @@ -1118,7 +1118,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { setting->set_initial_value("text_editor/highlighting/engine_type_color", Color::html("83d3ff"), true); setting->set_initial_value("text_editor/highlighting/comment_color", Color::html("676767"), true); setting->set_initial_value("text_editor/highlighting/string_color", Color::html("ef6ebe"), true); - setting->set_initial_value("text_editor/highlighting/background_color", Color::html("3b000000"), true); + setting->set_initial_value("text_editor/highlighting/background_color", dark_theme ? Color::html("3b000000") : Color::html("#323b4f"), true); setting->set_initial_value("text_editor/highlighting/completion_background_color", Color::html("2C2A32"), true); setting->set_initial_value("text_editor/highlighting/completion_selected_color", Color::html("434244"), true); setting->set_initial_value("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"), true); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index d76c515c1f..ac4166bb98 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -37,6 +37,7 @@ #include "io/resource_loader.h" #include "os/os.h" #include "scene/resources/bit_mask.h" +#include "scene/resources/dynamic_font.h" #include "scene/resources/material.h" #include "scene/resources/mesh.h" @@ -933,3 +934,100 @@ EditorMeshPreviewPlugin::~EditorMeshPreviewPlugin() { VS::get_singleton()->free(camera); VS::get_singleton()->free(scenario); } + +/////////////////////////////////////////////////////////////////////////// + +void EditorFontPreviewPlugin::_preview_done(const Variant &p_udata) { + + preview_done = true; +} + +void EditorFontPreviewPlugin::_bind_methods() { + + ClassDB::bind_method("_preview_done", &EditorFontPreviewPlugin::_preview_done); +} + +bool EditorFontPreviewPlugin::handles(const String &p_type) const { + + return ClassDB::is_parent_class(p_type, "DynamicFontData"); +} + +Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path) { + if (canvas.is_valid()) { + VS::get_singleton()->viewport_remove_canvas(viewport, canvas); + } + + canvas = VS::get_singleton()->canvas_create(); + canvas_item = VS::get_singleton()->canvas_item_create(); + + VS::get_singleton()->viewport_attach_canvas(viewport, canvas); + VS::get_singleton()->canvas_item_set_parent(canvas_item, canvas); + + Ref<DynamicFontData> SampledFont; + SampledFont.instance(); + SampledFont->set_font_path(p_path); + + int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); + thumbnail_size *= EDSCALE; + + Ref<DynamicFont> sampled_font; + sampled_font.instance(); + sampled_font->set_size(50); + sampled_font->set_font_data(SampledFont); + + String sampled_text = "Abg"; + Vector2 size = sampled_font->get_string_size(sampled_text); + + Vector2 pos; + + pos.x = 64 - size.x / 2; + pos.y = 80; + + Ref<Font> font = sampled_font; + + font->draw(canvas_item, pos, sampled_text); + + VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture + + preview_done = false; + VS::get_singleton()->request_frame_drawn_callback(this, "_preview_done", Variant()); + + while (!preview_done) { + OS::get_singleton()->delay_usec(10); + } + + Ref<Image> img = VS::get_singleton()->VS::get_singleton()->texture_get_data(viewport_texture); + ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); + + img->convert(Image::FORMAT_RGBA8); + img->resize(thumbnail_size, thumbnail_size); + + post_process_preview(img); + + Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); + ptex->create_from_image(img, 0); + + return ptex; +} + +Ref<Texture> EditorFontPreviewPlugin::generate(const RES &p_from) { + + return generate_from_path(p_from->get_path()); +} + +EditorFontPreviewPlugin::EditorFontPreviewPlugin() { + + viewport = VS::get_singleton()->viewport_create(); + VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED); + VS::get_singleton()->viewport_set_vflip(viewport, true); + VS::get_singleton()->viewport_set_size(viewport, 128, 128); + VS::get_singleton()->viewport_set_active(viewport, true); + viewport_texture = VS::get_singleton()->viewport_get_texture(viewport); +} + +EditorFontPreviewPlugin::~EditorFontPreviewPlugin() { + + VS::get_singleton()->free(canvas_item); + VS::get_singleton()->free(canvas); + VS::get_singleton()->free(viewport); +} diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h index 35b5c3a5f0..332f991b49 100644 --- a/editor/plugins/editor_preview_plugins.h +++ b/editor/plugins/editor_preview_plugins.h @@ -140,4 +140,27 @@ public: ~EditorMeshPreviewPlugin(); }; +class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator { + + GDCLASS(EditorFontPreviewPlugin, EditorResourcePreviewGenerator) + + RID viewport; + RID viewport_texture; + RID canvas; + RID canvas_item; + volatile bool preview_done; + + void _preview_done(const Variant &p_udata); + +protected: + static void _bind_methods(); + +public: + virtual bool handles(const String &p_type) const; + virtual Ref<Texture> generate(const RES &p_from); + virtual Ref<Texture> generate_from_path(const String &p_path); + + EditorFontPreviewPlugin(); + ~EditorFontPreviewPlugin(); +}; #endif // EDITORPREVIEWPLUGINS_H diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index b82a036130..32b4e7f962 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -113,7 +113,7 @@ void SceneTreeDock::instance(const String &p_file) { Node *parent = scene_tree->get_selected(); if (!parent) { - Node *parent = edited_scene; + parent = edited_scene; }; if (!edited_scene) { diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 9ce4305683..62848a6035 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -872,7 +872,7 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType reason->add_color_override("font_color", get_color("success_color", "Editor")); } reason->set_text(p_reason); - reason->set_tooltip(p_reason); + reason->set_tooltip(p_reason.word_wrap(80)); } void ScriptEditorDebugger::_performance_select() { @@ -1877,6 +1877,9 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { reason->set_text(""); hbc->add_child(reason); reason->set_h_size_flags(SIZE_EXPAND_FILL); + reason->set_autowrap(true); + reason->set_max_lines_visible(3); + reason->set_mouse_filter(Control::MOUSE_FILTER_PASS); hbc->add_child(memnew(VSeparator)); diff --git a/main/main.cpp b/main/main.cpp index 70713e2dd8..ad49e1f5bd 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1706,7 +1706,7 @@ bool Main::start() { uint64_t Main::last_ticks = 0; uint64_t Main::target_ticks = 0; -uint32_t Main::frames = 0; +Array Main::frame_times = Array(); uint32_t Main::frame = 0; bool Main::force_redraw_requested = false; @@ -1825,10 +1825,19 @@ bool Main::iteration() { script_debugger->idle_poll(); } - frames++; Engine::get_singleton()->_idle_frames++; - if (frame > 1000000) { + // FPS counter + frame_times.push_back(ticks); + int frames = frame_times.size(); + + while (frame_times.size() > 0 && (int)frame_times.get(0) <= ticks - 1000000) { + frame_times.pop_front(); + } + + int update_frequency = MAX(1, (int)GLOBAL_GET("debug/settings/performance/update_frequency_msec")); + + if (frame > update_frequency * 1000) { if (editor || project_manager) { if (print_fps) { @@ -1844,8 +1853,7 @@ bool Main::iteration() { idle_process_max = 0; physics_process_max = 0; - frame %= 1000000; - frames = 0; + frame %= update_frequency * 1000; } if (fixed_fps != -1) diff --git a/main/main.h b/main/main.h index c20592bf3b..8f264d7720 100644 --- a/main/main.h +++ b/main/main.h @@ -44,7 +44,7 @@ class Main { static void print_help(const char *p_binary); static uint64_t last_ticks; static uint64_t target_ticks; - static uint32_t frames; + static Array frame_times; static uint32_t frame; static bool force_redraw_requested; diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index 18ab616826..c95a8ac2dd 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -263,8 +263,8 @@ float AudioStreamOGGVorbis::get_length() const { void AudioStreamOGGVorbis::_bind_methods() { - ClassDB::bind_method(D_METHOD("_set_data", "data"), &AudioStreamOGGVorbis::set_data); - ClassDB::bind_method(D_METHOD("_get_data"), &AudioStreamOGGVorbis::get_data); + ClassDB::bind_method(D_METHOD("set_data", "data"), &AudioStreamOGGVorbis::set_data); + ClassDB::bind_method(D_METHOD("get_data"), &AudioStreamOGGVorbis::get_data); ClassDB::bind_method(D_METHOD("set_loop", "enable"), &AudioStreamOGGVorbis::set_loop); ClassDB::bind_method(D_METHOD("has_loop"), &AudioStreamOGGVorbis::has_loop); @@ -272,7 +272,7 @@ void AudioStreamOGGVorbis::_bind_methods() { ClassDB::bind_method(D_METHOD("set_loop_offset", "seconds"), &AudioStreamOGGVorbis::set_loop_offset); ClassDB::bind_method(D_METHOD("get_loop_offset"), &AudioStreamOGGVorbis::get_loop_offset); - ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data"); + ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_data", "get_data"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_loop", "has_loop"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "loop_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_loop_offset", "get_loop_offset"); } diff --git a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml index ac95a7197f..e2281babf7 100644 --- a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml +++ b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml @@ -13,6 +13,9 @@ <methods> </methods> <members> + <member name="data" type="PoolByteArray" setter="set_data" getter="get_data"> + Contains the audio data in bytes. + </member> <member name="loop" type="bool" setter="set_loop" getter="has_loop"> </member> <member name="loop_offset" type="float" setter="set_loop_offset" getter="get_loop_offset"> diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 03bc4c114a..318fb7fb9c 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -121,6 +121,10 @@ Array VisualScriptNode::_get_default_input_values() const { return default_input_values; } +String VisualScriptNode::get_text() const { + return ""; +} + void VisualScriptNode::_bind_methods() { ClassDB::bind_method(D_METHOD("get_visual_script"), &VisualScriptNode::get_visual_script); diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index dad9c68312..a15360ad39 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -78,7 +78,7 @@ public: Variant get_default_input_value(int p_port) const; virtual String get_caption() const = 0; - virtual String get_text() const = 0; + virtual String get_text() const; virtual String get_category() const = 0; //used by editor, this is not really saved diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 7f0a42da82..73b6d702c1 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -666,12 +666,14 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons return PropertyInfo(t, ""); } +/* String VisualScriptBuiltinFunc::get_caption() const { return "BuiltinFunc"; } +*/ -String VisualScriptBuiltinFunc::get_text() const { +String VisualScriptBuiltinFunc::get_caption() const { return func_name[func]; } diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h index f862d5c26f..3345762b9f 100644 --- a/modules/visual_script/visual_script_builtin_funcs.h +++ b/modules/visual_script/visual_script_builtin_funcs.h @@ -129,7 +129,7 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; + //virtual String get_text() const; virtual String get_category() const { return "functions"; } void set_func(BuiltinFunc p_which); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index dfaa873b13..0618064ea6 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -527,6 +527,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { GraphNode *gnode = memnew(GraphNode); gnode->set_title(node->get_caption()); + gnode->set_offset(pos * EDSCALE); if (error_line == E->get()) { gnode->set_overlay(GraphNode::OVERLAY_POSITION); } else if (node->is_breakpoint()) { @@ -543,8 +544,10 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->set_show_close_button(true); } - if (Object::cast_to<VisualScriptExpression>(node.ptr())) { + bool has_gnode_text = false; + if (Object::cast_to<VisualScriptExpression>(node.ptr())) { + has_gnode_text = true; LineEdit *line_edit = memnew(LineEdit); line_edit->set_text(node->get_text()); line_edit->set_expand_to_text_length(true); @@ -552,9 +555,13 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->add_child(line_edit); line_edit->connect("text_changed", this, "_expression_text_changed", varray(E->get())); } else { - Label *text = memnew(Label); - text->set_text(node->get_text()); - gnode->add_child(text); + String text = node->get_text(); + if (!text.empty()) { + has_gnode_text = true; + Label *label = memnew(Label); + label->set_text(text); + gnode->add_child(label); + } } if (Object::cast_to<VisualScriptComment>(node.ptr())) { @@ -589,9 +596,21 @@ void VisualScriptEditor::_update_graph(int p_only_id) { int slot_idx = 0; bool single_seq_output = node->get_output_sequence_port_count() == 1 && node->get_output_sequence_port_text(0) == String(); - gnode->set_slot(0, node->has_input_sequence_port(), TYPE_SEQUENCE, mono_color, single_seq_output, TYPE_SEQUENCE, mono_color, seq_port, seq_port); - gnode->set_offset(pos * EDSCALE); - slot_idx++; + if ((node->has_input_sequence_port() || single_seq_output) || has_gnode_text) { + // IF has_gnode_text is true BUT we have no sequence ports to draw (in here), + // we still draw the disabled default ones to shift up the slots by one, + // so the slots DON'T start with the content text. + + // IF has_gnode_text is false, but we DO want to draw default sequence ports, + // we draw a dummy text to take up the position of the sequence nodes, so all the other ports are still aligned correctly. + if (!has_gnode_text) { + Label *dummy = memnew(Label); + dummy->set_text(" "); + gnode->add_child(dummy); + } + gnode->set_slot(0, node->has_input_sequence_port(), TYPE_SEQUENCE, mono_color, single_seq_output, TYPE_SEQUENCE, mono_color, seq_port, seq_port); + slot_idx++; + } int mixed_seq_ports = 0; diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp index 5c097dfa76..ea23ab1b2a 100644 --- a/modules/visual_script/visual_script_flow_control.cpp +++ b/modules/visual_script/visual_script_flow_control.cpp @@ -772,7 +772,7 @@ PropertyInfo VisualScriptTypeCast::get_output_value_port_info(int p_idx) const { String VisualScriptTypeCast::get_caption() const { - return "TypeCast"; + return "Type Cast"; } String VisualScriptTypeCast::get_text() const { diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index 187c9b0b9e..bdf5705ecd 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -262,26 +262,6 @@ PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) con } String VisualScriptFunctionCall::get_caption() const { - - static const char *cname[5] = { - "CallSelf", - "CallNode", - "CallInstance", - "CallBasic", - "CallSingleton" - }; - - String caption = cname[call_mode]; - - if (rpc_call_mode) { - caption += " (RPC)"; - } - - return caption; -} - -String VisualScriptFunctionCall::get_text() const { - if (call_mode == CALL_MODE_SELF) return " " + String(function) + "()"; if (call_mode == CALL_MODE_SINGLETON) @@ -294,6 +274,14 @@ String VisualScriptFunctionCall::get_text() const { return " " + base_type + "." + String(function) + "()"; } +String VisualScriptFunctionCall::get_text() const { + + if (rpc_call_mode) { + return "RPC"; + } + return ""; +} + void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) { if (basic_type == p_type) @@ -1075,36 +1063,31 @@ PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) cons String VisualScriptPropertySet::get_caption() const { - static const char *cname[4] = { - "Self", - "Node", - "Instance", - "Basic" - }; - static const char *opname[ASSIGN_OP_MAX] = { - "Set", "Add", "Sub", "Mul", "Div", "Mod", "ShiftLeft", "ShiftRight", "BitAnd", "BitOr", "BitXor" + "Set", "Add", "Subtract", "Multiply", "Divide", "Mod", "ShiftLeft", "ShiftRight", "BitAnd", "BitOr", "BitXor" }; - return String(cname[call_mode]) + opname[assign_op]; + + String prop = String(opname[assign_op]) + " " + property; + if (index != StringName()) { + prop += "." + String(index); + } + + return prop; } String VisualScriptPropertySet::get_text() const { - String prop; + if (call_mode == CALL_MODE_BASIC_TYPE) { + return String("On ") + Variant::get_type_name(basic_type); + } - if (call_mode == CALL_MODE_BASIC_TYPE) - prop = Variant::get_type_name(basic_type) + "." + property; - else if (call_mode == CALL_MODE_NODE_PATH) - prop = String(base_path) + ":" + property; - else if (call_mode == CALL_MODE_SELF) - prop = property; - else if (call_mode == CALL_MODE_INSTANCE) - prop = String(base_type) + ":" + property; + static const char *cname[3] = { + "Self", + "Scene Node", + "Instance" + }; - if (index != StringName()) { - prop += "." + String(index); - } - return prop; + return String("On ") + cname[call_mode]; } void VisualScriptPropertySet::_update_base_type() { @@ -1838,30 +1821,22 @@ PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) cons String VisualScriptPropertyGet::get_caption() const { - static const char *cname[4] = { - "SelfGet", - "NodeGet", - "InstanceGet", - "BasicGet" - }; - - return cname[call_mode]; + return String("Get ") + property; } String VisualScriptPropertyGet::get_text() const { - String prop; + if (call_mode == CALL_MODE_BASIC_TYPE) { + return String("On ") + Variant::get_type_name(basic_type); + } - if (call_mode == CALL_MODE_BASIC_TYPE) - prop = Variant::get_type_name(basic_type) + "." + property; - else if (call_mode == CALL_MODE_NODE_PATH) - prop = String(base_path) + ":" + property; - else if (call_mode == CALL_MODE_SELF) - prop = property; - else if (call_mode == CALL_MODE_INSTANCE) - prop = String(base_type) + ":" + property; + static const char *cname[3] = { + "Self", + "Scene Node", + "Instance" + }; - return prop; + return String("On ") + cname[call_mode]; } void VisualScriptPropertyGet::set_base_type(const StringName &p_type) { @@ -2399,12 +2374,7 @@ PropertyInfo VisualScriptEmitSignal::get_output_value_port_info(int p_idx) const String VisualScriptEmitSignal::get_caption() const { - return "EmitSignal"; -} - -String VisualScriptEmitSignal::get_text() const { - - return "emit " + String(name); + return "Emit " + String(name); } void VisualScriptEmitSignal::set_signal(const StringName &p_type) { diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h index 0b30eae65a..3b522564d4 100644 --- a/modules/visual_script/visual_script_func_nodes.h +++ b/modules/visual_script/visual_script_func_nodes.h @@ -346,7 +346,7 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; + //virtual String get_text() const; virtual String get_category() const { return "functions"; } void set_signal(const StringName &p_type); diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index c5654a5a20..4803f29519 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -467,12 +467,12 @@ PropertyInfo VisualScriptOperator::get_output_value_port_info(int p_idx) const { static const char *op_names[] = { //comparison - "Equal", //OP_EQUAL, - "NotEqual", //OP_NOT_EQUAL, - "Less", //OP_LESS, - "LessEqual", //OP_LESS_EQUAL, - "Greater", //OP_GREATER, - "GreaterEq", //OP_GREATER_EQUAL, + "Are Equal", //OP_EQUAL, + "Are Not Equal", //OP_NOT_EQUAL, + "Less Than", //OP_LESS, + "Less Than or Equal", //OP_LESS_EQUAL, + "Greater Than", //OP_GREATER, + "Greater Than or Equal", //OP_GREATER_EQUAL, //mathematic "Add", //OP_ADD, "Subtract", //OP_SUBTRACT, @@ -481,14 +481,14 @@ static const char *op_names[] = { "Negate", //OP_NEGATE, "Positive", //OP_POSITIVE, "Remainder", //OP_MODULE, - "Concat", //OP_STRING_CONCAT, + "Concatenate", //OP_STRING_CONCAT, //bitwise - "ShiftLeft", //OP_SHIFT_LEFT, - "ShiftRight", //OP_SHIFT_RIGHT, - "BitAnd", //OP_BIT_AND, - "BitOr", //OP_BIT_OR, - "BitXor", //OP_BIT_XOR, - "BitNeg", //OP_BIT_NEGATE, + "Bit Shift Left", //OP_SHIFT_LEFT, + "Bit Shift Right", //OP_SHIFT_RIGHT, + "Bit And", //OP_BIT_AND, + "Bit Or", //OP_BIT_OR, + "Bit Xor", //OP_BIT_XOR, + "Bit Negate", //OP_BIT_NEGATE, //logic "And", //OP_AND, "Or", //OP_OR, @@ -500,11 +500,6 @@ static const char *op_names[] = { String VisualScriptOperator::get_caption() const { - return op_names[op]; -} - -String VisualScriptOperator::get_text() const { - static const wchar_t *op_names[] = { //comparison L"A = B", //OP_EQUAL, @@ -803,14 +798,8 @@ PropertyInfo VisualScriptVariableGet::get_output_value_port_info(int p_idx) cons String VisualScriptVariableGet::get_caption() const { - return "Variable"; + return "Get " + variable; } - -String VisualScriptVariableGet::get_text() const { - - return variable; -} - void VisualScriptVariableGet::set_variable(StringName p_variable) { if (variable == p_variable) @@ -928,12 +917,7 @@ PropertyInfo VisualScriptVariableSet::get_output_value_port_info(int p_idx) cons String VisualScriptVariableSet::get_caption() const { - return "VariableSet"; -} - -String VisualScriptVariableSet::get_text() const { - - return variable; + return "Set " + variable; } void VisualScriptVariableSet::set_variable(StringName p_variable) { @@ -1044,7 +1028,7 @@ PropertyInfo VisualScriptConstant::get_input_value_port_info(int p_idx) const { PropertyInfo VisualScriptConstant::get_output_value_port_info(int p_idx) const { PropertyInfo pinfo; - pinfo.name = "get"; + pinfo.name = String(value); pinfo.type = type; return pinfo; } @@ -1054,11 +1038,6 @@ String VisualScriptConstant::get_caption() const { return "Constant"; } -String VisualScriptConstant::get_text() const { - - return String(value); -} - void VisualScriptConstant::set_constant_type(Variant::Type p_type) { if (type == p_type) @@ -1174,10 +1153,20 @@ PropertyInfo VisualScriptPreload::get_input_value_port_info(int p_idx) const { PropertyInfo VisualScriptPreload::get_output_value_port_info(int p_idx) const { - PropertyInfo pinfo = PropertyInfo(Variant::OBJECT, "res"); + PropertyInfo pinfo; + pinfo.type = Variant::OBJECT; if (preload.is_valid()) { pinfo.hint = PROPERTY_HINT_RESOURCE_TYPE; pinfo.hint_string = preload->get_class(); + if (preload->get_path().is_resource_file()) { + pinfo.name = preload->get_path(); + } else if (preload->get_name() != String()) { + pinfo.name = preload->get_name(); + } else { + pinfo.name = preload->get_class(); + } + } else { + pinfo.name = "<empty>"; } return pinfo; @@ -1188,21 +1177,6 @@ String VisualScriptPreload::get_caption() const { return "Preload"; } -String VisualScriptPreload::get_text() const { - - if (preload.is_valid()) { - if (preload->get_path().is_resource_file()) { - return preload->get_path(); - } else if (preload->get_name() != String()) { - return preload->get_name(); - } else { - return preload->get_class(); - } - } else { - return "<empty>"; - } -} - void VisualScriptPreload::set_preload(const Ref<Resource> &p_preload) { if (preload == p_preload) @@ -1291,12 +1265,7 @@ PropertyInfo VisualScriptIndexGet::get_output_value_port_info(int p_idx) const { String VisualScriptIndexGet::get_caption() const { - return "IndexGet"; -} - -String VisualScriptIndexGet::get_text() const { - - return String("get"); + return "Get Index"; } class VisualScriptNodeInstanceIndexGet : public VisualScriptNodeInstance { @@ -1371,12 +1340,7 @@ PropertyInfo VisualScriptIndexSet::get_output_value_port_info(int p_idx) const { String VisualScriptIndexSet::get_caption() const { - return "IndexSet"; -} - -String VisualScriptIndexSet::get_text() const { - - return String("set"); + return "Set Index"; } class VisualScriptNodeInstanceIndexSet : public VisualScriptNodeInstance { @@ -1439,18 +1403,13 @@ PropertyInfo VisualScriptGlobalConstant::get_input_value_port_info(int p_idx) co } PropertyInfo VisualScriptGlobalConstant::get_output_value_port_info(int p_idx) const { - - return PropertyInfo(Variant::REAL, "value"); + String name = GlobalConstants::get_global_constant_name(index); + return PropertyInfo(Variant::REAL, name); } String VisualScriptGlobalConstant::get_caption() const { - return "GlobalConst"; -} - -String VisualScriptGlobalConstant::get_text() const { - - return GlobalConstants::get_global_constant_name(index); + return "Global Constant"; } void VisualScriptGlobalConstant::set_global_constant(int p_which) { @@ -1539,17 +1498,12 @@ PropertyInfo VisualScriptClassConstant::get_input_value_port_info(int p_idx) con PropertyInfo VisualScriptClassConstant::get_output_value_port_info(int p_idx) const { - return PropertyInfo(Variant::INT, "value"); + return PropertyInfo(Variant::INT, String(base_type) + "." + String(name)); } String VisualScriptClassConstant::get_caption() const { - return "ClassConst"; -} - -String VisualScriptClassConstant::get_text() const { - - return String(base_type) + "." + String(name); + return "Class Constant"; } void VisualScriptClassConstant::set_class_constant(const StringName &p_which) { @@ -1673,7 +1627,7 @@ PropertyInfo VisualScriptBasicTypeConstant::get_output_value_port_info(int p_idx String VisualScriptBasicTypeConstant::get_caption() const { - return "BasicConst"; + return "Basic Constant"; } String VisualScriptBasicTypeConstant::get_text() const { @@ -1828,17 +1782,12 @@ PropertyInfo VisualScriptMathConstant::get_input_value_port_info(int p_idx) cons PropertyInfo VisualScriptMathConstant::get_output_value_port_info(int p_idx) const { - return PropertyInfo(Variant::REAL, "value"); + return PropertyInfo(Variant::REAL, const_name[constant]); } String VisualScriptMathConstant::get_caption() const { - return "MathConst"; -} - -String VisualScriptMathConstant::get_text() const { - - return const_name[constant]; + return "Math Constant"; } void VisualScriptMathConstant::set_math_constant(MathConstant p_which) { @@ -1903,7 +1852,7 @@ VisualScriptMathConstant::VisualScriptMathConstant() { } ////////////////////////////////////////// -////////////////GLOBALSINGLETON/////////// +////////////////ENGINESINGLETON/////////// ////////////////////////////////////////// int VisualScriptEngineSingleton::get_output_sequence_port_count() const { @@ -1937,17 +1886,12 @@ PropertyInfo VisualScriptEngineSingleton::get_input_value_port_info(int p_idx) c PropertyInfo VisualScriptEngineSingleton::get_output_value_port_info(int p_idx) const { - return PropertyInfo(Variant::OBJECT, "instance"); + return PropertyInfo(Variant::OBJECT, singleton); } String VisualScriptEngineSingleton::get_caption() const { - return "EngineSingleton"; -} - -String VisualScriptEngineSingleton::get_text() const { - - return singleton; + return "Get Engine Singleton"; } void VisualScriptEngineSingleton::set_singleton(const String &p_string) { @@ -2058,17 +2002,12 @@ PropertyInfo VisualScriptSceneNode::get_input_value_port_info(int p_idx) const { PropertyInfo VisualScriptSceneNode::get_output_value_port_info(int p_idx) const { - return PropertyInfo(Variant::OBJECT, "node"); + return PropertyInfo(Variant::OBJECT, path.simplified()); } String VisualScriptSceneNode::get_caption() const { - return "SceneNode"; -} - -String VisualScriptSceneNode::get_text() const { - - return path.simplified(); + return "Get Scene Node"; } void VisualScriptSceneNode::set_node_path(const NodePath &p_path) { @@ -2259,17 +2198,12 @@ PropertyInfo VisualScriptSceneTree::get_input_value_port_info(int p_idx) const { PropertyInfo VisualScriptSceneTree::get_output_value_port_info(int p_idx) const { - return PropertyInfo(Variant::OBJECT, "instance"); + return PropertyInfo(Variant::OBJECT, "Scene Tree"); } String VisualScriptSceneTree::get_caption() const { - return "SceneTree"; -} - -String VisualScriptSceneTree::get_text() const { - - return ""; + return "Get Scene Tree"; } class VisualScriptNodeInstanceSceneTree : public VisualScriptNodeInstance { @@ -2361,17 +2295,12 @@ PropertyInfo VisualScriptResourcePath::get_input_value_port_info(int p_idx) cons PropertyInfo VisualScriptResourcePath::get_output_value_port_info(int p_idx) const { - return PropertyInfo(Variant::STRING, "path"); + return PropertyInfo(Variant::STRING, path); } String VisualScriptResourcePath::get_caption() const { - return "ResourcePath"; -} - -String VisualScriptResourcePath::get_text() const { - - return path; + return "Resource Path"; } void VisualScriptResourcePath::set_resource_path(const String &p_path) { @@ -2453,20 +2382,18 @@ PropertyInfo VisualScriptSelf::get_input_value_port_info(int p_idx) const { PropertyInfo VisualScriptSelf::get_output_value_port_info(int p_idx) const { - return PropertyInfo(Variant::OBJECT, "instance"); -} - -String VisualScriptSelf::get_caption() const { + String type_name; + if (get_visual_script().is_valid()) + type_name = get_visual_script()->get_instance_base_type(); + else + type_name = "instance"; - return "Self"; + return PropertyInfo(Variant::OBJECT, type_name); } -String VisualScriptSelf::get_text() const { +String VisualScriptSelf::get_caption() const { - if (get_visual_script().is_valid()) - return get_visual_script()->get_instance_base_type(); - else - return ""; + return "Get Self"; } class VisualScriptNodeInstanceSelf : public VisualScriptNodeInstance { @@ -3032,12 +2959,7 @@ PropertyInfo VisualScriptConstructor::get_output_value_port_info(int p_idx) cons String VisualScriptConstructor::get_caption() const { - return "Construct"; -} - -String VisualScriptConstructor::get_text() const { - - return "new " + Variant::get_type_name(type) + "()"; + return "Construct " + Variant::get_type_name(type); } String VisualScriptConstructor::get_category() const { @@ -3163,17 +3085,12 @@ PropertyInfo VisualScriptLocalVar::get_input_value_port_info(int p_idx) const { } PropertyInfo VisualScriptLocalVar::get_output_value_port_info(int p_idx) const { - return PropertyInfo(type, "get"); + return PropertyInfo(type, name); } String VisualScriptLocalVar::get_caption() const { - return "LocalVarGet"; -} - -String VisualScriptLocalVar::get_text() const { - - return name; + return "Get Local Var"; } String VisualScriptLocalVar::get_category() const { @@ -3289,7 +3206,7 @@ PropertyInfo VisualScriptLocalVarSet::get_output_value_port_info(int p_idx) cons String VisualScriptLocalVarSet::get_caption() const { - return "LocalVarSet"; + return "Set Local Var"; } String VisualScriptLocalVarSet::get_text() const { @@ -3427,12 +3344,7 @@ PropertyInfo VisualScriptInputAction::get_output_value_port_info(int p_idx) cons String VisualScriptInputAction::get_caption() const { - return "Action"; -} - -String VisualScriptInputAction::get_text() const { - - return name; + return "Action " + name; } String VisualScriptInputAction::get_category() const { @@ -3600,12 +3512,7 @@ PropertyInfo VisualScriptDeconstruct::get_output_value_port_info(int p_idx) cons String VisualScriptDeconstruct::get_caption() const { - return "Deconstruct"; -} - -String VisualScriptDeconstruct::get_text() const { - - return "from " + Variant::get_type_name(type) + ":"; + return "Deconstruct " + Variant::get_type_name(type); } String VisualScriptDeconstruct::get_category() const { diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h index a581e81c8c..a0bc35dd92 100644 --- a/modules/visual_script/visual_script_nodes.h +++ b/modules/visual_script/visual_script_nodes.h @@ -124,7 +124,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "operators"; } void set_operator(Variant::Operator p_op); @@ -194,7 +193,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "data"; } void set_variable(StringName p_variable); @@ -228,7 +226,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "data"; } void set_variable(StringName p_variable); @@ -263,7 +260,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "constants"; } void set_constant_type(Variant::Type p_type); @@ -299,7 +295,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "data"; } void set_preload(const Ref<Resource> &p_preload); @@ -327,7 +322,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "operators"; } virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); @@ -352,7 +346,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "operators"; } virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); @@ -381,7 +374,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "constants"; } void set_global_constant(int p_which); @@ -416,7 +408,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "constants"; } void set_class_constant(const StringName &p_which); @@ -505,7 +496,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "constants"; } void set_math_constant(MathConstant p_which); @@ -539,7 +529,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "data"; } void set_singleton(const String &p_string); @@ -575,7 +564,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "data"; } void set_node_path(const NodePath &p_path); @@ -609,7 +597,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "data"; } virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); @@ -641,7 +628,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "data"; } void set_resource_path(const String &p_path); @@ -672,7 +658,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "data"; } virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); @@ -822,7 +807,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const; void set_constructor_type(Variant::Type p_type); @@ -859,7 +843,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const; void set_var_name(const StringName &p_name); @@ -942,7 +925,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const; void set_action_name(const StringName &p_name); @@ -993,7 +975,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const; void set_deconstruct_type(Variant::Type p_type); diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index ee8d249981..385956dc16 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -583,11 +583,14 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec rel_vel = normal.dot(vel); // !BAS! We had this set to 0.4, in bullet its 0.2 - // real_t contactDamping = real_t(0.2); + real_t contactDamping = real_t(0.2); + + if (p_rollInfluence > 0.0) { + // !BAS! But seeing we apply this frame by frame, makes more sense to me to make this time based + // keeping in mind our anti roll factor if it is set + contactDamping = s->get_step() / p_rollInfluence; + } - // !BAS! But seeing we apply this frame by frame, makes more sense to me to make this time based - // keeping in mind our anti roll factor - real_t contactDamping = s->get_step() / p_rollInfluence; #define ONLY_USE_LINEAR_MASS #ifdef ONLY_USE_LINEAR_MASS real_t massTerm = real_t(1.) / ((1.0 / mass) + b2invmass); diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index ce5b372d72..143684bdf9 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -1216,6 +1216,12 @@ String AnimationTreePlayer::animation_node_get_master_animation(const StringName return n->from; } +float AnimationTreePlayer::animation_node_get_position(const StringName &p_node) const { + + GET_NODE_V(NODE_ANIMATION, AnimationNode, 0); + return n->time; +} + bool AnimationTreePlayer::animation_node_is_path_filtered(const StringName &p_node, const NodePath &p_path) const { GET_NODE_V(NODE_ANIMATION, AnimationNode, 0); @@ -1724,6 +1730,7 @@ void AnimationTreePlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("animation_node_set_master_animation", "id", "source"), &AnimationTreePlayer::animation_node_set_master_animation); ClassDB::bind_method(D_METHOD("animation_node_get_master_animation", "id"), &AnimationTreePlayer::animation_node_get_master_animation); + ClassDB::bind_method(D_METHOD("animation_node_get_position", "id"), &AnimationTreePlayer::animation_node_get_position); ClassDB::bind_method(D_METHOD("animation_node_set_filter_path", "id", "path", "enable"), &AnimationTreePlayer::animation_node_set_filter_path); ClassDB::bind_method(D_METHOD("oneshot_node_set_fadein_time", "id", "time_sec"), &AnimationTreePlayer::oneshot_node_set_fadein_time); diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h index 09d6f6fcb4..d2d7b1c9ec 100644 --- a/scene/animation/animation_tree_player.h +++ b/scene/animation/animation_tree_player.h @@ -348,6 +348,7 @@ public: Ref<Animation> animation_node_get_animation(const StringName &p_node) const; void animation_node_set_master_animation(const StringName &p_node, const String &p_master_animation); String animation_node_get_master_animation(const StringName &p_node) const; + float animation_node_get_position(const StringName &p_node) const; void animation_node_set_filter_path(const StringName &p_node, const NodePath &p_track_path, bool p_filter); void animation_node_set_get_filtered_paths(const StringName &p_node, List<NodePath> *r_paths) const; diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index b77143cd9d..02a9e4d69b 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -524,6 +524,9 @@ String AudioStreamSample::get_stream_name() const { void AudioStreamSample::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_data", "data"), &AudioStreamSample::set_data); + ClassDB::bind_method(D_METHOD("get_data"), &AudioStreamSample::get_data); + ClassDB::bind_method(D_METHOD("set_format", "format"), &AudioStreamSample::set_format); ClassDB::bind_method(D_METHOD("get_format"), &AudioStreamSample::get_format); @@ -542,16 +545,13 @@ void AudioStreamSample::_bind_methods() { ClassDB::bind_method(D_METHOD("set_stereo", "stereo"), &AudioStreamSample::set_stereo); ClassDB::bind_method(D_METHOD("is_stereo"), &AudioStreamSample::is_stereo); - ClassDB::bind_method(D_METHOD("_set_data", "data"), &AudioStreamSample::set_data); - ClassDB::bind_method(D_METHOD("_get_data"), &AudioStreamSample::get_data); - + ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_data", "get_data"); ADD_PROPERTY(PropertyInfo(Variant::INT, "format", PROPERTY_HINT_ENUM, "8-Bit,16-Bit,IMA-ADPCM"), "set_format", "get_format"); ADD_PROPERTY(PropertyInfo(Variant::INT, "loop_mode", PROPERTY_HINT_ENUM, "Disabled,Forward,Ping-Pong"), "set_loop_mode", "get_loop_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "loop_begin"), "set_loop_begin", "get_loop_begin"); ADD_PROPERTY(PropertyInfo(Variant::INT, "loop_end"), "set_loop_end", "get_loop_end"); ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_rate"), "set_mix_rate", "get_mix_rate"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stereo"), "set_stereo", "is_stereo"); - ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data"); BIND_ENUM_CONSTANT(FORMAT_8_BITS); BIND_ENUM_CONSTANT(FORMAT_16_BITS); diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 503ca0af4a..0e1f74d8d0 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -181,12 +181,15 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans Rect2 aabb = p_xform.xform(shape->get_aabb()); aabb = aabb.grow(p_margin); - int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, p_result_max, space->intersection_query_subindex_results); + int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, Space2DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); int cc = 0; for (int i = 0; i < amount; i++) { + if (cc >= p_result_max) + break; + if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask)) continue; |