diff options
38 files changed, 301 insertions, 40 deletions
diff --git a/core/resource.cpp b/core/resource.cpp index 78e20bada4..d339eb78ad 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -184,6 +184,35 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res return Ref<Resource>(r); } +void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource> > &remap_cache) { + + print_line("configure for local: " + get_class()); + List<PropertyInfo> plist; + get_property_list(&plist); + + local_scene = p_for_scene; + + for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { + + if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) + continue; + Variant p = get(E->get().name); + if (p.get_type() == Variant::OBJECT) { + + RES sr = p; + if (sr.is_valid()) { + + if (sr->is_local_to_scene()) { + if (!remap_cache.has(sr)) { + sr->configure_for_local_scene(p_for_scene, remap_cache); + remap_cache[sr] = sr; + } + } + } + } + } +} + Ref<Resource> Resource::duplicate(bool p_subresources) const { List<PropertyInfo> plist; diff --git a/core/resource.h b/core/resource.h index 7dc3b67291..19714a68d1 100644 --- a/core/resource.h +++ b/core/resource.h @@ -108,6 +108,7 @@ public: virtual Ref<Resource> duplicate(bool p_subresources = false) const; Ref<Resource> duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource> > &remap_cache); + void configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource> > &remap_cache); void set_local_to_scene(bool p_enable); bool is_local_to_scene() const; diff --git a/doc/classes/CenterContainer.xml b/doc/classes/CenterContainer.xml index 0db18aed53..6235a3fec4 100644 --- a/doc/classes/CenterContainer.xml +++ b/doc/classes/CenterContainer.xml @@ -14,6 +14,7 @@ </methods> <members> <member name="use_top_left" type="bool" setter="set_use_top_left" getter="is_using_top_left"> + If [code]true[/code] centers children relative to the [code]CenterContainer[/code]'s top left corner. Default value: [code]false[/code]. </member> </members> <constants> diff --git a/doc/classes/ColorPickerButton.xml b/doc/classes/ColorPickerButton.xml index c538f66779..c8a4b850d0 100644 --- a/doc/classes/ColorPickerButton.xml +++ b/doc/classes/ColorPickerButton.xml @@ -15,13 +15,16 @@ <return type="ColorPicker"> </return> <description> + Returns the [code]ColorPicker[/code] that this [code]ColorPickerButton[/code] toggles. </description> </method> </methods> <members> <member name="color" type="Color" setter="set_pick_color" getter="get_pick_color"> + The currently selected color. </member> <member name="edit_alpha" type="bool" setter="set_edit_alpha" getter="is_editing_alpha"> + If [code]true[/code] the alpha channel in the displayed [ColorPicker] will be visible. Default value: [code]true[/code]. </member> </members> <signals> @@ -29,7 +32,7 @@ <argument index="0" name="color" type="Color"> </argument> <description> - Emitted when the color is changed. + Emitted when the color changes. </description> </signal> </signals> diff --git a/doc/classes/PackedScene.xml b/doc/classes/PackedScene.xml index 3940995936..80ef3afdb1 100644 --- a/doc/classes/PackedScene.xml +++ b/doc/classes/PackedScene.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="PackedScene" inherits="Resource" category="Core" version="3.0-beta"> <brief_description> + An abstraction of a serialized scene. </brief_description> <description> + A simplified interface to a scene file. Provides access to operations and checks that can be performed on the scene resource itself. TODO: explain ownership, and that node does not need to own itself </description> <tutorials> @@ -14,12 +16,14 @@ <return type="bool"> </return> <description> + Returns [code]true[/code] if the scene file has nodes. </description> </method> <method name="get_state"> <return type="SceneState"> </return> <description> + Returns the [code]SceneState[/code] representing the scene file contents. </description> </method> <method name="instance" qualifiers="const"> @@ -28,6 +32,7 @@ <argument index="0" name="edit_state" type="int" enum="PackedScene.GenEditState" default="0"> </argument> <description> + Instantiates the scene's node hierarchy. Triggers child scene instantiation(s). Triggers the [enum Object.NOTIFICATION_INSTANCED] notification on the root node. </description> </method> <method name="pack"> @@ -42,14 +47,19 @@ </methods> <members> <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene"> + A dictionary representation of the scene contents. + Available keys include "rnames" and "variants" for resources, "node_count", "nodes", "node_paths" for nodes, "editable_instances" for base scene children overrides, "conn_count" and "conns" for signal connections, and "version" for the format style of the PackedScene. </member> </members> <constants> <constant name="GEN_EDIT_STATE_DISABLED" value="0" enum="GenEditState"> + If passed to [method instance], blocks edits to the scene state. </constant> <constant name="GEN_EDIT_STATE_INSTANCE" value="1" enum="GenEditState"> + If passed to [method instance], provides local scene resources to the local scene. Requires tools compiled. </constant> <constant name="GEN_EDIT_STATE_MAIN" value="2" enum="GenEditState"> + If passed to [method instance], provides local scene resources to the local scene. Only the main scene should receive the main edit state. Requires tools compiled. </constant> </constants> </class> diff --git a/doc/classes/SceneState.xml b/doc/classes/SceneState.xml index 20ca43b71a..4fcaaa23dc 100644 --- a/doc/classes/SceneState.xml +++ b/doc/classes/SceneState.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="SceneState" inherits="Reference" category="Core" version="3.0-beta"> <brief_description> + A script interface to a scene file's data. </brief_description> <description> + Maintains a list of resources, nodes, exported and overridden properties, and built-in scripts associated with a scene. </description> <tutorials> </tutorials> @@ -15,12 +17,14 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the list of bound parameters for the signal at [code]idx[/code]. </description> </method> <method name="get_connection_count" qualifiers="const"> <return type="int"> </return> <description> + Returns the number of signal connections in the scene. </description> </method> <method name="get_connection_flags" qualifiers="const"> @@ -29,6 +33,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the flags for the signal at [code]idx[/code]. See [Object]'s [code]CONNECT_*[/code] flags. </description> </method> <method name="get_connection_method" qualifiers="const"> @@ -37,6 +42,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the method connected to the signal at [code]idx[/code]. </description> </method> <method name="get_connection_signal" qualifiers="const"> @@ -45,6 +51,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the name of the signal at [code]idx[/code]. </description> </method> <method name="get_connection_source" qualifiers="const"> @@ -53,6 +60,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the path to the node that owns the signal at [code]idx[/code], relative to the root node. </description> </method> <method name="get_connection_target" qualifiers="const"> @@ -61,12 +69,14 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the path to the node that owns the method connected to the signal at [code]idx[/code], relative to the root node. </description> </method> <method name="get_node_count" qualifiers="const"> <return type="int"> </return> <description> + Returns the number of nodes in the scene. </description> </method> <method name="get_node_groups" qualifiers="const"> @@ -75,6 +85,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the list of group names associated with the node at [code]idx[/code]. </description> </method> <method name="get_node_instance" qualifiers="const"> @@ -83,6 +94,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the scene for the node at [code]idx[/code] or [code]null[/code] if the node is not an instance. </description> </method> <method name="get_node_instance_placeholder" qualifiers="const"> @@ -91,6 +103,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the path to the represented scene file if the node at [code]idx[/code] is an [InstancePlaceholder]. </description> </method> <method name="get_node_name" qualifiers="const"> @@ -99,6 +112,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the name of the node at [code]idx[/code]. </description> </method> <method name="get_node_owner_path" qualifiers="const"> @@ -107,6 +121,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the path to the owner of the node at [code]idx[/code], relative to the root node. </description> </method> <method name="get_node_path" qualifiers="const"> @@ -117,6 +132,7 @@ <argument index="1" name="for_parent" type="bool" default="false"> </argument> <description> + Returns the path to the node at [code]idx[/code]. </description> </method> <method name="get_node_property_count" qualifiers="const"> @@ -125,6 +141,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the number of exported or overridden properties for the node at [code]idx[/code]. </description> </method> <method name="get_node_property_name" qualifiers="const"> @@ -135,6 +152,7 @@ <argument index="1" name="prop_idx" type="int"> </argument> <description> + Returns the name of the property at [code]prop_idx[/code] for the node at [code]idx[/code]. </description> </method> <method name="get_node_property_value" qualifiers="const"> @@ -145,6 +163,7 @@ <argument index="1" name="prop_idx" type="int"> </argument> <description> + Returns the value of the property at [code]prop_idx[/code] for the node at [code]idx[/code]. </description> </method> <method name="get_node_type" qualifiers="const"> @@ -153,6 +172,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the type of the node at [code]idx[/code]. </description> </method> <method name="is_node_instance_placeholder" qualifiers="const"> @@ -161,15 +181,19 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns [code]true[/code] if the node at [code]idx[/code] is an [InstancePlaceholder]. </description> </method> </methods> <constants> <constant name="GEN_EDIT_STATE_DISABLED" value="0" enum="GenEditState"> + If passed to [method PackedScene.instance], blocks edits to the scene state. </constant> <constant name="GEN_EDIT_STATE_INSTANCE" value="1" enum="GenEditState"> + If passed to [method PackedScene.instance], provides inherited scene resources to the local scene. Requires tools compiled. </constant> <constant name="GEN_EDIT_STATE_MAIN" value="2" enum="GenEditState"> + If passed to [method PackedScene.instance], provides local scene resources to the local scene. Only the main scene should receive the main edit state. Requires tools compiled. </constant> </constants> </class> diff --git a/doc/classes/WindowDialog.xml b/doc/classes/WindowDialog.xml index 41aa71b782..5bdcfe238d 100644 --- a/doc/classes/WindowDialog.xml +++ b/doc/classes/WindowDialog.xml @@ -21,8 +21,10 @@ </methods> <members> <member name="resizable" type="bool" setter="set_resizable" getter="get_resizable"> + If [code]true[/code] the user can resize the window. Default value: [code]false[/code]. </member> <member name="window_title" type="String" setter="set_title" getter="get_title"> + The text displayed in the window's title bar. Default value: "Save a File". </member> </members> <constants> diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 5b3e43fc43..0839f930c9 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -208,6 +208,8 @@ RasterizerStorageGLES3::Texture *RasterizerCanvasGLES3::_bind_canvas_texture(con } else { + texture = texture->get_ptr(); + if (texture->render_target) texture->render_target->used_in_frame = true; @@ -243,6 +245,7 @@ RasterizerStorageGLES3::Texture *RasterizerCanvasGLES3::_bind_canvas_texture(con } else { + normal_map = normal_map->get_ptr(); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, normal_map->tex_id); state.current_normal = p_normal_map; @@ -1115,6 +1118,8 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons continue; } + t = t->get_ptr(); + if (storage->config.srgb_decode_supported && t->using_srgb) { //no srgb in 2D glTexParameteri(t->target, _TEXTURE_SRGB_DECODE_EXT, _SKIP_DECODE_EXT); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 0f8f98b021..3031b70f70 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1235,6 +1235,7 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m } else { + t = t->get_ptr(); //resolve for proxies #ifdef TOOLS_ENABLED if (t->detect_3d) { t->detect_3d(t->detect_3d_ud); @@ -2164,7 +2165,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ state.scene_shader.set_conditional(SceneShaderGLES3::USE_OPAQUE_PREPASS, false); } -void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_depth_pass,bool p_shadow_pass) { +void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_depth_pass, bool p_shadow_pass) { RasterizerStorageGLES3::Material *m = NULL; RID m_src = p_instance->material_override.is_valid() ? p_instance->material_override : (p_material >= 0 ? p_instance->materials[p_material] : p_geometry->material); @@ -2238,11 +2239,11 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) { //shader does not use discard and does not write a vertex position, use generic material if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) { - p_material = storage->material_owner.getptr( !p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided); + p_material = storage->material_owner.getptr(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided); no_cull = true; mirror = false; } else { - p_material = storage->material_owner.getptr( !p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material); + p_material = storage->material_owner.getptr(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material); } } @@ -2289,10 +2290,8 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G } else { e->sort_key |= uint64_t(e->instance->depth_layer) << RenderList::SORT_KEY_OPAQUE_DEPTH_LAYER_SHIFT; e->sort_key |= uint64_t(e->material->index) << RenderList::SORT_KEY_MATERIAL_INDEX_SHIFT; - } - /* if (e->geometry->type==RasterizerStorageGLES3::Geometry::GEOMETRY_MULTISURFACE) e->sort_flags|=RenderList::SORT_FLAG_INSTANCING; @@ -4090,7 +4089,6 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const _setup_lights(p_light_cull_result, p_light_cull_count, p_cam_transform.affine_inverse(), p_cam_projection, p_shadow_atlas); _setup_reflections(p_reflection_probe_cull_result, p_reflection_probe_cull_count, p_cam_transform.affine_inverse(), p_cam_projection, p_reflection_atlas, env); - bool use_mrt = false; render_list.clear(); @@ -4774,7 +4772,6 @@ void RasterizerSceneGLES3::initialize() { default_worldcoord_material_twosided = storage->material_create(); storage->shader_set_code(default_worldcoord_shader_twosided, "shader_type spatial; render_mode cull_disabled,world_vertex_coords;\n"); storage->material_set_shader(default_worldcoord_material_twosided, default_worldcoord_shader_twosided); - } { diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 7e3d21adbb..cba9f08537 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -1232,6 +1232,25 @@ RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source, int p_ return texture_owner.make_rid(ctex); } +void RasterizerStorageGLES3::texture_set_proxy(RID p_texture, RID p_proxy) { + + Texture *texture = texture_owner.get(p_texture); + ERR_FAIL_COND(!texture); + + if (texture->proxy) { + texture->proxy->proxy_owners.erase(texture); + texture->proxy = NULL; + } + + if (p_proxy.is_valid()) { + Texture *proxy = texture_owner.get(p_proxy); + ERR_FAIL_COND(!proxy); + ERR_FAIL_COND(proxy == texture); + proxy->proxy_owners.insert(texture); + texture->proxy = proxy; + } +} + RID RasterizerStorageGLES3::sky_create() { Sky *sky = memnew(Sky); @@ -1617,7 +1636,6 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const { shaders.actions_scene.render_mode_values["cull_back"] = Pair<int *, int>(&p_shader->spatial.cull_mode, Shader::Spatial::CULL_MODE_BACK); shaders.actions_scene.render_mode_values["cull_disabled"] = Pair<int *, int>(&p_shader->spatial.cull_mode, Shader::Spatial::CULL_MODE_DISABLED); - shaders.actions_scene.render_mode_flags["unshaded"] = &p_shader->spatial.unshaded; shaders.actions_scene.render_mode_flags["depth_test_disable"] = &p_shader->spatial.no_depth_test; diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 7c86862425..d5efd5307c 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -242,6 +242,9 @@ public: struct Texture : public RID_Data { + Texture *proxy; + Set<Texture *> proxy_owners; + String path; uint32_t flags; int width, height; @@ -301,6 +304,15 @@ public: detect_srgb_ud = NULL; detect_normal = NULL; detect_normal_ud = NULL; + proxy = NULL; + } + + _ALWAYS_INLINE_ Texture *get_ptr() { + if (proxy) { + return proxy; //->get_ptr(); only one level of indirection, else not inlining possible. + } else { + return this; + } } ~Texture() { @@ -309,6 +321,14 @@ public: glDeleteTextures(1, &tex_id); } + + for (Set<Texture *>::Element *E = proxy_owners.front(); E; E = E->next()) { + E->get()->proxy = NULL; + } + + if (proxy) { + proxy->proxy_owners.erase(this); + } } }; @@ -343,6 +363,8 @@ public: virtual void texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata); virtual void texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata); + virtual void texture_set_proxy(RID p_texture, RID p_proxy); + /* SKY API */ struct Sky : public RID_Data { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index fbf6c86c35..9e242b4ecd 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1674,7 +1674,6 @@ void EditorNode::_resource_selected(const RES &p_res, const String &p_property) void EditorNode::_run(bool p_current, const String &p_custom) { if (editor_run.get_status() == EditorRun::STATUS_PLAY) { - play_button->set_pressed(!_playing_edited); play_scene_button->set_pressed(_playing_edited); return; @@ -1806,6 +1805,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) { play_button->set_pressed(true); play_button->set_icon(gui_base->get_icon("Reload", "EditorIcons")); } + stop_button->set_disabled(false); _playing_edited = p_current; } @@ -2277,6 +2277,8 @@ 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")); + stop_button->set_disabled(true); + 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) { @@ -5264,6 +5266,7 @@ EditorNode::EditorNode() { stop_button->set_icon(gui_base->get_icon("Stop", "EditorIcons")); stop_button->connect("pressed", this, "_menu_option", make_binds(RUN_STOP)); stop_button->set_tooltip(TTR("Stop the scene.")); + stop_button->set_disabled(true); stop_button->set_shortcut(ED_SHORTCUT("editor/stop", TTR("Stop"), KEY_F8)); run_native = memnew(EditorRunNative); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 19293360ed..3a443e1bf7 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1042,8 +1042,13 @@ void ScriptTextEditor::_edit_option(int p_op) { String delimiter = "#"; List<String> comment_delimiters; scr->get_language()->get_comment_delimiters(&comment_delimiters); - if (!comment_delimiters.empty()) { - delimiter = comment_delimiters.front()->get(); + + for (List<String>::Element *E = comment_delimiters.front(); E; E = E->next()) { + String script_delimiter = E->get(); + if (script_delimiter.find(" ") == -1) { + delimiter = script_delimiter; + break; + } } tx->begin_complex_operation(); diff --git a/editor/translations/README.md b/editor/translations/README.md index 351bc9e2d1..f30f4e61fb 100644 --- a/editor/translations/README.md +++ b/editor/translations/README.md @@ -16,5 +16,8 @@ Link if you missed it: https://hosted.weblate.org/projects/godot-engine/godot ## Adding new languages If you want to translate for a language which is not featured yet on Weblate, -open an issue on this repo to ask that the language is added, or contact -Akien/@akien-mga directly on IRC (#godotengine channel on Freenode). +you can add it (when logged in) by clicking the "Start new translation" +button at the bottom of the page. + +Alternatively, you can use this +[direct link](https://hosted.weblate.org/new-lang/godot-engine/godot/). diff --git a/modules/gdnative/gdnative/basis.cpp b/modules/gdnative/gdnative/basis.cpp index 39ca754dc7..7a65996036 100644 --- a/modules/gdnative/gdnative/basis.cpp +++ b/modules/gdnative/gdnative/basis.cpp @@ -221,7 +221,7 @@ godot_basis GDAPI godot_basis_operator_add(const godot_basis *p_self, const godo return raw_dest; } -godot_basis GDAPI godot_basis_operator_substract(const godot_basis *p_self, const godot_basis *p_b) { +godot_basis GDAPI godot_basis_operator_subtract(const godot_basis *p_self, const godot_basis *p_b) { godot_basis raw_dest; Basis *dest = (Basis *)&raw_dest; const Basis *self = (const Basis *)p_self; diff --git a/modules/gdnative/gdnative/quat.cpp b/modules/gdnative/gdnative/quat.cpp index 2d012c069f..c308e5973d 100644 --- a/modules/gdnative/gdnative/quat.cpp +++ b/modules/gdnative/gdnative/quat.cpp @@ -181,7 +181,7 @@ godot_quat GDAPI godot_quat_operator_add(const godot_quat *p_self, const godot_q return raw_dest; } -godot_quat GDAPI godot_quat_operator_substract(const godot_quat *p_self, const godot_quat *p_b) { +godot_quat GDAPI godot_quat_operator_subtract(const godot_quat *p_self, const godot_quat *p_b) { godot_quat raw_dest; Quat *dest = (Quat *)&raw_dest; const Quat *self = (const Quat *)p_self; diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp index 7a5b29e0c4..7be08929b1 100644 --- a/modules/gdnative/gdnative/vector2.cpp +++ b/modules/gdnative/gdnative/vector2.cpp @@ -207,7 +207,7 @@ godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_self, cons return raw_dest; } -godot_vector2 GDAPI godot_vector2_operator_substract(const godot_vector2 *p_self, const godot_vector2 *p_b) { +godot_vector2 GDAPI godot_vector2_operator_subtract(const godot_vector2 *p_self, const godot_vector2 *p_b) { godot_vector2 raw_dest; Vector2 *dest = (Vector2 *)&raw_dest; const Vector2 *self = (const Vector2 *)p_self; diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp index 11ffb3320b..0027d236f2 100644 --- a/modules/gdnative/gdnative/vector3.cpp +++ b/modules/gdnative/gdnative/vector3.cpp @@ -224,7 +224,7 @@ godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_self, cons return raw_dest; } -godot_vector3 GDAPI godot_vector3_operator_substract(const godot_vector3 *p_self, const godot_vector3 *p_b) { +godot_vector3 GDAPI godot_vector3_operator_subtract(const godot_vector3 *p_self, const godot_vector3 *p_b) { godot_vector3 raw_dest; Vector3 *dest = (Vector3 *)&raw_dest; Vector3 *self = (Vector3 *)p_self; diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 488ed93206..31f3b0b77b 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -387,7 +387,7 @@ ] }, { - "name": "godot_vector2_operator_substract", + "name": "godot_vector2_operator_subtract", "return_type": "godot_vector2", "arguments": [ ["const godot_vector2 *", "p_self"], @@ -663,7 +663,7 @@ ] }, { - "name": "godot_quat_operator_substract", + "name": "godot_quat_operator_subtract", "return_type": "godot_quat", "arguments": [ ["const godot_quat *", "p_self"], @@ -907,7 +907,7 @@ ] }, { - "name": "godot_basis_operator_substract", + "name": "godot_basis_operator_subtract", "return_type": "godot_basis", "arguments": [ ["const godot_basis *", "p_self"], @@ -1142,7 +1142,7 @@ ] }, { - "name": "godot_vector3_operator_substract", + "name": "godot_vector3_operator_subtract", "return_type": "godot_vector3", "arguments": [ ["const godot_vector3 *", "p_self"], diff --git a/modules/gdnative/include/gdnative/basis.h b/modules/gdnative/include/gdnative/basis.h index 49ca765a01..4898eab24c 100644 --- a/modules/gdnative/include/gdnative/basis.h +++ b/modules/gdnative/include/gdnative/basis.h @@ -111,7 +111,7 @@ godot_bool GDAPI godot_basis_operator_equal(const godot_basis *p_self, const god godot_basis GDAPI godot_basis_operator_add(const godot_basis *p_self, const godot_basis *p_b); -godot_basis GDAPI godot_basis_operator_substract(const godot_basis *p_self, const godot_basis *p_b); +godot_basis GDAPI godot_basis_operator_subtract(const godot_basis *p_self, const godot_basis *p_b); godot_basis GDAPI godot_basis_operator_multiply_vector(const godot_basis *p_self, const godot_basis *p_b); diff --git a/modules/gdnative/include/gdnative/quat.h b/modules/gdnative/include/gdnative/quat.h index acae6e3e90..2be9d8849d 100644 --- a/modules/gdnative/include/gdnative/quat.h +++ b/modules/gdnative/include/gdnative/quat.h @@ -98,7 +98,7 @@ godot_quat GDAPI godot_quat_operator_multiply(const godot_quat *p_self, const go godot_quat GDAPI godot_quat_operator_add(const godot_quat *p_self, const godot_quat *p_b); -godot_quat GDAPI godot_quat_operator_substract(const godot_quat *p_self, const godot_quat *p_b); +godot_quat GDAPI godot_quat_operator_subtract(const godot_quat *p_self, const godot_quat *p_b); godot_quat GDAPI godot_quat_operator_divide(const godot_quat *p_self, const godot_real p_b); diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h index 07105abaf2..4d1117e3aa 100644 --- a/modules/gdnative/include/gdnative/vector2.h +++ b/modules/gdnative/include/gdnative/vector2.h @@ -106,7 +106,7 @@ godot_vector2 GDAPI godot_vector2_clamped(const godot_vector2 *p_self, const god godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_self, const godot_vector2 *p_b); -godot_vector2 GDAPI godot_vector2_operator_substract(const godot_vector2 *p_self, const godot_vector2 *p_b); +godot_vector2 GDAPI godot_vector2_operator_subtract(const godot_vector2 *p_self, const godot_vector2 *p_b); godot_vector2 GDAPI godot_vector2_operator_multiply_vector(const godot_vector2 *p_self, const godot_vector2 *p_b); diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h index 3ed23778ec..135a13acc8 100644 --- a/modules/gdnative/include/gdnative/vector3.h +++ b/modules/gdnative/include/gdnative/vector3.h @@ -117,7 +117,7 @@ godot_vector3 GDAPI godot_vector3_reflect(const godot_vector3 *p_self, const god godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_self, const godot_vector3 *p_b); -godot_vector3 GDAPI godot_vector3_operator_substract(const godot_vector3 *p_self, const godot_vector3 *p_b); +godot_vector3 GDAPI godot_vector3_operator_subtract(const godot_vector3 *p_self, const godot_vector3 *p_b); godot_vector3 GDAPI godot_vector3_operator_multiply_vector(const godot_vector3 *p_self, const godot_vector3 *p_b); diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index 34099bf528..365def75bc 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -103,16 +103,34 @@ static void actual_discoverer_handler() { Set<String> file_paths = get_gdnative_singletons(dir); + bool changed = false; + Array current_files = ProjectSettings::get_singleton()->get("gdnative/singletons"); Array files; files.resize(file_paths.size()); int i = 0; for (Set<String>::Element *E = file_paths.front(); E; i++, E = E->next()) { + if (!current_files.has(E->get())) { + changed = true; + } files.set(i, E->get()); } - ProjectSettings::get_singleton()->set("gdnative/singletons", files); + // Check for removed files + if (!changed) { + for (int i = 0; i < current_files.size(); i++) { + if (!file_paths.has(current_files[i])) { + changed = true; + break; + } + } + } - ProjectSettings::get_singleton()->save(); + if (changed) { + + ProjectSettings::get_singleton()->set("gdnative/singletons", files); + + ProjectSettings::get_singleton()->save(); + } } static GDNativeSingletonDiscover *discoverer = NULL; diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 95ad7256b3..5f98951bec 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -390,7 +390,7 @@ PropertyInfo VisualScriptOperator::get_input_value_port_info(int p_idx) const { { Variant::NIL, Variant::NIL }, //OP_GREATER_EQUAL, //mathematic { Variant::NIL, Variant::NIL }, //OP_ADD, - { Variant::NIL, Variant::NIL }, //OP_SUBSTRACT, + { Variant::NIL, Variant::NIL }, //OP_SUBTRACT, { Variant::NIL, Variant::NIL }, //OP_MULTIPLY, { Variant::NIL, Variant::NIL }, //OP_DIVIDE, { Variant::NIL, Variant::NIL }, //OP_NEGATE, @@ -433,7 +433,7 @@ PropertyInfo VisualScriptOperator::get_output_value_port_info(int p_idx) const { Variant::BOOL, //OP_GREATER_EQUAL, //mathematic Variant::NIL, //OP_ADD, - Variant::NIL, //OP_SUBSTRACT, + Variant::NIL, //OP_SUBTRACT, Variant::NIL, //OP_MULTIPLY, Variant::NIL, //OP_DIVIDE, Variant::NIL, //OP_NEGATE, @@ -474,7 +474,7 @@ static const char *op_names[] = { "GreaterEq", //OP_GREATER_EQUAL, //mathematic "Add", //OP_ADD, - "Subtract", //OP_SUBSTRACT, + "Subtract", //OP_SUBTRACT, "Multiply", //OP_MULTIPLY, "Divide", //OP_DIVIDE, "Negate", //OP_NEGATE, @@ -514,7 +514,7 @@ String VisualScriptOperator::get_text() const { L"A \u2265 B", //OP_GREATER_EQUAL, //mathematic L"A + B", //OP_ADD, - L"A - B", //OP_SUBSTRACT, + L"A - B", //OP_SUBTRACT, L"A x B", //OP_MULTIPLY, L"A \u00F7 B", //OP_DIVIDE, L"\u00AC A", //OP_NEGATE, diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index f74bf161f0..5ee286c2d5 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -418,12 +418,12 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) { if (!input_handled) { call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_vp_unhandled_input", ev); //special one for GUI, as controls use their own process check - input_handled = true; _flush_ugc(); + // input_handled = true; - no reason to set this as handled root_lock--; //MessageQueue::get_singleton()->flush(); //flushing here causes UI and other places slowness } else { - input_handled = true; + // input_handled = true; - no reason to set this as handled root_lock--; } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 1fc2d4b16e..d864b0f763 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -69,6 +69,8 @@ void ViewportTexture::setup_local_to_scene() { ERR_FAIL_COND(!vp); vp->viewport_textures.insert(this); + + VS::get_singleton()->texture_set_proxy(proxy, vp->texture_rid); } void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) { @@ -105,8 +107,8 @@ Size2 ViewportTexture::get_size() const { } RID ViewportTexture::get_rid() const { - ERR_FAIL_COND_V(!vp, RID()); - return vp->texture_rid; + //ERR_FAIL_COND_V(!vp, RID()); + return proxy; } bool ViewportTexture::has_alpha() const { @@ -147,6 +149,7 @@ ViewportTexture::ViewportTexture() { vp = NULL; set_local_to_scene(true); + proxy = VS::get_singleton()->texture_create(); } ViewportTexture::~ViewportTexture() { @@ -154,6 +157,8 @@ ViewportTexture::~ViewportTexture() { if (vp) { vp->viewport_textures.erase(this); } + + VS::get_singleton()->free(proxy); } ///////////////////////////////////// @@ -2813,6 +2818,7 @@ Viewport::Viewport() { default_texture.instance(); default_texture->vp = const_cast<Viewport *>(this); viewport_textures.insert(default_texture.ptr()); + VS::get_singleton()->texture_set_proxy(default_texture->proxy, texture_rid); //internal_listener = SpatialSoundServer::get_singleton()->listener_create(); audio_listener = false; diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 6bbd4b26b5..0835e3f69a 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -59,6 +59,8 @@ class ViewportTexture : public Texture { friend class Viewport; Viewport *vp; + RID proxy; + protected: static void _bind_methods(); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index c99bc3c9ef..d6557f508e 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -529,6 +529,7 @@ void register_scene_types() { ClassDB::register_class<LargeTexture>(); ClassDB::register_class<CurveTexture>(); ClassDB::register_class<GradientTexture>(); + ClassDB::register_class<ProxyTexture>(); ClassDB::register_class<CubeMap>(); ClassDB::register_class<Animation>(); ClassDB::register_virtual_class<Font>(); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 79f642a09b..15710f4c14 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -689,6 +689,10 @@ void SpatialMaterial::_update_shader() { } } + if (flags[FLAG_ALBEDO_TEXTURE_FORCE_SRGB]) { + code += "\talbedo_tex.rgb = mix(pow((albedo_tex.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)),vec3(2.4)),albedo_tex.rgb.rgb * (1.0 / 12.92),lessThan(albedo_tex.rgb,vec3(0.04045)));\n"; + } + if (flags[FLAG_ALBEDO_FROM_VERTEX_COLOR]) { code += "\talbedo_tex *= COLOR;\n"; } @@ -1833,6 +1837,7 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_use_point_size"), "set_flag", "get_flag", FLAG_USE_POINT_SIZE); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_world_triplanar"), "set_flag", "get_flag", FLAG_TRIPLANAR_USE_WORLD); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_fixed_size"), "set_flag", "get_flag", FLAG_FIXED_SIZE); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_albedo_tex_force_srgb"), "set_flag", "get_flag", FLAG_ALBEDO_TEXTURE_FORCE_SRGB); ADD_GROUP("Vertex Color", "vertex_color"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "vertex_color_use_as_albedo"), "set_flag", "get_flag", FLAG_ALBEDO_FROM_VERTEX_COLOR); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "vertex_color_is_srgb"), "set_flag", "get_flag", FLAG_SRGB_VERTEX_COLOR); @@ -2019,6 +2024,7 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(FLAG_AO_ON_UV2); BIND_ENUM_CONSTANT(FLAG_USE_ALPHA_SCISSOR); BIND_ENUM_CONSTANT(FLAG_TRIPLANAR_USE_WORLD); + BIND_ENUM_CONSTANT(FLAG_ALBEDO_TEXTURE_FORCE_SRGB); BIND_ENUM_CONSTANT(FLAG_MAX); BIND_ENUM_CONSTANT(DIFFUSE_BURLEY); diff --git a/scene/resources/material.h b/scene/resources/material.h index 877d4dfd41..374ec853dc 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -181,6 +181,7 @@ public: FLAG_TRIPLANAR_USE_WORLD, FLAG_AO_ON_UV2, FLAG_USE_ALPHA_SCISSOR, + FLAG_ALBEDO_TEXTURE_FORCE_SRGB, FLAG_MAX }; @@ -229,7 +230,7 @@ private: uint64_t blend_mode : 2; uint64_t depth_draw_mode : 2; uint64_t cull_mode : 2; - uint64_t flags : 12; + uint64_t flags : 13; uint64_t detail_blend_mode : 2; uint64_t diffuse_mode : 3; uint64_t specular_mode : 2; diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 5d6f44dfef..06829089be 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -232,11 +232,11 @@ Node *SceneState::instance(GenEditState p_edit_state) const { Node *base = i == 0 ? node : ret_nodes[0]; if (p_edit_state == GEN_EDIT_STATE_MAIN) { - - res->local_scene = base; - resources_local_to_scene[res] = res; + //for the main scene, use the resource as is + res->configure_for_local_scene(base, resources_local_to_scene); } else { + //for instances, a copy must be made Node *base = i == 0 ? node : ret_nodes[0]; Ref<Resource> local_dupe = res->duplicate_for_local_scene(base, resources_local_to_scene); resources_local_to_scene[res] = local_dupe; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 162edd0d1c..987d6c5f6a 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -1601,3 +1601,72 @@ int GradientTexture::get_width() const { Ref<Image> GradientTexture::get_data() const { return VisualServer::get_singleton()->texture_get_data(texture); } + +////////////////////////////////////// + +void ProxyTexture::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_base", "base"), &ProxyTexture::set_base); + ClassDB::bind_method(D_METHOD("get_base"), &ProxyTexture::get_base); + + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "base", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_base", "get_base"); +} + +void ProxyTexture::set_base(const Ref<Texture> &p_texture) { + + base = p_texture; + if (base.is_valid()) { + VS::get_singleton()->texture_set_proxy(proxy, base->get_rid()); + } else { + VS::get_singleton()->texture_set_proxy(proxy, RID()); + } +} + +Ref<Texture> ProxyTexture::get_base() const { + + return base; +} + +int ProxyTexture::get_width() const { + + if (base.is_valid()) + return base->get_width(); + return 1; +} +int ProxyTexture::get_height() const { + + if (base.is_valid()) + return base->get_height(); + return 1; +} +RID ProxyTexture::get_rid() const { + + return proxy; +} + +bool ProxyTexture::has_alpha() const { + + if (base.is_valid()) + return base->has_alpha(); + return false; +} + +void ProxyTexture::set_flags(uint32_t p_flags) { +} + +uint32_t ProxyTexture::get_flags() const { + + if (base.is_valid()) + return base->get_flags(); + return 0; +} + +ProxyTexture::ProxyTexture() { + + proxy = VS::get_singleton()->texture_create(); +} + +ProxyTexture::~ProxyTexture() { + + VS::get_singleton()->free(proxy); +} diff --git a/scene/resources/texture.h b/scene/resources/texture.h index ee54156647..76c0195ef9 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -493,4 +493,31 @@ public: virtual ~GradientTexture(); }; +class ProxyTexture : public Texture { + GDCLASS(ProxyTexture, Texture) + +private: + RID proxy; + Ref<Texture> base; + +protected: + static void _bind_methods(); + +public: + void set_base(const Ref<Texture> &p_texture); + Ref<Texture> get_base() const; + + virtual int get_width() const; + virtual int get_height() const; + virtual RID get_rid() const; + + virtual bool has_alpha() const; + + virtual void set_flags(uint32_t p_flags); + virtual uint32_t get_flags() const; + + ProxyTexture(); + ~ProxyTexture(); +}; + #endif diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 2499551607..4bb34af241 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -193,6 +193,8 @@ public: virtual void textures_keep_original(bool p_enable) = 0; + virtual void texture_set_proxy(RID p_proxy, RID p_base) = 0; + /* SKY API */ virtual RID sky_create() = 0; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index f34951f452..91542625e0 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -168,6 +168,8 @@ public: BIND1(textures_keep_original, bool) + BIND2(texture_set_proxy, RID, RID) + /* SKY API */ BIND0R(RID, sky_create) diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index d1069a410c..1c3b34d16f 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -100,6 +100,8 @@ public: FUNC1(textures_keep_original, bool) + FUNC2(texture_set_proxy, RID, RID) + /* SKY API */ FUNCRID(sky) diff --git a/servers/visual_server.h b/servers/visual_server.h index 9df389999a..350097c1b5 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -141,6 +141,8 @@ public: virtual void textures_keep_original(bool p_enable) = 0; + virtual void texture_set_proxy(RID p_proxy, RID p_base) = 0; + /* SKY API */ virtual RID sky_create() = 0; |