diff options
86 files changed, 1152 insertions, 411 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a9ada58e64..6cb52cf5ff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -87,7 +87,7 @@ rebase -i`` and relevant help about rebasing or ammending commits on the Internet). This git style guide has some good practices to have in mind: -https://github.com/agis-/git-style-guide +[Git Style Guide](https://github.com/agis-/git-style-guide) #### Format your commit logs with readability in mind diff --git a/core/class_db.cpp b/core/class_db.cpp index 12310f6151..57e88044b5 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -187,6 +187,25 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_ return md; } +MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11) { + + MethodDefinition md; + md.name = StaticCString::create(p_name); + md.args.resize(11); + md.args[0] = StaticCString::create(p_arg1); + md.args[1] = StaticCString::create(p_arg2); + md.args[2] = StaticCString::create(p_arg3); + md.args[3] = StaticCString::create(p_arg4); + md.args[4] = StaticCString::create(p_arg5); + md.args[5] = StaticCString::create(p_arg6); + md.args[6] = StaticCString::create(p_arg7); + md.args[7] = StaticCString::create(p_arg8); + md.args[8] = StaticCString::create(p_arg9); + md.args[9] = StaticCString::create(p_arg10); + md.args[10] = StaticCString::create(p_arg11); + return md; +} + #endif ClassDB::APIType ClassDB::current_api = API_CORE; diff --git a/core/class_db.h b/core/class_db.h index 5910a2ce01..24db4c61bb 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -66,6 +66,7 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8); MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9); MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10); +MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11); #else diff --git a/core/io/logger.cpp b/core/io/logger.cpp index ad6371f1e1..ce2ce44b1d 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -110,7 +110,7 @@ void RotatedFileLogger::close_file() { void RotatedFileLogger::clear_old_backups() { int max_backups = max_files - 1; // -1 for the current file - String basename = base_path.get_basename(); + String basename = base_path.get_file().get_basename(); String extension = "." + base_path.get_extension(); DirAccess *da = DirAccess::open(base_path.get_base_dir()); @@ -122,7 +122,7 @@ void RotatedFileLogger::clear_old_backups() { String f = da->get_next(); Set<String> backups; while (f != String()) { - if (!da->current_is_dir() && f.begins_with(basename) && f.ends_with(extension) && f != base_path) { + if (!da->current_is_dir() && f.begins_with(basename) && f.ends_with(extension) && f != base_path.get_file()) { backups.insert(f); } f = da->get_next(); @@ -149,7 +149,7 @@ void RotatedFileLogger::rotate_file() { char timestamp[21]; OS::Date date = OS::get_singleton()->get_date(); OS::Time time = OS::get_singleton()->get_time(); - sprintf(timestamp, "-%04d-%02d-%02d-%02d-%02d-%02d", date.year, date.month, date.day + 1, time.hour, time.min, time.sec); + sprintf(timestamp, "-%04d-%02d-%02d-%02d-%02d-%02d", date.year, date.month, date.day, time.hour, time.min, time.sec); String backup_name = base_path.get_basename() + timestamp + "." + base_path.get_extension(); diff --git a/core/make_binders.py b/core/make_binders.py index 6468c029f0..6f42c6e8eb 100644 --- a/core/make_binders.py +++ b/core/make_binders.py @@ -244,7 +244,7 @@ def make_version(template, nargs, argmax, const, ret): def run(target, source, env): - versions = 10 + versions = 11 versions_ext = 6 text = "" text_ext = "" diff --git a/core/variant.h b/core/variant.h index e0d0bf05c8..45066af401 100644 --- a/core/variant.h +++ b/core/variant.h @@ -99,15 +99,15 @@ public: _RID, OBJECT, DICTIONARY, - ARRAY, // 20 + ARRAY, // arrays - POOL_BYTE_ARRAY, + POOL_BYTE_ARRAY, // 20 POOL_INT_ARRAY, POOL_REAL_ARRAY, POOL_STRING_ARRAY, - POOL_VECTOR2_ARRAY, // 25 - POOL_VECTOR3_ARRAY, + POOL_VECTOR2_ARRAY, + POOL_VECTOR3_ARRAY, // 25 POOL_COLOR_ARRAY, VARIANT_MAX diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 03ec336291..6362090902 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -1655,13 +1655,13 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } else if (p_index == CoreStringNames::singleton->a) { return v->a; } else if (p_index == CoreStringNames::singleton->r8) { - return v->r * 255.0; + return int(v->r * 255.0); } else if (p_index == CoreStringNames::singleton->g8) { - return v->g * 255.0; + return int(v->g * 255.0); } else if (p_index == CoreStringNames::singleton->b8) { - return v->b * 255.0; + return int(v->b * 255.0); } else if (p_index == CoreStringNames::singleton->a8) { - return v->a * 255.0; + return int(v->a * 255.0); } else if (p_index == CoreStringNames::singleton->h) { return v->get_h(); } else if (p_index == CoreStringNames::singleton->s) { diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml index 203c96516b..23a937791c 100644 --- a/doc/classes/EditorInterface.xml +++ b/doc/classes/EditorInterface.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="EditorInterface" inherits="Node" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Editor interface and main components. </brief_description> <description> + Editor interface. Allows saving and (re-)loading scenes, rendering mesh previews, inspecting and editing resources and objects and provides access to [EditorSettings], [EditorFileSystem], [EditorResourcePreview]\ er, [ScriptEditor], the editor viewport, as well as information about scenes. Also see [EditorPlugin] and [EditorScript]. </description> <tutorials> </tutorials> @@ -15,60 +17,70 @@ <argument index="0" name="resource" type="Resource"> </argument> <description> + Edits the given [Resource]. </description> </method> <method name="get_base_control"> <return type="Control"> </return> <description> + Returns the base [Control]. </description> </method> <method name="get_edited_scene_root"> <return type="Node"> </return> <description> + Returns the edited scene's root [Node]. </description> </method> <method name="get_editor_settings"> <return type="EditorSettings"> </return> <description> + Returns the [EditorSettings]. </description> </method> <method name="get_editor_viewport"> <return type="Control"> </return> <description> + Returns the editor [Viewport]. </description> </method> <method name="get_open_scenes" qualifiers="const"> <return type="Array"> </return> <description> + Returns an [Array] of the currently opened scenes. </description> </method> <method name="get_resource_filesystem"> <return type="EditorFileSystem"> </return> <description> + Returns the [EditorFileSystem]. </description> </method> <method name="get_resource_previewer"> <return type="EditorResourcePreview"> </return> <description> + Returns the [EditorResourcePreview]\ er. </description> </method> <method name="get_script_editor"> <return type="ScriptEditor"> </return> <description> + Returns the [ScriptEditor]. </description> </method> <method name="get_selection"> <return type="EditorSelection"> </return> <description> + Returns the [EditorSelection]. </description> </method> <method name="inspect_object"> @@ -79,6 +91,7 @@ <argument index="1" name="for_property" type="String" default=""""> </argument> <description> + Shows the given property on the given [code]object[/code] in the Editor's Inspector dock. </description> </method> <method name="make_mesh_previews"> @@ -89,6 +102,7 @@ <argument index="1" name="preview_size" type="int"> </argument> <description> + Returns mesh previews rendered at the given size as an [Array] of [Texture]\ s. </description> </method> <method name="open_scene_from_path"> @@ -97,6 +111,7 @@ <argument index="0" name="scene_filepath" type="String"> </argument> <description> + Opens the scene at the given path. </description> </method> <method name="reload_scene_from_path"> @@ -105,12 +120,14 @@ <argument index="0" name="scene_filepath" type="String"> </argument> <description> + Reloads the scene at the given path. </description> </method> <method name="save_scene"> <return type="int" enum="Error"> </return> <description> + Saves the scene. Returns either OK or ERR_CANT_CREATE. See [@Global Scope] constants. </description> </method> <method name="save_scene_as"> @@ -121,6 +138,7 @@ <argument index="1" name="with_preview" type="bool" default="true"> </argument> <description> + Saves the scene as a file at [code]path[/code]. </description> </method> </methods> diff --git a/doc/classes/EditorScript.xml b/doc/classes/EditorScript.xml index 48cf3e9843..9e774345a2 100644 --- a/doc/classes/EditorScript.xml +++ b/doc/classes/EditorScript.xml @@ -1,10 +1,19 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="EditorScript" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> <brief_description> - Simple script to perform changes in the currently edited scene. + Base script that can be used to add extension functions to the editor. </brief_description> <description> - This script can be run from the Scene -> Run Script menu option. + Scripts extending this class and implementing its [code]_run()[/code] method can be executed from the Script Editor's [code]File -> Run[/code] menu option (or by pressing [code]CTRL+Shift+X[/code]) while the editor is running. This is useful for adding custom in-editor functionality to Godot. For more complex additions, consider using [EditorPlugin]\ s instead. Note that extending scripts need to have [code]tool mode[/code] enabled. + Example script: + [codeblock] + tool + extends EditorScript + + func _run(): + print("Hello from the Godot Editor!") + [/codeblock] + Note that the script is run in the Editor context, which means the output is visible in the console window started with the Editor (STDOUT) instead of the usual Godot *Output* dock. </description> <tutorials> </tutorials> @@ -15,6 +24,7 @@ <return type="void"> </return> <description> + This method is executed by the Editor when [code]File -> Run[/code] is used. </description> </method> <method name="add_root_node"> @@ -29,12 +39,14 @@ <return type="EditorInterface"> </return> <description> + Returns the [EditorInterface] singleton instance. </description> </method> <method name="get_scene"> <return type="Node"> </return> <description> + Returns the Editor's currently active scene. </description> </method> </methods> diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml index a4faa697de..f2584de5aa 100644 --- a/doc/classes/RigidBody2D.xml +++ b/doc/classes/RigidBody2D.xml @@ -113,7 +113,7 @@ <return type="float"> </return> <description> - Return the body's moment of inertia. This is usually automatically computed from the mass and the shapes. Note that this doesn't seem to work in a [code]_ready[/code] function: it apparently has not been auto-computed yet. + Returns the body's moment of inertia. Automatically computed from associated [class CollisionShape2D]s' mass during physic frames. Inertia is not computed the same frame in which the node was added in. Therefore inertia is not computed during the [code]_ready[/code] function. </description> </method> <method name="get_linear_damp" qualifiers="const"> @@ -127,7 +127,7 @@ <return type="Vector2"> </return> <description> - Return the body linear velocity. This changes by physics granularity. See [method set_linear_velocity]. + Returns the body's linear velocity. This changes when a physics frame has passed, not during a normal update. See [method set_linear_velocity]. </description> </method> <method name="get_mass" qualifiers="const"> diff --git a/doc/tools/doc_status.py b/doc/tools/doc_status.py index e89b49eb4d..170ded9f50 100644 --- a/doc/tools/doc_status.py +++ b/doc/tools/doc_status.py @@ -250,15 +250,16 @@ class ClassStatus: for tag in list(c): if tag.tag in ['methods']: for sub_tag in list(tag): - methods.append(sub_tag.find('name')) + methods.append(sub_tag.attrib['name']) if tag.tag in ['members']: for sub_tag in list(tag): try: - methods.remove(sub_tag.find('setter')) - methods.remove(sub_tag.find('getter')) + if(sub_tag.attrib['setter'].startswith('_') == False): + methods.remove(sub_tag.attrib['setter']) + if(sub_tag.attrib['getter'].startswith('_') == False): + methods.remove(sub_tag.attrib['getter']) except: pass - for tag in list(c): if tag.tag == 'brief_description': @@ -269,7 +270,7 @@ class ClassStatus: elif tag.tag in ['methods', 'signals']: for sub_tag in list(tag): - if sub_tag.find('name') in methods or tag.tag == 'signals': + if sub_tag.attrib['name'] in methods or tag.tag == 'signals': descr = sub_tag.find('description') status.progresses[tag.tag].increment(len(descr.text.strip()) > 0) elif tag.tag in ['constants', 'members']: diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 44a9909bd7..296d945cda 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -2430,7 +2430,8 @@ void RasterizerStorageGLES3::_update_material(Material *material) { if (material->shader && material->shader->mode == VS::SHADER_SPATIAL) { - if (!material->shader->spatial.uses_alpha && material->shader->spatial.blend_mode == Shader::Spatial::BLEND_MODE_MIX) { + if (material->shader->spatial.blend_mode == Shader::Spatial::BLEND_MODE_MIX && + (!material->shader->spatial.uses_alpha || (material->shader->spatial.uses_alpha && material->shader->spatial.depth_draw_mode == Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS))) { can_cast_shadow = true; } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index aca2f59134..f109cdddc3 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1454,7 +1454,7 @@ void EditorNode::_edit_current() { } } else if (current_res->get_path().is_resource_file()) { if (FileAccess::exists(current_res->get_path() + ".import")) { - editable_warning = TTR("This resource was imported, so it's not editable. Change it's settings in the import panel and re-import."); + editable_warning = TTR("This resource was imported, so it's not editable. Change its settings in the import panel and then re-import."); } } } else if (is_node) { @@ -5541,6 +5541,10 @@ EditorNode::EditorNode() { Ref<SpatialMaterialConversionPlugin> spatial_mat_convert; spatial_mat_convert.instance(); resource_conversion_plugins.push_back(spatial_mat_convert); + + Ref<ParticlesMaterialConversionPlugin> particles_mat_convert; + particles_mat_convert.instance(); + resource_conversion_plugins.push_back(particles_mat_convert); } circle_step_msec = OS::get_singleton()->get_ticks_msec(); circle_step_frame = Engine::get_singleton()->get_frames_drawn(); @@ -5691,12 +5695,12 @@ void EditorPluginList::edit(Object *p_object) { } } -bool EditorPluginList::forward_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event) { +bool EditorPluginList::forward_gui_input(const Ref<InputEvent> &p_event) { bool discard = false; for (int i = 0; i < plugins_list.size(); i++) { - if (plugins_list[i]->forward_canvas_gui_input(p_canvas_xform, p_event)) { + if (plugins_list[i]->forward_canvas_gui_input(p_event)) { discard = true; } } @@ -5720,10 +5724,10 @@ bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp return discard; } -void EditorPluginList::forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas) { +void EditorPluginList::forward_draw_over_canvas(Control *p_canvas) { for (int i = 0; i < plugins_list.size(); i++) { - plugins_list[i]->forward_draw_over_canvas(p_canvas_xform, p_canvas); + plugins_list[i]->forward_draw_over_canvas(p_canvas); } } diff --git a/editor/editor_node.h b/editor/editor_node.h index 0d1c6787cd..32d46e686b 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -812,9 +812,9 @@ public: void make_visible(bool p_visible); void edit(Object *p_object); - bool forward_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event); + bool forward_gui_input(const Ref<InputEvent> &p_event); bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled); - void forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas); + void forward_draw_over_canvas(Control *p_canvas); void add_plugin(EditorPlugin *p_plugin); void clear(); bool empty(); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index a528662e0f..229d6adfef 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -402,18 +402,18 @@ Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial *p_spatial) { return Ref<SpatialEditorGizmo>(); } -bool EditorPlugin::forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event) { +bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { if (get_script_instance() && get_script_instance()->has_method("forward_canvas_gui_input")) { - return get_script_instance()->call("forward_canvas_gui_input", p_canvas_xform, p_event); + return get_script_instance()->call("forward_canvas_gui_input", p_event); } return false; } -void EditorPlugin::forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas) { +void EditorPlugin::forward_draw_over_canvas(Control *p_canvas) { if (get_script_instance() && get_script_instance()->has_method("forward_draw_over_canvas")) { - get_script_instance()->call("forward_draw_over_canvas", p_canvas_xform, p_canvas); + get_script_instance()->call("forward_draw_over_canvas", p_canvas); } } diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 18530e9ce4..1d68eee117 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -156,8 +156,8 @@ public: void notify_scene_closed(const String &scene_filepath); virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial); - virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event); - virtual void forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas); + virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event); + virtual void forward_draw_over_canvas(Control *p_canvas); virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event); virtual String get_name() const; virtual bool has_main_screen() const; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 13ed7a7f30..992322978e 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -392,7 +392,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { editor_register_and_generate_icons(theme, dark_theme, thumb_size); } // thumbnail size has changed, so we regenerate the medium sizes - if (p_theme != NULL && fabs(p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) { + if (p_theme != NULL && fabs((double)p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) { editor_register_and_generate_icons(p_theme, dark_theme, thumb_size, true); } diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 2fd74d529e..ffa4e36b5a 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -195,9 +195,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform(); Vector2 gpoint = mb->get_position(); - Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint); - cpoint = canvas_item_editor->snap_point(cpoint); - cpoint = _get_node()->get_global_transform().affine_inverse().xform(cpoint); + Vector2 cpoint = _get_node()->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position()))); //first check if a point is to be added (segment split) real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); @@ -425,15 +423,14 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) if (edited_point != -1 && (wip_active || (mm->get_button_mask() & BUTTON_MASK_LEFT))) { Vector2 gpoint = mm->get_position(); - Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint); - cpoint = canvas_item_editor->snap_point(cpoint); - edited_point_pos = _get_node()->get_global_transform().affine_inverse().xform(cpoint); + Vector2 cpoint = _get_node()->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mm->get_position()))); + edited_point_pos = cpoint; if (!wip_active) { Vector<Vector2> vertices = _get_polygon(edited_polygon); ERR_FAIL_INDEX_V(edited_point, vertices.size(), false); - vertices[edited_point] = edited_point_pos - _get_offset(edited_polygon); + vertices[edited_point] = cpoint - _get_offset(edited_polygon); _set_polygon(edited_polygon, vertices); } @@ -444,8 +441,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) return false; } -void AbstractPolygon2DEditor::_canvas_draw() { - +void AbstractPolygon2DEditor::forward_draw_over_canvas(Control *p_canvas) { if (!_get_node()) return; @@ -527,9 +523,6 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) { if (_is_empty()) _menu_option(MODE_CREATE); - if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw"); - wip.clear(); wip_active = false; edited_point = -1; @@ -539,15 +532,11 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) { } else { _set_node(NULL); - - if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw"); } } void AbstractPolygon2DEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_canvas_draw"), &AbstractPolygon2DEditor::_canvas_draw); ClassDB::bind_method(D_METHOD("_node_removed"), &AbstractPolygon2DEditor::_node_removed); ClassDB::bind_method(D_METHOD("_menu_option"), &AbstractPolygon2DEditor::_menu_option); ClassDB::bind_method(D_METHOD("_create_resource"), &AbstractPolygon2DEditor::_create_resource); diff --git a/editor/plugins/abstract_polygon_2d_editor.h b/editor/plugins/abstract_polygon_2d_editor.h index 86e14694da..3e3bff6d0d 100644 --- a/editor/plugins/abstract_polygon_2d_editor.h +++ b/editor/plugins/abstract_polygon_2d_editor.h @@ -75,7 +75,6 @@ protected: virtual void _menu_option(int p_option); void _wip_close(); - void _canvas_draw(); void _notification(int p_what); void _node_removed(Node *p_node); @@ -103,6 +102,8 @@ protected: public: bool forward_gui_input(const Ref<InputEvent> &p_event); + void forward_draw_over_canvas(Control *p_canvas); + void edit(Node *p_polygon); AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wip_destructive = true); }; @@ -116,7 +117,8 @@ class AbstractPolygon2DEditorPlugin : public EditorPlugin { String klass; public: - virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event) { return polygon_editor->forward_gui_input(p_event); } + virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return polygon_editor->forward_gui_input(p_event); } + virtual void forward_draw_over_canvas(Control *p_canvas) { polygon_editor->forward_draw_over_canvas(p_canvas); } bool has_main_screen() const { return false; } virtual String get_name() const { return klass; } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 3f64e75bc8..2270421eca 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1198,14 +1198,23 @@ void CanvasItemEditor::_update_cursor() { viewport->set_default_cursor_shape(c); } -void CanvasItemEditor::_viewport_base_gui_input(const Ref<InputEvent> &p_event) { +void CanvasItemEditor::_gui_input_viewport_base(const Ref<InputEvent> &p_event) { + + Ref<InputEventMouseMotion> m = p_event; + if (m.is_valid()) { + if (!viewport_base->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) + viewport_base->call_deferred("grab_focus"); + } +} + +void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { { EditorNode *en = editor; EditorPluginList *over_plugin_list = en->get_editor_plugins_over(); if (!over_plugin_list->empty()) { - bool discard = over_plugin_list->forward_gui_input(transform, p_event); + bool discard = over_plugin_list->forward_gui_input(p_event); if (discard) { accept_event(); return; @@ -1224,7 +1233,7 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref<InputEvent> &p_event) _update_scroll(0); viewport->update(); } else { - _zoom_on_position(zoom * (1 - (0.05 * b->get_factor())), viewport_scrollable->get_transform().affine_inverse().xform(b->get_position())); + _zoom_on_position(zoom * (1 - (0.05 * b->get_factor())), b->get_position()); } return; @@ -1237,7 +1246,7 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref<InputEvent> &p_event) _update_scroll(0); viewport->update(); } else { - _zoom_on_position(zoom * ((0.95 + (0.05 * b->get_factor())) / 0.95), viewport_scrollable->get_transform().affine_inverse().xform(b->get_position())); + _zoom_on_position(zoom * ((0.95 + (0.05 * b->get_factor())) / 0.95), b->get_position()); } return; @@ -1320,7 +1329,7 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref<InputEvent> &p_event) if (b->get_button_index() == BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) { if (b->is_pressed()) { // Set the pivot point - Point2 mouse_pos = viewport_scrollable->get_transform().affine_inverse().xform(b->get_position()); + Point2 mouse_pos = b->get_position(); mouse_pos = transform.affine_inverse().xform(mouse_pos); mouse_pos = snap_point(mouse_pos, SNAP_DEFAULT, _get_single_item()); _edit_set_pivot(mouse_pos); @@ -1443,8 +1452,8 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref<InputEvent> &p_event) E->get().to }; - Vector2 p = Geometry::get_closest_point_to_segment_2d(viewport_scrollable->get_transform().affine_inverse().xform(b->get_position()), s); - float d = p.distance_to(viewport_scrollable->get_transform().affine_inverse().xform(b->get_position())); + Vector2 p = Geometry::get_closest_point_to_segment_2d(b->get_position(), s); + float d = p.distance_to(b->get_position()); if (d < bone_width && d < closest_dist) { Cbone = E; closest_dist = d; @@ -1506,7 +1515,7 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref<InputEvent> &p_event) CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); ERR_FAIL_COND(!se); - Point2 click = viewport_scrollable->get_transform().affine_inverse().xform(b->get_position()); + Point2 click = b->get_position(); // Rotation if ((b->get_control() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) { @@ -1561,7 +1570,7 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref<InputEvent> &p_event) } // Multiple selected items - Point2 click = viewport_scrollable->get_transform().affine_inverse().xform(b->get_position()); + Point2 click = b->get_position(); if ((b->get_alt() || tool == TOOL_MOVE) && get_item_count()) { // Drag the nodes @@ -1621,12 +1630,9 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref<InputEvent> &p_event) // Mouse motion event _update_cursor(); - if (!viewport_base->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) - viewport_base->call_deferred("grab_focus"); - if (box_selecting) { // Update box selection - box_selecting_to = transform.affine_inverse().xform(viewport_scrollable->get_transform().affine_inverse().xform(m->get_position())); + box_selecting_to = transform.affine_inverse().xform(m->get_position()); viewport->update(); return; } @@ -1672,7 +1678,7 @@ void CanvasItemEditor::_viewport_base_gui_input(const Ref<InputEvent> &p_event) } Vector2 dfrom = drag_from; - Vector2 dto = transform.affine_inverse().xform(viewport_scrollable->get_transform().affine_inverse().xform(m->get_position())); + Vector2 dto = transform.affine_inverse().xform(m->get_position()); if (canvas_item->has_meta("_edit_lock_")) continue; @@ -2159,8 +2165,8 @@ void CanvasItemEditor::_draw_grid() { Vector2 real_grid_offset; if (snap_relative && get_item_count() > 0) { Vector2 topleft = _find_topleftmost_point(); - real_grid_offset.x = fmod(topleft.x, grid_step.x * Math::pow(2.0, grid_step_multiplier)); - real_grid_offset.y = fmod(topleft.y, grid_step.y * Math::pow(2.0, grid_step_multiplier)); + real_grid_offset.x = fmod(topleft.x, grid_step.x * (real_t)Math::pow(2.0, grid_step_multiplier)); + real_grid_offset.y = fmod(topleft.y, grid_step.y * (real_t)Math::pow(2.0, grid_step_multiplier)); } else { real_grid_offset = grid_offset; } @@ -2681,9 +2687,8 @@ void CanvasItemEditor::_draw_viewport() { EditorPluginList *over_plugin_list = editor->get_editor_plugins_over(); if (!over_plugin_list->empty()) { - over_plugin_list->forward_draw_over_canvas(transform, viewport); + over_plugin_list->forward_draw_over_canvas(viewport); } - _draw_focus(); _draw_bones(); } @@ -3694,7 +3699,8 @@ void CanvasItemEditor::_bind_methods() { ClassDB::bind_method("_unhandled_key_input", &CanvasItemEditor::_unhandled_key_input); ClassDB::bind_method("_draw_viewport", &CanvasItemEditor::_draw_viewport); ClassDB::bind_method("_draw_viewport_base", &CanvasItemEditor::_draw_viewport_base); - ClassDB::bind_method("_viewport_base_gui_input", &CanvasItemEditor::_viewport_base_gui_input); + ClassDB::bind_method("_gui_input_viewport", &CanvasItemEditor::_gui_input_viewport); + ClassDB::bind_method("_gui_input_viewport_base", &CanvasItemEditor::_gui_input_viewport_base); ClassDB::bind_method("_snap_changed", &CanvasItemEditor::_snap_changed); ClassDB::bind_method(D_METHOD("_selection_result_pressed"), &CanvasItemEditor::_selection_result_pressed); ClassDB::bind_method(D_METHOD("_selection_menu_hide"), &CanvasItemEditor::_selection_menu_hide); @@ -3747,7 +3753,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { palette_split->add_child(viewport_base); viewport_base->set_clip_contents(true); viewport_base->connect("draw", this, "_draw_viewport_base"); - viewport_base->connect("gui_input", this, "_viewport_base_gui_input"); + viewport_base->connect("gui_input", this, "_gui_input_viewport_base"); viewport_base->set_focus_mode(FOCUS_ALL); viewport_base->set_v_size_flags(SIZE_EXPAND_FILL); viewport_base->set_h_size_flags(SIZE_EXPAND_FILL); @@ -3771,6 +3777,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { viewport->set_anchors_and_margins_preset(Control::PRESET_WIDE); viewport->set_clip_contents(true); viewport->connect("draw", this, "_draw_viewport"); + viewport->connect("gui_input", this, "_gui_input_viewport"); h_scroll = memnew(HScrollBar); viewport->add_child(h_scroll); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 69dc25d180..a8183ba286 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -410,10 +410,11 @@ class CanvasItemEditor : public VBoxContainer { void _draw_locks_and_groups(Node *p_node, const Transform2D &p_xform); void _draw_viewport(); - - void _viewport_base_gui_input(const Ref<InputEvent> &p_event); void _draw_viewport_base(); + void _gui_input_viewport(const Ref<InputEvent> &p_event); + void _gui_input_viewport_base(const Ref<InputEvent> &p_event); + void _focus_selection(int p_op); void _snap_if_closer(Point2 p_value, Point2 p_target_snap, Point2 &r_current_snap, bool (&r_snapped)[2], real_t rotation = 0.0, float p_radius = 10.0); diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp index 00e6d617a1..00e6d617a1 100755..100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.h b/editor/plugins/collision_polygon_2d_editor_plugin.h index edf3bbcc08..edf3bbcc08 100755..100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.h +++ b/editor/plugins/collision_polygon_2d_editor_plugin.h diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index 3e6165e552..005de096cd 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -302,7 +302,7 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { undo_redo->commit_action(); } -bool CollisionShape2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { +bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { if (!node) { return false; @@ -317,17 +317,17 @@ bool CollisionShape2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } Ref<InputEventMouseButton> mb = p_event; + Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); if (mb.is_valid()) { - Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - - Point2 gpoint(mb->get_position().x, mb->get_position().y); + Vector2 gpoint = mb->get_position(); + Vector2 cpoint = node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position()))); if (mb->get_button_index() == BUTTON_LEFT) { if (mb->is_pressed()) { for (int i = 0; i < handles.size(); i++) { - if (gt.xform(handles[i]).distance_to(gpoint) < 8) { + if (xform.xform(handles[i]).distance_to(gpoint) < 8) { edit_handle = i; break; @@ -368,9 +368,7 @@ bool CollisionShape2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return false; } - Point2 gpoint = mm->get_position(); - Point2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint); - cpoint = canvas_item_editor->snap_point(cpoint); + Vector2 cpoint = canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mm->get_position())); cpoint = node->get_global_transform().affine_inverse().xform(cpoint); set_handle(edit_handle, cpoint); @@ -416,7 +414,7 @@ void CollisionShape2DEditor::_get_current_shape_type() { canvas_item_editor->get_viewport_control()->update(); } -void CollisionShape2DEditor::_canvas_draw() { +void CollisionShape2DEditor::forward_draw_over_canvas(Control *p_canvas) { if (!node) { return; @@ -432,7 +430,6 @@ void CollisionShape2DEditor::_canvas_draw() { return; } - Control *c = canvas_item_editor->get_viewport_control(); Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); Ref<Texture> h = get_icon("EditorHandle", "EditorIcons"); @@ -451,8 +448,8 @@ void CollisionShape2DEditor::_canvas_draw() { handles[0] = Point2(radius, -height); handles[1] = Point2(0, -(height + radius)); - c->draw_texture(h, gt.xform(handles[0]) - size); - c->draw_texture(h, gt.xform(handles[1]) - size); + p_canvas->draw_texture(h, gt.xform(handles[0]) - size); + p_canvas->draw_texture(h, gt.xform(handles[1]) - size); } break; @@ -462,7 +459,7 @@ void CollisionShape2DEditor::_canvas_draw() { handles.resize(1); handles[0] = Point2(shape->get_radius(), 0); - c->draw_texture(h, gt.xform(handles[0]) - size); + p_canvas->draw_texture(h, gt.xform(handles[0]) - size); } break; @@ -481,8 +478,8 @@ void CollisionShape2DEditor::_canvas_draw() { handles[0] = shape->get_normal() * shape->get_d(); handles[1] = shape->get_normal() * (shape->get_d() + 30.0); - c->draw_texture(h, gt.xform(handles[0]) - size); - c->draw_texture(h, gt.xform(handles[1]) - size); + p_canvas->draw_texture(h, gt.xform(handles[0]) - size); + p_canvas->draw_texture(h, gt.xform(handles[1]) - size); } break; @@ -492,7 +489,7 @@ void CollisionShape2DEditor::_canvas_draw() { handles.resize(1); handles[0] = Point2(0, shape->get_length()); - c->draw_texture(h, gt.xform(handles[0]) - size); + p_canvas->draw_texture(h, gt.xform(handles[0]) - size); } break; @@ -504,8 +501,8 @@ void CollisionShape2DEditor::_canvas_draw() { handles[0] = Point2(ext.x, 0); handles[1] = Point2(0, -ext.y); - c->draw_texture(h, gt.xform(handles[0]) - size); - c->draw_texture(h, gt.xform(handles[1]) - size); + p_canvas->draw_texture(h, gt.xform(handles[0]) - size); + p_canvas->draw_texture(h, gt.xform(handles[1]) - size); } break; @@ -516,8 +513,8 @@ void CollisionShape2DEditor::_canvas_draw() { handles[0] = shape->get_a(); handles[1] = shape->get_b(); - c->draw_texture(h, gt.xform(handles[0]) - size); - c->draw_texture(h, gt.xform(handles[1]) - size); + p_canvas->draw_texture(h, gt.xform(handles[0]) - size); + p_canvas->draw_texture(h, gt.xform(handles[1]) - size); } break; } @@ -532,18 +529,12 @@ void CollisionShape2DEditor::edit(Node *p_node) { if (p_node) { node = Object::cast_to<CollisionShape2D>(p_node); - if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw"); - _get_current_shape_type(); } else { edit_handle = -1; shape_type = -1; - if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw"); - node = NULL; } @@ -552,7 +543,6 @@ void CollisionShape2DEditor::edit(Node *p_node) { void CollisionShape2DEditor::_bind_methods() { - ClassDB::bind_method("_canvas_draw", &CollisionShape2DEditor::_canvas_draw); ClassDB::bind_method("_get_current_shape_type", &CollisionShape2DEditor::_get_current_shape_type); } diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h index ffa91952e0..d4fbe87fb3 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/editor/plugins/collision_shape_2d_editor_plugin.h @@ -68,13 +68,13 @@ class CollisionShape2DEditor : public Control { void commit_handle(int idx, Variant &p_org); void _get_current_shape_type(); - void _canvas_draw(); protected: static void _bind_methods(); public: - bool forward_gui_input(const Ref<InputEvent> &p_event); + bool forward_canvas_gui_input(const Ref<InputEvent> &p_event); + void forward_draw_over_canvas(Control *p_canvas); void edit(Node *p_node); CollisionShape2DEditor(EditorNode *p_editor); @@ -87,7 +87,8 @@ class CollisionShape2DEditorPlugin : public EditorPlugin { EditorNode *editor; public: - virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event) { return collision_shape_2d_editor->forward_gui_input(p_event); } + virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return collision_shape_2d_editor->forward_canvas_gui_input(p_event); } + virtual void forward_draw_over_canvas(Control *p_canvas) { return collision_shape_2d_editor->forward_draw_over_canvas(p_canvas); } virtual String get_name() const { return "CollisionShape2D"; } bool has_main_screen() const { return false; } diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp index ed0bc60d2f..485657d2c9 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -119,9 +119,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); Vector2 gpoint = mb->get_position(); - Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint); - cpoint = canvas_item_editor->snap_point(cpoint); - cpoint = node->get_global_transform().affine_inverse().xform(cpoint); + Vector2 cpoint = node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position()))); Vector<Vector2> poly = Variant(node->get_occluder_polygon()->get_polygon()); @@ -319,7 +317,8 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return false; } -void LightOccluder2DEditor::_canvas_draw() { + +void LightOccluder2DEditor::forward_draw_over_canvas(Control *p_canvas) { if (!node || !node->get_occluder_polygon().is_valid()) return; @@ -368,17 +367,12 @@ void LightOccluder2DEditor::edit(Node *p_collision_polygon) { if (p_collision_polygon) { node = Object::cast_to<LightOccluder2D>(p_collision_polygon); - if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw"); wip.clear(); wip_active = false; edited_point = -1; canvas_item_editor->get_viewport_control()->update(); } else { node = NULL; - - if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw"); } } @@ -395,7 +389,6 @@ void LightOccluder2DEditor::_create_poly() { void LightOccluder2DEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_menu_option"), &LightOccluder2DEditor::_menu_option); - ClassDB::bind_method(D_METHOD("_canvas_draw"), &LightOccluder2DEditor::_canvas_draw); ClassDB::bind_method(D_METHOD("_node_removed"), &LightOccluder2DEditor::_node_removed); ClassDB::bind_method(D_METHOD("_create_poly"), &LightOccluder2DEditor::_create_poly); } @@ -430,7 +423,7 @@ LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) { void LightOccluder2DEditorPlugin::edit(Object *p_object) { - collision_polygon_editor->edit(Object::cast_to<Node>(p_object)); + light_occluder_editor->edit(Object::cast_to<Node>(p_object)); } bool LightOccluder2DEditorPlugin::handles(Object *p_object) const { @@ -441,21 +434,21 @@ bool LightOccluder2DEditorPlugin::handles(Object *p_object) const { void LightOccluder2DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { - collision_polygon_editor->show(); + light_occluder_editor->show(); } else { - collision_polygon_editor->hide(); - collision_polygon_editor->edit(NULL); + light_occluder_editor->hide(); + light_occluder_editor->edit(NULL); } } LightOccluder2DEditorPlugin::LightOccluder2DEditorPlugin(EditorNode *p_node) { editor = p_node; - collision_polygon_editor = memnew(LightOccluder2DEditor(p_node)); - CanvasItemEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor); + light_occluder_editor = memnew(LightOccluder2DEditor(p_node)); + CanvasItemEditor::get_singleton()->add_control_to_menu_panel(light_occluder_editor); - collision_polygon_editor->hide(); + light_occluder_editor->hide(); } LightOccluder2DEditorPlugin::~LightOccluder2DEditorPlugin() { diff --git a/editor/plugins/light_occluder_2d_editor_plugin.h b/editor/plugins/light_occluder_2d_editor_plugin.h index b270dcb6e5..068832d8ed 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.h +++ b/editor/plugins/light_occluder_2d_editor_plugin.h @@ -72,7 +72,6 @@ class LightOccluder2DEditor : public HBoxContainer { ConfirmationDialog *create_poly; void _wip_close(bool p_closed); - void _canvas_draw(); void _menu_option(int p_option); void _create_poly(); @@ -83,6 +82,7 @@ protected: public: Vector2 snap_point(const Vector2 &p_point) const; + void forward_draw_over_canvas(Control *p_canvas); bool forward_gui_input(const Ref<InputEvent> &p_event); void edit(Node *p_collision_polygon); LightOccluder2DEditor(EditorNode *p_editor); @@ -92,11 +92,12 @@ class LightOccluder2DEditorPlugin : public EditorPlugin { GDCLASS(LightOccluder2DEditorPlugin, EditorPlugin); - LightOccluder2DEditor *collision_polygon_editor; + LightOccluder2DEditor *light_occluder_editor; EditorNode *editor; public: - virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_gui_input(p_event); } + virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return light_occluder_editor->forward_gui_input(p_event); } + virtual void forward_draw_over_canvas(Control *p_canvas) { return light_occluder_editor->forward_draw_over_canvas(p_canvas); } virtual String get_name() const { return "LightOccluder2D"; } bool has_main_screen() const { return false; } diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp index ef3ee6a78f..0533aaa9c0 100644 --- a/editor/plugins/line_2d_editor_plugin.cpp +++ b/editor/plugins/line_2d_editor_plugin.cpp @@ -54,16 +54,10 @@ void Line2DEditor::_notification(int p_what) { } } -Vector2 Line2DEditor::mouse_to_local_pos(Vector2 gpos, bool alt) { - Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - return !alt ? canvas_item_editor->snap_point(xform.affine_inverse().xform(gpos)) : node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpos))); -} - -int Line2DEditor::get_point_index_at(Vector2 gpos) { +int Line2DEditor::get_point_index_at(const Transform2D &xform, Vector2 gpos) { ERR_FAIL_COND_V(node == 0, -1); real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); - Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); for (int i = 0; i < node->get_point_count(); ++i) { Point2 p = xform.xform(node->get_point_position(i)); @@ -75,7 +69,7 @@ int Line2DEditor::get_point_index_at(Vector2 gpos) { return -1; } -bool Line2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { +bool Line2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { if (!node) return false; @@ -88,10 +82,10 @@ bool Line2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid()) { Vector2 gpoint = mb->get_position(); - Vector2 cpoint = mouse_to_local_pos(gpoint, mb->get_alt()); + Vector2 cpoint = node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position()))); if (mb->is_pressed() && _dragging == false) { - int i = get_point_index_at(gpoint); + int i = get_point_index_at(canvas_item_editor->get_canvas_transform() * node->get_global_transform(), gpoint); if (i != -1) { if (mb->get_button_index() == BUTTON_LEFT && !mb->get_shift() && mode == MODE_EDIT) { _dragging = true; @@ -146,7 +140,8 @@ bool Line2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (mm.is_valid()) { if (_dragging) { - Vector2 cpoint = mouse_to_local_pos(mm->get_position(), mm->get_alt()); + Vector2 gpoint = mm->get_position(); + Vector2 cpoint = node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mm->get_position()))); node->set_point_position(action_point, cpoint); canvas_item_editor->get_viewport_control()->update(); return true; @@ -156,7 +151,7 @@ bool Line2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return false; } -void Line2DEditor::_canvas_draw() { +void Line2DEditor::forward_draw_over_canvas(Control *p_canvas) { if (!node) return; @@ -190,13 +185,9 @@ void Line2DEditor::edit(Node *p_line2d) { if (p_line2d) { node = Object::cast_to<Line2D>(p_line2d); - if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw"); if (!node->is_connected("visibility_changed", this, "_node_visibility_changed")) node->connect("visibility_changed", this, "_node_visibility_changed"); } else { - if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw"); // node may have been deleted at this point if (node && node->is_connected("visibility_changed", this, "_node_visibility_changed")) node->disconnect("visibility_changed", this, "_node_visibility_changed"); @@ -205,7 +196,6 @@ void Line2DEditor::edit(Node *p_line2d) { } void Line2DEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_canvas_draw"), &Line2DEditor::_canvas_draw); ClassDB::bind_method(D_METHOD("_node_visibility_changed"), &Line2DEditor::_node_visibility_changed); ClassDB::bind_method(D_METHOD("_mode_selected"), &Line2DEditor::_mode_selected); } diff --git a/editor/plugins/line_2d_editor_plugin.h b/editor/plugins/line_2d_editor_plugin.h index dea0433084..6858680aed 100644 --- a/editor/plugins/line_2d_editor_plugin.h +++ b/editor/plugins/line_2d_editor_plugin.h @@ -40,27 +40,11 @@ class CanvasItemEditor; class Line2DEditor : public HBoxContainer { GDCLASS(Line2DEditor, HBoxContainer) - -public: - bool forward_gui_input(const Ref<InputEvent> &p_event); - void edit(Node *p_line2d); - Line2DEditor(EditorNode *p_editor); - -protected: - void _node_removed(Node *p_node); - void _notification(int p_what); - - Vector2 mouse_to_local_pos(Vector2 mpos); - - static void _bind_methods(); - private: void _mode_selected(int p_mode); - void _canvas_draw(); void _node_visibility_changed(); - int get_point_index_at(Vector2 gpos); - Vector2 mouse_to_local_pos(Vector2 gpos, bool alt); + int get_point_index_at(const Transform2D &xform, Vector2 gpos); UndoRedo *undo_redo; @@ -86,17 +70,26 @@ private: int action_point; Point2 moving_from; Point2 moving_screen_from; + +protected: + void _node_removed(Node *p_node); + void _notification(int p_what); + + static void _bind_methods(); + +public: + bool forward_canvas_gui_input(const Ref<InputEvent> &p_event); + void forward_draw_over_canvas(Control *p_canvas); + void edit(Node *p_line2d); + Line2DEditor(EditorNode *p_editor); }; class Line2DEditorPlugin : public EditorPlugin { GDCLASS(Line2DEditorPlugin, EditorPlugin) public: - virtual bool forward_canvas_gui_input( - const Transform2D &p_canvas_xform, - const Ref<InputEvent> &p_event) { - return line2d_editor->forward_gui_input(p_event); - } + virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return line2d_editor->forward_canvas_gui_input(p_event); } + virtual void forward_draw_over_canvas(Control *p_canvas) { return line2d_editor->forward_draw_over_canvas(p_canvas); } virtual String get_name() const { return "Line2D"; } bool has_main_screen() const { return false; } diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 043a0f3199..bd4891ccb7 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -32,6 +32,7 @@ // Waiting for PropertyEditor rewrite (planned for 3.1) to be refactored. #include "material_editor_plugin.h" +#include "scene/3d/particles.h" #if 0 @@ -464,3 +465,41 @@ Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_re smat->set_render_priority(mat->get_render_priority()); return smat; } + +String ParticlesMaterialConversionPlugin::converts_to() const { + + return "ShaderMaterial"; +} +bool ParticlesMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { + + Ref<ParticlesMaterial> mat = p_resource; + return mat.is_valid(); +} +Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) { + + Ref<ParticlesMaterial> mat = p_resource; + ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); + + Ref<ShaderMaterial> smat; + smat.instance(); + + Ref<Shader> shader; + shader.instance(); + + String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + + shader->set_code(code); + + smat->set_shader(shader); + + List<PropertyInfo> params; + VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + + for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { + Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + smat->set_shader_param(E->get().name, value); + } + + smat->set_render_priority(mat->get_render_priority()); + return smat; +} diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index af9602f944..52c73cb7d8 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -111,4 +111,12 @@ public: virtual Ref<Resource> convert(const Ref<Resource> &p_resource); }; +class ParticlesMaterialConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(ParticlesMaterialConversionPlugin, EditorResourceConversionPlugin) +public: + virtual String converts_to() const; + virtual bool handles(const Ref<Resource> &p_resource) const; + virtual Ref<Resource> convert(const Ref<Resource> &p_resource); +}; + #endif // MATERIAL_EDITOR_PLUGIN_H diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp index 6560a8dac7..6560a8dac7 100755..100644 --- a/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/editor/plugins/navigation_polygon_editor_plugin.cpp diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h index 54cc347a8c..54cc347a8c 100755..100644 --- a/editor/plugins/navigation_polygon_editor_plugin.h +++ b/editor/plugins/navigation_polygon_editor_plugin.h diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index df10ac8929..2174f08e23 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -76,10 +76,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); Vector2 gpoint = mb->get_position(); - Vector2 cpoint = - !mb->get_alt() ? - canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint)) : - node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint))); + Vector2 cpoint = node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position()))); real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); @@ -239,10 +236,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { // Handle point/control movement. Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); Vector2 gpoint = mm->get_position(); - Vector2 cpoint = - !mm->get_alt() ? - canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint)) : - node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint))); + Vector2 cpoint = node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mm->get_position()))); Ref<Curve2D> curve = node->get_curve(); @@ -274,7 +268,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return false; } -void Path2DEditor::_canvas_draw() { + +void Path2DEditor::forward_draw_over_canvas(Control *p_canvas) { if (!node) return; @@ -329,16 +324,11 @@ void Path2DEditor::edit(Node *p_path2d) { if (p_path2d) { node = Object::cast_to<Path2D>(p_path2d); - if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw"); if (!node->is_connected("visibility_changed", this, "_node_visibility_changed")) node->connect("visibility_changed", this, "_node_visibility_changed"); } else { - if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw"); - // node may have been deleted at this point if (node && node->is_connected("visibility_changed", this, "_node_visibility_changed")) node->disconnect("visibility_changed", this, "_node_visibility_changed"); @@ -349,7 +339,6 @@ void Path2DEditor::edit(Node *p_path2d) { void Path2DEditor::_bind_methods() { //ClassDB::bind_method(D_METHOD("_menu_option"),&Path2DEditor::_menu_option); - ClassDB::bind_method(D_METHOD("_canvas_draw"), &Path2DEditor::_canvas_draw); ClassDB::bind_method(D_METHOD("_node_visibility_changed"), &Path2DEditor::_node_visibility_changed); ClassDB::bind_method(D_METHOD("_mode_selected"), &Path2DEditor::_mode_selected); } diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h index f0f5d4d637..516e48c471 100644 --- a/editor/plugins/path_2d_editor_plugin.h +++ b/editor/plugins/path_2d_editor_plugin.h @@ -84,7 +84,6 @@ class Path2DEditor : public HBoxContainer { void _mode_selected(int p_mode); - void _canvas_draw(); void _node_visibility_changed(); friend class Path2DEditorPlugin; @@ -95,6 +94,7 @@ protected: public: bool forward_gui_input(const Ref<InputEvent> &p_event); + void forward_draw_over_canvas(Control *p_canvas); void edit(Node *p_path2d); Path2DEditor(EditorNode *p_editor); }; @@ -107,7 +107,8 @@ class Path2DEditorPlugin : public EditorPlugin { EditorNode *editor; public: - virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event) { return path2d_editor->forward_gui_input(p_event); } + virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return path2d_editor->forward_gui_input(p_event); } + virtual void forward_draw_over_canvas(Control *p_canvas) { return path2d_editor->forward_draw_over_canvas(p_canvas); } virtual String get_name() const { return "Path2D"; } bool has_main_screen() const { return false; } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 0e8c13b067..0e8c13b067 100755..100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h index 90da3e61c1..90da3e61c1 100755..100644 --- a/editor/plugins/polygon_2d_editor_plugin.h +++ b/editor/plugins/polygon_2d_editor_plugin.h diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 703c9e96b6..547679b056 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2765,8 +2765,14 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const normal = hit_normal; } } - Vector3 center = preview_bounds->get_size() * 0.5; - return point + (center * normal); + Vector3 offset = Vector3(); + for (int i = 0; i < 3; i++) { + if (normal[i] > 0.0) + offset[i] = (preview_bounds->get_size()[i] - (preview_bounds->get_size()[i] + preview_bounds->get_position()[i])); + else if (normal[i] < 0.0) + offset[i] = -(preview_bounds->get_size()[i] + preview_bounds->get_position()[i]); + } + return point + offset; } Rect3 SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds) { diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 2f2ed7bdf0..d12b3f1e0e 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -229,7 +229,7 @@ struct _PaletteEntry { return name < p_rhs.name; } }; -} +} // namespace void TileMapEditor::_update_palette() { @@ -1152,7 +1152,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return false; } -void TileMapEditor::_canvas_draw() { +void TileMapEditor::forward_draw_over_canvas(Control *p_canvas) { if (!node) return; @@ -1379,8 +1379,6 @@ void TileMapEditor::edit(Node *p_tile_map) { if (p_tile_map) { node = Object::cast_to<TileMap>(p_tile_map); - if (!canvas_item_editor->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->connect("draw", this, "_canvas_draw"); if (!canvas_item_editor->is_connected("mouse_entered", this, "_canvas_mouse_enter")) canvas_item_editor->connect("mouse_entered", this, "_canvas_mouse_enter"); if (!canvas_item_editor->is_connected("mouse_exited", this, "_canvas_mouse_exit")) @@ -1391,8 +1389,6 @@ void TileMapEditor::edit(Node *p_tile_map) { } else { node = NULL; - if (canvas_item_editor->is_connected("draw", this, "_canvas_draw")) - canvas_item_editor->disconnect("draw", this, "_canvas_draw"); if (canvas_item_editor->is_connected("mouse_entered", this, "_canvas_mouse_enter")) canvas_item_editor->disconnect("mouse_entered", this, "_canvas_mouse_enter"); if (canvas_item_editor->is_connected("mouse_exited", this, "_canvas_mouse_exit")) @@ -1428,7 +1424,6 @@ void TileMapEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_text_changed"), &TileMapEditor::_text_changed); ClassDB::bind_method(D_METHOD("_sbox_input"), &TileMapEditor::_sbox_input); ClassDB::bind_method(D_METHOD("_menu_option"), &TileMapEditor::_menu_option); - ClassDB::bind_method(D_METHOD("_canvas_draw"), &TileMapEditor::_canvas_draw); ClassDB::bind_method(D_METHOD("_canvas_mouse_enter"), &TileMapEditor::_canvas_mouse_enter); ClassDB::bind_method(D_METHOD("_canvas_mouse_exit"), &TileMapEditor::_canvas_mouse_exit); ClassDB::bind_method(D_METHOD("_tileset_settings_changed"), &TileMapEditor::_tileset_settings_changed); diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h index c8f29dfb7b..5b042e4780 100644 --- a/editor/plugins/tile_map_editor_plugin.h +++ b/editor/plugins/tile_map_editor_plugin.h @@ -163,7 +163,6 @@ class TileMapEditor : public VBoxContainer { void _text_changed(const String &p_text); void _sbox_input(const Ref<InputEvent> &p_ie); void _update_palette(); - void _canvas_draw(); void _menu_option(int p_option); void _set_cell(const Point2i &p_pos, int p_value, bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false, bool p_with_undo = false); @@ -183,6 +182,8 @@ public: HBoxContainer *get_toolbar() const { return toolbar; } bool forward_gui_input(const Ref<InputEvent> &p_event); + void forward_draw_over_canvas(Control *p_canvas); + void edit(Node *p_tile_map); TileMapEditor(EditorNode *p_editor); @@ -197,6 +198,7 @@ class TileMapEditorPlugin : public EditorPlugin { public: virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event) { return tile_map_editor->forward_gui_input(p_event); } + virtual void forward_draw_over_canvas(Control *p_canvas) { tile_map_editor->forward_draw_over_canvas(p_canvas); } virtual String get_name() const { return "TileMap"; } bool has_main_screen() const { return false; } diff --git a/main/main.cpp b/main/main.cpp index 68e518ae3d..04ed902c28 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1350,7 +1350,7 @@ bool Main::start() { String stretch_mode = GLOBAL_DEF("display/window/stretch/mode", "disabled"); String stretch_aspect = GLOBAL_DEF("display/window/stretch/aspect", "ignore"); Size2i stretch_size = Size2(GLOBAL_DEF("display/window/size/width", 0), GLOBAL_DEF("display/window/size/height", 0)); - int stretch_shrink = GLOBAL_DEF("display/window/stretch/shrink", 1); + real_t stretch_shrink = GLOBAL_DEF("display/window/stretch/shrink", 1.0f); SceneTree::StretchMode sml_sm = SceneTree::STRETCH_MODE_DISABLED; if (stretch_mode == "2d") diff --git a/modules/gdnative/include/gdnative/array.h b/modules/gdnative/include/gdnative/array.h index edab028cba..d0639589b7 100644 --- a/modules/gdnative/include/gdnative/array.h +++ b/modules/gdnative/include/gdnative/array.h @@ -46,11 +46,20 @@ typedef struct { } godot_array; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/pool_arrays.h> #include <gdnative/variant.h> #include <gdnative/gdnative.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_array_new(godot_array *r_dest); void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src); void GDAPI godot_array_new_pool_color_array(godot_array *r_dest, const godot_pool_color_array *p_pca); diff --git a/modules/gdnative/include/gdnative/basis.h b/modules/gdnative/include/gdnative/basis.h index 8ff6a6f541..b86b1c17d8 100644 --- a/modules/gdnative/include/gdnative/basis.h +++ b/modules/gdnative/include/gdnative/basis.h @@ -45,10 +45,19 @@ typedef struct { } godot_basis; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> #include <gdnative/quat.h> #include <gdnative/vector3.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis); void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi); void GDAPI godot_basis_new_with_euler(godot_basis *r_dest, const godot_vector3 *p_euler); diff --git a/modules/gdnative/include/gdnative/color.h b/modules/gdnative/include/gdnative/color.h index 14265466b9..857e86a738 100644 --- a/modules/gdnative/include/gdnative/color.h +++ b/modules/gdnative/include/gdnative/color.h @@ -45,9 +45,18 @@ typedef struct { } godot_color; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> #include <gdnative/string.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a); void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b); diff --git a/modules/gdnative/include/gdnative/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h index c85c3f3830..e68d0fdc29 100644 --- a/modules/gdnative/include/gdnative/dictionary.h +++ b/modules/gdnative/include/gdnative/dictionary.h @@ -45,10 +45,19 @@ typedef struct { } godot_dictionary; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/array.h> #include <gdnative/gdnative.h> #include <gdnative/variant.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_dictionary_new(godot_dictionary *r_dest); void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src); void GDAPI godot_dictionary_destroy(godot_dictionary *p_self); diff --git a/modules/gdnative/include/gdnative/node_path.h b/modules/gdnative/include/gdnative/node_path.h index 0cfdbc1127..42446175d8 100644 --- a/modules/gdnative/include/gdnative/node_path.h +++ b/modules/gdnative/include/gdnative/node_path.h @@ -45,9 +45,18 @@ typedef struct { } godot_node_path; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> #include <gdnative/string.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from); void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src); void GDAPI godot_node_path_destroy(godot_node_path *p_self); diff --git a/modules/gdnative/include/gdnative/plane.h b/modules/gdnative/include/gdnative/plane.h index 6a8915e08b..dddd172122 100644 --- a/modules/gdnative/include/gdnative/plane.h +++ b/modules/gdnative/include/gdnative/plane.h @@ -45,9 +45,18 @@ typedef struct { } godot_plane; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> #include <gdnative/vector3.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d); void GDAPI godot_plane_new_with_vectors(godot_plane *r_dest, const godot_vector3 *p_v1, const godot_vector3 *p_v2, const godot_vector3 *p_v3); void GDAPI godot_plane_new_with_normal(godot_plane *r_dest, const godot_vector3 *p_normal, const godot_real p_d); diff --git a/modules/gdnative/include/gdnative/pool_arrays.h b/modules/gdnative/include/gdnative/pool_arrays.h index cb1095ee8c..93181f2a6b 100644 --- a/modules/gdnative/include/gdnative/pool_arrays.h +++ b/modules/gdnative/include/gdnative/pool_arrays.h @@ -113,6 +113,11 @@ typedef struct { } godot_pool_color_array; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/array.h> #include <gdnative/color.h> #include <gdnative/vector2.h> @@ -120,6 +125,10 @@ typedef struct { #include <gdnative/gdnative.h> +#ifdef __cplusplus +extern "C" { +#endif + // byte void GDAPI godot_pool_byte_array_new(godot_pool_byte_array *r_dest); diff --git a/modules/gdnative/include/gdnative/quat.h b/modules/gdnative/include/gdnative/quat.h index 4ffb96eb26..acae6e3e90 100644 --- a/modules/gdnative/include/gdnative/quat.h +++ b/modules/gdnative/include/gdnative/quat.h @@ -45,9 +45,18 @@ typedef struct { } godot_quat; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> #include <gdnative/vector3.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w); void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle); diff --git a/modules/gdnative/include/gdnative/rect2.h b/modules/gdnative/include/gdnative/rect2.h index 9e6cf60342..1c66443d4f 100644 --- a/modules/gdnative/include/gdnative/rect2.h +++ b/modules/gdnative/include/gdnative/rect2.h @@ -43,9 +43,18 @@ typedef struct godot_rect2 { } godot_rect2; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> #include <gdnative/vector2.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size); void GDAPI godot_rect2_new(godot_rect2 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_width, const godot_real p_height); diff --git a/modules/gdnative/include/gdnative/rect3.h b/modules/gdnative/include/gdnative/rect3.h index f94b6fea25..f603a9268a 100644 --- a/modules/gdnative/include/gdnative/rect3.h +++ b/modules/gdnative/include/gdnative/rect3.h @@ -45,10 +45,19 @@ typedef struct { } godot_rect3; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> #include <gdnative/plane.h> #include <gdnative/vector3.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size); godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self); diff --git a/modules/gdnative/include/gdnative/rid.h b/modules/gdnative/include/gdnative/rid.h index d9b5336fc9..caa1bb967e 100644 --- a/modules/gdnative/include/gdnative/rid.h +++ b/modules/gdnative/include/gdnative/rid.h @@ -45,8 +45,17 @@ typedef struct { } godot_rid; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_rid_new(godot_rid *r_dest); godot_int GDAPI godot_rid_get_id(const godot_rid *p_self); diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h index aca23a81d8..f30fdb8dc7 100644 --- a/modules/gdnative/include/gdnative/string.h +++ b/modules/gdnative/include/gdnative/string.h @@ -46,9 +46,18 @@ typedef struct { } godot_string; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> #include <gdnative/variant.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_string_new(godot_string *r_dest); void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src); void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size); diff --git a/modules/gdnative/include/gdnative/string_name.h b/modules/gdnative/include/gdnative/string_name.h index e217487250..ee9f603d20 100644 --- a/modules/gdnative/include/gdnative/string_name.h +++ b/modules/gdnative/include/gdnative/string_name.h @@ -46,8 +46,17 @@ typedef struct { } godot_string_name; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_string_name_new(godot_string_name *r_dest, const godot_string *p_name); void GDAPI godot_string_name_new_data(godot_string_name *r_dest, const char *p_name); diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h index 656afae129..8f50b01fb5 100644 --- a/modules/gdnative/include/gdnative/transform.h +++ b/modules/gdnative/include/gdnative/transform.h @@ -45,11 +45,20 @@ typedef struct { } godot_transform; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/basis.h> #include <gdnative/gdnative.h> #include <gdnative/variant.h> #include <gdnative/vector3.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin); void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin); diff --git a/modules/gdnative/include/gdnative/transform2d.h b/modules/gdnative/include/gdnative/transform2d.h index a945868b17..c68bd2963f 100644 --- a/modules/gdnative/include/gdnative/transform2d.h +++ b/modules/gdnative/include/gdnative/transform2d.h @@ -45,10 +45,19 @@ typedef struct { } godot_transform2d; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> #include <gdnative/variant.h> #include <gdnative/vector2.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos); void GDAPI godot_transform2d_new_axis_origin(godot_transform2d *r_dest, const godot_vector2 *p_x_axis, const godot_vector2 *p_y_axis, const godot_vector2 *p_origin); diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h index 7b804c1eaf..3d744ef1f2 100644 --- a/modules/gdnative/include/gdnative/variant.h +++ b/modules/gdnative/include/gdnative/variant.h @@ -99,6 +99,11 @@ typedef struct godot_variant_call_error { godot_variant_type expected; } godot_variant_call_error; +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/array.h> #include <gdnative/basis.h> #include <gdnative/color.h> @@ -119,6 +124,10 @@ typedef struct godot_variant_call_error { #include <gdnative/gdnative.h> +#ifdef __cplusplus +extern "C" { +#endif + godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v); void GDAPI godot_variant_new_copy(godot_variant *r_dest, const godot_variant *p_src); diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h index 0af4abae27..07105abaf2 100644 --- a/modules/gdnative/include/gdnative/vector2.h +++ b/modules/gdnative/include/gdnative/vector2.h @@ -45,8 +45,17 @@ typedef struct { } godot_vector2; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/gdnative.h> +#ifdef __cplusplus +extern "C" { +#endif + void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y); godot_string GDAPI godot_vector2_as_string(const godot_vector2 *p_self); diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h index a27d516ec5..3ed23778ec 100644 --- a/modules/gdnative/include/gdnative/vector3.h +++ b/modules/gdnative/include/gdnative/vector3.h @@ -45,9 +45,18 @@ typedef struct { } godot_vector3; #endif +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + #include <gdnative/basis.h> #include <gdnative/gdnative.h> +#ifdef __cplusplus +extern "C" { +#endif + typedef enum { GODOT_VECTOR3_AXIS_X, GODOT_VECTOR3_AXIS_Y, diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp index 2198e66ae4..d4b86ae5b4 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.cpp +++ b/modules/gdnative/pluginscript/pluginscript_language.cpp @@ -28,7 +28,6 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <stdlib.h> // Godot imports #include "core/os/file_access.h" #include "core/os/os.h" diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h index 051ef46bae..e6b8643cd9 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.h +++ b/modules/gdnative/pluginscript/pluginscript_script.h @@ -31,7 +31,6 @@ #ifndef PLUGINSCRIPT_SCRIPT_H #define PLUGINSCRIPT_SCRIPT_H -#include <iostream> // Godot imports #include "core/script_language.h" // PluginScript imports diff --git a/modules/mobile_vr/mobile_interface.h b/modules/mobile_vr/mobile_interface.h index 6a5e01c163..747377ae46 100644 --- a/modules/mobile_vr/mobile_interface.h +++ b/modules/mobile_vr/mobile_interface.h @@ -90,7 +90,7 @@ private: ///@TODO a few support functions for trackers, most are math related and should likely be moved elsewhere float floor_decimals(float p_value, float p_decimals) { - float power_of_10 = pow(10.0, p_decimals); + float power_of_10 = pow(10.0f, p_decimals); return floor(p_value * power_of_10) / power_of_10; }; diff --git a/modules/mono/config.py b/modules/mono/config.py index 13b9a4b1e6..0833d30ce1 100644 --- a/modules/mono/config.py +++ b/modules/mono/config.py @@ -125,7 +125,11 @@ def configure(env): else: env.Append(LIBS=[mono_lib]) - env.Append(LIBS=['m', 'rt', 'dl', 'pthread']) + if sys.platform == "darwin": + env.Append(LIBS=['iconv', 'pthread']) + elif sys.platform == "linux" or sys.platform == "linux2": + env.Append(LIBS=['m', 'rt', 'dl', 'pthread']) + else: if mono_static: raise RuntimeError('mono-static: Not supported with pkg-config. Specify a mono prefix manually') diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 1980f86114..4b294325dc 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -1280,6 +1280,11 @@ void VisualScriptBuiltinFunc::_bind_methods() { BIND_ENUM_CONSTANT(FUNC_MAX); } +VisualScriptBuiltinFunc::VisualScriptBuiltinFunc(VisualScriptBuiltinFunc::BuiltinFunc func) { + + this->func = func; +} + VisualScriptBuiltinFunc::VisualScriptBuiltinFunc() { func = MATH_SIN; @@ -1288,9 +1293,7 @@ VisualScriptBuiltinFunc::VisualScriptBuiltinFunc() { template <VisualScriptBuiltinFunc::BuiltinFunc func> static Ref<VisualScriptNode> create_builtin_func_node(const String &p_name) { - Ref<VisualScriptBuiltinFunc> node; - node.instance(); - node->set_func(func); + Ref<VisualScriptBuiltinFunc> node = memnew(VisualScriptBuiltinFunc(func)); return node; } diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h index af24f16a2f..5758d23e8f 100644 --- a/modules/visual_script/visual_script_builtin_funcs.h +++ b/modules/visual_script/visual_script_builtin_funcs.h @@ -132,6 +132,7 @@ public: virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); + VisualScriptBuiltinFunc(VisualScriptBuiltinFunc::BuiltinFunc func); VisualScriptBuiltinFunc(); }; diff --git a/platform/iphone/game_center.h b/platform/iphone/game_center.h index c0a7830fe9..21f40fa362 100644 --- a/platform/iphone/game_center.h +++ b/platform/iphone/game_center.h @@ -43,11 +43,13 @@ class GameCenter : public Object { List<Variant> pending_events; - bool connected; + bool authenticated; + + void return_connect_error(const char *p_error_description); public: - Error connect(); - bool is_connected(); + void connect(); + bool is_authenticated(); Error post_score(Variant p_score); Error award_achievement(Variant p_params); @@ -55,6 +57,7 @@ public: void request_achievements(); void request_achievement_descriptions(); Error show_game_center(Variant p_params); + Error request_identity_verification_signature(); void game_center_closed(); diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm index 3955b9f0aa..531b80eee3 100644 --- a/platform/iphone/game_center.mm +++ b/platform/iphone/game_center.mm @@ -49,8 +49,7 @@ extern "C" { GameCenter *GameCenter::instance = NULL; void GameCenter::_bind_methods() { - ClassDB::bind_method(D_METHOD("connect"), &GameCenter::connect); - ClassDB::bind_method(D_METHOD("is_connected"), &GameCenter::is_connected); + ClassDB::bind_method(D_METHOD("is_authenticated"), &GameCenter::is_authenticated); ClassDB::bind_method(D_METHOD("post_score"), &GameCenter::post_score); ClassDB::bind_method(D_METHOD("award_achievement"), &GameCenter::award_achievement); @@ -58,24 +57,41 @@ void GameCenter::_bind_methods() { ClassDB::bind_method(D_METHOD("request_achievements"), &GameCenter::request_achievements); ClassDB::bind_method(D_METHOD("request_achievement_descriptions"), &GameCenter::request_achievement_descriptions); ClassDB::bind_method(D_METHOD("show_game_center"), &GameCenter::show_game_center); + ClassDB::bind_method(D_METHOD("request_identity_verification_signature"), &GameCenter::request_identity_verification_signature); ClassDB::bind_method(D_METHOD("get_pending_event_count"), &GameCenter::get_pending_event_count); ClassDB::bind_method(D_METHOD("pop_pending_event"), &GameCenter::pop_pending_event); }; -Error GameCenter::connect() { +void GameCenter::return_connect_error(const char *p_error_description) { + authenticated = false; + Dictionary ret; + ret["type"] = "authentication"; + ret["result"] = "error"; + ret["error_code"] = 0; + ret["error_description"] = p_error_description; + pending_events.push_back(ret); +} + +void GameCenter::connect() { //if this class isn't available, game center isn't implemented if ((NSClassFromString(@"GKLocalPlayer")) == nil) { - GameCenter::get_singleton()->connected = false; - return ERR_UNAVAILABLE; + return_connect_error("GameCenter not available"); + return; } GKLocalPlayer *player = [GKLocalPlayer localPlayer]; - ERR_FAIL_COND_V(![player respondsToSelector:@selector(authenticateHandler)], ERR_UNAVAILABLE); + if (![player respondsToSelector:@selector(authenticateHandler)]) { + return_connect_error("GameCenter doesn't respond to 'authenticateHandler'"); + return; + } ViewController *root_controller = (ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController; - ERR_FAIL_COND_V(!root_controller, FAILED); + if (!root_controller) { + return_connect_error("Window doesn't have root ViewController"); + return; + } // This handler is called several times. First when the view needs to be shown, then again // after the view is cancelled or the user logs in. Or if the user's already logged in, it's @@ -90,23 +106,21 @@ Error GameCenter::connect() { if (player.isAuthenticated) { ret["result"] = "ok"; ret["player_id"] = [player.playerID UTF8String]; - GameCenter::get_singleton()->connected = true; + GameCenter::get_singleton()->authenticated = true; } else { ret["result"] = "error"; ret["error_code"] = error.code; ret["error_description"] = [error.localizedDescription UTF8String]; - GameCenter::get_singleton()->connected = false; + GameCenter::get_singleton()->authenticated = false; }; pending_events.push_back(ret); }; }); - - return OK; }; -bool GameCenter::is_connected() { - return connected; +bool GameCenter::is_authenticated() { + return authenticated; }; Error GameCenter::post_score(Variant p_score) { @@ -117,7 +131,7 @@ Error GameCenter::post_score(Variant p_score) { String category = params["category"]; NSString *cat_str = [[[NSString alloc] initWithUTF8String:category.utf8().get_data()] autorelease]; - GKScore *reporter = [[[GKScore alloc] initWithCategory:cat_str] autorelease]; + GKScore *reporter = [[[GKScore alloc] initWithLeaderboardIdentifier:cat_str] autorelease]; reporter.value = score; ERR_FAIL_COND_V([GKScore respondsToSelector:@selector(reportScores)], ERR_UNAVAILABLE); @@ -326,6 +340,34 @@ Error GameCenter::show_game_center(Variant p_params) { return OK; }; +Error GameCenter::request_identity_verification_signature() { + + ERR_FAIL_COND_V(!is_authenticated(), ERR_UNAUTHORIZED); + + GKLocalPlayer *player = [GKLocalPlayer localPlayer]; + [player generateIdentityVerificationSignatureWithCompletionHandler:^(NSURL *publicKeyUrl, NSData *signature, NSData *salt, uint64_t timestamp, NSError *error) { + + Dictionary ret; + ret["type"] = "identity_verification_signature"; + if (error == nil) { + ret["result"] = "ok"; + ret["public_key_url"] = [publicKeyUrl.absoluteString UTF8String]; + ret["signature"] = [[signature base64EncodedStringWithOptions:0] UTF8String]; + ret["salt"] = [[salt base64EncodedStringWithOptions:0] UTF8String]; + ret["timestamp"] = timestamp; + ret["player_id"] = [player.playerID UTF8String]; + } else { + ret["result"] = "error"; + ret["error_code"] = error.code; + ret["error_description"] = [error.localizedDescription UTF8String]; + }; + + pending_events.push_back(ret); + }]; + + return OK; +}; + void GameCenter::game_center_closed() { Dictionary ret; @@ -354,7 +396,7 @@ GameCenter *GameCenter::get_singleton() { GameCenter::GameCenter() { ERR_FAIL_COND(instance != NULL); instance = this; - connected = false; + authenticated = false; }; GameCenter::~GameCenter(){}; diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 1f7f67fe10..8c68c9ffd1 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -239,6 +239,9 @@ def configure(env): if (platform.system() == "Linux"): env.Append(LIBS=['dl']) + if (platform.system().find("BSD") >= 0): + env.Append(LIBS=['execinfo']) + ## Cross-compilation if (is64 and env["bits"] == "32"): diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index bc18d0c1f0..48e2d8f81e 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -35,7 +35,11 @@ #include "servers/physics/physics_server_sw.h" #include "servers/visual/visual_server_raster.h" #include "servers/visual/visual_server_wrap_mt.h" + +#ifdef HAVE_MNTENT #include <mntent.h> +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -2182,6 +2186,7 @@ static String get_mountpoint(const String &p_path) { return ""; } +#ifdef HAVE_MNTENT dev_t dev = s.st_dev; FILE *fd = setmntent("/proc/mounts", "r"); if (!fd) { @@ -2199,6 +2204,7 @@ static String get_mountpoint(const String &p_path) { } endmntent(fd); +#endif return ""; } diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index 352ec3b300..35f94bff59 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -329,7 +329,7 @@ void NavigationPolygonInstance::_notification(int p_what) { break; } - c = Object::cast_to<Node2D>(get_parent()); + c = Object::cast_to<Node2D>(c->get_parent()); } } break; diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp index 0ddcb7b51b..a13ce6278e 100644 --- a/scene/2d/parallax_background.cpp +++ b/scene/2d/parallax_background.cpp @@ -49,8 +49,8 @@ void ParallaxBackground::_notification(int p_what) { void ParallaxBackground::_camera_moved(const Transform2D &p_transform) { - set_scroll_offset(p_transform.get_origin()); set_scroll_scale(p_transform.get_scale().dot(Vector2(0.5, 0.5))); + set_scroll_offset(p_transform.get_origin() / p_transform.get_scale()); } void ParallaxBackground::set_scroll_scale(float p_scale) { diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp index c6b6c02129..064a249190 100644 --- a/scene/3d/arvr_nodes.cpp +++ b/scene/3d/arvr_nodes.cpp @@ -204,7 +204,7 @@ void ARVRController::_notification(int p_what) { int mask = 1; // check button states for (int i = 0; i < 16; i++) { - bool was_pressed = (button_states && mask) == mask; + bool was_pressed = (button_states & mask) == mask; bool is_pressed = Input::get_singleton()->is_joy_button_pressed(joy_id, i); if (!was_pressed && is_pressed) { @@ -336,6 +336,7 @@ String ARVRController::get_configuration_warning() const { ARVRController::ARVRController() { controller_id = 0; is_active = true; + button_states = 0; }; ARVRController::~ARVRController(){ diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 73749cacb3..4e19214c59 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -585,298 +585,294 @@ void ParticlesMaterial::_update_shader() { //need a random function code += "\n\n"; code += "float rand_from_seed(inout uint seed) {\n"; - code += " int k;\n"; - code += " int s = int(seed);\n"; - code += " if (s == 0)\n"; + code += " int k;\n"; + code += " int s = int(seed);\n"; + code += " if (s == 0)\n"; code += " s = 305420679;\n"; - code += " k = s / 127773;\n"; - code += " s = 16807 * (s - k * 127773) - 2836 * k;\n"; - code += " if (s < 0)\n"; - code += " s += 2147483647;\n"; - code += " seed = uint(s);\n"; - code += " return float(seed % uint(65536))/65535.0;\n"; + code += " k = s / 127773;\n"; + code += " s = 16807 * (s - k * 127773) - 2836 * k;\n"; + code += " if (s < 0)\n"; + code += " s += 2147483647;\n"; + code += " seed = uint(s);\n"; + code += " return float(seed % uint(65536))/65535.0;\n"; code += "}\n"; + code += "\n"; + //improve seed quality code += "uint hash(uint x) {\n"; - code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n"; - code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n"; - code += " x = (x >> uint(16)) ^ x;\n"; - code += " return x;\n"; + code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n"; + code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n"; + code += " x = (x >> uint(16)) ^ x;\n"; + code += " return x;\n"; code += "}\n"; - code += "void vertex() {\n\n"; code += "\n"; - code += " uint base_number=NUMBER/uint(trail_divisor);\n"; - code += " uint alt_seed=hash(base_number+uint(1)+RANDOM_SEED);\n"; - code += " float angle_rand=rand_from_seed(alt_seed);\n"; - code += " float scale_rand=rand_from_seed(alt_seed);\n"; - code += " float hue_rot_rand=rand_from_seed(alt_seed);\n"; - code += " float anim_offset_rand=rand_from_seed(alt_seed);\n"; - code += "\n"; - code += "\n"; - code += "\n"; + code += "void vertex() {\n"; + code += " uint base_number = NUMBER/uint(trail_divisor);\n"; + code += " uint alt_seed = hash(base_number+uint(1)+RANDOM_SEED);\n"; + code += " float angle_rand = rand_from_seed(alt_seed);\n"; + code += " float scale_rand = rand_from_seed(alt_seed);\n"; + code += " float hue_rot_rand = rand_from_seed(alt_seed);\n"; + code += " float anim_offset_rand = rand_from_seed(alt_seed);\n"; code += "\n"; + if (emission_shape >= EMISSION_SHAPE_POINTS) { - code += " int point = min(emission_texture_point_count-1,int(rand_from_seed(alt_seed) * float(emission_texture_point_count)));\n"; - code += " ivec2 emission_tex_size = textureSize( emission_texture_points, 0 );\n"; - code += " ivec2 emission_tex_ofs = ivec2( point % emission_tex_size.x, point / emission_tex_size.x );\n"; + code += " int point = min(emission_texture_point_count-1,int(rand_from_seed(alt_seed) * float(emission_texture_point_count)));\n"; + code += " ivec2 emission_tex_size = textureSize( emission_texture_points, 0 );\n"; + code += " ivec2 emission_tex_ofs = ivec2( point % emission_tex_size.x, point / emission_tex_size.x );\n"; } - code += " if (RESTART) {\n"; + code += " if (RESTART) {\n"; if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) - code += " float tex_linear_velocity = textureLod(linear_velocity_texture,vec2(0.0,0.0),0.0).r;\n"; + code += " float tex_linear_velocity = textureLod(linear_velocity_texture,vec2(0.0,0.0),0.0).r;\n"; else - code += " float tex_linear_velocity = 0.0;\n"; + code += " float tex_linear_velocity = 0.0;\n"; if (tex_parameters[PARAM_ANGLE].is_valid()) - code += " float tex_angle = textureLod(angle_texture,vec2(0.0,0.0),0.0).r;\n"; + code += " float tex_angle = textureLod(angle_texture,vec2(0.0,0.0),0.0).r;\n"; else - code += " float tex_angle = 0.0;\n"; + code += " float tex_angle = 0.0;\n"; if (tex_parameters[PARAM_ANIM_OFFSET].is_valid()) - code += " float tex_anim_offset = textureLod(anim_offset_texture,vec2(0.0,0.0),0.0).r;\n"; + code += " float tex_anim_offset = textureLod(anim_offset_texture,vec2(0.0,0.0),0.0).r;\n"; else - code += " float tex_anim_offset = 0.0;\n"; + code += " float tex_anim_offset = 0.0;\n"; if (flags[FLAG_DISABLE_Z]) { - code += " float angle1 = (rand_from_seed(alt_seed)*2.0-1.0)*spread/180.0*3.1416;\n"; - code += " vec3 rot=vec3( cos(angle1), sin(angle1),0.0 );\n"; - code += " VELOCITY=(rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n"; + code += " float angle1 = (rand_from_seed(alt_seed)*2.0-1.0)*spread/180.0*3.1416;\n"; + code += " vec3 rot = vec3( cos(angle1), sin(angle1),0.0 );\n"; + code += " VELOCITY = (rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n"; } else { //initiate velocity spread in 3D - code += " float angle1 = rand_from_seed(alt_seed)*spread*3.1416;\n"; - code += " float angle2 = rand_from_seed(alt_seed)*20.0*3.1416; // make it more random like\n"; - code += " vec3 rot_xz=vec3( sin(angle1), 0.0, cos(angle1) );\n"; - code += " vec3 rot = vec3( cos(angle2)*rot_xz.x,sin(angle2)*rot_xz.x, rot_xz.z);\n"; - code += " VELOCITY=(rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n"; + code += " float angle1 = rand_from_seed(alt_seed)*spread*3.1416;\n"; + code += " float angle2 = rand_from_seed(alt_seed)*20.0*3.1416; // make it more random like\n"; + code += " vec3 rot_xz = vec3( sin(angle1), 0.0, cos(angle1) );\n"; + code += " vec3 rot = vec3( cos(angle2)*rot_xz.x,sin(angle2)*rot_xz.x, rot_xz.z);\n"; + code += " VELOCITY = (rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n"; } - code += " float base_angle=(initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n"; - code += " CUSTOM.x=base_angle*3.1416/180.0;\n"; //angle - code += " CUSTOM.y=0.0;\n"; //phase - code += " CUSTOM.z=(anim_offset+tex_anim_offset)*mix(1.0,anim_offset_rand,anim_offset_random);\n"; //animation offset (0-1) + code += " float base_angle = (initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n"; + code += " CUSTOM.x = base_angle*3.1416/180.0;\n"; //angle + code += " CUSTOM.y = 0.0;\n"; //phase + code += " CUSTOM.z = (anim_offset+tex_anim_offset)*mix(1.0,anim_offset_rand,anim_offset_random);\n"; //animation offset (0-1) switch (emission_shape) { case EMISSION_SHAPE_POINT: { //do none } break; case EMISSION_SHAPE_SPHERE: { - code += " TRANSFORM[3].xyz = normalize(vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0-1.0, rand_from_seed(alt_seed) * 2.0-1.0 ))*emission_sphere_radius;\n"; + code += " TRANSFORM[3].xyz = normalize(vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0-1.0, rand_from_seed(alt_seed) * 2.0-1.0 ))*emission_sphere_radius;\n"; } break; case EMISSION_SHAPE_BOX: { - code += " TRANSFORM[3].xyz = vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0-1.0, rand_from_seed(alt_seed) * 2.0-1.0)*emission_box_extents;\n"; + code += " TRANSFORM[3].xyz = vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0-1.0, rand_from_seed(alt_seed) * 2.0-1.0)*emission_box_extents;\n"; } break; case EMISSION_SHAPE_POINTS: case EMISSION_SHAPE_DIRECTED_POINTS: { - code += " TRANSFORM[3].xyz = texelFetch(emission_texture_points, emission_tex_ofs,0).xyz;\n"; + code += " TRANSFORM[3].xyz = texelFetch(emission_texture_points, emission_tex_ofs,0).xyz;\n"; if (emission_shape == EMISSION_SHAPE_DIRECTED_POINTS) { if (flags[FLAG_DISABLE_Z]) { - code += " mat2 rotm;"; - code += " rotm[0]=texelFetch(emission_texture_normal, emission_tex_ofs,0).xy;\n"; - code += " rotm[1]=rotm[0].yx * vec2(1.0,-1.0);\n"; - code += " VELOCITY.xy = rotm * VELOCITY.xy;\n"; + code += " mat2 rotm;"; + code += " rotm[0] = texelFetch(emission_texture_normal, emission_tex_ofs,0).xy;\n"; + code += " rotm[1] = rotm[0].yx * vec2(1.0,-1.0);\n"; + code += " VELOCITY.xy = rotm * VELOCITY.xy;\n"; } else { - code += " vec3 normal = texelFetch(emission_texture_normal, emission_tex_ofs,0).xyz;\n"; - code += " vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0, 1.0, 0.0);\n"; - code += " vec3 tangent = normalize(cross(v0, normal));\n"; - code += " vec3 bitangent = normalize(cross(tangent, normal));\n"; - code += " VELOCITY = mat3(tangent,bitangent,normal) * VELOCITY;\n"; + code += " vec3 normal = texelFetch(emission_texture_normal, emission_tex_ofs,0).xyz;\n"; + code += " vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0, 1.0, 0.0);\n"; + code += " vec3 tangent = normalize(cross(v0, normal));\n"; + code += " vec3 bitangent = normalize(cross(tangent, normal));\n"; + code += " VELOCITY = mat3(tangent,bitangent,normal) * VELOCITY;\n"; } } } break; } - code += " VELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY,0.0)).xyz;\n"; - code += " TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;\n"; + code += " VELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY,0.0)).xyz;\n"; + code += " TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;\n"; if (flags[FLAG_DISABLE_Z]) { - code += " VELOCITY.z=0.0;\n"; - code += " TRANSFORM[3].z=0.0;\n"; + code += " VELOCITY.z = 0.0;\n"; + code += " TRANSFORM[3].z = 0.0;\n"; } - code += " } else {\n"; + code += " } else {\n"; - code += " CUSTOM.y+=DELTA/LIFETIME;\n"; + code += " CUSTOM.y += DELTA/LIFETIME;\n"; if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) - code += " float tex_linear_velocity = textureLod(linear_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_linear_velocity = textureLod(linear_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_linear_velocity = 0.0;\n"; + code += " float tex_linear_velocity = 0.0;\n"; if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid()) - code += " float tex_orbit_velocity = textureLod(orbit_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_orbit_velocity = textureLod(orbit_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_orbit_velocity = 0.0;\n"; + code += " float tex_orbit_velocity = 0.0;\n"; if (tex_parameters[PARAM_ANGULAR_VELOCITY].is_valid()) - code += " float tex_angular_velocity = textureLod(angular_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_angular_velocity = textureLod(angular_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_angular_velocity = 0.0;\n"; + code += " float tex_angular_velocity = 0.0;\n"; if (tex_parameters[PARAM_LINEAR_ACCEL].is_valid()) - code += " float tex_linear_accel = textureLod(linear_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_linear_accel = textureLod(linear_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_linear_accel = 0.0;\n"; + code += " float tex_linear_accel = 0.0;\n"; if (tex_parameters[PARAM_RADIAL_ACCEL].is_valid()) - code += " float tex_radial_accel = textureLod(radial_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_radial_accel = textureLod(radial_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_radial_accel = 0.0;\n"; + code += " float tex_radial_accel = 0.0;\n"; if (tex_parameters[PARAM_TANGENTIAL_ACCEL].is_valid()) - code += " float tex_tangent_accel = textureLod(tangent_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_tangent_accel = textureLod(tangent_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_tangent_accel = 0.0;\n"; + code += " float tex_tangent_accel = 0.0;\n"; if (tex_parameters[PARAM_DAMPING].is_valid()) - code += " float tex_damping = textureLod(damping_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_damping = textureLod(damping_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_damping = 0.0;\n"; + code += " float tex_damping = 0.0;\n"; if (tex_parameters[PARAM_ANGLE].is_valid()) - code += " float tex_angle = textureLod(angle_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_angle = textureLod(angle_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_angle = 0.0;\n"; + code += " float tex_angle = 0.0;\n"; if (tex_parameters[PARAM_ANIM_SPEED].is_valid()) - code += " float tex_anim_speed = textureLod(anim_speed_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_anim_speed = textureLod(anim_speed_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_anim_speed = 0.0;\n"; + code += " float tex_anim_speed = 0.0;\n"; if (tex_parameters[PARAM_ANIM_OFFSET].is_valid()) - code += " float tex_anim_offset = textureLod(anim_offset_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_anim_offset = textureLod(anim_offset_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_anim_offset = 0.0;\n"; + code += " float tex_anim_offset = 0.0;\n"; - code += " vec3 force = gravity; \n"; - code += " vec3 pos = TRANSFORM[3].xyz; \n"; + code += " vec3 force = gravity; \n"; + code += " vec3 pos = TRANSFORM[3].xyz; \n"; if (flags[FLAG_DISABLE_Z]) { - code += " pos.z=0.0; \n"; + code += " pos.z = 0.0; \n"; } - code += " //apply linear acceleration\n"; - code += " force+= length(VELOCITY) > 0.0 ? normalize(VELOCITY) * (linear_accel+tex_linear_accel)*mix(1.0,rand_from_seed(alt_seed),linear_accel_random) : vec3(0.0);\n"; - code += " //apply radial acceleration\n"; - code += " vec3 org = vec3(0.0);\n"; - code += " // if (!p_system->local_coordinates)\n"; - code += " //org=p_transform.origin;\n"; - code += " vec3 diff = pos-org;\n"; - code += " force+=length(diff) > 0.0 ? normalize(diff) * (radial_accel+tex_radial_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random) : vec3(0.0);\n"; - code += " //apply tangential acceleration;\n"; + code += " //apply linear acceleration\n"; + code += " force += length(VELOCITY) > 0.0 ? normalize(VELOCITY) * (linear_accel+tex_linear_accel)*mix(1.0,rand_from_seed(alt_seed),linear_accel_random) : vec3(0.0);\n"; + code += " //apply radial acceleration\n"; + code += " vec3 org = vec3(0.0);\n"; + code += " vec3 diff = pos-org;\n"; + code += " force += length(diff) > 0.0 ? normalize(diff) * (radial_accel+tex_radial_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random) : vec3(0.0);\n"; + code += " //apply tangential acceleration;\n"; if (flags[FLAG_DISABLE_Z]) { - code += " force+=length(diff.yx) > 0.0 ? vec3(normalize(diff.yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n"; + code += " force += length(diff.yx) > 0.0 ? vec3(normalize(diff.yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n"; } else { - code += " vec3 crossDiff = cross(normalize(diff),normalize(gravity));\n"; - code += " force+=length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n"; + code += " vec3 crossDiff = cross(normalize(diff),normalize(gravity));\n"; + code += " force += length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n"; } - code += " //apply attractor forces\n"; - code += " VELOCITY+=force * DELTA;\n"; + code += " //apply attractor forces\n"; + code += " VELOCITY += force * DELTA;\n"; if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) { - code += " VELOCITY=normalize(VELOCITY)*tex_linear_velocity;\n"; + code += " VELOCITY = normalize(VELOCITY)*tex_linear_velocity;\n"; } - code += " if (damping+tex_damping>0.0) {\n"; - code += " \n"; - code += " float v = length(VELOCITY);\n"; - code += " float damp = (damping+tex_damping)*mix(1.0,rand_from_seed(alt_seed),damping_random);\n"; - code += " v -= damp * DELTA;\n"; - code += " if (v<0.0) {\n"; - code += " VELOCITY=vec3(0.0);\n"; - code += " } else {\n"; - code += " VELOCITY=normalize(VELOCITY) * v;\n"; - code += " }\n"; - code += " }\n"; - code += " float base_angle=(initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n"; - code += " base_angle+=CUSTOM.y*LIFETIME*(angular_velocity+tex_angular_velocity)*mix(1.0,rand_from_seed(alt_seed)*2.0-1.0,angular_velocity_random);\n"; - code += " CUSTOM.x=base_angle*3.1416/180.0;\n"; //angle - code += " CUSTOM.z=(anim_offset+tex_anim_offset)*mix(1.0,anim_offset_rand,anim_offset_random)+CUSTOM.y*(anim_speed+tex_anim_speed)*mix(1.0,rand_from_seed(alt_seed),anim_speed_random);\n"; //angle + code += " if (damping + tex_damping > 0.0) {\n"; + code += " \n"; + code += " float v = length(VELOCITY);\n"; + code += " float damp = (damping+tex_damping)*mix(1.0,rand_from_seed(alt_seed),damping_random);\n"; + code += " v -= damp * DELTA;\n"; + code += " if (v < 0.0) {\n"; + code += " VELOCITY = vec3(0.0);\n"; + code += " } else {\n"; + code += " VELOCITY = normalize(VELOCITY) * v;\n"; + code += " }\n"; + code += " }\n"; + code += " float base_angle = (initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n"; + code += " base_angle += CUSTOM.y*LIFETIME*(angular_velocity+tex_angular_velocity)*mix(1.0,rand_from_seed(alt_seed)*2.0-1.0,angular_velocity_random);\n"; + code += " CUSTOM.x = base_angle*3.1416/180.0;\n"; //angle + code += " CUSTOM.z = (anim_offset+tex_anim_offset)*mix(1.0,anim_offset_rand,anim_offset_random)+CUSTOM.y*(anim_speed+tex_anim_speed)*mix(1.0,rand_from_seed(alt_seed),anim_speed_random);\n"; //angle if (flags[FLAG_ANIM_LOOP]) { - code += " CUSTOM.z=mod(CUSTOM.z,1.0);\n"; //loop + code += " CUSTOM.z = mod(CUSTOM.z,1.0);\n"; //loop } else { - code += " CUSTOM.z=clamp(CUSTOM.z,0.0,1.0);\n"; //0 to 1 only + code += " CUSTOM.z = clamp(CUSTOM.z,0.0,1.0);\n"; //0 to 1 only } - code += " }\n"; + code += " }\n"; //apply color //apply hue rotation if (tex_parameters[PARAM_SCALE].is_valid()) - code += " float tex_scale = textureLod(scale_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_scale = textureLod(scale_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_scale = 1.0;\n"; + code += " float tex_scale = 1.0;\n"; if (tex_parameters[PARAM_HUE_VARIATION].is_valid()) - code += " float tex_hue_variation = textureLod(hue_variation_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + code += " float tex_hue_variation = textureLod(hue_variation_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; else - code += " float tex_hue_variation = 0.0;\n"; - - code += " float hue_rot_angle = (hue_variation+tex_hue_variation)*3.1416*2.0*mix(1.0,hue_rot_rand*2.0-1.0,hue_variation_random);\n"; - code += " float hue_rot_c = cos(hue_rot_angle);\n"; - code += " float hue_rot_s = sin(hue_rot_angle);\n"; - code += " mat4 hue_rot_mat = mat4( vec4(0.299, 0.587, 0.114, 0.0),\n"; - code += " vec4(0.299, 0.587, 0.114, 0.0),\n"; - code += " vec4(0.299, 0.587, 0.114, 0.0),\n"; - code += " vec4(0.000, 0.000, 0.000, 1.0)) +\n"; - code += " \n"; - code += " mat4( vec4(0.701, -0.587, -0.114, 0.0),\n"; - code += " vec4(-0.299, 0.413, -0.114, 0.0),\n"; - code += " vec4(-0.300, -0.588, 0.886, 0.0),\n"; - code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_c +\n"; - code += "\n"; - code += " mat4( vec4(0.168, 0.330, -0.497, 0.0),\n"; - code += " vec4(-0.328, 0.035, 0.292, 0.0),\n"; - code += " vec4(1.250, -1.050, -0.203, 0.0),\n"; - code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_s;\n"; + code += " float tex_hue_variation = 0.0;\n"; + + code += " float hue_rot_angle = (hue_variation+tex_hue_variation)*3.1416*2.0*mix(1.0,hue_rot_rand*2.0-1.0,hue_variation_random);\n"; + code += " float hue_rot_c = cos(hue_rot_angle);\n"; + code += " float hue_rot_s = sin(hue_rot_angle);\n"; + code += " mat4 hue_rot_mat = mat4( vec4(0.299, 0.587, 0.114, 0.0),\n"; + code += " vec4(0.299, 0.587, 0.114, 0.0),\n"; + code += " vec4(0.299, 0.587, 0.114, 0.0),\n"; + code += " vec4(0.000, 0.000, 0.000, 1.0)) +\n"; + code += " mat4( vec4(0.701, -0.587, -0.114, 0.0),\n"; + code += " vec4(-0.299, 0.413, -0.114, 0.0),\n"; + code += " vec4(-0.300, -0.588, 0.886, 0.0),\n"; + code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_c +\n"; + code += " mat4( vec4(0.168, 0.330, -0.497, 0.0),\n"; + code += " vec4(-0.328, 0.035, 0.292, 0.0),\n"; + code += " vec4(1.250, -1.050, -0.203, 0.0),\n"; + code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_s;\n"; if (color_ramp.is_valid()) { - code += " COLOR = textureLod(color_ramp,vec2(CUSTOM.y,0.0),0.0) * hue_rot_mat;\n"; + code += " COLOR = textureLod(color_ramp,vec2(CUSTOM.y,0.0),0.0) * hue_rot_mat;\n"; } else { - code += " COLOR = color_value * hue_rot_mat;\n"; + code += " COLOR = color_value * hue_rot_mat;\n"; } if (emission_color_texture.is_valid() && emission_shape >= EMISSION_SHAPE_POINTS) { - code += " COLOR*= texelFetch(emission_texture_color,emission_tex_ofs,0);\n"; + code += " COLOR*= texelFetch(emission_texture_color,emission_tex_ofs,0);\n"; } if (trail_color_modifier.is_valid()) { - code += "if (trail_divisor>1) { COLOR*=textureLod(trail_color_modifier,vec2(float(int(NUMBER)%trail_divisor)/float(trail_divisor-1),0.0),0.0); }\n"; + code += " if (trail_divisor > 1) { COLOR *= textureLod(trail_color_modifier,vec2(float(int(NUMBER)%trail_divisor)/float(trail_divisor-1),0.0),0.0); }\n"; } code += "\n"; if (flags[FLAG_DISABLE_Z]) { - code += " TRANSFORM[0]=vec4(cos(CUSTOM.x),-sin(CUSTOM.x),0.0,0.0);\n"; - code += " TRANSFORM[1]=vec4(sin(CUSTOM.x),cos(CUSTOM.x),0.0,0.0);\n"; - code += " TRANSFORM[2]=vec4(0.0,0.0,1.0,0.0);\n"; + code += " TRANSFORM[0] = vec4(cos(CUSTOM.x),-sin(CUSTOM.x),0.0,0.0);\n"; + code += " TRANSFORM[1] = vec4(sin(CUSTOM.x),cos(CUSTOM.x),0.0,0.0);\n"; + code += " TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);\n"; } else { //orient particle Y towards velocity if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) { - code += " if (length(VELOCITY)>0.0) {TRANSFORM[1].xyz=normalize(VELOCITY);} else {TRANSFORM[1].xyz=normalize(TRANSFORM[1].xyz);}\n"; - code += " if (TRANSFORM[1].xyz==normalize(TRANSFORM[0].xyz)) {\n"; - code += "\tTRANSFORM[0].xyz=normalize(cross(normalize(TRANSFORM[1].xyz),normalize(TRANSFORM[2].xyz)));\n"; - code += "\tTRANSFORM[2].xyz=normalize(cross(normalize(TRANSFORM[0].xyz),normalize(TRANSFORM[1].xyz)));\n"; - code += " } else {\n"; - code += "\tTRANSFORM[2].xyz=normalize(cross(normalize(TRANSFORM[0].xyz),normalize(TRANSFORM[1].xyz)));\n"; - code += "\tTRANSFORM[0].xyz=normalize(cross(normalize(TRANSFORM[1].xyz),normalize(TRANSFORM[2].xyz)));\n"; - code += " }\n"; + code += " if (length(VELOCITY) > 0.0) { TRANSFORM[1].xyz = normalize(VELOCITY); } else { TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz); }\n"; + code += " if (TRANSFORM[1].xyz == normalize(TRANSFORM[0].xyz)) {\n"; + code += " TRANSFORM[0].xyz = normalize(cross(normalize(TRANSFORM[1].xyz),normalize(TRANSFORM[2].xyz)));\n"; + code += " TRANSFORM[2].xyz = normalize(cross(normalize(TRANSFORM[0].xyz),normalize(TRANSFORM[1].xyz)));\n"; + code += " } else {\n"; + code += " TRANSFORM[2].xyz = normalize(cross(normalize(TRANSFORM[0].xyz),normalize(TRANSFORM[1].xyz)));\n"; + code += " TRANSFORM[0].xyz = normalize(cross(normalize(TRANSFORM[1].xyz),normalize(TRANSFORM[2].xyz)));\n"; + code += " }\n"; } else { - code += "\tTRANSFORM[0].xyz=normalize(TRANSFORM[0].xyz);\n"; - code += "\tTRANSFORM[1].xyz=normalize(TRANSFORM[1].xyz);\n"; - code += "\tTRANSFORM[2].xyz=normalize(TRANSFORM[2].xyz);\n"; + code += " TRANSFORM[0].xyz = normalize(TRANSFORM[0].xyz);\n"; + code += " TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz);\n"; + code += " TRANSFORM[2].xyz = normalize(TRANSFORM[2].xyz);\n"; } //turn particle by rotation in Y if (flags[FLAG_ROTATE_Y]) { - code += "\tTRANSFORM = TRANSFORM * mat4( vec4(cos(CUSTOM.x),0.0,-sin(CUSTOM.x),0.0), vec4(0.0,1.0,0.0,0.0),vec4(sin(CUSTOM.x),0.0,cos(CUSTOM.x),0.0),vec4(0.0,0.0,0.0,1.0));\n"; + code += " TRANSFORM = TRANSFORM * mat4( vec4(cos(CUSTOM.x),0.0,-sin(CUSTOM.x),0.0), vec4(0.0,1.0,0.0,0.0),vec4(sin(CUSTOM.x),0.0,cos(CUSTOM.x),0.0),vec4(0.0,0.0,0.0,1.0));\n"; } } //scale by scale - code += " float base_scale=mix(scale*tex_scale,1.0,scale_random*scale_rand);\n"; + code += " float base_scale = mix(scale*tex_scale,1.0,scale_random*scale_rand);\n"; if (trail_size_modifier.is_valid()) { - code += "if (trail_divisor>1) { base_scale*=textureLod(trail_size_modifier,vec2(float(int(NUMBER)%trail_divisor)/float(trail_divisor-1),0.0),0.0).r; } \n"; + code += " if (trail_divisor > 1) { base_scale *= textureLod(trail_size_modifier,vec2(float(int(NUMBER)%trail_divisor)/float(trail_divisor-1),0.0),0.0).r; } \n"; } - code += " TRANSFORM[0].xyz*=base_scale;\n"; - code += " TRANSFORM[1].xyz*=base_scale;\n"; - code += " TRANSFORM[2].xyz*=base_scale;\n"; + code += " TRANSFORM[0].xyz *= base_scale;\n"; + code += " TRANSFORM[1].xyz *= base_scale;\n"; + code += " TRANSFORM[2].xyz *= base_scale;\n"; if (flags[FLAG_DISABLE_Z]) { - code += " VELOCITY.z=0.0;\n"; - code += " TRANSFORM[3].z=0.0;\n"; + code += " VELOCITY.z = 0.0;\n"; + code += " TRANSFORM[3].z = 0.0;\n"; } code += "}\n"; code += "\n"; @@ -1325,6 +1321,12 @@ Vector3 ParticlesMaterial::get_gravity() const { return gravity; } +RID ParticlesMaterial::get_shader_rid() const { + + ERR_FAIL_COND_V(!shader_map.has(current_key), RID()); + return shader_map[current_key].shader; +} + void ParticlesMaterial::_validate_property(PropertyInfo &property) const { if (property.name == "color" && color_ramp.is_valid()) { diff --git a/scene/3d/particles.h b/scene/3d/particles.h index 2c109d6ec8..e3109f470f 100644 --- a/scene/3d/particles.h +++ b/scene/3d/particles.h @@ -388,6 +388,8 @@ public: static void finish_shaders(); static void flush_changes(); + RID get_shader_rid() const; + ParticlesMaterial(); ~ParticlesMaterial(); }; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index c4cfce5d72..2ecb184733 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -405,6 +405,10 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float if (a->value_track_get_update_mode(i) == Animation::UPDATE_CONTINUOUS || (p_delta == 0 && a->value_track_get_update_mode(i) == Animation::UPDATE_DISCRETE)) { //delta == 0 means seek Variant value = a->value_track_interpolate(i, p_time); + + if (value == Variant()) + continue; + //thanks to trigger mode, this should be solved now.. /* if (p_delta==0 && value.get_type()==Variant::STRING) diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index a034c7224f..623a110263 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -489,7 +489,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (mb->get_button_index() == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, pos); + emit_signal("item_rmb_selected", i, get_local_mouse_position()); } } else { @@ -500,7 +500,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (items[i].selected && mb->get_button_index() == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, pos); + emit_signal("item_rmb_selected", i, get_local_mouse_position()); } else { bool selected = !items[i].selected; @@ -515,7 +515,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (mb->get_button_index() == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, pos); + emit_signal("item_rmb_selected", i, get_local_mouse_position()); } else if (/*select_mode==SELECT_SINGLE &&*/ mb->is_doubleclick()) { emit_signal("item_activated", i); diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index 116e0ac354..e88742a3e3 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -157,6 +157,12 @@ void Slider::_notification(int p_what) { mouse_inside = false; update(); } break; + case NOTIFICATION_VISIBILITY_CHANGED: // fallthrough + case NOTIFICATION_EXIT_TREE: { + + mouse_inside = false; + grab.active = false; + } break; case NOTIFICATION_DRAW: { RID ci = get_canvas_item(); Size2i size = get_size(); diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 6e50614e8f..cfe924ecd4 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -94,15 +94,20 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { // Handle navigation buttons. if (buttons_visible_cache) { + int popup_ofs = 0; + if (popup) { + popup_ofs = menu->get_width(); + } + Ref<Texture> increment = get_icon("increment"); Ref<Texture> decrement = get_icon("decrement"); - if (pos.x > size.width - increment->get_width()) { + if (pos.x > size.width - increment->get_width() - popup_ofs) { if (last_tab_cache < tabs.size() - 1) { first_tab_cache += 1; update(); } return; - } else if (pos.x > size.width - increment->get_width() - decrement->get_width()) { + } else if (pos.x > size.width - increment->get_width() - decrement->get_width() - popup_ofs) { if (first_tab_cache > 0) { first_tab_cache -= 1; update(); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index c2a31b4a8b..cee25b53a1 100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -212,6 +212,8 @@ void Node::_propagate_enter_tree() { emit_signal(SceneStringNames::get_singleton()->tree_entered); + data.tree->node_added(this); + data.blocked++; //block while adding children diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 7a28e2a6f8..d4be683a2b 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -85,6 +85,11 @@ void SceneTree::tree_changed() { emit_signal(tree_changed_name); } +void SceneTree::node_added(Node *p_node) { + + emit_signal(node_added_name, p_node); +} + void SceneTree::node_removed(Node *p_node) { if (current_scene == p_node) { @@ -1172,7 +1177,7 @@ void SceneTree::_update_root_rect() { } } -void SceneTree::set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize, int p_shrink) { +void SceneTree::set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize, real_t p_shrink) { stretch_mode = p_mode; stretch_aspect = p_aspect; @@ -2189,6 +2194,7 @@ void SceneTree::_bind_methods() { ClassDB::bind_method(D_METHOD("_server_disconnected"), &SceneTree::_server_disconnected); ADD_SIGNAL(MethodInfo("tree_changed")); + ADD_SIGNAL(MethodInfo("node_added", PropertyInfo(Variant::OBJECT, "node"))); ADD_SIGNAL(MethodInfo("node_removed", PropertyInfo(Variant::OBJECT, "node"))); ADD_SIGNAL(MethodInfo("screen_resized")); ADD_SIGNAL(MethodInfo("node_configuration_warning_changed", PropertyInfo(Variant::OBJECT, "node"))); @@ -2260,6 +2266,7 @@ SceneTree::SceneTree() { root = NULL; current_frame = 0; tree_changed_name = "tree_changed"; + node_added_name = "node_added"; node_removed_name = "node_removed"; ugc_locked = false; call_lock = 0; diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index f3e689adab..bc3efdc42f 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -124,6 +124,7 @@ private: bool input_handled; Size2 last_screen_size; StringName tree_changed_name; + StringName node_added_name; StringName node_removed_name; int64_t current_frame; @@ -147,7 +148,7 @@ private: StretchMode stretch_mode; StretchAspect stretch_aspect; Size2i stretch_min; - int stretch_shrink; + real_t stretch_shrink; void _update_root_rect(); @@ -233,6 +234,7 @@ private: void _rpc(Node *p_from, int p_to, bool p_unreliable, bool p_set, const StringName &p_name, const Variant **p_arg, int p_argcount); void tree_changed(); + void node_added(Node *p_node); void node_removed(Node *p_node); Group *add_to_group(const StringName &p_group, Node *p_node); @@ -415,7 +417,7 @@ public: void get_nodes_in_group(const StringName &p_group, List<Node *> *p_list); bool has_group(const StringName &p_identifier) const; - void set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize, int p_shrink = 1); + void set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize, real_t p_shrink = 1); //void change_scene(const String& p_path); //Node *get_loaded_scene(); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 37a393b55b..0a02f471c1 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2371,8 +2371,13 @@ void Viewport::input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(!is_inside_tree()); - get_tree()->_call_input_pause(input_group, "_input", p_event); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input - _gui_input_event(p_event); + if (!get_tree()->is_input_handled()) { + get_tree()->_call_input_pause(input_group, "_input", p_event); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input + } + + if (!get_tree()->is_input_handled()) { + _gui_input_event(p_event); + } //get_tree()->call_group(SceneTree::GROUP_CALL_REVERSE|SceneTree::GROUP_CALL_REALTIME|SceneTree::GROUP_CALL_MULIILEVEL,gui_input_group,"_gui_input",p_event); //special one for GUI, as controls use their own process check } @@ -2711,7 +2716,7 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "debug_draw", PROPERTY_HINT_ENUM, "Disabled,Unshaded,Overdraw,Wireframe"), "set_debug_draw", "get_debug_draw"); ADD_GROUP("Render Target", "render_target_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_target_v_flip"), "set_vflip", "get_vflip"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_target_clear_mode", PROPERTY_HINT_ENUM, "Always,Never,NextFrame"), "set_clear_mode", "get_clear_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_clear_mode", PROPERTY_HINT_ENUM, "Always,Never,Next Frame"), "set_clear_mode", "get_clear_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_update_mode", PROPERTY_HINT_ENUM, "Disabled,Once,When Visible,Always"), "set_update_mode", "get_update_mode"); ADD_GROUP("Audio Listener", "audio_listener_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_listener_enable_2d"), "set_as_audio_listener_2d", "is_audio_listener_2d"); diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 8dcc8d4e14..21e4a85cd1 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1171,9 +1171,7 @@ T Animation::_interpolate(const Vector<TKey<T> > &p_keys, float p_time, Interpol ERR_FAIL_COND_V(idx == -2, T()); - if (p_ok) - *p_ok = true; - + bool result = true; int next = 0; float c = 0; // prepare for all cases of interpolation @@ -1243,10 +1241,19 @@ T Animation::_interpolate(const Vector<TKey<T> > &p_keys, float p_time, Interpol } else if (idx < 0) { - idx = next = 0; + // only allow extending first key to anim start if looping + if (loop) + idx = next = 0; + else + result = false; } } + if (p_ok) + *p_ok = result; + if (!result) + return T(); + float tr = p_keys[idx].transition; if (tr == 0 || idx == next) { @@ -1298,7 +1305,7 @@ Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3 TransformKey tk = _interpolate(tt->transforms, p_time, tt->interpolation, tt->loop_wrap, &ok); - if (!ok) // ?? + if (!ok) return ERR_UNAVAILABLE; if (r_loc) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 979b2ed8ec..64bc978037 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -62,6 +62,31 @@ RID VisualServer::texture_create_from_image(const Ref<Image> &p_image, uint32_t return texture; } +Array VisualServer::_texture_debug_usage_bind() { + + List<TextureInfo> list; + texture_debug_usage(&list); + Array arr; + for (const List<TextureInfo>::Element *E = list.front(); E; E = E->next()) { + + Dictionary dict; + dict["texture"] = E->get().texture; + dict["size"] = E->get().size; + dict["format"] = E->get().format; + dict["bytes"] = E->get().bytes; + dict["path"] = E->get().path; + arr.push_back(dict); + } + return arr; +} + +Array VisualServer::_shader_get_param_list_bind(RID p_shader) const { + + List<PropertyInfo> l; + shader_get_param_list(p_shader, &l); + return convert_property_list(&l); +} + RID VisualServer::get_test_texture() { if (test_texture.is_valid()) { @@ -1443,22 +1468,395 @@ Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surfac } } +Array VisualServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const { + + Vector<Rect3> vec = VS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface); + Array arr; + for (int i = 0; i < vec.size(); i++) { + arr[i] = vec[i]; + } + return arr; +} + void VisualServer::_bind_methods() { ClassDB::bind_method(D_METHOD("force_sync"), &VisualServer::sync); ClassDB::bind_method(D_METHOD("force_draw"), &VisualServer::draw); - ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "where", "method", "userdata"), &VisualServer::request_frame_drawn_callback); + ClassDB::bind_method(D_METHOD("texture_create"), &VisualServer::texture_create); ClassDB::bind_method(D_METHOD("texture_create_from_image", "image", "flags"), &VisualServer::texture_create_from_image, DEFVAL(TEXTURE_FLAGS_DEFAULT)); - //ClassDB::bind_method(D_METHOD("texture_allocate"),&VisualServer::texture_allocate,DEFVAL( TEXTURE_FLAGS_DEFAULT ) ); - //ClassDB::bind_method(D_METHOD("texture_set_data"),&VisualServer::texture_blit_rect,DEFVAL( CUBEMAP_LEFT ) ); - //ClassDB::bind_method(D_METHOD("texture_get_rect"),&VisualServer::texture_get_rect ); + ClassDB::bind_method(D_METHOD("texture_allocate", "texture", "width", "height", "format", "flags"), &VisualServer::texture_allocate, DEFVAL(TEXTURE_FLAGS_DEFAULT)); + ClassDB::bind_method(D_METHOD("texture_set_data", "texture", "image", "cube_side"), &VisualServer::texture_set_data, DEFVAL(CUBEMAP_LEFT)); + ClassDB::bind_method(D_METHOD("texture_get_data", "texture", "cube_side"), &VisualServer::texture_get_data, DEFVAL(CUBEMAP_LEFT)); ClassDB::bind_method(D_METHOD("texture_set_flags", "texture", "flags"), &VisualServer::texture_set_flags); ClassDB::bind_method(D_METHOD("texture_get_flags", "texture"), &VisualServer::texture_get_flags); + ClassDB::bind_method(D_METHOD("texture_get_format", "texture"), &VisualServer::texture_get_format); + ClassDB::bind_method(D_METHOD("texture_get_texid", "texture"), &VisualServer::texture_get_texid); ClassDB::bind_method(D_METHOD("texture_get_width", "texture"), &VisualServer::texture_get_width); ClassDB::bind_method(D_METHOD("texture_get_height", "texture"), &VisualServer::texture_get_height); - + ClassDB::bind_method(D_METHOD("texture_set_size_override", "texture", "width", "height"), &VisualServer::texture_set_size_override); + ClassDB::bind_method(D_METHOD("texture_set_path", "texture", "path"), &VisualServer::texture_set_path); + ClassDB::bind_method(D_METHOD("texture_get_path", "texture"), &VisualServer::texture_get_path); ClassDB::bind_method(D_METHOD("texture_set_shrink_all_x2_on_set_data", "shrink"), &VisualServer::texture_set_shrink_all_x2_on_set_data); + + ClassDB::bind_method(D_METHOD("texture_debug_usage"), &VisualServer::_texture_debug_usage_bind); + ClassDB::bind_method(D_METHOD("textures_keep_original", "enable"), &VisualServer::textures_keep_original); + + ClassDB::bind_method(D_METHOD("sky_create"), &VisualServer::sky_create); + ClassDB::bind_method(D_METHOD("sky_set_texture", "sky", "cube_map", "radiance_size"), &VisualServer::sky_set_texture); + + ClassDB::bind_method(D_METHOD("shader_create"), &VisualServer::shader_create); + ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &VisualServer::shader_set_code); + ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &VisualServer::shader_get_code); + ClassDB::bind_method(D_METHOD("shader_get_param_list", "shader"), &VisualServer::_shader_get_param_list_bind); + ClassDB::bind_method(D_METHOD("shader_set_default_texture_param", "shader", "name", "texture"), &VisualServer::shader_set_default_texture_param); + ClassDB::bind_method(D_METHOD("shader_get_default_texture_param", "shader", "name"), &VisualServer::shader_get_default_texture_param); + + ClassDB::bind_method(D_METHOD("material_create"), &VisualServer::material_create); + ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &VisualServer::material_set_shader); + ClassDB::bind_method(D_METHOD("material_get_shader", "shader_material"), &VisualServer::material_get_shader); + ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &VisualServer::material_set_param); + ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &VisualServer::material_get_param); + ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &VisualServer::material_set_render_priority); + ClassDB::bind_method(D_METHOD("material_set_line_width", "material", "width"), &VisualServer::material_set_line_width); + ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &VisualServer::material_set_next_pass); + + ClassDB::bind_method(D_METHOD("mesh_create"), &VisualServer::mesh_create); + ClassDB::bind_method(D_METHOD("mesh_add_surface_from_arrays", "mesh", "primtive", "arrays", "blend_shapes", "compress_format"), &VisualServer::mesh_add_surface_from_arrays, DEFVAL(Array()), DEFVAL(ARRAY_COMPRESS_DEFAULT)); + ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_count", "mesh", "amount"), &VisualServer::mesh_set_blend_shape_count); + ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &VisualServer::mesh_get_blend_shape_count); + ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &VisualServer::mesh_set_blend_shape_mode); + ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &VisualServer::mesh_get_blend_shape_mode); + ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &VisualServer::mesh_surface_set_material); + ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &VisualServer::mesh_surface_get_material); + ClassDB::bind_method(D_METHOD("mesh_surface_get_array_len", "mesh", "surface"), &VisualServer::mesh_surface_get_array_len); + ClassDB::bind_method(D_METHOD("mesh_surface_get_array_index_len", "mesh", "surface"), &VisualServer::mesh_surface_get_array_index_len); + ClassDB::bind_method(D_METHOD("mesh_surface_get_array", "mesh", "surface"), &VisualServer::mesh_surface_get_array); + ClassDB::bind_method(D_METHOD("mesh_surface_get_index_array", "mesh", "surface"), &VisualServer::mesh_surface_get_index_array); + ClassDB::bind_method(D_METHOD("mesh_surface_get_arrays", "mesh", "surface"), &VisualServer::mesh_surface_get_arrays); + ClassDB::bind_method(D_METHOD("mesh_surface_get_blend_shape_arrays", "mesh", "surface"), &VisualServer::mesh_surface_get_blend_shape_arrays); + ClassDB::bind_method(D_METHOD("mesh_surface_get_format", "mesh", "surface"), &VisualServer::mesh_surface_get_format); + ClassDB::bind_method(D_METHOD("mesh_surface_get_primitive_type", "mesh", "surface"), &VisualServer::mesh_surface_get_primitive_type); + ClassDB::bind_method(D_METHOD("mesh_surface_get_aabb", "mesh", "surface"), &VisualServer::mesh_surface_get_aabb); + ClassDB::bind_method(D_METHOD("mesh_surface_get_skeleton_aabb", "mesh", "surface"), &VisualServer::_mesh_surface_get_skeleton_aabb_bind); + ClassDB::bind_method(D_METHOD("mesh_remove_surface", "mesh", "index"), &VisualServer::mesh_remove_surface); + ClassDB::bind_method(D_METHOD("mesh_get_surface_count", "mesh"), &VisualServer::mesh_get_surface_count); + ClassDB::bind_method(D_METHOD("mesh_set_custom_aabb", "mesh", "aabb"), &VisualServer::mesh_set_custom_aabb); + ClassDB::bind_method(D_METHOD("mesh_get_custom_aabb", "mesh"), &VisualServer::mesh_get_custom_aabb); + ClassDB::bind_method(D_METHOD("mesh_clear", "mesh"), &VisualServer::mesh_clear); + + // TODO: multimesh_*, immediate_*, skeleton_*, light_*, reflection_probe_*, gi_probe_*, particles_*, camera_* + + ClassDB::bind_method(D_METHOD("viewport_create"), &VisualServer::viewport_create); + ClassDB::bind_method(D_METHOD("viewport_set_use_arvr", "viewport", "use_arvr"), &VisualServer::viewport_set_use_arvr); + ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &VisualServer::viewport_set_size); + ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &VisualServer::viewport_set_active); + ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &VisualServer::viewport_set_parent_viewport); + ClassDB::bind_method(D_METHOD("viewport_attach_to_screen", "viewport", "rect", "screen"), &VisualServer::viewport_attach_to_screen, DEFVAL(Rect2()), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("viewport_detach", "viewport"), &VisualServer::viewport_detach); + ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &VisualServer::viewport_set_update_mode); + ClassDB::bind_method(D_METHOD("viewport_set_vflip", "viewport", "enabled"), &VisualServer::viewport_set_vflip); + ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &VisualServer::viewport_set_clear_mode); + ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &VisualServer::viewport_get_texture); + ClassDB::bind_method(D_METHOD("viewport_set_hide_scenario", "viewport", "hidden"), &VisualServer::viewport_set_hide_scenario); + ClassDB::bind_method(D_METHOD("viewport_set_hide_canvas", "viewport", "hidden"), &VisualServer::viewport_set_hide_canvas); + ClassDB::bind_method(D_METHOD("viewport_set_disable_environment", "viewport", "disabled"), &VisualServer::viewport_set_disable_environment); + ClassDB::bind_method(D_METHOD("viewport_set_disable_3d", "viewport", "disabled"), &VisualServer::viewport_set_disable_3d); + ClassDB::bind_method(D_METHOD("viewport_attach_camera", "viewport", "camera"), &VisualServer::viewport_attach_camera); + ClassDB::bind_method(D_METHOD("viewport_set_scenario", "viewport", "scenario"), &VisualServer::viewport_set_scenario); + ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &VisualServer::viewport_attach_canvas); + ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &VisualServer::viewport_remove_canvas); + ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &VisualServer::viewport_set_canvas_transform); + ClassDB::bind_method(D_METHOD("viewport_set_transparent_background", "viewport", "enabled"), &VisualServer::viewport_set_transparent_background); + ClassDB::bind_method(D_METHOD("viewport_set_global_canvas_transform", "viewport", "transform"), &VisualServer::viewport_set_global_canvas_transform); + ClassDB::bind_method(D_METHOD("viewport_set_canvas_layer", "viewport", "canvas", "layer"), &VisualServer::viewport_set_canvas_layer); + ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_size", "viewport", "size"), &VisualServer::viewport_set_shadow_atlas_size); + ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &VisualServer::viewport_set_shadow_atlas_quadrant_subdivision); + ClassDB::bind_method(D_METHOD("viewport_set_msaa", "viewport", "msaa"), &VisualServer::viewport_set_msaa); + ClassDB::bind_method(D_METHOD("viewport_set_hdr", "viewport", "enabled"), &VisualServer::viewport_set_hdr); + ClassDB::bind_method(D_METHOD("viewport_set_usage", "viewport", "usage"), &VisualServer::viewport_set_usage); + ClassDB::bind_method(D_METHOD("viewport_get_render_info", "viewport", "info"), &VisualServer::viewport_get_render_info); + ClassDB::bind_method(D_METHOD("viewport_set_debug_draw", "viewport", "draw"), &VisualServer::viewport_set_debug_draw); + + // TODO: environment_*, scenario_*, instance_* + + ClassDB::bind_method(D_METHOD("canvas_create"), &VisualServer::canvas_create); + ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &VisualServer::canvas_set_item_mirroring); + ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &VisualServer::canvas_set_modulate); + + ClassDB::bind_method(D_METHOD("canvas_item_create"), &VisualServer::canvas_item_create); + ClassDB::bind_method(D_METHOD("canvas_item_set_parent", "item", "parent"), &VisualServer::canvas_item_set_parent); + ClassDB::bind_method(D_METHOD("canvas_item_set_visible", "item", "visible"), &VisualServer::canvas_item_set_visible); + ClassDB::bind_method(D_METHOD("canvas_item_set_light_mask", "item", "mask"), &VisualServer::canvas_item_set_light_mask); + ClassDB::bind_method(D_METHOD("canvas_item_set_transform", "item", "transform"), &VisualServer::canvas_item_set_transform); + ClassDB::bind_method(D_METHOD("canvas_item_set_clip", "item", "clip"), &VisualServer::canvas_item_set_clip); + ClassDB::bind_method(D_METHOD("canvas_item_set_distance_field_mode", "item", "enabled"), &VisualServer::canvas_item_set_distance_field_mode); + ClassDB::bind_method(D_METHOD("canvas_item_set_custom_rect", "item", "use_custom_rect", "rect"), &VisualServer::canvas_item_set_custom_rect, DEFVAL(Rect2())); + ClassDB::bind_method(D_METHOD("canvas_item_set_modulate", "item", "color"), &VisualServer::canvas_item_set_modulate); + ClassDB::bind_method(D_METHOD("canvas_item_set_self_modulate", "item", "color"), &VisualServer::canvas_item_set_self_modulate); + ClassDB::bind_method(D_METHOD("canvas_item_set_draw_behind_parent", "item", "enabled"), &VisualServer::canvas_item_set_draw_behind_parent); + ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width", "antialiased"), &VisualServer::canvas_item_add_line, DEFVAL(1.0), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &VisualServer::canvas_item_add_polyline, DEFVAL(1.0), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color"), &VisualServer::canvas_item_add_rect); + ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color"), &VisualServer::canvas_item_add_circle); + ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect", "item", "rect", "texture", "tile", "modulate", "transpose", "normal_map"), &VisualServer::canvas_item_add_texture_rect, DEFVAL(false), DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &VisualServer::canvas_item_add_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID()), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("canvas_item_add_nine_patch", "item", "rect", "source", "texture", "topleft", "bottomright", "x_axis_mode", "y_axis_mode", "draw_center", "modulate", "normal_map"), &VisualServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)), DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width", "normal_map"), &VisualServer::canvas_item_add_primitive, DEFVAL(1.0), DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &VisualServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(RID()), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "texture", "count", "normal_map"), &VisualServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "skeleton"), &VisualServer::canvas_item_add_mesh, DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "skeleton"), &VisualServer::canvas_item_add_multimesh, DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture", "normal_map", "h_frames", "v_frames"), &VisualServer::canvas_item_add_particles); + ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &VisualServer::canvas_item_add_set_transform); + ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &VisualServer::canvas_item_add_clip_ignore); + ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &VisualServer::canvas_item_set_sort_children_by_y); + ClassDB::bind_method(D_METHOD("canvas_item_set_z", "item", "z"), &VisualServer::canvas_item_set_z); + ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &VisualServer::canvas_item_set_z_as_relative_to_parent); + ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &VisualServer::canvas_item_set_copy_to_backbuffer); + ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &VisualServer::canvas_item_clear); + ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &VisualServer::canvas_item_set_draw_index); + ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &VisualServer::canvas_item_set_material); + ClassDB::bind_method(D_METHOD("canvas_item_set_use_parent_material", "item", "enabled"), &VisualServer::canvas_item_set_use_parent_material); + ClassDB::bind_method(D_METHOD("canvas_light_create"), &VisualServer::canvas_light_create); + ClassDB::bind_method(D_METHOD("canvas_light_attach_to_canvas", "light", "canvas"), &VisualServer::canvas_light_attach_to_canvas); + ClassDB::bind_method(D_METHOD("canvas_light_set_enabled", "light", "enabled"), &VisualServer::canvas_light_set_enabled); + ClassDB::bind_method(D_METHOD("canvas_light_set_scale", "light", "scale"), &VisualServer::canvas_light_set_scale); + ClassDB::bind_method(D_METHOD("canvas_light_set_transform", "light", "transform"), &VisualServer::canvas_light_set_transform); + ClassDB::bind_method(D_METHOD("canvas_light_set_texture", "light", "texture"), &VisualServer::canvas_light_set_texture); + ClassDB::bind_method(D_METHOD("canvas_light_set_texture_offset", "light", "offset"), &VisualServer::canvas_light_set_texture_offset); + ClassDB::bind_method(D_METHOD("canvas_light_set_color", "light", "color"), &VisualServer::canvas_light_set_color); + ClassDB::bind_method(D_METHOD("canvas_light_set_height", "light", "height"), &VisualServer::canvas_light_set_height); + ClassDB::bind_method(D_METHOD("canvas_light_set_energy", "light", "energy"), &VisualServer::canvas_light_set_energy); + ClassDB::bind_method(D_METHOD("canvas_light_set_z_range", "light", "min_z", "max_z"), &VisualServer::canvas_light_set_z_range); + ClassDB::bind_method(D_METHOD("canvas_light_set_layer_range", "light", "min_layer", "max_layer"), &VisualServer::canvas_light_set_layer_range); + ClassDB::bind_method(D_METHOD("canvas_light_set_item_cull_mask", "light", "mask"), &VisualServer::canvas_light_set_item_cull_mask); + ClassDB::bind_method(D_METHOD("canvas_light_set_item_shadow_cull_mask", "light", "mask"), &VisualServer::canvas_light_set_item_shadow_cull_mask); + ClassDB::bind_method(D_METHOD("canvas_light_set_mode", "light", "mode"), &VisualServer::canvas_light_set_mode); + ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_enabled", "light", "enabled"), &VisualServer::canvas_light_set_shadow_enabled); + ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_buffer_size", "light", "size"), &VisualServer::canvas_light_set_shadow_buffer_size); + ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_gradient_length", "light", "length"), &VisualServer::canvas_light_set_shadow_gradient_length); + ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &VisualServer::canvas_light_set_shadow_filter); + ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &VisualServer::canvas_light_set_shadow_color); + ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &VisualServer::canvas_light_set_shadow_smooth); + + ClassDB::bind_method(D_METHOD("canvas_light_occluder_create"), &VisualServer::canvas_light_occluder_create); + ClassDB::bind_method(D_METHOD("canvas_light_occluder_attach_to_canvas", "occluder", "canvas"), &VisualServer::canvas_light_occluder_attach_to_canvas); + ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_enabled", "occluder", "enabled"), &VisualServer::canvas_light_occluder_set_enabled); + ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_polygon", "occluder", "polygon"), &VisualServer::canvas_light_occluder_set_polygon); + ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_transform", "occluder", "transform"), &VisualServer::canvas_light_occluder_set_transform); + ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_light_mask", "occluder", "mask"), &VisualServer::canvas_light_occluder_set_light_mask); + + ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_create"), &VisualServer::canvas_occluder_polygon_create); + ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape", "occluder_polygon", "shape", "closed"), &VisualServer::canvas_occluder_polygon_set_shape); + ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape_as_lines", "occluder_polygon", "shape"), &VisualServer::canvas_occluder_polygon_set_shape_as_lines); + ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_cull_mode", "occluder_polygon", "mode"), &VisualServer::canvas_occluder_polygon_set_cull_mode); + + ClassDB::bind_method(D_METHOD("black_bars_set_margins", "left", "top", "right", "bottom"), &VisualServer::black_bars_set_margins); + ClassDB::bind_method(D_METHOD("black_bars_set_images", "left", "top", "right", "bottom"), &VisualServer::black_bars_set_images); + + ClassDB::bind_method(D_METHOD("free", "rid"), &VisualServer::free); + + ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "where", "method", "userdata"), &VisualServer::request_frame_drawn_callback); + ClassDB::bind_method(D_METHOD("draw"), &VisualServer::draw); + ClassDB::bind_method(D_METHOD("sync"), &VisualServer::sync); + ClassDB::bind_method(D_METHOD("has_changed"), &VisualServer::has_changed); + ClassDB::bind_method(D_METHOD("init"), &VisualServer::init); + ClassDB::bind_method(D_METHOD("finish"), &VisualServer::finish); + ClassDB::bind_method(D_METHOD("get_render_info", "info"), &VisualServer::get_render_info); + + ClassDB::bind_method(D_METHOD("get_test_cube"), &VisualServer::get_test_cube); + ClassDB::bind_method(D_METHOD("get_test_texture"), &VisualServer::get_test_texture); + ClassDB::bind_method(D_METHOD("get_white_texture"), &VisualServer::get_white_texture); + + ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &VisualServer::make_sphere_mesh); + + ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale"), &VisualServer::set_boot_image); + ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &VisualServer::set_default_clear_color); + + ClassDB::bind_method(D_METHOD("has_feature", "feature"), &VisualServer::has_feature); + ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &VisualServer::has_os_feature); + ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &VisualServer::set_debug_generate_wireframes); + + BIND_CONSTANT(NO_INDEX_ARRAY); + BIND_CONSTANT(ARRAY_WEIGHTS_SIZE); + BIND_CONSTANT(CANVAS_ITEM_Z_MIN); + BIND_CONSTANT(CANVAS_ITEM_Z_MAX); + BIND_CONSTANT(MAX_GLOW_LEVELS); + BIND_CONSTANT(MAX_CURSORS); + BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MIN); + BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MAX); + + BIND_ENUM_CONSTANT(CUBEMAP_LEFT); + BIND_ENUM_CONSTANT(CUBEMAP_RIGHT); + BIND_ENUM_CONSTANT(CUBEMAP_BOTTOM); + BIND_ENUM_CONSTANT(CUBEMAP_TOP); + BIND_ENUM_CONSTANT(CUBEMAP_FRONT); + BIND_ENUM_CONSTANT(CUBEMAP_BACK); + + BIND_ENUM_CONSTANT(TEXTURE_FLAG_MIPMAPS); + BIND_ENUM_CONSTANT(TEXTURE_FLAG_REPEAT); + BIND_ENUM_CONSTANT(TEXTURE_FLAG_FILTER); + BIND_ENUM_CONSTANT(TEXTURE_FLAG_ANISOTROPIC_FILTER); + BIND_ENUM_CONSTANT(TEXTURE_FLAG_CONVERT_TO_LINEAR); + BIND_ENUM_CONSTANT(TEXTURE_FLAG_MIRRORED_REPEAT); + BIND_ENUM_CONSTANT(TEXTURE_FLAG_CUBEMAP); + BIND_ENUM_CONSTANT(TEXTURE_FLAG_USED_FOR_STREAMING); + BIND_ENUM_CONSTANT(TEXTURE_FLAGS_DEFAULT); + + BIND_ENUM_CONSTANT(SHADER_SPATIAL); + BIND_ENUM_CONSTANT(SHADER_CANVAS_ITEM); + BIND_ENUM_CONSTANT(SHADER_PARTICLES); + BIND_ENUM_CONSTANT(SHADER_MAX); + + BIND_ENUM_CONSTANT(ARRAY_VERTEX); + BIND_ENUM_CONSTANT(ARRAY_NORMAL); + BIND_ENUM_CONSTANT(ARRAY_TANGENT); + BIND_ENUM_CONSTANT(ARRAY_COLOR); + BIND_ENUM_CONSTANT(ARRAY_TEX_UV); + BIND_ENUM_CONSTANT(ARRAY_TEX_UV2); + BIND_ENUM_CONSTANT(ARRAY_BONES); + BIND_ENUM_CONSTANT(ARRAY_WEIGHTS); + BIND_ENUM_CONSTANT(ARRAY_INDEX); + BIND_ENUM_CONSTANT(ARRAY_MAX); + + BIND_ENUM_CONSTANT(ARRAY_FORMAT_VERTEX); + BIND_ENUM_CONSTANT(ARRAY_FORMAT_NORMAL); + BIND_ENUM_CONSTANT(ARRAY_FORMAT_TANGENT); + BIND_ENUM_CONSTANT(ARRAY_FORMAT_COLOR); + BIND_ENUM_CONSTANT(ARRAY_FORMAT_TEX_UV); + BIND_ENUM_CONSTANT(ARRAY_FORMAT_TEX_UV2); + BIND_ENUM_CONSTANT(ARRAY_FORMAT_BONES); + BIND_ENUM_CONSTANT(ARRAY_FORMAT_WEIGHTS); + BIND_ENUM_CONSTANT(ARRAY_FORMAT_INDEX); + BIND_ENUM_CONSTANT(ARRAY_COMPRESS_BASE); + BIND_ENUM_CONSTANT(ARRAY_COMPRESS_VERTEX); + BIND_ENUM_CONSTANT(ARRAY_COMPRESS_NORMAL); + BIND_ENUM_CONSTANT(ARRAY_COMPRESS_TANGENT); + BIND_ENUM_CONSTANT(ARRAY_COMPRESS_COLOR); + BIND_ENUM_CONSTANT(ARRAY_COMPRESS_TEX_UV); + BIND_ENUM_CONSTANT(ARRAY_COMPRESS_TEX_UV2); + BIND_ENUM_CONSTANT(ARRAY_COMPRESS_BONES); + BIND_ENUM_CONSTANT(ARRAY_COMPRESS_WEIGHTS); + BIND_ENUM_CONSTANT(ARRAY_COMPRESS_INDEX); + BIND_ENUM_CONSTANT(ARRAY_FLAG_USE_2D_VERTICES); + BIND_ENUM_CONSTANT(ARRAY_FLAG_USE_16_BIT_BONES); + BIND_ENUM_CONSTANT(ARRAY_COMPRESS_DEFAULT); + + BIND_ENUM_CONSTANT(PRIMITIVE_POINTS); + BIND_ENUM_CONSTANT(PRIMITIVE_LINES); + BIND_ENUM_CONSTANT(PRIMITIVE_LINE_STRIP); + BIND_ENUM_CONSTANT(PRIMITIVE_LINE_LOOP); + BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLES); + BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_STRIP); + BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_FAN); + BIND_ENUM_CONSTANT(PRIMITIVE_MAX); + + BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_NORMALIZED); + BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_RELATIVE); + + BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL); + BIND_ENUM_CONSTANT(LIGHT_OMNI); + BIND_ENUM_CONSTANT(LIGHT_SPOT); + + BIND_ENUM_CONSTANT(LIGHT_PARAM_ENERGY); + BIND_ENUM_CONSTANT(LIGHT_PARAM_SPECULAR); + BIND_ENUM_CONSTANT(LIGHT_PARAM_RANGE); + BIND_ENUM_CONSTANT(LIGHT_PARAM_ATTENUATION); + BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ANGLE); + BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ATTENUATION); + BIND_ENUM_CONSTANT(LIGHT_PARAM_CONTACT_SHADOW_SIZE); + BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_MAX_DISTANCE); + BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET); + BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET); + BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET); + BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_NORMAL_BIAS); + BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BIAS); + BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE); + BIND_ENUM_CONSTANT(LIGHT_PARAM_MAX); + + BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_DISABLED); + BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ONCE); + BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_VISIBLE); + BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ALWAYS); + + BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ALWAYS); + BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_NEVER); + BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ONLY_NEXT_FRAME); + + BIND_ENUM_CONSTANT(VIEWPORT_MSAA_DISABLED); + BIND_ENUM_CONSTANT(VIEWPORT_MSAA_2X); + BIND_ENUM_CONSTANT(VIEWPORT_MSAA_4X); + BIND_ENUM_CONSTANT(VIEWPORT_MSAA_8X); + BIND_ENUM_CONSTANT(VIEWPORT_MSAA_16X); + + BIND_ENUM_CONSTANT(VIEWPORT_USAGE_2D); + BIND_ENUM_CONSTANT(VIEWPORT_USAGE_2D_NO_SAMPLING); + BIND_ENUM_CONSTANT(VIEWPORT_USAGE_3D); + BIND_ENUM_CONSTANT(VIEWPORT_USAGE_3D_NO_EFFECTS); + + BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME); + BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME); + BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME); + BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME); + BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME); + BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME); + BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_MAX); + + BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLED); + BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_UNSHADED); + BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OVERDRAW); + BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_WIREFRAME); + + BIND_ENUM_CONSTANT(SCENARIO_DEBUG_DISABLED); + BIND_ENUM_CONSTANT(SCENARIO_DEBUG_WIREFRAME); + BIND_ENUM_CONSTANT(SCENARIO_DEBUG_OVERDRAW); + BIND_ENUM_CONSTANT(SCENARIO_DEBUG_SHADELESS); + + BIND_ENUM_CONSTANT(INSTANCE_NONE); + BIND_ENUM_CONSTANT(INSTANCE_MESH); + BIND_ENUM_CONSTANT(INSTANCE_MULTIMESH); + BIND_ENUM_CONSTANT(INSTANCE_IMMEDIATE); + BIND_ENUM_CONSTANT(INSTANCE_PARTICLES); + BIND_ENUM_CONSTANT(INSTANCE_LIGHT); + BIND_ENUM_CONSTANT(INSTANCE_REFLECTION_PROBE); + BIND_ENUM_CONSTANT(INSTANCE_GI_PROBE); + BIND_ENUM_CONSTANT(INSTANCE_MAX); + BIND_ENUM_CONSTANT(INSTANCE_GEOMETRY_MASK); + + BIND_ENUM_CONSTANT(NINE_PATCH_STRETCH); + BIND_ENUM_CONSTANT(NINE_PATCH_TILE); + BIND_ENUM_CONSTANT(NINE_PATCH_TILE_FIT); + + BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_ADD); + BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_SUB); + BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_MIX); + BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_MASK); + + BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_NONE); + BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF3); + BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF5); + BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF7); + BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF9); + BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF13); + + BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_DISABLED); + BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE); + BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE); + + BIND_ENUM_CONSTANT(INFO_OBJECTS_IN_FRAME); + BIND_ENUM_CONSTANT(INFO_VERTICES_IN_FRAME); + BIND_ENUM_CONSTANT(INFO_MATERIAL_CHANGES_IN_FRAME); + BIND_ENUM_CONSTANT(INFO_SHADER_CHANGES_IN_FRAME); + BIND_ENUM_CONSTANT(INFO_SURFACE_CHANGES_IN_FRAME); + BIND_ENUM_CONSTANT(INFO_DRAW_CALLS_IN_FRAME); + BIND_ENUM_CONSTANT(INFO_USAGE_VIDEO_MEM_TOTAL); + BIND_ENUM_CONSTANT(INFO_VIDEO_MEM_USED); + BIND_ENUM_CONSTANT(INFO_TEXTURE_MEM_USED); + BIND_ENUM_CONSTANT(INFO_VERTEX_MEM_USED); + + BIND_ENUM_CONSTANT(FEATURE_SHADERS); + BIND_ENUM_CONSTANT(FEATURE_MULTITHREADED); } void VisualServer::_canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate) { diff --git a/servers/visual_server.h b/servers/visual_server.h index 1cc097f50e..7b83bb929d 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -137,6 +137,7 @@ public: }; virtual void texture_debug_usage(List<TextureInfo> *r_info) = 0; + Array _texture_debug_usage_bind(); virtual void textures_keep_original(bool p_enable) = 0; @@ -160,6 +161,7 @@ public: virtual void shader_set_code(RID p_shader, const String &p_code) = 0; virtual String shader_get_code(RID p_shader) const = 0; virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0; + Array _shader_get_param_list_bind(RID p_shader) const; virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) = 0; virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const = 0; @@ -275,6 +277,7 @@ public: virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0; virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const = 0; virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0; + Array _mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const; virtual void mesh_remove_surface(RID p_mesh, int p_index) = 0; virtual int mesh_get_surface_count(RID p_mesh) const = 0; @@ -941,18 +944,29 @@ public: }; // make variant understand the enums - VARIANT_ENUM_CAST(VisualServer::CubeMapSide); VARIANT_ENUM_CAST(VisualServer::TextureFlags); VARIANT_ENUM_CAST(VisualServer::ShaderMode); VARIANT_ENUM_CAST(VisualServer::ArrayType); VARIANT_ENUM_CAST(VisualServer::ArrayFormat); VARIANT_ENUM_CAST(VisualServer::PrimitiveType); +VARIANT_ENUM_CAST(VisualServer::BlendShapeMode); VARIANT_ENUM_CAST(VisualServer::LightType); VARIANT_ENUM_CAST(VisualServer::LightParam); +VARIANT_ENUM_CAST(VisualServer::ViewportUpdateMode); +VARIANT_ENUM_CAST(VisualServer::ViewportClearMode); +VARIANT_ENUM_CAST(VisualServer::ViewportMSAA); +VARIANT_ENUM_CAST(VisualServer::ViewportUsage); +VARIANT_ENUM_CAST(VisualServer::ViewportRenderInfo); +VARIANT_ENUM_CAST(VisualServer::ViewportDebugDraw); VARIANT_ENUM_CAST(VisualServer::ScenarioDebugMode); VARIANT_ENUM_CAST(VisualServer::InstanceType); +VARIANT_ENUM_CAST(VisualServer::NinePatchAxisMode); +VARIANT_ENUM_CAST(VisualServer::CanvasLightMode); +VARIANT_ENUM_CAST(VisualServer::CanvasLightShadowFilter); +VARIANT_ENUM_CAST(VisualServer::CanvasOccluderPolygonCullMode); VARIANT_ENUM_CAST(VisualServer::RenderInfo); +VARIANT_ENUM_CAST(VisualServer::Features); //typedef VisualServer VS; // makes it easier to use #define VS VisualServer diff --git a/thirdparty/enet/enet/enet.h b/thirdparty/enet/enet/enet.h index 8c9ad5463e..246cbb0a62 100644 --- a/thirdparty/enet/enet/enet.h +++ b/thirdparty/enet/enet/enet.h @@ -10,6 +10,7 @@ extern "C" { #endif +#include <stdint.h> #include <stdlib.h> #include "enet/godot.h" |